Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
db7680b8ec | ||
|
8ba9a00ccc | ||
|
14271607f2 | ||
|
ab637e3bbc | ||
|
5d31067f6b |
11
123.sln
11
123.sln
@ -5,6 +5,10 @@ VisualStudioVersion = 17.11.35312.102
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "123\Demo.csproj", "{5A6EDB7C-E5C5-4FCD-B6CE-7E131BD9EDA3}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "123", "123", "{C10296D5-B348-4B12-B15C-226DD4F1C7EB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "presence_api", "123\presence_api\presence_api.csproj", "{1BCA5E0B-EF97-421C-AC72-0655BB7AEF7B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -15,6 +19,10 @@ Global
|
||||
{5A6EDB7C-E5C5-4FCD-B6CE-7E131BD9EDA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5A6EDB7C-E5C5-4FCD-B6CE-7E131BD9EDA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5A6EDB7C-E5C5-4FCD-B6CE-7E131BD9EDA3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1BCA5E0B-EF97-421C-AC72-0655BB7AEF7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1BCA5E0B-EF97-421C-AC72-0655BB7AEF7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1BCA5E0B-EF97-421C-AC72-0655BB7AEF7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1BCA5E0B-EF97-421C-AC72-0655BB7AEF7B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -22,4 +30,7 @@ Global
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {B3D7FA9B-E7AA-4A2B-8D13-416D51577CB6}
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{1BCA5E0B-EF97-421C-AC72-0655BB7AEF7B} = {C10296D5-B348-4B12-B15C-226DD4F1C7EB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
@ -13,7 +13,7 @@ namespace _123.Data.RemoteData.RemoteDatabase.DAO
|
||||
|
||||
public required int LessonNumber { get; set; }
|
||||
public UserDao UserDao { get; set; }
|
||||
public int UserID { get; set; }
|
||||
public int UserDaoUserId { get; set; }
|
||||
public int GroupId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace _123.Data.RemoteData.RemoteDatabase
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseNpgsql("Host = 45.67.56.214; Port = 5421; Username = user3; Database = user3; Password = VOTfZ8PQ");
|
||||
optionsBuilder.UseNpgsql("Host = 45.67.56.214; Port = 5454; Username = user3; Database = user3; Password = VOTfZ8PQ");
|
||||
}
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
@ -22,7 +22,7 @@ namespace _123.Data.RemoteData.RemoteDatabase
|
||||
modelBuilder.Entity<UserDao>().Property(user => user.UserID).ValueGeneratedOnAdd();
|
||||
modelBuilder.Entity<PresenceDao>().HasKey(presence => new
|
||||
{
|
||||
presence.UserID,
|
||||
presence.UserDaoUserId,
|
||||
presence.Date,
|
||||
presence.IsAttedance,
|
||||
presence.LessonNumber
|
||||
|
@ -21,7 +21,7 @@ namespace _123.Data.Repository
|
||||
public void AddPresence(PresenceDao presence)
|
||||
{
|
||||
PresenceDao? presenceLocal = GetAllPresences.FirstOrDefault();
|
||||
presenceLocal.UserID = presence.UserID;
|
||||
presenceLocal.UserDaoUserId = presence.UserDaoUserId;
|
||||
presenceLocal.Date = presence.Date;
|
||||
presenceLocal.IsAttedance = presence.IsAttedance;
|
||||
presenceLocal.LessonNumber = presence.LessonNumber;
|
||||
@ -41,7 +41,7 @@ namespace _123.Data.Repository
|
||||
public bool UnCheckAttendence(int firstClass, int lastClass, DateOnly date, int userId)
|
||||
{
|
||||
var presToUpdate = GetAllPresences
|
||||
.Where(x => x.UserID == userId && x.LessonNumber >= firstClass
|
||||
.Where(x => x.UserDaoUserId == userId && x.LessonNumber >= firstClass
|
||||
&& x.LessonNumber <= lastClass && x.Date == date).ToList();
|
||||
foreach (var presence in presToUpdate)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ namespace _123.Data.Repository
|
||||
public bool UnCheckAttendence(int firstClass, int lastClass, DateOnly date, int userId)
|
||||
{
|
||||
var presToUpdate = _remoteDatabaseContext.PresencesDaos
|
||||
.Where(x => x.UserID == userId && x.LessonNumber >= firstClass
|
||||
.Where(x => x.UserDaoUserId == userId && x.LessonNumber >= firstClass
|
||||
&& x.LessonNumber <= lastClass && x.Date == date).ToList();
|
||||
|
||||
foreach (var presence in presToUpdate)
|
||||
|
@ -9,6 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ClosedXML" Version="0.104.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkcore" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkcore.Design" Version="8.0.10">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
@ -21,18 +21,18 @@ namespace _123.Domain.UseCase
|
||||
var users = _userRepositoryImpl.GetAllUser().Where(x => x.GroupID == groupId).ToList();
|
||||
|
||||
var presenceByGroup = _presenceRepositoryImpl.GetPresenceByGroup(groupId)
|
||||
.Where(x => users.Any(user => user.UserID == x.UserID))
|
||||
.Where(x => users.Any(user => user.UserID == x.UserDaoUserId))
|
||||
.Select(presence => new Presence
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
UserID = presence.UserID,
|
||||
UserID = presence.UserDaoUserId,
|
||||
UserGroup = new Group
|
||||
{
|
||||
ID = groupId,
|
||||
Name = _groupRepositoryImpl.GetAllGroup().First(group => group.ID == groupId).Name
|
||||
},
|
||||
UserFIO = users.First(user => user.UserID == presence.UserID).UserFIO,
|
||||
UserFIO = users.First(user => user.UserID == presence.UserDaoUserId).UserFIO,
|
||||
},
|
||||
ClassNum = presence.LessonNumber,
|
||||
Date = presence.Date,
|
||||
@ -45,18 +45,18 @@ namespace _123.Domain.UseCase
|
||||
var users = _userRepositoryImpl.GetAllUser().Where(x => x.GroupID == groupId).ToList();
|
||||
|
||||
var presenceByGroup = _presenceRepositoryImpl.GetPresenceByGroup(groupId)
|
||||
.Where(x => users.Any(user => user.UserID == x.UserID && x.Date == date))
|
||||
.Where(x => users.Any(user => user.UserID == x.UserDaoUserId && x.Date == date))
|
||||
.Select(presence => new Presence
|
||||
{
|
||||
User = new User
|
||||
{
|
||||
UserID = presence.UserID,
|
||||
UserID = presence.UserDaoUserId,
|
||||
UserGroup = new Group
|
||||
{
|
||||
ID = groupId,
|
||||
Name = _groupRepositoryImpl.GetAllGroup().First(group => group.ID == groupId).Name
|
||||
},
|
||||
UserFIO = users.First(user => user.UserID == presence.UserID).UserFIO,
|
||||
UserFIO = users.First(user => user.UserID == presence.UserDaoUserId).UserFIO,
|
||||
},
|
||||
ClassNum = presence.LessonNumber,
|
||||
Date = presence.Date,
|
||||
|
118
123/Migrations/20241118090715_InitialCreate.Designer.cs
generated
Normal file
118
123/Migrations/20241118090715_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using _123.Data.RemoteData.RemoteDatabase;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace _123.Migrations
|
||||
{
|
||||
[DbContext(typeof(RemoteDatabaseContext))]
|
||||
[Migration("20241118090715_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("_123.Data.RemoteData.RemoteDatabase.DAO.GroupDao", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Groups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_123.Data.RemoteData.RemoteDatabase.DAO.PresenceDao", b =>
|
||||
{
|
||||
b.Property<int>("UserDaoUserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<bool>("IsAttedance")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("LessonNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("GroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("UserDaoUserId", "Date", "IsAttedance", "LessonNumber");
|
||||
|
||||
b.ToTable("PresencesDaos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_123.Data.RemoteData.RemoteDatabase.DAO.UserDao", b =>
|
||||
{
|
||||
b.Property<int>("UserID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("UserID"));
|
||||
|
||||
b.Property<int>("GroupID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("UserFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("UserID");
|
||||
|
||||
b.HasIndex("GroupID");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_123.Data.RemoteData.RemoteDatabase.DAO.PresenceDao", b =>
|
||||
{
|
||||
b.HasOne("_123.Data.RemoteData.RemoteDatabase.DAO.UserDao", "UserDao")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserDaoUserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("UserDao");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_123.Data.RemoteData.RemoteDatabase.DAO.UserDao", b =>
|
||||
{
|
||||
b.HasOne("_123.Data.RemoteData.RemoteDatabase.DAO.GroupDao", "Group")
|
||||
.WithMany("Users")
|
||||
.HasForeignKey("GroupID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Group");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_123.Data.RemoteData.RemoteDatabase.DAO.GroupDao", b =>
|
||||
{
|
||||
b.Navigation("Users");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
88
123/Migrations/20241118090715_InitialCreate.cs
Normal file
88
123/Migrations/20241118090715_InitialCreate.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace _123.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Groups",
|
||||
columns: table => new
|
||||
{
|
||||
ID = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Groups", x => x.ID);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
UserID = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
UserFIO = table.Column<string>(type: "text", nullable: false),
|
||||
GroupID = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.UserID);
|
||||
table.ForeignKey(
|
||||
name: "FK_Users_Groups_GroupID",
|
||||
column: x => x.GroupID,
|
||||
principalTable: "Groups",
|
||||
principalColumn: "ID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PresencesDaos",
|
||||
columns: table => new
|
||||
{
|
||||
IsAttedance = table.Column<bool>(type: "boolean", nullable: false),
|
||||
Date = table.Column<DateOnly>(type: "date", nullable: false),
|
||||
LessonNumber = table.Column<int>(type: "integer", nullable: false),
|
||||
UserDaoUserId = table.Column<int>(type: "integer", nullable: false),
|
||||
GroupId = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PresencesDaos", x => new { x.UserDaoUserId, x.Date, x.IsAttedance, x.LessonNumber });
|
||||
table.ForeignKey(
|
||||
name: "FK_PresencesDaos_Users_UserDaoUserId",
|
||||
column: x => x.UserDaoUserId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "UserID",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Users_GroupID",
|
||||
table: "Users",
|
||||
column: "GroupID");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "PresencesDaos");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Groups");
|
||||
}
|
||||
}
|
||||
}
|
115
123/Migrations/RemoteDatabaseContextModelSnapshot.cs
Normal file
115
123/Migrations/RemoteDatabaseContextModelSnapshot.cs
Normal file
@ -0,0 +1,115 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using _123.Data.RemoteData.RemoteDatabase;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace _123.Migrations
|
||||
{
|
||||
[DbContext(typeof(RemoteDatabaseContext))]
|
||||
partial class RemoteDatabaseContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.10")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("_123.Data.RemoteData.RemoteDatabase.DAO.GroupDao", b =>
|
||||
{
|
||||
b.Property<int>("ID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("ID"));
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("ID");
|
||||
|
||||
b.ToTable("Groups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_123.Data.RemoteData.RemoteDatabase.DAO.PresenceDao", b =>
|
||||
{
|
||||
b.Property<int>("UserDaoUserId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<bool>("IsAttedance")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("LessonNumber")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("GroupId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("UserDaoUserId", "Date", "IsAttedance", "LessonNumber");
|
||||
|
||||
b.ToTable("PresencesDaos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_123.Data.RemoteData.RemoteDatabase.DAO.UserDao", b =>
|
||||
{
|
||||
b.Property<int>("UserID")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("UserID"));
|
||||
|
||||
b.Property<int>("GroupID")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("UserFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("UserID");
|
||||
|
||||
b.HasIndex("GroupID");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_123.Data.RemoteData.RemoteDatabase.DAO.PresenceDao", b =>
|
||||
{
|
||||
b.HasOne("_123.Data.RemoteData.RemoteDatabase.DAO.UserDao", "UserDao")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserDaoUserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("UserDao");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_123.Data.RemoteData.RemoteDatabase.DAO.UserDao", b =>
|
||||
{
|
||||
b.HasOne("_123.Data.RemoteData.RemoteDatabase.DAO.GroupDao", "Group")
|
||||
.WithMany("Users")
|
||||
.HasForeignKey("GroupID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Group");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("_123.Data.RemoteData.RemoteDatabase.DAO.GroupDao", b =>
|
||||
{
|
||||
b.Navigation("Users");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -95,6 +95,80 @@ namespace _123.UI
|
||||
|
||||
Console.WriteLine(output.ToString());
|
||||
}
|
||||
|
||||
public void ExportPresenceToExcel(string groupId, string filePath)
|
||||
{
|
||||
int Id;
|
||||
bool isParsed = int.TryParse(groupId, out Id);
|
||||
if (!isParsed)
|
||||
{
|
||||
Console.WriteLine("Введено не число");
|
||||
}
|
||||
var presence = _presenceUseCase.GetPresenceByGroup(Id);
|
||||
var stats = _presenceUseCase.GetPresenceStatsByGroup(Id);
|
||||
|
||||
using (var workbook = new XLWorkbook())
|
||||
{
|
||||
var worksheet = workbook.Worksheets.Add("Посещаемость");
|
||||
|
||||
// Заголовок листа
|
||||
worksheet.Cell(1, 1).Value = $"Группа {groupId}";
|
||||
worksheet.Range(1, 1, 1, 3).Merge();
|
||||
worksheet.Cell(1, 1).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
|
||||
// Заголовки столбцов
|
||||
worksheet.Cell(3, 1).Value = "№";
|
||||
worksheet.Cell(3, 2).Value = "ФИО";
|
||||
|
||||
// Получаем все уникальные даты
|
||||
var dates = presence.Select(p => p.Date).Distinct().OrderBy(d => d).ToList();
|
||||
int col = 3;
|
||||
foreach (var date in dates)
|
||||
{
|
||||
worksheet.Cell(3, col).Value = date.ToString("dd.MM.yyyy");
|
||||
col++;
|
||||
}
|
||||
|
||||
// Группируем данные по студентам
|
||||
var studentGroups = presence.GroupBy(p => p.User);
|
||||
int row = 4;
|
||||
int studentNumber = 1;
|
||||
|
||||
foreach (var studentGroup in studentGroups)
|
||||
{
|
||||
// Номер и ФИО студента
|
||||
worksheet.Cell(row, 1).Value = studentNumber++;
|
||||
worksheet.Cell(row, 2).Value = studentGroup.Key.FIO;
|
||||
|
||||
// Заполняем посещаемость по датам
|
||||
col = 3;
|
||||
foreach (var date in dates)
|
||||
{
|
||||
var presenceOnDate = studentGroup.FirstOrDefault(p => p.Date == date);
|
||||
worksheet.Cell(row, col).Value = presenceOnDate?.IsAttendence == true ? "+" : "н";
|
||||
worksheet.Cell(row, col).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
|
||||
col++;
|
||||
}
|
||||
row++;
|
||||
}
|
||||
|
||||
// Форматирование
|
||||
var tableRange = worksheet.Range(3, 1, row - 1, dates.Count + 2);
|
||||
tableRange.Style.Border.OutsideBorder = XLBorderStyleValues.Thin;
|
||||
tableRange.Style.Border.InsideBorder = XLBorderStyleValues.Thin;
|
||||
|
||||
worksheet.Columns().AdjustToContents();
|
||||
|
||||
try
|
||||
{
|
||||
workbook.SaveAs(filePath);
|
||||
Console.WriteLine($"Данные успешно экспортированы в файл: {filePath}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Ошибка при сохранении файла: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
6
123/presence/console/Class1.cs
Normal file
6
123/presence/console/Class1.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace console;
|
||||
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
9
123/presence/console/console.csproj
Normal file
9
123/presence/console/console.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,10 @@
|
||||
namespace presence_api.Controllers;
|
||||
[ApiConytoller]
|
||||
[Route("api/[apicontroller]")]
|
||||
public class GroupController(): ControllerBaswe {
|
||||
private readonly GroupUseCase _groupUserCase;
|
||||
GroupController(GroupUseCase groupUseCase){
|
||||
_groupUserCase = groupUseCase();
|
||||
}
|
||||
|
||||
}
|
44
123/presence_api/Program.cs
Normal file
44
123/presence_api/Program.cs
Normal file
@ -0,0 +1,44 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
var summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
app.MapGet("/weatherforecast", () =>
|
||||
{
|
||||
var forecast = Enumerable.Range(1, 5).Select(index =>
|
||||
new WeatherForecast
|
||||
(
|
||||
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
Random.Shared.Next(-20, 55),
|
||||
summaries[Random.Shared.Next(summaries.Length)]
|
||||
))
|
||||
.ToArray();
|
||||
return forecast;
|
||||
})
|
||||
.WithName("GetWeatherForecast")
|
||||
.WithOpenApi();
|
||||
|
||||
app.Run();
|
||||
|
||||
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
||||
{
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
41
123/presence_api/Properties/launchSettings.json
Normal file
41
123/presence_api/Properties/launchSettings.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:6036",
|
||||
"sslPort": 44357
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5013",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"https": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:7117;http://localhost:5013",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
8
123/presence_api/appsettings.Development.json
Normal file
8
123/presence_api/appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
9
123/presence_api/appsettings.json
Normal file
9
123/presence_api/appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
18
123/presence_api/presence_api.csproj
Normal file
18
123/presence_api/presence_api.csproj
Normal file
@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.8" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Domain\Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
6
123/presence_api/presence_api.http
Normal file
6
123/presence_api/presence_api.http
Normal file
@ -0,0 +1,6 @@
|
||||
@presence_api_HostAddress = http://localhost:5013
|
||||
|
||||
GET {{presence_api_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
Loading…
Reference in New Issue
Block a user