diff --git a/e-suite.Database.Core/e-suite.Database.Core/Tables/Activity/ActivityAssignment.cs b/e-suite.Database.Core/e-suite.Database.Core/Tables/Activity/ActivityAssignment.cs index b8ad471..2802dd6 100644 --- a/e-suite.Database.Core/e-suite.Database.Core/Tables/Activity/ActivityAssignment.cs +++ b/e-suite.Database.Core/e-suite.Database.Core/Tables/Activity/ActivityAssignment.cs @@ -1,12 +1,13 @@ -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; -using e_suite.Database.Audit.Attributes; +using e_suite.Database.Audit.Attributes; using e_suite.Database.Core.Models; using e_suite.Database.Core.Tables.Domain; using e_suite.Database.Core.Tables.UserManager; +using eSuite.Core.Enums; using eSuite.Core.Workflow; using Microsoft.EntityFrameworkCore; +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; namespace e_suite.Database.Core.Tables.Activity; @@ -51,10 +52,11 @@ public class ActivityAssignment : IGeneralId, ISoftDeletable, IRuntimeOutcomes [ForeignKey(nameof(UserId))] public virtual User User { get; set; } = null!; - public List Outcomes { get; set; } + public List Outcomes { get; set; } = []; public DateTimeOffset? StartDateTime { get; set; } public DateTimeOffset? FinishDateTime { get; set; } - public string Comments { get; set; } + public string Comments { get; set; } = string.Empty; public long? CompletedByUserId { get; set; } public string? CompletedByUserDisplayName { get; set; } + public ActivityState ActivityState { get; set; } = ActivityState.Pending; } \ No newline at end of file diff --git a/e-suite.Database.Core/e-suite.Database.Core/Tables/Activity/ActivityTask.cs b/e-suite.Database.Core/e-suite.Database.Core/Tables/Activity/ActivityTask.cs index 5291467..feda106 100644 --- a/e-suite.Database.Core/e-suite.Database.Core/Tables/Activity/ActivityTask.cs +++ b/e-suite.Database.Core/e-suite.Database.Core/Tables/Activity/ActivityTask.cs @@ -53,7 +53,7 @@ public class ActivityTask : IGeneralId, ISoftDeletable, IRuntimeOutcomes /// public DateTimeOffset? FinishDateTime { get; set; } - public string Comments { get; set; } + public string Comments { get; set; } = string.Empty; public long? CompletedByUserId { get; set; } public string? CompletedByUserDisplayName { get; set; } diff --git a/e-suite.Database.SqlServer/e-suite.Database.SqlServer/Migrations/20260316161358_Added ActivityState to the assignment table.Designer.cs b/e-suite.Database.SqlServer/e-suite.Database.SqlServer/Migrations/20260316161358_Added ActivityState to the assignment table.Designer.cs new file mode 100644 index 0000000..adcdf2a --- /dev/null +++ b/e-suite.Database.SqlServer/e-suite.Database.SqlServer/Migrations/20260316161358_Added ActivityState to the assignment table.Designer.cs @@ -0,0 +1,2335 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using e_suite.Database.SqlServer; + +#nullable disable + +namespace esuite.Database.SqlServer.Migrations +{ + [DbContext(typeof(SqlEsuiteDatabaseDbContext))] + [Migration("20260316161358_Added ActivityState to the assignment table")] + partial class AddedActivityStatetotheassignmenttable + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("e_suite.Database.Audit.Tables.Audit.AuditDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Comment") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateTime") + .HasColumnType("datetimeoffset"); + + b.Property("Fields") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Type") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UserDisplayName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("AuditDetails", "Audit"); + }); + + modelBuilder.Entity("e_suite.Database.Audit.Tables.Audit.AuditDrillHierarchy", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChildAuditDrillDownEntityId") + .HasColumnType("bigint"); + + b.Property("ParentAuditDrillDownEntityId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ChildAuditDrillDownEntityId"); + + b.HasIndex("ParentAuditDrillDownEntityId"); + + b.ToTable("AuditDrillHierarchies", "Audit"); + }); + + modelBuilder.Entity("e_suite.Database.Audit.Tables.Audit.AuditEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AuditLogId") + .HasColumnType("bigint"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EntityName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsPrimary") + .HasColumnType("bit"); + + b.Property("PrimaryKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("AuditLogId"); + + b.ToTable("AuditEntries", "Audit"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Activity.Activity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivityState") + .HasColumnType("int"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("WorkflowVersionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("Name") + .IsUnique(); + + b.HasIndex("WorkflowVersionId"); + + b.ToTable("Activities", "Activity"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Activity.ActivityAssignment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivityState") + .HasColumnType("int"); + + b.Property("AllowNoVerdict") + .HasColumnType("bit"); + + b.Property("Bypassable") + .HasColumnType("bit"); + + b.Property("Comments") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CompletedByUserDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("CompletedByUserId") + .HasColumnType("bigint"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("FinishDateTime") + .HasColumnType("datetimeoffset"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.PrimitiveCollection("Outcomes") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Raci") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("StartDateTime") + .HasColumnType("datetimeoffset"); + + b.Property("TaskId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("RoleId"); + + b.HasIndex("TaskId"); + + b.HasIndex("UserId"); + + b.ToTable("ActivityAssignments", "Activity"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Activity.ActivityTask", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivityId") + .HasColumnType("bigint"); + + b.Property("ActivityOrdinal") + .HasColumnType("bigint"); + + b.Property("ActivityState") + .HasColumnType("int"); + + b.Property("Comments") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CompletedByUserDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("CompletedByUserId") + .HasColumnType("bigint"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("FinishDateTime") + .HasColumnType("datetimeoffset"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.PrimitiveCollection("Outcomes") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.Property("StartDateTime") + .HasColumnType("datetimeoffset"); + + b.Property("TaskGuid") + .HasColumnType("uniqueidentifier"); + + b.Property("TaskName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TaskType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("ParentId"); + + b.HasIndex("ActivityId", "ActivityOrdinal") + .IsUnique(); + + b.ToTable("ActivityTasks", "Activity"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Contacts.Contact", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("JCard") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Contacts", "Contacts"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.CustomFields.CustomField", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DefaultValue") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("FieldType") + .HasColumnType("int"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("MaxEntries") + .HasColumnType("bigint"); + + b.Property("MinEntries") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("CustomFields", "CustomFields"); + + b.HasData( + new + { + Id = 1L, + DefaultValue = "", + Deleted = false, + FieldType = 7, + Guid = new Guid("8d910089-3079-4a29-abad-8ddf82db6dbb"), + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + MaxEntries = 1L, + MinEntries = 1L, + Name = "Print Specification Form Template" + }); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.CustomFields.CustomFieldFormTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomFieldId") + .HasColumnType("bigint"); + + b.Property("FormTemplateId") + .HasColumnType("bigint"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("CustomFieldId"); + + b.HasIndex("FormTemplateId"); + + b.ToTable("CustomFieldFormTemplates", "CustomFields"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.CustomFields.CustomFieldGlossary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomFieldId") + .HasColumnType("bigint"); + + b.Property("GlossaryId") + .HasColumnType("bigint"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("CustomFieldId"); + + b.HasIndex("GlossaryId"); + + b.ToTable("CustomFieldGlossaries", "CustomFields"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.CustomFields.CustomFieldNumber", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomFieldId") + .HasColumnType("bigint"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("MaximumValue") + .HasPrecision(28, 8) + .HasColumnType("decimal(28,8)"); + + b.Property("MinimumValue") + .HasPrecision(28, 8) + .HasColumnType("decimal(28,8)"); + + b.Property("Step") + .HasPrecision(28, 8) + .HasColumnType("decimal(28,8)"); + + b.HasKey("Id"); + + b.HasIndex("CustomFieldId"); + + b.ToTable("CustomFieldNumbers", "CustomFields"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.CustomFields.CustomFieldSequence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomFieldId") + .HasColumnType("bigint"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("SequenceId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("CustomFieldId"); + + b.HasIndex("SequenceId"); + + b.ToTable("CustomFieldSequences", "CustomFields"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.CustomFields.CustomFieldText", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomFieldId") + .HasColumnType("bigint"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("MultiLine") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("CustomFieldId"); + + b.ToTable("CustomFieldTexts", "CustomFields"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Diagnostics.ExceptionLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Application") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExceptionJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Message") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OccuredAt") + .HasColumnType("datetimeoffset"); + + b.Property("StackTrace") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SupportingData") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("ExceptionLogs", "Diagnostics"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Diagnostics.PerformanceReport", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActionName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ActionParameters") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ControllerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Host") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RequestType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("StartDateTime") + .HasColumnType("datetimeoffset"); + + b.Property("Timings") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TotalTimeMS") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("PerformanceReports", "Diagnostics"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Diagnostics.PerformanceThreshold", b => + { + b.Property("ControllerName") + .HasColumnType("nvarchar(450)"); + + b.Property("ActionName") + .HasColumnType("nvarchar(450)"); + + b.Property("RequestType") + .HasColumnType("nvarchar(450)"); + + b.Property("TotalTimeMS") + .HasColumnType("int"); + + b.HasKey("ControllerName", "ActionName", "RequestType"); + + b.ToTable("PerformanceThresholds", "Diagnostics"); + + b.HasData( + new + { + ControllerName = "", + ActionName = "", + RequestType = "", + TotalTimeMS = 2000 + }); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Domain.Domain", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("SigmaId") + .HasColumnType("bigint"); + + b.Property("SsoProviderId") + .HasColumnType("bigint"); + + b.Property("SunriseAppId") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("SunriseCategoryId") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b.Property("SunriseHostname") + .IsRequired() + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("Name") + .IsUnique(); + + b.HasIndex("SsoProviderId"); + + b.ToTable("Domains", "Domain"); + + b.HasData( + new + { + Id = 1L, + Deleted = false, + Guid = new Guid("4eb1b0c7-e81b-4c9d-ba91-384ed47a1cf9"), + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "Sun-Strategy", + SunriseAppId = "", + SunriseCategoryId = "", + SunriseHostname = "" + }); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CanDelete") + .HasColumnType("bit"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("DomainId") + .HasColumnType("bigint"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("IsAdministrator") + .HasColumnType("bit"); + + b.Property("IsSuperUser") + .HasColumnType("bit"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("DomainId", "Name") + .IsUnique(); + + b.ToTable("Roles", "Domain"); + + b.HasData( + new + { + Id = 1L, + CanDelete = false, + Deleted = false, + DomainId = 1L, + Guid = new Guid("32d65817-4de4-4bd5-912e-2b33054a2171"), + IsAdministrator = false, + IsSuperUser = true, + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "Super Users" + }, + new + { + Id = 2L, + CanDelete = false, + Deleted = false, + DomainId = 1L, + Guid = new Guid("2f77f57c-fe2c-4a36-ad17-5d902afc86cb"), + IsAdministrator = true, + IsSuperUser = false, + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "Administrators" + }); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Domain.RoleAccess", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("AccessKey") + .HasColumnType("int"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.HasKey("RoleId", "AccessKey"); + + b.ToTable("RoleAccess", "Domain"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Domain.UserAccess", b => + { + b.Property("AccessKey") + .HasColumnType("int"); + + b.Property("DomainId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasIndex("DomainId"); + + b.HasIndex("UserId"); + + b.ToTable("UserAccess", "Domain"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Domain.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRoles", "Domain"); + + b.HasData( + new + { + Id = 1L, + Deleted = false, + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + RoleId = 1L, + UserId = 1L + }); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Forms.FormFieldInstance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomFieldId") + .HasColumnType("bigint"); + + b.Property("DisplayValue") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FormInstanceId") + .HasColumnType("bigint"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Index") + .HasColumnType("bigint"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Value") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CustomFieldId"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("FormInstanceId", "CustomFieldId", "Index") + .IsUnique(); + + b.ToTable("FormFieldInstances", "Forms"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Forms.FormInstance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("FormTemplateVersionId") + .HasColumnType("bigint"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("FormTemplateVersionId"); + + b.HasIndex("Guid") + .IsUnique(); + + b.ToTable("FormInstances", "Forms"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Forms.FormTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("FormTemplates", "Forms"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Forms.FormTemplateVersion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("FormDefinition") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("TemplateId") + .HasColumnType("bigint"); + + b.Property("Version") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("TemplateId", "Version") + .IsUnique(); + + b.ToTable("FormTemplateVersions", "Forms"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Glossaries.Glossary", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ParentId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("Name") + .IsUnique(); + + b.HasIndex("ParentId"); + + b.HasIndex("Id", "ParentId") + .IsUnique() + .HasFilter("[ParentId] IS NOT NULL"); + + b.ToTable("Glossaries", "Glossaries"); + + b.HasData( + new + { + Id = 1L, + Deleted = false, + Guid = new Guid("fa6566f8-b4b0-48c5-9985-336c9284796e"), + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "System" + }, + new + { + Id = 2L, + Deleted = false, + Guid = new Guid("90c48cf1-1a2b-4a76-b30b-260ecb149ccc"), + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "Domain" + }, + new + { + Id = 3L, + Deleted = false, + Guid = new Guid("35eb8c23-4528-49a7-a798-b8bae3b06daf"), + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "Print Specifications", + ParentId = 1L + }); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Glossaries.GlossaryCustomField", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomFieldId") + .HasColumnType("bigint"); + + b.Property("GlossaryId") + .HasColumnType("bigint"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasAlternateKey("GlossaryId", "CustomFieldId"); + + b.HasIndex("CustomFieldId"); + + b.ToTable("GlossaryCustomFields", "Glossaries"); + + b.HasData( + new + { + Id = 1L, + CustomFieldId = 1L, + GlossaryId = 3L, + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)) + }); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Glossaries.GlossaryCustomFieldValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomFieldId") + .HasColumnType("bigint"); + + b.Property("DisplayValue") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GlossaryId") + .HasColumnType("bigint"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Index") + .HasColumnType("bigint"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Value") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasAlternateKey("GlossaryId", "CustomFieldId", "Index"); + + b.HasIndex("CustomFieldId"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("GlossaryId", "CustomFieldId", "Index") + .IsUnique(); + + b.ToTable("GlossaryCustomFieldValues", "Glossaries"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Mail.MailTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("DomainId") + .HasColumnType("bigint"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("MailType") + .HasColumnType("int"); + + b.Property("Subject") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TemplateDefinition") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("DomainId", "MailType") + .IsUnique(); + + b.ToTable("MailTemplates", "Mail"); + + b.HasData( + new + { + Id = 1L, + Deleted = false, + DomainId = 1L, + Guid = new Guid("32b657af-5e17-47f3-b8dc-59580516b141"), + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + MailType = 0, + Subject = "Confirmation e-mail", + TemplateDefinition = "

