diff --git a/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs b/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs index 32ea06e..7a0cb03 100644 --- a/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs +++ b/DepartmentPortal/Common/DatabaseCore/DatabaseContext.cs @@ -120,6 +120,8 @@ namespace DatabaseCore public virtual DbSet Students { set; get; } public virtual DbSet Orders { set; get; } public virtual DbSet OrderStudentRecords { set; get; } + public virtual DbSet OrderSyncHistories { set; get; } + public virtual DbSet OrderSyncHistoryRecords { set; get; } #endregion } } \ No newline at end of file diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210417172126_AddOrderSyncHistories.Designer.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210417172126_AddOrderSyncHistories.Designer.cs new file mode 100644 index 0000000..d3e07ad --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210417172126_AddOrderSyncHistories.Designer.cs @@ -0,0 +1,1449 @@ +// +using System; +using DatabaseCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace DatabaseCore.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20210417172126_AddOrderSyncHistories")] + partial class AddOrderSyncHistories + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Relational:MaxIdentifierLength", 128) + .HasAnnotation("ProductVersion", "5.0.4") + .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlan", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EducationDirectionId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("YearEntrance") + .HasColumnType("int"); + + b.Property("YearFinish") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EducationDirectionId", "YearEntrance") + .IsUnique() + .HasFilter("[EducationDirectionId] IS NOT NULL"); + + b.ToTable("AcademicPlans"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecord", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicPlanId") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicPlanRecordParentId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineId") + .HasColumnType("uniqueidentifier"); + + b.Property("InDepartment") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsFacultative") + .HasColumnType("bit"); + + b.Property("IsParent") + .HasColumnType("bit"); + + b.Property("Semester") + .HasColumnType("int"); + + b.Property("Zet") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineId"); + + b.HasIndex("AcademicPlanId", "DisciplineId", "Semester") + .IsUnique(); + + b.ToTable("AcademicPlanRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecordTimeNormHour", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicPlanRecordId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("PlanHours") + .HasColumnType("decimal(18,2)"); + + b.Property("TimeNormId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("TimeNormId"); + + b.HasIndex("AcademicPlanRecordId", "TimeNormId") + .IsUnique(); + + b.ToTable("AcademicPlanRecordTimeNormHours"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Classroom", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("ClassroomType") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("HaveProjector") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Number") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("SecurityCode") + .HasColumnType("nvarchar(max)"); + + b.Property("Square") + .HasColumnType("decimal(18,2)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("Number") + .IsUnique(); + + b.ToTable("Classrooms"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineBlockId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisciplineBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("DisciplineShortName") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineBlockId"); + + b.HasIndex("DisciplineName") + .IsUnique(); + + b.ToTable("Disciplines"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineBlockBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("DisciplineBlockOrder") + .HasColumnType("int"); + + b.Property("DisciplineBlockUseForGrouping") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Title") + .IsUnique(); + + b.ToTable("DisciplineBlocks"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EducationDirection", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Cipher") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.Property("Profile") + .HasColumnType("nvarchar(450)"); + + b.Property("Qualification") + .HasColumnType("int"); + + b.Property("ShortName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("Title", "Profile") + .IsUnique() + .HasFilter("[Profile] IS NOT NULL"); + + b.ToTable("EducationDirections"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Address") + .HasColumnType("nvarchar(max)"); + + b.Property("DateBirth") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .HasColumnType("nvarchar(450)"); + + b.Property("GroupElectricalSafety") + .HasColumnType("nvarchar(max)"); + + b.Property("HomeNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastName") + .HasColumnType("nvarchar(450)"); + + b.Property("MobileNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("FirstName", "LastName", "Patronymic") + .IsUnique() + .HasFilter("[FirstName] IS NOT NULL AND [LastName] IS NOT NULL AND [Patronymic] IS NOT NULL"); + + b.ToTable("Employees"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("EmployeeId"); + + b.HasIndex("PostId"); + + b.ToTable("EmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Abbreviation") + .HasColumnType("nvarchar(max)"); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateBirth") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("GroupElectricalSafety") + .HasColumnType("nvarchar(max)"); + + b.Property("HomeNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("LecturerAcademicDegreeId") + .HasColumnType("uniqueidentifier"); + + b.Property("LecturerAcademicRankId") + .HasColumnType("uniqueidentifier"); + + b.Property("MobileNumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OnlyForPrivate") + .HasColumnType("bit"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(450)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicDegreeId"); + + b.HasIndex("LecturerAcademicRankId"); + + b.HasIndex("UserId"); + + b.HasIndex("FirstName", "LastName", "Patronymic") + .IsUnique() + .HasFilter("[Patronymic] IS NOT NULL"); + + b.ToTable("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicDegree", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerAcademicDegreeName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicDegreeName") + .IsUnique(); + + b.ToTable("LecturerAcademicDegrees"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerAcademicRankName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Order") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("LecturerAcademicRankName") + .IsUnique(); + + b.ToTable("LecturerAcademicRanks"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsExternalCombination") + .HasColumnType("bit"); + + b.Property("IsInternalCombination") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.Property("PostId") + .HasColumnType("uniqueidentifier"); + + b.Property("Rate") + .HasColumnType("decimal(18,2)"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("PostId"); + + b.ToTable("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Order", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("OrderDate") + .HasColumnType("datetime2"); + + b.Property("OrderNumber") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("OrderType") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("OrderNumber") + .IsUnique(); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.OrderStudentRecord", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Info") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("OrderId") + .HasColumnType("uniqueidentifier"); + + b.Property("OrderStudentMoveType") + .HasColumnType("int"); + + b.Property("StudentGroupFromId") + .HasColumnType("uniqueidentifier"); + + b.Property("StudentGroupToId") + .HasColumnType("uniqueidentifier"); + + b.Property("StudentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("StudentGroupFromId"); + + b.HasIndex("StudentGroupToId"); + + b.HasIndex("StudentId", "OrderId") + .IsUnique(); + + b.ToTable("OrderStudentRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.OrderSyncHistory", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("SyncDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("OrderSyncHistories"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.OrderSyncHistoryRecord", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Information") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderSyncHistoryId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderSyncHistoryId"); + + b.ToTable("OrderSyncHistoryRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Hours") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Order") + .HasColumnType("int"); + + b.Property("PostName") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("PostName") + .IsUnique() + .HasFilter("[PostName] IS NOT NULL"); + + b.ToTable("Posts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Student", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsSteward") + .HasColumnType("bit"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NumberOfBook") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Patronymic") + .HasColumnType("nvarchar(max)"); + + b.Property("Photo") + .HasColumnType("varbinary(max)"); + + b.Property("StudentGroupId") + .HasColumnType("uniqueidentifier"); + + b.Property("StudentState") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("NumberOfBook") + .IsUnique(); + + b.HasIndex("StudentGroupId"); + + b.HasIndex("UserId"); + + b.ToTable("Students"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.StudentGroup", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AcademicPlanId") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("EnrollmentYear") + .HasColumnType("int"); + + b.Property("GroupNumber") + .HasColumnType("int"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("LecturerId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("LecturerId"); + + b.HasIndex("AcademicPlanId", "EnrollmentYear", "GroupNumber") + .IsUnique(); + + b.ToTable("StudentGroups"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.TimeNorm", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DisciplineBlockId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("KindOfLoadAttributeName") + .HasColumnType("nvarchar(max)"); + + b.Property("KindOfLoadBlueAsteriskAttributeName") + .HasColumnType("nvarchar(max)"); + + b.Property("KindOfLoadBlueAsteriskName") + .HasColumnType("nvarchar(max)"); + + b.Property("KindOfLoadBlueAsteriskPracticName") + .HasColumnType("nvarchar(max)"); + + b.Property("KindOfLoadName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TimeNormEducationDirectionQualification") + .HasColumnType("int"); + + b.Property("TimeNormName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("TimeNormOrder") + .HasColumnType("int"); + + b.Property("TimeNormShortName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("UseInLearningProgress") + .HasColumnType("bit"); + + b.Property("UseInSite") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("DisciplineBlockId"); + + b.HasIndex("TimeNormName", "TimeNormShortName") + .IsUnique(); + + b.ToTable("TimeNorms"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AccessOperation") + .HasColumnType("int"); + + b.Property("AccessType") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("Accesses"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.EnviromentSetting", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("Key") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Key") + .IsUnique(); + + b.ToTable("EnviromentSettings"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("RolePriority") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("RoleName") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.User", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Avatar") + .HasColumnType("varbinary(max)"); + + b.Property("CountAttempt") + .HasColumnType("int"); + + b.Property("DateBanned") + .HasColumnType("datetime2"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("DateLastVisit") + .HasColumnType("datetime2"); + + b.Property("IsBanned") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("UserName"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateDelete") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("RoleId") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("UserRoles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlan", b => + { + b.HasOne("DatabaseCore.Models.Department.EducationDirection", "EducationDirection") + .WithMany("AcademicPlans") + .HasForeignKey("EducationDirectionId"); + + b.Navigation("EducationDirection"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecord", b => + { + b.HasOne("DatabaseCore.Models.Department.AcademicPlan", "AcademicPlan") + .WithMany("AcademicPlanRecords") + .HasForeignKey("AcademicPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Discipline", "Discipline") + .WithMany("AcademicPlanRecords") + .HasForeignKey("DisciplineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AcademicPlan"); + + b.Navigation("Discipline"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecordTimeNormHour", b => + { + b.HasOne("DatabaseCore.Models.Department.AcademicPlanRecord", "AcademicPlanRecord") + .WithMany("AcademicPlanRecordTimeNormHours") + .HasForeignKey("AcademicPlanRecordId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.TimeNorm", "TimeNorm") + .WithMany("AcademicPlanRecordTimeNormHours") + .HasForeignKey("TimeNormId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("AcademicPlanRecord"); + + b.Navigation("TimeNorm"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Classroom", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("Classrooms") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.HasOne("DatabaseCore.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("Disciplines") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DisciplineBlock"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EducationDirection", b => + { + b.HasOne("DatabaseCore.Models.Department.Lecturer", "Lecturer") + .WithMany("EducationDirections") + .HasForeignKey("LecturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lecturer"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Employees") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EmployeePost", b => + { + b.HasOne("DatabaseCore.Models.Department.Employee", "Employee") + .WithMany("EmployeePosts") + .HasForeignKey("EmployeeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("EmployeePosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Employee"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.HasOne("DatabaseCore.Models.Department.LecturerAcademicDegree", "LecturerAcademicDegree") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicDegreeId"); + + b.HasOne("DatabaseCore.Models.Department.LecturerAcademicRank", "LecturerAcademicRank") + .WithMany("Lecturers") + .HasForeignKey("LecturerAcademicRankId"); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Lecturers") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LecturerAcademicDegree"); + + b.Navigation("LecturerAcademicRank"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerPost", b => + { + b.HasOne("DatabaseCore.Models.Department.Lecturer", "Lecturer") + .WithMany("LecturerPosts") + .HasForeignKey("LecturerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Post", "Post") + .WithMany("LecturerPosts") + .HasForeignKey("PostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Lecturer"); + + b.Navigation("Post"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.OrderStudentRecord", b => + { + b.HasOne("DatabaseCore.Models.Department.Order", "Order") + .WithMany("OrderStudentRecords") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.StudentGroup", "StudentGroupFrom") + .WithMany("OrderStudentRecordFroms") + .HasForeignKey("StudentGroupFromId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("DatabaseCore.Models.Department.StudentGroup", "StudentGroupTo") + .WithMany("OrderStudentRecordTos") + .HasForeignKey("StudentGroupToId") + .OnDelete(DeleteBehavior.NoAction); + + b.HasOne("DatabaseCore.Models.Department.Student", "Student") + .WithMany("OrderStudentRecords") + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("Order"); + + b.Navigation("Student"); + + b.Navigation("StudentGroupFrom"); + + b.Navigation("StudentGroupTo"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.OrderSyncHistoryRecord", b => + { + b.HasOne("DatabaseCore.Models.Department.OrderSyncHistory", "OrderSyncHistory") + .WithMany("OrderSyncHistoryRecords") + .HasForeignKey("OrderSyncHistoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderSyncHistory"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Student", b => + { + b.HasOne("DatabaseCore.Models.Department.StudentGroup", "StudentGroup") + .WithMany("Students") + .HasForeignKey("StudentGroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("Students") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("StudentGroup"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.StudentGroup", b => + { + b.HasOne("DatabaseCore.Models.Department.AcademicPlan", "AcademicPlan") + .WithMany("StudentGroups") + .HasForeignKey("AcademicPlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Department.Lecturer", "Lecturer") + .WithMany("StudentGroups") + .HasForeignKey("LecturerId"); + + b.Navigation("AcademicPlan"); + + b.Navigation("Lecturer"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.TimeNorm", b => + { + b.HasOne("DatabaseCore.Models.Department.DisciplineBlock", "DisciplineBlock") + .WithMany("TimeNorms") + .HasForeignKey("DisciplineBlockId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DisciplineBlock"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Access", b => + { + b.HasOne("DatabaseCore.Models.Security.Role", "Role") + .WithMany("Access") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.UserRole", b => + { + b.HasOne("DatabaseCore.Models.Security.Role", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("DatabaseCore.Models.Security.User", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlan", b => + { + b.Navigation("AcademicPlanRecords"); + + b.Navigation("StudentGroups"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlanRecord", b => + { + b.Navigation("AcademicPlanRecordTimeNormHours"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Discipline", b => + { + b.Navigation("AcademicPlanRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.DisciplineBlock", b => + { + b.Navigation("Disciplines"); + + b.Navigation("TimeNorms"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.EducationDirection", b => + { + b.Navigation("AcademicPlans"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Employee", b => + { + b.Navigation("Classrooms"); + + b.Navigation("EmployeePosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Lecturer", b => + { + b.Navigation("EducationDirections"); + + b.Navigation("LecturerPosts"); + + b.Navigation("StudentGroups"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicDegree", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.LecturerAcademicRank", b => + { + b.Navigation("Lecturers"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Order", b => + { + b.Navigation("OrderStudentRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.OrderSyncHistory", b => + { + b.Navigation("OrderSyncHistoryRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => + { + b.Navigation("EmployeePosts"); + + b.Navigation("LecturerPosts"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.Student", b => + { + b.Navigation("OrderStudentRecords"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.StudentGroup", b => + { + b.Navigation("OrderStudentRecordFroms"); + + b.Navigation("OrderStudentRecordTos"); + + b.Navigation("Students"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.TimeNorm", b => + { + b.Navigation("AcademicPlanRecordTimeNormHours"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.Role", b => + { + b.Navigation("Access"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Security.User", b => + { + b.Navigation("Employees"); + + b.Navigation("Lecturers"); + + b.Navigation("Students"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/20210417172126_AddOrderSyncHistories.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/20210417172126_AddOrderSyncHistories.cs new file mode 100644 index 0000000..d0241c1 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/20210417172126_AddOrderSyncHistories.cs @@ -0,0 +1,102 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace DatabaseCore.Migrations +{ + public partial class AddOrderSyncHistories : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_OrderStudentRecords_StudentGroups_StudentGroupToId", + table: "OrderStudentRecords"); + + migrationBuilder.DropForeignKey( + name: "FK_OrderStudentRecords_Students_StudentId", + table: "OrderStudentRecords"); + + migrationBuilder.CreateTable( + name: "OrderSyncHistories", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + SyncDate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_OrderSyncHistories", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "OrderSyncHistoryRecords", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + OrderSyncHistoryId = table.Column(type: "uniqueidentifier", nullable: false), + Information = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_OrderSyncHistoryRecords", x => x.Id); + table.ForeignKey( + name: "FK_OrderSyncHistoryRecords_OrderSyncHistories_OrderSyncHistoryId", + column: x => x.OrderSyncHistoryId, + principalTable: "OrderSyncHistories", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_OrderSyncHistoryRecords_OrderSyncHistoryId", + table: "OrderSyncHistoryRecords", + column: "OrderSyncHistoryId"); + + migrationBuilder.AddForeignKey( + name: "FK_OrderStudentRecords_StudentGroups_StudentGroupToId", + table: "OrderStudentRecords", + column: "StudentGroupToId", + principalTable: "StudentGroups", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_OrderStudentRecords_Students_StudentId", + table: "OrderStudentRecords", + column: "StudentId", + principalTable: "Students", + principalColumn: "Id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_OrderStudentRecords_StudentGroups_StudentGroupToId", + table: "OrderStudentRecords"); + + migrationBuilder.DropForeignKey( + name: "FK_OrderStudentRecords_Students_StudentId", + table: "OrderStudentRecords"); + + migrationBuilder.DropTable( + name: "OrderSyncHistoryRecords"); + + migrationBuilder.DropTable( + name: "OrderSyncHistories"); + + migrationBuilder.AddForeignKey( + name: "FK_OrderStudentRecords_StudentGroups_StudentGroupToId", + table: "OrderStudentRecords", + column: "StudentGroupToId", + principalTable: "StudentGroups", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + + migrationBuilder.AddForeignKey( + name: "FK_OrderStudentRecords_Students_StudentId", + table: "OrderStudentRecords", + column: "StudentId", + principalTable: "Students", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs b/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs index ff1aeb0..c93c182 100644 --- a/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs +++ b/DepartmentPortal/Common/DatabaseCore/Migrations/DatabaseContextModelSnapshot.cs @@ -16,7 +16,7 @@ namespace DatabaseCore.Migrations #pragma warning disable 612, 618 modelBuilder .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("ProductVersion", "5.0.4") + .HasAnnotation("ProductVersion", "5.0.5") .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity("DatabaseCore.Models.Department.AcademicPlan", b => @@ -669,6 +669,38 @@ namespace DatabaseCore.Migrations b.ToTable("OrderStudentRecords"); }); + modelBuilder.Entity("DatabaseCore.Models.Department.OrderSyncHistory", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("SyncDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("OrderSyncHistories"); + }); + + modelBuilder.Entity("DatabaseCore.Models.Department.OrderSyncHistoryRecord", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Information") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderSyncHistoryId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("OrderSyncHistoryId"); + + b.ToTable("OrderSyncHistoryRecords"); + }); + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => { b.Property("Id") @@ -743,7 +775,8 @@ namespace DatabaseCore.Migrations b.Property("Photo") .HasColumnType("varbinary(max)"); - b.Property("StudentGroupId") + b.Property("StudentGroupId") + .IsRequired() .HasColumnType("uniqueidentifier"); b.Property("StudentState") @@ -1196,12 +1229,12 @@ namespace DatabaseCore.Migrations b.HasOne("DatabaseCore.Models.Department.StudentGroup", "StudentGroupTo") .WithMany("OrderStudentRecordTos") .HasForeignKey("StudentGroupToId") - .OnDelete(DeleteBehavior.SetNull); + .OnDelete(DeleteBehavior.NoAction); b.HasOne("DatabaseCore.Models.Department.Student", "Student") .WithMany("OrderStudentRecords") .HasForeignKey("StudentId") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.NoAction) .IsRequired(); b.Navigation("Order"); @@ -1213,6 +1246,17 @@ namespace DatabaseCore.Migrations b.Navigation("StudentGroupTo"); }); + modelBuilder.Entity("DatabaseCore.Models.Department.OrderSyncHistoryRecord", b => + { + b.HasOne("DatabaseCore.Models.Department.OrderSyncHistory", "OrderSyncHistory") + .WithMany("OrderSyncHistoryRecords") + .HasForeignKey("OrderSyncHistoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderSyncHistory"); + }); + modelBuilder.Entity("DatabaseCore.Models.Department.Student", b => { b.HasOne("DatabaseCore.Models.Department.StudentGroup", "StudentGroup") @@ -1350,6 +1394,11 @@ namespace DatabaseCore.Migrations b.Navigation("OrderStudentRecords"); }); + modelBuilder.Entity("DatabaseCore.Models.Department.OrderSyncHistory", b => + { + b.Navigation("OrderSyncHistoryRecords"); + }); + modelBuilder.Entity("DatabaseCore.Models.Department.Post", b => { b.Navigation("EmployeePosts"); diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/OrderSyncHistory.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/OrderSyncHistory.cs new file mode 100644 index 0000000..e8864f2 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/OrderSyncHistory.cs @@ -0,0 +1,36 @@ +using ModuleTools.Attributes; +using ModuleTools.Interfaces; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; + +namespace DatabaseCore.Models.Department +{ + /// + /// Класс, описывающий историю синхронизации приказов + /// + [DataContract] + [EntityDescription("OrderSyncHistory", "История синхронизации приказов")] + public class OrderSyncHistory : IdEntity, IEntitySecurityExtenstion + { + [DataMember] + [Required(ErrorMessage = "required")] + [MapConfiguration("SyncDate")] + public DateTime SyncDate { get; set; } + + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + + [ForeignKey("OrderSyncHistoryId")] + public virtual List OrderSyncHistoryRecords { get; set; } + + //------------------------------------------------------------------------- + + public OrderSyncHistory SecurityCheck(OrderSyncHistory entity, bool allowFullData) => entity; + + public override string ToString() => SyncDate.ToShortDateString(); + } +} \ No newline at end of file diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/OrderSyncHistoryRecord.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/OrderSyncHistoryRecord.cs new file mode 100644 index 0000000..fff6ba7 --- /dev/null +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/OrderSyncHistoryRecord.cs @@ -0,0 +1,47 @@ +using ModuleTools.Attributes; +using ModuleTools.Interfaces; +using System; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; + +namespace DatabaseCore.Models.Department +{ + /// + /// Класс, описывающий запись истории синхронизации приказов + /// + [DataContract] + [EntityDescription("OrderSyncHistoryRecord", "Дисципилна кафедры")] + [EntityDependency("OrderSyncHistory", "OrderSyncHistoryId", "История синхронизации прказов, к которой относитя запись")] + public class OrderSyncHistoryRecord : IdEntity, IEntitySecurityExtenstion + { + [DataMember] + [Required(ErrorMessage = "required")] + [MapConfiguration("OrderSyncHistoryId")] + public Guid OrderSyncHistoryId { get; set; } + + [DataMember] + [Required(ErrorMessage = "required")] + [MapConfiguration("Information")] + public string Information { get; set; } + + //------------------------------------------------------------------------- + + public virtual OrderSyncHistory OrderSyncHistory { get; set; } + + //------------------------------------------------------------------------- + + //------------------------------------------------------------------------- + + public OrderSyncHistoryRecord SecurityCheck(OrderSyncHistoryRecord entity, bool allowFullData) + { + if (!allowFullData) + { + entity.Information = "скрыто"; + } + + return entity; + } + + public override string ToString() => Information; + } +} diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/Student.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/Student.cs index 0d9c669..b046a34 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/Student.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/Student.cs @@ -27,7 +27,7 @@ namespace DatabaseCore.Models.Department [DataMember] [Required] [MapConfiguration("StudentGroupId")] - public Guid StudentGroupId { get; set; } + public Guid? StudentGroupId { get; set; } [DataMember] [Required] diff --git a/DepartmentPortal/Common/DatabaseCore/Models/Department/StudentGroup.cs b/DepartmentPortal/Common/DatabaseCore/Models/Department/StudentGroup.cs index 6ae6c57..059a2fb 100644 --- a/DepartmentPortal/Common/DatabaseCore/Models/Department/StudentGroup.cs +++ b/DepartmentPortal/Common/DatabaseCore/Models/Department/StudentGroup.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Runtime.Serialization; +using System.Text; namespace DatabaseCore.Models.Department { @@ -57,6 +58,20 @@ namespace DatabaseCore.Models.Department public StudentGroup SecurityCheck(StudentGroup entity, bool allowFullData) => entity; - public override string ToString() => $"{AcademicPlan.EducationDirection.ShortName}({EnrollmentYear})-{GroupNumber}"; + public override string ToString() + { + var builder = new StringBuilder(); + builder.Append(AcademicPlan?.EducationDirection?.ShortName); + builder.Append('-'); + var year = DateTime.Now.Year - EnrollmentYear; + if (DateTime.Now.Month > 8) + { + year++; + } + builder.Append(year); + builder.Append(GroupNumber); + + return builder.ToString(); + } } } \ No newline at end of file diff --git a/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs b/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs index 1338538..00d5eb1 100644 --- a/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs +++ b/DepartmentPortal/Common/DatabaseCore/SecurityManager.cs @@ -132,7 +132,10 @@ namespace DatabaseCore "Даты семестра", "Дисциплины (модули)", "Кафедра", - "ГИА" + "ГИА", + "SyncStudentOrderIpAddress", + "SyncStudentOrderUserName", + "SyncStudentOrderPassword" }; foreach(var key in enviromentKeys) { diff --git a/DepartmentPortal/Common/ModuleTools/Enums/AccessOperation.cs b/DepartmentPortal/Common/ModuleTools/Enums/AccessOperation.cs index e680168..d75d4a3 100644 --- a/DepartmentPortal/Common/ModuleTools/Enums/AccessOperation.cs +++ b/DepartmentPortal/Common/ModuleTools/Enums/AccessOperation.cs @@ -47,6 +47,8 @@ Студенты = 110, Приказы = 111, + + СинхронизацияПриказов = 150, #endregion // Меню Учебный процесс diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/OrderBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/OrderBindingModels.cs index a0b0515..306e059 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/OrderBindingModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/OrderBindingModels.cs @@ -11,6 +11,9 @@ namespace DepartmentBusinessLogic.BindingModels /// public class OrderGetBindingModel : GetBindingModel { + public string OrderNumber { get; set; } + + public DateTime? OrderDate { get; set; } } /// diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/OrderSyncHistoryBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/OrderSyncHistoryBindingModels.cs new file mode 100644 index 0000000..b71e3ae --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/OrderSyncHistoryBindingModels.cs @@ -0,0 +1,24 @@ +using ModuleTools.Attributes; +using ModuleTools.BindingModels; +using System; +using System.ComponentModel.DataAnnotations; + +namespace DepartmentBusinessLogic.BindingModels +{ + /// + /// Получение истории синхронизации приказов + /// + public class OrderSyncHistoryGetBindingModel : GetBindingModel + { + } + + /// + /// Сохранение истории синхронизации приказов + /// + public class OrderSyncHistorySetBindingModel : SetBindingModel + { + [Required(ErrorMessage = "required")] + [MapConfiguration("SyncDate")] + public DateTime SyncDate { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/OrderSyncHistoryRecordBindingModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/OrderSyncHistoryRecordBindingModels.cs new file mode 100644 index 0000000..d7ac655 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BindingModels/OrderSyncHistoryRecordBindingModels.cs @@ -0,0 +1,29 @@ +using ModuleTools.Attributes; +using ModuleTools.BindingModels; +using System; +using System.ComponentModel.DataAnnotations; + +namespace DepartmentBusinessLogic.BindingModels +{ + /// + /// Получение записи истории синхронизации приказов + /// + public class OrderSyncHistoryRecordGetBindingModel : GetBindingModel + { + public Guid? OrderSyncHistoryId { get; set; } + } + + /// + /// Сохранение записи истории синхронизации приказов + /// + public class OrderSyncHistoryRecordSetBindingModel : SetBindingModel + { + [Required(ErrorMessage = "required")] + [MapConfiguration("OrderSyncHistoryId")] + public Guid OrderSyncHistoryId { get; set; } + + [Required(ErrorMessage = "required")] + [MapConfiguration("Information")] + public string Information { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/OrderSyncHistoryBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/OrderSyncHistoryBusinessLogic.cs new file mode 100644 index 0000000..943a3a9 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/OrderSyncHistoryBusinessLogic.cs @@ -0,0 +1,263 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Enums; +using DepartmentBusinessLogic.HelperModels; +using DepartmentBusinessLogic.Interfaces; +using DepartmentBusinessLogic.ViewModels; +using ModuleTools.BusinessLogics; +using ModuleTools.Enums; +using ModuleTools.Extensions; +using SecurityBusinessLogic.BindingModels; +using SecurityBusinessLogic.BusinessLogics; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +namespace DepartmentBusinessLogic.BusinessLogics +{ + /// + /// Логика работы с историями синхронизации приказов + /// + public class OrderSyncHistoryBusinessLogic : GenericBusinessLogic + { + public OrderSyncHistoryBusinessLogic(IOrderSyncHistoryService service) : base(service, "Синхронизация Приказов", AccessOperation.СинхронизацияПриказов) { } + + public async Task SyncOrders() + { + var history = await CreateAsync(new OrderSyncHistorySetBindingModel { SyncDate = DateTime.Now }); + if (history == null) + { + Errors.Add(("Ошибка создание истории", "Не удалось создать историю")); + return false; + } + + var recordLogic = DependencyManager.Instance.Resolve(); + + var enviromentSettingLogic = DependencyManager.Instance.Resolve(); + + var address = (await enviromentSettingLogic.GetListAsync(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderIpAddress" }))?.List?.FirstOrDefault(); + if (address == null || address.Value.IsEmpty()) + { + Errors = enviromentSettingLogic.Errors; + Errors.Add(("Ошибка получения данных", "Не удалось получить адрес серверая для получения приказов по студентам")); + await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel + { + OrderSyncHistoryId = history.Id, + Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message)) + }); + return false; + } + + var username = (await enviromentSettingLogic.GetListAsync(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderUserName" }))?.List?.FirstOrDefault(); + if (username == null || username.Value.IsEmpty()) + { + Errors = enviromentSettingLogic.Errors; + Errors.Add(("Ошибка получения данных", "Не удалось получить имя пользователя для получения приказов по студентам")); + await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel + { + OrderSyncHistoryId = history.Id, + Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message)) + }); + return false; + } + + var password = (await enviromentSettingLogic.GetListAsync(new EnviromentSettingGetBindingModel { Key = "SyncStudentOrderPassword" }))?.List?.FirstOrDefault(); + if (password == null || password.Value.IsEmpty()) + { + Errors = enviromentSettingLogic.Errors; + Errors.Add(("Ошибка получения данных", "Не удалось получить пароль для получения приказов по студентам")); + await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel + { + OrderSyncHistoryId = history.Id, + Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message)) + }); + return false; + } + + var client = new HttpClient + { + BaseAddress = new Uri(address.Value) + }; + client.DefaultRequestHeaders.Accept.Clear(); + client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username.Value}:{password.Value}"))); + + // авторизация + + // получение списка студентов + HttpResponseMessage response = await client.GetAsync($"{address.Value}/univer_Testing/hs/Ulstu_StudentsInfo/v1/GetCurrentStudentsOfDepartment"); + if (!response.IsSuccessStatusCode) + { + Errors.Add(("Ошибка получения данных", "Не удалось получить список студентов с сервера")); + await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel + { + OrderSyncHistoryId = history.Id, + Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message)) + }); + return false; + } + var studentFromServer = JsonSerializer.Deserialize(response.Content.ReadAsStringAsync().Result); + if (studentFromServer.CurrentStudentsList.Count == 0) + { + await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel + { + OrderSyncHistoryId = history.Id, + Information = "Полученный список студентов пустой" + }); + return true; + } + + var groupsLogic = DependencyManager.Instance.Resolve(); + var groups = await groupsLogic.GetListAsync(new StudentGroupGetBindingModel()); + if (groups == null || groups.List == null) + { + Errors = groupsLogic.Errors; + Errors.Add(("Ошибка получения данных", "Не удалось получить список групп")); + await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel + { + OrderSyncHistoryId = history.Id, + Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message)) + }); + return false; + } + + var studentLogic = DependencyManager.Instance.Resolve(); + var userLogic = DependencyManager.Instance.Resolve(); + foreach (var group in groups.List) + { + var students = await studentLogic.GetListAsync(new StudentGetBindingModel { StudentGroupId = group.Id }); + foreach (var student in students.List) + { + var studentSync = studentFromServer.CurrentStudentsList.FirstOrDefault(x => x.recordBookName == student.NumberOfBook); + // студент не найден, значит он ушел с кафедры, выясняем почему + if (studentSync == null) + { + await SyncStudentOrders(history, student, client, address.Value, studentSync.iduniv); + } + // перевод в другую группу + else if (group.GroupName != studentSync.groupName) + { + await SyncStudentOrders(history, student, client, address.Value, studentSync.iduniv); + } + + studentFromServer.CurrentStudentsList.Remove(studentSync); + } + // новые студенты в группе + var studentSyncs = studentFromServer.CurrentStudentsList.Where(x => x.groupName == group.GroupName); + foreach (var student in studentSyncs) + { + var userName = $"{student.lastName}{(student.firstName.IsNotEmpty() ? $" {student.firstName[0]}." : string.Empty)}{(student.patronymicName.IsNotEmpty() ? $"{student.patronymicName[0]}." : string.Empty)}"; + var result = await userLogic.GetListAsync(new UserGetBindingModel { UserNameForSearch = userName }); + + var newuser = await userLogic.CreateAsync(new UserSetBindingModel + { + Login = userName, + Password = student.recordBookName + }); + if (newuser == null) + { + var errors = userLogic.Errors; + errors.Add(("Ошибка создания пользователя под студента", $"Не удалось создать пользователя под студента {student.lastName} {student.firstName} {student.patronymicName}")); + await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel + { + OrderSyncHistoryId = history.Id, + Information = string.Join(Environment.NewLine, errors.Select(x => x.Message)) + }); + continue; + } + + var newStudent = await studentLogic.CreateAsync(new StudentSetBindingModel + { + UserId = newuser.Id, + FirstName = student.firstName, + LastName = student.lastName, + Patronymic = student.patronymicName, + NumberOfBook = student.recordBookName, + StudentGroupId = group.Id, + StudentState = GetStudentState(student.stateName), + Description = student.presenatationOfRecordBook + }); + + if (newStudent == null) + { + var errors = studentLogic.Errors; + errors.Add(("Ошибка добавления студента", $"Не удалось добавить студента {student.lastName} {student.firstName} {student.patronymicName}")); + await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel + { + OrderSyncHistoryId = history.Id, + Information = string.Join(Environment.NewLine, errors.Select(x => x.Message)) + }); + continue; + } + + await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel + { + OrderSyncHistoryId = history.Id, + Information = $"Добавлен студент {newStudent}" + }); + + await SyncStudentOrders(history, newStudent, client, address.Value, student.iduniv); + + studentFromServer.CurrentStudentsList.Remove(student); + } + } + + return true; + } + + private static StudentState GetStudentState(string state) => state switch + { + "Является студентом" => StudentState.Учится, + "Находится в академическом отпуске" => StudentState.Академ, + _ => StudentState.Неопределен, + }; + + /// + /// Синхронизация приказов по студенту + /// + /// + /// + /// + /// + /// + /// + private async Task SyncStudentOrders(OrderSyncHistoryViewModel history, StudentViewModel student, HttpClient client, string address, string iduniv) + { + var recordLogic = DependencyManager.Instance.Resolve(); + var orderLogic = DependencyManager.Instance.Resolve(); + HttpResponseMessage response = await client.GetAsync($"{address}/univer_Testing/hs/Ulstu_StudentsInfo/v1/GetStudentOrdersByIdAndRecordBook?iduniv={iduniv}&recordBookName={student.NumberOfBook}&allOrders=sppd"); + if (!response.IsSuccessStatusCode) + { + Errors.Add(("Ошибка получения данных", "Не удалось получить список приказов по студенту")); + await recordLogic.CreateAsync(new OrderSyncHistoryRecordSetBindingModel + { + OrderSyncHistoryId = history.Id, + Information = string.Join(Environment.NewLine, Errors.Select(x => x.Message)) + }); + return; + } + var syncOrders = JsonSerializer.Deserialize(response.Content.ReadAsStringAsync().Result); + foreach(var syncOrder in syncOrders.StudentOrders) + { + var orderType = GetOrderType(syncOrder.orderSubTypeName); + if (orderType != OrderType.Неопределено) + { + var order = await orderLogic.GetListAsync(new OrderGetBindingModel { OrderNumber = syncOrder.clericNumber, OrderDate = Convert.ToDateTime(syncOrder.clericDate) }); + + } + } + } + + private static OrderType GetOrderType(string orderTitle) => orderTitle switch + { + "Зачисление в вуз" => OrderType.ЗачислениеСтудентов, + "Распределение по группам" => OrderType.РаспределениеСтудентов, + "Перевод на следующий курс" => OrderType.ДвижениеСтудентов, + _ => OrderType.Неопределено, + }; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/OrderSyncHistoryRecordBusinessLogic.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/OrderSyncHistoryRecordBusinessLogic.cs new file mode 100644 index 0000000..0db68ad --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/BusinessLogics/OrderSyncHistoryRecordBusinessLogic.cs @@ -0,0 +1,16 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Interfaces; +using DepartmentBusinessLogic.ViewModels; +using ModuleTools.BusinessLogics; +using ModuleTools.Enums; + +namespace DepartmentBusinessLogic.BusinessLogics +{ + /// + /// Логика работы с записями историй синхронизации приказов + /// + public class OrderSyncHistoryRecordBusinessLogic : GenericBusinessLogic + { + public OrderSyncHistoryRecordBusinessLogic(IOrderSyncHistoryRecordService service) : base(service, "Синхронизация Приказов", AccessOperation.СинхронизацияПриказов) { } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentBusinessLogic.csproj b/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentBusinessLogic.csproj index 9258d73..93b6fc3 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentBusinessLogic.csproj +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/DepartmentBusinessLogic.csproj @@ -6,6 +6,7 @@ + diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Enums/OrderType.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Enums/OrderType.cs index 01d2fe6..c928369 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/Enums/OrderType.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/Enums/OrderType.cs @@ -5,6 +5,8 @@ /// public enum OrderType { + Неопределено = -1, + ЗачислениеСтудентов = 0, РаспределениеСтудентов = 1, diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Enums/StudentState.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Enums/StudentState.cs index b82e9fc..72a9501 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/Enums/StudentState.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/Enums/StudentState.cs @@ -11,6 +11,8 @@ Завершил = 2, - Отчислен = 3 + Отчислен = 3, + + Неопределен = -1 } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/HelperModels/StudentListSyncModel.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/HelperModels/StudentListSyncModel.cs new file mode 100644 index 0000000..ebf9d81 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/HelperModels/StudentListSyncModel.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace DepartmentBusinessLogic.HelperModels +{ + /// + /// Класс-модель для списка студентов из 1С + /// + public class StudentListSyncModel + { + public List CurrentStudentsList { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/HelperModels/StudentOrderListSyncModel.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/HelperModels/StudentOrderListSyncModel.cs new file mode 100644 index 0000000..839acfa --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/HelperModels/StudentOrderListSyncModel.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace DepartmentBusinessLogic.HelperModels +{ + /// + /// Класс-модель для списка приказов по студенту из 1С + /// + public class StudentOrderListSyncModel + { + public List StudentOrders { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/HelperModels/StudentOrderSyncModel.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/HelperModels/StudentOrderSyncModel.cs new file mode 100644 index 0000000..bf76472 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/HelperModels/StudentOrderSyncModel.cs @@ -0,0 +1,20 @@ +namespace DepartmentBusinessLogic.HelperModels +{ + /// + /// Класс-модель для приказа по студенту из 1С + /// + public class StudentOrderSyncModel + { + public string clericNumber { get; set; } + + public string clericDate { get; set; } + + public string orderTypeName { get; set; } + + public string orderSubTypeName { get; set; } + + public string groupNameBefore { get; set; } + + public string groupNameAfter { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/HelperModels/StudentSyncModel.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/HelperModels/StudentSyncModel.cs new file mode 100644 index 0000000..637691e --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/HelperModels/StudentSyncModel.cs @@ -0,0 +1,28 @@ +namespace DepartmentBusinessLogic.HelperModels +{ + /// + /// Класс-модель для студента из 1С + /// + public class StudentSyncModel + { + public string iduniv { get; set; } + + public string recordBookName { get; set; } + + public string lastName { get; set; } + + public string firstName { get; set; } + + public string patronymicName { get; set; } + + public string groupName { get; set; } + + public string studyFormName { get; set; } + + public string stateName { get; set; } + + public string payBasisName { get; set; } + + public string presenatationOfRecordBook { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IOrderSyncHistoryRecordService.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IOrderSyncHistoryRecordService.cs new file mode 100644 index 0000000..59f3244 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IOrderSyncHistoryRecordService.cs @@ -0,0 +1,10 @@ +using DepartmentBusinessLogic.BindingModels; +using ModuleTools.Interfaces; + +namespace DepartmentBusinessLogic.Interfaces +{ + /// + /// Хранение записей историй синхронизации приказов + /// + public interface IOrderSyncHistoryRecordService : IGenerticEntityService { } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IOrderSyncHistoryService.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IOrderSyncHistoryService.cs new file mode 100644 index 0000000..308050a --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/Interfaces/IOrderSyncHistoryService.cs @@ -0,0 +1,10 @@ +using DepartmentBusinessLogic.BindingModels; +using ModuleTools.Interfaces; + +namespace DepartmentBusinessLogic.Interfaces +{ + /// + /// Хранение историй синхронизации приказов + /// + public interface IOrderSyncHistoryService : IGenerticEntityService { } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/OrderSyncHistoryRecordViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/OrderSyncHistoryRecordViewModels.cs new file mode 100644 index 0000000..d205d02 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/OrderSyncHistoryRecordViewModels.cs @@ -0,0 +1,32 @@ +using ModuleTools.Attributes; +using ModuleTools.Enums; +using ModuleTools.ViewModels; +using System; + +namespace DepartmentBusinessLogic.ViewModels +{ + /// + /// Список записей историй синхронизации приказов + /// + public class OrderSyncHistoryRecordListViewModel : ListViewModel { } + + /// + /// Элемент записи историй синхронизации приказов + /// + [ViewModelControlElementClass(HaveDependenceEntities = false, Width = 800, Height = 500)] + public class OrderSyncHistoryRecordViewModel : ElementViewModel + { + [ViewModelControlElementProperty("История", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlOrderSyncHistoryList, DepartmentWindowsDesktop")] + [MapConfiguration("OrderSyncHistoryId")] + public Guid OrderSyncHistoryId { get; set; } + + [ViewModelControlListProperty("Дата", ColumnWidth = 100, DefaultCellStyleFormat = "dd.MM.yyyy")] + [MapConfiguration("OrderSyncHistory.SyncDate", IsDifficle = true)] + public DateTime SyncDate { get; set; } + + [ViewModelControlListProperty("Описание")] + [ViewModelControlElementProperty("Описание", ControlType.ControlText, Height = 200, MustHaveValue = true)] + [MapConfiguration("Information")] + public string Information { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/OrderSyncHistoryViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/OrderSyncHistoryViewModels.cs new file mode 100644 index 0000000..d5286db --- /dev/null +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/OrderSyncHistoryViewModels.cs @@ -0,0 +1,30 @@ +using ModuleTools.Attributes; +using ModuleTools.Enums; +using ModuleTools.ViewModels; + +namespace DepartmentBusinessLogic.ViewModels +{ + /// + /// Список историй синхронизации приказов + /// + public class OrderSyncHistoryListViewModel : ListViewModel { } + + /// + /// Элемент история синхронизации приказов + /// + [ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)] + [ViewModelControlElementDependenceEntity(Title = "Записи", Order = 1, ParentPropertyName = "OrderSyncHistoryId", + ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlOrderSyncHistoryRecordList, DepartmentWindowsDesktop")] + public class OrderSyncHistoryViewModel : ElementViewModel + { + [ViewModelControlListProperty("Дата", ColumnWidth = 100, DefaultCellStyleFormat = "dd.MM.yyyy")] + [ViewModelControlElementProperty("Дата", ControlType.ControlDateTime, MustHaveValue = true, ReadOnly = true)] + [MapConfiguration("SyncDate")] + public string SyncDate { get; set; } + + [ViewModelControlListProperty("События")] + [ViewModelControlElementProperty("События", ControlType.ControlText, MustHaveValue = true, ReadOnly = true, Width = 300, Height = 500)] + [MapConfiguration("History")] + public string History { get; set; } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/OrderViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/OrderViewModels.cs index a5ad50a..0533fca 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/OrderViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/OrderViewModels.cs @@ -25,7 +25,7 @@ namespace DepartmentBusinessLogic.ViewModels public string OrderNumber { get; set; } [ViewModelControlListProperty("Дата приказа", ColumnWidth = 120, DefaultCellStyleFormat = "dd.MM.yyyy")] - [ViewModelControlElementProperty("Дата приказа", ControlType.ControlInt, MustHaveValue = true)] + [ViewModelControlElementProperty("Дата приказа", ControlType.ControlDateTime, MustHaveValue = true)] [MapConfiguration("OrderDate")] public DateTime OrderDate { get; set; } diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/StudentGroupViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/StudentGroupViewModels.cs index e0efc90..7231313 100644 --- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/StudentGroupViewModels.cs +++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/StudentGroupViewModels.cs @@ -2,6 +2,7 @@ using ModuleTools.Enums; using ModuleTools.ViewModels; using System; +using System.Text; namespace DepartmentBusinessLogic.ViewModels { @@ -36,7 +37,24 @@ namespace DepartmentBusinessLogic.ViewModels public string AcademicPlanEducationDirectionShortName { get; set; } [ViewModelControlListProperty("Группа")] - public string GroupName => $"{AcademicPlanEducationDirectionShortName}({EnrollmentYear})-{GroupNumber}"; + public string GroupName + { + get + { + var builder = new StringBuilder(); + builder.Append(AcademicPlanEducationDirectionShortName); + builder.Append('-'); + var year = DateTime.Now.Year - EnrollmentYear; + if (DateTime.Now.Month > 8) + { + year++; + } + builder.Append(year); + builder.Append(GroupNumber); + + return builder.ToString(); + } + } [ViewModelControlListProperty("Номер группы")] [ViewModelControlElementProperty("Номер группы", ControlType.ControlInt, MustHaveValue = true, MinValue = 1, MaxValue = 4)] @@ -50,7 +68,7 @@ namespace DepartmentBusinessLogic.ViewModels [ViewModelControlElementProperty("Куратор", ControlType.ControlGuid, MustHaveValue = false, ReadOnly = false, ControlTypeObject = "DepartmentWindowsDesktop.EntityControls.ControlLecturerList, DepartmentWindowsDesktop")] [MapConfiguration("LecturerId")] - public Guid? CuratorId { get; set; } + public Guid? LecturerId { get; set; } [ViewModelControlListProperty("Куратор")] [MapConfiguration("Lecturer.ToString", IsDifficle = true)] diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationExtensions.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationExtensions.cs index 4dd2558..4aceecc 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationExtensions.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/DepartmentImplementationExtensions.cs @@ -38,6 +38,9 @@ namespace DepartmentDatabaseImplementation DependencyManager.Instance.RegisterType(); DependencyManager.Instance.RegisterType(); + + DependencyManager.Instance.RegisterType(); + DependencyManager.Instance.RegisterType(); } } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/OrderService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/OrderService.cs index 65424e5..33e65da 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/OrderService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/OrderService.cs @@ -5,6 +5,7 @@ using DepartmentBusinessLogic.Interfaces; using DepartmentBusinessLogic.ViewModels; using Microsoft.EntityFrameworkCore; using ModuleTools.Enums; +using ModuleTools.Extensions; using ModuleTools.Models; using System.Linq; @@ -28,7 +29,15 @@ namespace DepartmentDatabaseImplementation.Implementations return OperationResultModel.Success(null); } - protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, OrderGetBindingModel model) => query; + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, OrderGetBindingModel model) + { + if(model.OrderDate.HasValue && model.OrderNumber.IsNotEmpty()) + { + query = query.Where(x => x.OrderNumber == model.OrderNumber && x.OrderDate == model.OrderDate); + } + + return query; + } protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, OrderSetBindingModel model) => OperationResultModel.Success(null); diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/OrderSyncHistoryRecordService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/OrderSyncHistoryRecordService.cs new file mode 100644 index 0000000..17fffee --- /dev/null +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/OrderSyncHistoryRecordService.cs @@ -0,0 +1,107 @@ +using DatabaseCore; +using DatabaseCore.Models.Department; +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Interfaces; +using DepartmentBusinessLogic.ViewModels; +using Microsoft.EntityFrameworkCore; +using ModuleTools.BusinessLogics; +using ModuleTools.Enums; +using ModuleTools.Models; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace DepartmentDatabaseImplementation.Implementations +{ + /// + /// Реализация IOrderSyncHistoryRecordService + /// + public class OrderSyncHistoryRecordService : IOrderSyncHistoryRecordService + { + public async Task CreateAsync(OrderSyncHistoryRecordSetBindingModel model) + { + using var context = DatabaseManager.GetContext; + + var entity = Mapper.MapToClass(model, true); + await context.OrderSyncHistoryRecords.AddAsync(entity); + await context.SaveChangesAsync(); + return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + } + + public async Task DeleteAsync(OrderSyncHistoryRecordGetBindingModel model) + { + using var context = DatabaseManager.GetContext; + var entity = context.OrderSyncHistoryRecords.FirstOrDefault(x => x.Id == model.Id); + if (entity == null) + { + return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); + } + context.OrderSyncHistoryRecords.Remove(entity); + await context.SaveChangesAsync(); + + return OperationResultModel.Success(true); + } + + public async Task ReadAsync(OrderSyncHistoryRecordGetBindingModel model) + { + int countPages = 0; + using var context = DatabaseManager.GetContext; + + // для одной записи + if (model.Id.HasValue) + { + var entity = context.OrderSyncHistoryRecords.FirstOrDefault(x => x.Id == model.Id.Value); + if (entity == null) + { + return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); + } + return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); + } + + var query = context.OrderSyncHistoryRecords.AsQueryable(); + + if(model.OrderSyncHistoryId.HasValue) + { + query = query.Where(x => x.OrderSyncHistoryId == model.OrderSyncHistoryId.Value); + } + + query = query.OrderByDescending(x => x.Information); + + query = query.Include(x => x.OrderSyncHistory); + + return await Task.Run(() => + { + if (model.PageNumber.HasValue && model.PageSize.HasValue) + { + countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); + query = query + .Skip(model.PageSize.Value * model.PageNumber.Value) + .Take(model.PageSize.Value); + } + var result = new OrderSyncHistoryRecordListViewModel + { + MaxCount = countPages, + List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() + }; + + return OperationResultModel.Success(result); + }); + } + + public async Task UpdateAsync(OrderSyncHistoryRecordSetBindingModel model) + { + using var context = DatabaseManager.GetContext; + + var entity = context.OrderSyncHistoryRecords.FirstOrDefault(x => x.Id == model.Id); + if (entity == null) + { + return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); + } + entity = Mapper.MapToClass(model, entity, true); + + await context.SaveChangesAsync(); + + return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/OrderSyncHistoryService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/OrderSyncHistoryService.cs new file mode 100644 index 0000000..fa93993 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/OrderSyncHistoryService.cs @@ -0,0 +1,115 @@ +using DatabaseCore; +using DatabaseCore.Models.Department; +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.Interfaces; +using DepartmentBusinessLogic.ViewModels; +using ModuleTools.BusinessLogics; +using ModuleTools.Enums; +using ModuleTools.Models; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace DepartmentDatabaseImplementation.Implementations +{ + /// + /// Реализация IOrderSyncHistoryService + /// + public class OrderSyncHistoryService : IOrderSyncHistoryService + { + public async Task CreateAsync(OrderSyncHistorySetBindingModel model) + { + using var context = DatabaseManager.GetContext; + + var entity = Mapper.MapToClass(model, true); + await context.OrderSyncHistories.AddAsync(entity); + await context.SaveChangesAsync(); + return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + } + + public async Task DeleteAsync(OrderSyncHistoryGetBindingModel model) + { + using var context = DatabaseManager.GetContext; + using var transaction = context.Database.BeginTransaction(); + try + { + var entity = context.OrderSyncHistories.FirstOrDefault(x => x.Id == model.Id); + if (entity == null) + { + return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); + } + + context.OrderSyncHistories.Remove(entity); + await context.SaveChangesAsync(); + + var records = context.OrderSyncHistoryRecords.Where(x => x.OrderSyncHistoryId == model.Id); + context.OrderSyncHistoryRecords.RemoveRange(records); + await context.SaveChangesAsync(); + + await transaction.CommitAsync(); + } + catch (Exception) + { + await transaction.RollbackAsync(); + throw; + } + + return OperationResultModel.Success(true); + } + + public async Task ReadAsync(OrderSyncHistoryGetBindingModel model) + { + int countPages = 0; + using var context = DatabaseManager.GetContext; + + // для одной записи + if (model.Id.HasValue) + { + var entity = context.OrderSyncHistories.FirstOrDefault(x => x.Id == model.Id.Value); + if (entity == null) + { + return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); + } + return OperationResultModel.Success(Mapper.MapToClass(entity, model.HaveRight)); + } + + var query = context.OrderSyncHistories.AsQueryable(); + + query = query.OrderByDescending(x => x.SyncDate); + + return await Task.Run(() => + { + if (model.PageNumber.HasValue && model.PageSize.HasValue) + { + countPages = (int)Math.Ceiling((double)query.Count() / model.PageSize.Value); + query = query + .Skip(model.PageSize.Value * model.PageNumber.Value) + .Take(model.PageSize.Value); + } + var result = new OrderSyncHistoryListViewModel + { + MaxCount = countPages, + List = query.Select(x => Mapper.MapToClass(x, model.HaveRight)).ToList() + }; + + return OperationResultModel.Success(result); + }); + } + + public async Task UpdateAsync(OrderSyncHistorySetBindingModel model) + { + using var context = DatabaseManager.GetContext; + + var entity = context.OrderSyncHistories.FirstOrDefault(x => x.Id == model.Id); + if (entity == null) + { + return OperationResultModel.Error("Error:", "Элемент не найден", ResultServiceStatusCode.NotFound); + } + entity = Mapper.MapToClass(model, entity, true); + + await context.SaveChangesAsync(); + + return OperationResultModel.Success(Mapper.MapToClass(entity, true)); + } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/StudentGroupService.cs b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/StudentGroupService.cs index 6d700e2..bb0d3e9 100644 --- a/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/StudentGroupService.cs +++ b/DepartmentPortal/Department/DepartmentDatabaseImplementation.csproj/Implementations/StudentGroupService.cs @@ -59,6 +59,6 @@ namespace DepartmentDatabaseImplementation.Implementations protected override IQueryable IncludingWhenReading(IQueryable query) => query.Include(x => x.AcademicPlan).Include(x => x.AcademicPlan.EducationDirection).Include(x => x.Lecturer); - protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.EnrollmentYear).ThenBy(x => x.GroupNumber); + protected override IQueryable OrderingWhenReading(IQueryable query) => query.OrderBy(x => x.AcademicPlan.EducationDirection.Cipher).ThenBy(x => x.EnrollmentYear).ThenBy(x => x.GroupNumber); } } \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowDesktopExtension.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowDesktopExtension.cs index 50d21bd..62d422a 100644 --- a/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowDesktopExtension.cs +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/DepartmentWindowDesktopExtension.cs @@ -45,7 +45,8 @@ namespace DepartmentWindowsDesktop new ControlAcademicPlanList(), new ControlStudentGroupList(), new ControlStudentList(), - new ControlOrderList() + new ControlOrderList(), + new ControlOrderSyncHistoryList() }; foreach (var cntrl in _controls) diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryElement.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryElement.Designer.cs new file mode 100644 index 0000000..63ccf05 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryElement.Designer.cs @@ -0,0 +1,33 @@ + +namespace DepartmentWindowsDesktop.EntityControls +{ + partial class ControlOrderSyncHistoryElement + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryElement.cs new file mode 100644 index 0000000..0331779 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryElement.cs @@ -0,0 +1,30 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.BusinessLogics; +using DepartmentBusinessLogic.ViewModels; +using DesktopTools.Controls; +using DesktopTools.Interfaces; +using DesktopTools.Models; +using System; + +namespace DepartmentWindowsDesktop.EntityControls +{ + /// + /// Реализация контрола для истории синхронизации приказов + /// + public partial class ControlOrderSyncHistoryElement : + GenericControlEntityElement, + IGenericControlEntityElement + { + public ControlOrderSyncHistoryElement() + { + InitializeComponent(); + Title = "История синхронизации приказа"; + ControlId = new Guid("34368ebc-f657-45b3-93c8-4fba732a1457"); + _genericControlViewEntityElement = this; + } + + public IControl GetInstanceGenericControl() => new ControlOrderSyncHistoryElement() { ControlId = Guid.NewGuid() }; + + public ControlViewEntityElementConfiguration GetConfigControl() => new(); + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryElement.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryElement.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryElement.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryList.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryList.Designer.cs new file mode 100644 index 0000000..1a18894 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryList.Designer.cs @@ -0,0 +1,33 @@ + +namespace DepartmentWindowsDesktop.EntityControls +{ + partial class ControlOrderSyncHistoryList + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryList.cs new file mode 100644 index 0000000..09756b7 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryList.cs @@ -0,0 +1,64 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.BusinessLogics; +using DepartmentBusinessLogic.ViewModels; +using DesktopTools.Controls; +using DesktopTools.Enums; +using DesktopTools.Helpers; +using DesktopTools.Interfaces; +using DesktopTools.Models; +using ModuleTools.Enums; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace DepartmentWindowsDesktop.EntityControls +{ + /// + /// Реализация контрола для списка историй синхронизации приказов + /// + public partial class ControlOrderSyncHistoryList : + GenericControlEntityList, + IGenericControlEntityList + { + public ControlOrderSyncHistoryList() + { + InitializeComponent(); + Title = "Синхронизация Приказов"; + ControlId = new Guid("7b857c17-405e-40fb-961f-7fe74fddf84e"); + AccessOperation = AccessOperation.СинхронизацияПриказов; + ControlViewEntityElement = new ControlPostElement(); + _genericControlViewEntityList = this; + } + + public IControl GetInstanceGenericControl() => new ControlOrderSyncHistoryList() { ControlId = Guid.NewGuid() }; + + public ControlViewEntityListConfiguration GetConfigControl() => new() + { + PaginationOn = false, + HideToolStripButton = new List + { + ToolStripButtonListNames.toolStripButtonAdd, + ToolStripButtonListNames.toolStripButtonUpd, + ToolStripButtonListNames.toolStripButtonDel, + ToolStripButtonListNames.toolStripButtonSearch + }, + ControlOnMoveElem = new() + { + { "ToolStripMenuItemSyncOrders", ("Синхронизировать студентов", async (object sender, EventArgs e) => { await SyncOrders(); }) } + } + }; + + /// + /// Синхронизация приказов + /// + /// + private async Task SyncOrders() + { + var flag = await _businessLogic.SyncOrders(); + if (!flag) + { + DialogHelper.MessageException(_businessLogic.Errors, "Ошибки при синхронизации"); + } + } + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryList.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryList.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistory/ControlOrderSyncHistoryList.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordElement.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordElement.Designer.cs new file mode 100644 index 0000000..f1c38b3 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordElement.Designer.cs @@ -0,0 +1,33 @@ + +namespace DepartmentWindowsDesktop.EntityControls +{ + partial class ControlOrderSyncHistoryRecordElement + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordElement.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordElement.cs new file mode 100644 index 0000000..33d6c22 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordElement.cs @@ -0,0 +1,30 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.BusinessLogics; +using DepartmentBusinessLogic.ViewModels; +using DesktopTools.Controls; +using DesktopTools.Interfaces; +using DesktopTools.Models; +using System; + +namespace DepartmentWindowsDesktop.EntityControls +{ + /// + /// Реализация контрола для записи истории синхронизации приказов + /// + public partial class ControlOrderSyncHistoryRecordElement : + GenericControlEntityElement, + IGenericControlEntityElement + { + public ControlOrderSyncHistoryRecordElement() + { + InitializeComponent(); + Title = "Запись истории синхронизации приказа"; + ControlId = new Guid("2a13536d-47cb-49f0-9d05-82f69c8f2007"); + _genericControlViewEntityElement = this; + } + + public IControl GetInstanceGenericControl() => new ControlOrderSyncHistoryRecordElement() { ControlId = Guid.NewGuid() }; + + public ControlViewEntityElementConfiguration GetConfigControl() => new(); + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordElement.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordElement.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordElement.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordList.Designer.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordList.Designer.cs new file mode 100644 index 0000000..cbf72e0 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordList.Designer.cs @@ -0,0 +1,33 @@ + +namespace DepartmentWindowsDesktop.EntityControls +{ + partial class ControlOrderSyncHistoryRecordList + { + /// + /// Освободить все используемые ресурсы. + /// + /// истинно, если управляемый ресурс должен быть удален; иначе ложно. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Код, автоматически созданный конструктором компонентов + + /// + /// Требуемый метод для поддержки конструктора — не изменяйте + /// содержимое этого метода с помощью редактора кода. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordList.cs b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordList.cs new file mode 100644 index 0000000..99fe91d --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordList.cs @@ -0,0 +1,45 @@ +using DepartmentBusinessLogic.BindingModels; +using DepartmentBusinessLogic.BusinessLogics; +using DepartmentBusinessLogic.ViewModels; +using DesktopTools.Controls; +using DesktopTools.Enums; +using DesktopTools.Interfaces; +using DesktopTools.Models; +using ModuleTools.Enums; +using System; +using System.Collections.Generic; + +namespace DepartmentWindowsDesktop.EntityControls +{ + /// + /// Реализация контрола для списка записей истории синхронизации приказов + /// + public partial class ControlOrderSyncHistoryRecordList : + GenericControlEntityList, + IGenericControlEntityList + { + public ControlOrderSyncHistoryRecordList() + { + InitializeComponent(); + Title = "Записи Синхронизации Приказов"; + ControlId = new Guid("8d18e9fa-f056-47c8-b83d-f06f6bf553c2"); + AccessOperation = AccessOperation.СинхронизацияПриказов; + ControlViewEntityElement = new ControlPostElement(); + _genericControlViewEntityList = this; + } + + public IControl GetInstanceGenericControl() => new ControlOrderSyncHistoryRecordList() { ControlId = Guid.NewGuid() }; + + public ControlViewEntityListConfiguration GetConfigControl() => new() + { + PaginationOn = false, + HideToolStripButton = new List + { + ToolStripButtonListNames.toolStripButtonAdd, + ToolStripButtonListNames.toolStripButtonUpd, + ToolStripButtonListNames.toolStripButtonDel, + ToolStripButtonListNames.toolStripButtonSearch + } + }; + } +} \ No newline at end of file diff --git a/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordList.resx b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordList.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/DepartmentPortal/Department/DepartmentWindowsDesktop/EntityControls/OrderSyncHistoryRecord/ControlOrderSyncHistoryRecordList.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DepartmentPortal/DepartmentPortalDesctop/DepartmentPortalDesctop.csproj b/DepartmentPortal/DepartmentPortalDesctop/DepartmentPortalDesctop.csproj index f35c2cf..8702865 100644 --- a/DepartmentPortal/DepartmentPortalDesctop/DepartmentPortalDesctop.csproj +++ b/DepartmentPortal/DepartmentPortalDesctop/DepartmentPortalDesctop.csproj @@ -7,7 +7,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/EnviromentSettingService.cs b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/EnviromentSettingService.cs index 5502dc6..b39edb0 100644 --- a/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/EnviromentSettingService.cs +++ b/DepartmentPortal/Security/SecurityDatabaseImplementation/Implementations/EnviromentSettingService.cs @@ -1,6 +1,7 @@ using DatabaseCore; using DatabaseCore.Models.Security; using Microsoft.EntityFrameworkCore; +using ModuleTools.Extensions; using ModuleTools.Models; using SecurityBusinessLogic.BindingModels; using SecurityBusinessLogic.Interfaces; @@ -20,7 +21,15 @@ namespace SecurityDatabaseImplementation.Implementations protected override OperationResultModel AdditionalCheckingWhenDeleting(DbContext context, EnviromentSetting entity, EnviromentSettingGetBindingModel model) => OperationResultModel.Success(null); - protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, EnviromentSettingGetBindingModel model) => query; + protected override IQueryable AdditionalCheckingWhenReadingList(IQueryable query, EnviromentSettingGetBindingModel model) + { + if(model.Key.IsNotEmpty()) + { + query = query.Where(x => x.Key == model.Key); + } + + return query; + } protected override OperationResultModel AdditionalCheckingWhenUpdateing(DbContext context, EnviromentSettingSetBindingModel model) => OperationResultModel.Success(null);