Please confirm your e-mail

Welcome to . Please click on this link to confirm your e-mail address is correct." + }, + new + { + Id = 2L, + Deleted = false, + DomainId = 1L, + Guid = new Guid("77fff2b0-dd8c-43e6-a9fd-304c79850f81"), + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + MailType = 2, + Subject = "Password reset", + TemplateDefinition = "

Please follow the link to reset your password


Reset Password" + }, + new + { + Id = 3L, + Deleted = false, + DomainId = 1L, + Guid = new Guid("2e2d84a5-be1c-4e3b-a86a-bdafed42801b"), + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + MailType = 1, + Subject = "Disable two factor authentication", + TemplateDefinition = "

Please follow the link to reset two factor authentication


Disable two factor authentication" + }, + new + { + Id = 4L, + Deleted = false, + DomainId = 1L, + Guid = new Guid("421b67c7-5f4b-4cad-adc5-528e2921790c"), + LastUpdated = new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + MailType = 3, + Subject = "Password successfully reset", + TemplateDefinition = "

Your password has been reset. Please contact your admin if this wasn't you.

" + }); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Miscellaneous.ExternalKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EntityName") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ExternalId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ExternalSystemId") + .HasColumnType("bigint"); + + b.Property("PrimaryKey") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("EntityName", "PrimaryKey") + .IsUnique(); + + b.HasIndex("ExternalSystemId", "ExternalId") + .IsUnique(); + + b.ToTable("ExternalKeys", "Miscellaneous"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Miscellaneous.ExternalSystem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("SystemName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("SystemName") + .IsUnique(); + + b.ToTable("ExternalSystems", "Miscellaneous"); + + b.HasData( + new + { + Id = 1L, + SystemName = "e-flow" + }); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Printer.Organisation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Organisations", "Printer"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Printer.OrganisationContact", b => + { + b.Property("OrganisationId") + .HasColumnType("bigint"); + + b.Property("ContactId") + .HasColumnType("bigint"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Primary") + .HasColumnType("bit"); + + b.HasKey("OrganisationId", "ContactId"); + + b.HasIndex("ContactId"); + + b.ToTable("OrganisationContacts", "Printer"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Printer.Site", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrganisationId") + .HasColumnType("bigint"); + + b.Property("SigmaId") + .HasColumnType("bigint"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("OrganisationId"); + + b.HasIndex("SigmaId") + .IsUnique() + .HasFilter("[SigmaId] IS NOT NULL"); + + b.ToTable("Sites", "Printer"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Printer.SiteContact", b => + { + b.Property("SiteId") + .HasColumnType("bigint"); + + b.Property("ContactId") + .HasColumnType("bigint"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Primary") + .HasColumnType("bit"); + + b.HasKey("SiteId", "ContactId"); + + b.HasIndex("ContactId"); + + b.ToTable("SiteContacts", "Printer"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Printer.Specification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("FormInstanceId") + .HasColumnType("bigint"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SigmaId") + .HasColumnType("bigint"); + + b.Property("SiteId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("SigmaId") + .IsUnique() + .HasFilter("[SigmaId] IS NOT NULL"); + + b.HasIndex("SiteId"); + + b.ToTable("Specifications", "Printer"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Sentinel.FailedAccessAttempt", b => + { + b.Property("IPAddress") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("AttemptedTime") + .HasColumnType("datetimeoffset"); + + b.HasKey("IPAddress", "AttemptedTime"); + + b.ToTable("FailedAccessAttempts", "Sentinel"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Sequences.Sequence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("Increment") + .HasColumnType("bigint"); + + b.Property("LastIssueDate") + .HasColumnType("datetimeoffset"); + + b.Property("LastIssueValue") + .HasColumnType("bigint"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Pattern") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Rollover") + .HasColumnType("int"); + + b.Property("Seed") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Sequences", "Sequences"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.UserManager.EmailUserAction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetimeoffset"); + + b.Property("EmailActionType") + .HasColumnType("int"); + + b.Property("Expires") + .HasColumnType("datetimeoffset"); + + b.Property("Token") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Token", "EmailActionType"); + + b.HasIndex("UserId"); + + b.ToTable("EmailUserActions", "UserManager"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.UserManager.SingleUseGuid", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Expires") + .HasColumnType("datetimeoffset"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("UserId"); + + b.ToTable("SingleUseGuids", "UserManager"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.UserManager.SsoProvider", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AuthorizationEndpoint") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClientId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClientSecret") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("IsPublic") + .HasColumnType("bit"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("TokenEndpoint") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidIssuer") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("SsoProviders", "UserManager"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.UserManager.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("bit"); + + b.Property("Created") + .HasColumnType("datetimeoffset"); + + b.Property("DomainId") + .HasColumnType("bigint"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("FirstName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("MiddleNames") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PreferredLocale") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SsoProviderId") + .HasColumnType("bigint"); + + b.Property("SsoSubject") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorAuthenticationKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UsingTwoFactorAuthentication") + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("DomainId"); + + b.HasIndex("Email") + .IsUnique(); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("SsoProviderId"); + + b.ToTable("Users", "UserManager"); + + b.HasData( + new + { + Id = 1L, + Active = true, + Created = new DateTimeOffset(new DateTime(2022, 6, 9, 12, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + DomainId = 1L, + Email = "testuser1@sun-strategy.com", + EmailConfirmed = true, + FirstName = "Test1", + Guid = new Guid("30cfcd5b-3385-43f1-b59a-fd35236f3d92"), + LastName = "User", + LastUpdated = new DateTimeOffset(new DateTime(2022, 6, 9, 12, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + MiddleNames = "", + Password = "AgAAAAIAACcQAAAAAAAAABDGmF9Hre4l8k9lkZAxBRJk0zNHD2b6xfKz4C7h6UjuirkoyoP2fVR6d9b7riT03UnL5yAgFh2pSSVQDx+nQ5PBjZRB9UG4u5FrY8W7ouA/+w==", + PreferredLocale = "en-GB", + SsoSubject = "", + TwoFactorAuthenticationKey = "4EHHG42OWCN3L72TSRYSHTV6MRJXVOY3", + UsingTwoFactorAuthentication = false + }); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Workflow.Workflow", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Workflows", "Workflow"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Workflow.WorkflowVersion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActivityNameTemplate") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DomainId") + .HasColumnType("bigint"); + + b.Property("Guid") + .HasColumnType("uniqueidentifier"); + + b.Property("LastUpdated") + .HasColumnType("datetimeoffset"); + + b.Property("Tasks") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Version") + .HasColumnType("bigint"); + + b.Property("WorkflowId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DomainId"); + + b.HasIndex("Guid") + .IsUnique(); + + b.HasIndex("WorkflowId", "Version") + .IsUnique(); + + b.ToTable("WorkflowVersions", "Workflow"); + }); + + modelBuilder.Entity("e_suite.Database.Audit.Tables.Audit.AuditDrillHierarchy", b => + { + b.HasOne("e_suite.Database.Audit.Tables.Audit.AuditEntry", "ChildAuditDrillDownEntity") + .WithMany() + .HasForeignKey("ChildAuditDrillDownEntityId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.HasOne("e_suite.Database.Audit.Tables.Audit.AuditEntry", "ParentAuditDrillDownEntity") + .WithMany() + .HasForeignKey("ParentAuditDrillDownEntityId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("ChildAuditDrillDownEntity"); + + b.Navigation("ParentAuditDrillDownEntity"); + }); + + modelBuilder.Entity("e_suite.Database.Audit.Tables.Audit.AuditEntry", b => + { + b.HasOne("e_suite.Database.Audit.Tables.Audit.AuditDetail", "AuditLog") + .WithMany() + .HasForeignKey("AuditLogId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("AuditLog"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Activity.Activity", b => + { + b.HasOne("e_suite.Database.Core.Tables.Workflow.WorkflowVersion", "WorkflowVersion") + .WithMany() + .HasForeignKey("WorkflowVersionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkflowVersion"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Activity.ActivityAssignment", b => + { + b.HasOne("e_suite.Database.Core.Tables.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId"); + + b.HasOne("e_suite.Database.Core.Tables.Activity.ActivityTask", "Task") + .WithMany("Assignments") + .HasForeignKey("TaskId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.UserManager.User", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Role"); + + b.Navigation("Task"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Activity.ActivityTask", b => + { + b.HasOne("e_suite.Database.Core.Tables.Activity.Activity", "Activity") + .WithMany("Tasks") + .HasForeignKey("ActivityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.Activity.ActivityTask", "ParentTask") + .WithMany("Tasks") + .HasForeignKey("ParentId"); + + b.Navigation("Activity"); + + b.Navigation("ParentTask"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.CustomFields.CustomFieldFormTemplate", b => + { + b.HasOne("e_suite.Database.Core.Tables.CustomFields.CustomField", "CustomField") + .WithMany() + .HasForeignKey("CustomFieldId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.Forms.FormTemplate", "FormTemplate") + .WithMany() + .HasForeignKey("FormTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CustomField"); + + b.Navigation("FormTemplate"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.CustomFields.CustomFieldGlossary", b => + { + b.HasOne("e_suite.Database.Core.Tables.CustomFields.CustomField", "CustomField") + .WithMany() + .HasForeignKey("CustomFieldId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.Glossaries.Glossary", "Glossary") + .WithMany() + .HasForeignKey("GlossaryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CustomField"); + + b.Navigation("Glossary"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.CustomFields.CustomFieldNumber", b => + { + b.HasOne("e_suite.Database.Core.Tables.CustomFields.CustomField", "CustomField") + .WithMany() + .HasForeignKey("CustomFieldId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CustomField"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.CustomFields.CustomFieldSequence", b => + { + b.HasOne("e_suite.Database.Core.Tables.CustomFields.CustomField", "CustomField") + .WithMany() + .HasForeignKey("CustomFieldId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.Sequences.Sequence", "Sequence") + .WithMany() + .HasForeignKey("SequenceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CustomField"); + + b.Navigation("Sequence"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.CustomFields.CustomFieldText", b => + { + b.HasOne("e_suite.Database.Core.Tables.CustomFields.CustomField", "CustomField") + .WithMany() + .HasForeignKey("CustomFieldId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CustomField"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Domain.Domain", b => + { + b.HasOne("e_suite.Database.Core.Tables.UserManager.SsoProvider", "SsoProvider") + .WithMany() + .HasForeignKey("SsoProviderId"); + + b.Navigation("SsoProvider"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Domain.Role", b => + { + b.HasOne("e_suite.Database.Core.Tables.Domain.Domain", "Domain") + .WithMany() + .HasForeignKey("DomainId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Domain"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Domain.RoleAccess", b => + { + b.HasOne("e_suite.Database.Core.Tables.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Domain.UserAccess", b => + { + b.HasOne("e_suite.Database.Core.Tables.Domain.Domain", "Domain") + .WithMany() + .HasForeignKey("DomainId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.UserManager.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Domain"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Domain.UserRole", b => + { + b.HasOne("e_suite.Database.Core.Tables.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.UserManager.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Forms.FormFieldInstance", b => + { + b.HasOne("e_suite.Database.Core.Tables.CustomFields.CustomField", "CustomField") + .WithMany() + .HasForeignKey("CustomFieldId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.Forms.FormInstance", "FormInstance") + .WithMany("FormFields") + .HasForeignKey("FormInstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CustomField"); + + b.Navigation("FormInstance"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Forms.FormInstance", b => + { + b.HasOne("e_suite.Database.Core.Tables.Forms.FormTemplateVersion", "FormTemplateVersion") + .WithMany() + .HasForeignKey("FormTemplateVersionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("FormTemplateVersion"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Forms.FormTemplateVersion", b => + { + b.HasOne("e_suite.Database.Core.Tables.Forms.FormTemplate", "Template") + .WithMany("Versions") + .HasForeignKey("TemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Template"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Glossaries.Glossary", b => + { + b.HasOne("e_suite.Database.Core.Tables.Glossaries.Glossary", "Parent") + .WithMany() + .HasForeignKey("ParentId"); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Glossaries.GlossaryCustomField", b => + { + b.HasOne("e_suite.Database.Core.Tables.CustomFields.CustomField", "CustomField") + .WithMany() + .HasForeignKey("CustomFieldId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.Glossaries.Glossary", "Glossary") + .WithMany("CustomFieldDefinitions") + .HasForeignKey("GlossaryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CustomField"); + + b.Navigation("Glossary"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Glossaries.GlossaryCustomFieldValue", b => + { + b.HasOne("e_suite.Database.Core.Tables.CustomFields.CustomField", "CustomField") + .WithMany() + .HasForeignKey("CustomFieldId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.Glossaries.Glossary", "Glossary") + .WithMany("CustomFieldValues") + .HasForeignKey("GlossaryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CustomField"); + + b.Navigation("Glossary"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Mail.MailTemplate", b => + { + b.HasOne("e_suite.Database.Core.Tables.Domain.Domain", "Domain") + .WithMany() + .HasForeignKey("DomainId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Domain"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Miscellaneous.ExternalKey", b => + { + b.HasOne("e_suite.Database.Core.Tables.Miscellaneous.ExternalSystem", "ExternalSystem") + .WithMany() + .HasForeignKey("ExternalSystemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ExternalSystem"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Printer.OrganisationContact", b => + { + b.HasOne("e_suite.Database.Core.Tables.Contacts.Contact", "Contact") + .WithMany() + .HasForeignKey("ContactId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.Printer.Organisation", "Organisation") + .WithMany() + .HasForeignKey("OrganisationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contact"); + + b.Navigation("Organisation"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Printer.Site", b => + { + b.HasOne("e_suite.Database.Core.Tables.Printer.Organisation", "Organisation") + .WithMany("Sites") + .HasForeignKey("OrganisationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organisation"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Printer.SiteContact", b => + { + b.HasOne("e_suite.Database.Core.Tables.Contacts.Contact", "Contact") + .WithMany() + .HasForeignKey("ContactId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.Printer.Site", "Site") + .WithMany() + .HasForeignKey("SiteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Contact"); + + b.Navigation("Site"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Printer.Specification", b => + { + b.HasOne("e_suite.Database.Core.Tables.Printer.Site", "Site") + .WithMany("Specifications") + .HasForeignKey("SiteId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Site"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.UserManager.EmailUserAction", b => + { + b.HasOne("e_suite.Database.Core.Tables.UserManager.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.UserManager.SingleUseGuid", b => + { + b.HasOne("e_suite.Database.Core.Tables.UserManager.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.UserManager.User", b => + { + b.HasOne("e_suite.Database.Core.Tables.Domain.Domain", "Domain") + .WithMany() + .HasForeignKey("DomainId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.UserManager.SsoProvider", "SsoProvider") + .WithMany() + .HasForeignKey("SsoProviderId"); + + b.Navigation("Domain"); + + b.Navigation("SsoProvider"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Workflow.WorkflowVersion", b => + { + b.HasOne("e_suite.Database.Core.Tables.Domain.Domain", "Domain") + .WithMany() + .HasForeignKey("DomainId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("e_suite.Database.Core.Tables.Workflow.Workflow", "Workflow") + .WithMany("Versions") + .HasForeignKey("WorkflowId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Domain"); + + b.Navigation("Workflow"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Activity.Activity", b => + { + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Activity.ActivityTask", b => + { + b.Navigation("Assignments"); + + b.Navigation("Tasks"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Forms.FormInstance", b => + { + b.Navigation("FormFields"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Forms.FormTemplate", b => + { + b.Navigation("Versions"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Glossaries.Glossary", b => + { + b.Navigation("CustomFieldDefinitions"); + + b.Navigation("CustomFieldValues"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Printer.Organisation", b => + { + b.Navigation("Sites"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Printer.Site", b => + { + b.Navigation("Specifications"); + }); + + modelBuilder.Entity("e_suite.Database.Core.Tables.Workflow.Workflow", b => + { + b.Navigation("Versions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/e-suite.Database.SqlServer/e-suite.Database.SqlServer/Migrations/20260316161358_Added ActivityState to the assignment table.cs b/e-suite.Database.SqlServer/e-suite.Database.SqlServer/Migrations/20260316161358_Added ActivityState to the assignment table.cs new file mode 100644 index 0000000..cfb219c --- /dev/null +++ b/e-suite.Database.SqlServer/e-suite.Database.SqlServer/Migrations/20260316161358_Added ActivityState to the assignment table.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace esuite.Database.SqlServer.Migrations +{ + /// + public partial class AddedActivityStatetotheassignmenttable : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ActivityState", + schema: "Activity", + table: "ActivityAssignments", + type: "int", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ActivityState", + schema: "Activity", + table: "ActivityAssignments"); + } + } +} diff --git a/e-suite.Database.SqlServer/e-suite.Database.SqlServer/Migrations/SqlEsuiteDatabaseDbContextModelSnapshot.cs b/e-suite.Database.SqlServer/e-suite.Database.SqlServer/Migrations/SqlEsuiteDatabaseDbContextModelSnapshot.cs index 1ff994f..6817ac2 100644 --- a/e-suite.Database.SqlServer/e-suite.Database.SqlServer/Migrations/SqlEsuiteDatabaseDbContextModelSnapshot.cs +++ b/e-suite.Database.SqlServer/e-suite.Database.SqlServer/Migrations/SqlEsuiteDatabaseDbContextModelSnapshot.cs @@ -162,6 +162,9 @@ namespace esuite.Database.SqlServer.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("ActivityState") + .HasColumnType("int"); + b.Property("AllowNoVerdict") .HasColumnType("bit"); diff --git a/e-suite.Workflow.Core/Extensions/ActivityAssignmentExtensions.cs b/e-suite.Workflow.Core/Extensions/ActivityAssignmentExtensions.cs new file mode 100644 index 0000000..df0c551 --- /dev/null +++ b/e-suite.Workflow.Core/Extensions/ActivityAssignmentExtensions.cs @@ -0,0 +1,39 @@ +using e_suite.Database.Core.Tables.Activity; +using eSuite.Core.Enums; + +namespace e_suite.Workflow.Core.Extensions; + +public static class ActivityAssignmentExtensions +{ + extension(ActivityAssignment task) + { + public void SetState(ActivityState newState) + { + if (newState == ActivityState.Active) + { + if (task.StartDateTime == null) + throw new InvalidOperationException( + $"Cannot set state to Active because StartDateTime is not set for task {task.Id}." + ); + } + + if (newState == ActivityState.ReadyToComplete) + { + if (task.Outcomes == null || task.Outcomes.Count == 0) + throw new InvalidOperationException( + $"Cannot set state to ReadyToComplete because no outcomes have been recorded for task {task.Id}." + ); + } + + if (newState == ActivityState.Completed) + { + if (task.FinishDateTime == null) + throw new InvalidOperationException( + $"Cannot set state to Completed because FinishDateTime is not set for task {task.Id}." + ); + } + + task.ActivityState = newState; + } + } +} diff --git a/e-suite.Workflow.Core/Extensions/TaskExtensions.cs b/e-suite.Workflow.Core/Extensions/TaskExtensions.cs index 534b1be..1438c6e 100644 --- a/e-suite.Workflow.Core/Extensions/TaskExtensions.cs +++ b/e-suite.Workflow.Core/Extensions/TaskExtensions.cs @@ -180,9 +180,16 @@ public static class TaskExtensions public async Task StartTask(ActivityTask activityTask, IClock clock) { - activityTask.StartDateTime = clock.GetNow; + var now = clock.GetNow; + activityTask.StartDateTime = now; activityTask.SetState(ActivityState.Active); + foreach (var assignment in activityTask.Assignments) + { + assignment.StartDateTime = now; + assignment.SetState(ActivityState.Active); + } + await task.OnStartedAsync(activityTask); }