#138 device flag models
This commit is contained in:
@@ -175,6 +175,10 @@
|
|||||||
<Compile Include="Migrations\202304150715559_DBv22.Designer.cs">
|
<Compile Include="Migrations\202304150715559_DBv22.Designer.cs">
|
||||||
<DependentUpon>202304150715559_DBv22.cs</DependentUpon>
|
<DependentUpon>202304150715559_DBv22.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Migrations\202401130531317_DBv23.cs" />
|
||||||
|
<Compile Include="Migrations\202401130531317_DBv23.Designer.cs">
|
||||||
|
<DependentUpon>202401130531317_DBv23.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Migrations\Configuration.cs" />
|
<Compile Include="Migrations\Configuration.cs" />
|
||||||
<Compile Include="Migrations\DiscoDataMigrator.cs" />
|
<Compile Include="Migrations\DiscoDataMigrator.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
@@ -256,6 +260,9 @@
|
|||||||
<EmbeddedResource Include="Migrations\202304150715559_DBv22.resx">
|
<EmbeddedResource Include="Migrations\202304150715559_DBv22.resx">
|
||||||
<DependentUpon>202304150715559_DBv22.cs</DependentUpon>
|
<DependentUpon>202304150715559_DBv22.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Migrations\202401130531317_DBv23.resx">
|
||||||
|
<DependentUpon>202401130531317_DBv23.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
namespace Disco.Data.Migrations
|
||||||
|
{
|
||||||
|
using System.Data.Entity.Migrations;
|
||||||
|
using System.Data.Entity.Migrations.Infrastructure;
|
||||||
|
using System.Resources;
|
||||||
|
|
||||||
|
public sealed partial class DBv23 : IMigrationMetadata
|
||||||
|
{
|
||||||
|
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv23));
|
||||||
|
|
||||||
|
string IMigrationMetadata.Id
|
||||||
|
{
|
||||||
|
get { return "202401130531317_DBv23"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
string IMigrationMetadata.Source
|
||||||
|
{
|
||||||
|
get { return null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
string IMigrationMetadata.Target
|
||||||
|
{
|
||||||
|
get { return Resources.GetString("Target"); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
namespace Disco.Data.Migrations
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Data.Entity.Migrations;
|
||||||
|
|
||||||
|
public partial class DBv23 : DbMigration
|
||||||
|
{
|
||||||
|
public override void Up()
|
||||||
|
{
|
||||||
|
CreateTable(
|
||||||
|
"dbo.DeviceFlagAssignments",
|
||||||
|
c => new
|
||||||
|
{
|
||||||
|
Id = c.Int(nullable: false, identity: true),
|
||||||
|
DeviceFlagId = c.Int(nullable: false),
|
||||||
|
DeviceSerialNumber = c.String(nullable: false, maxLength: 60),
|
||||||
|
AddedDate = c.DateTime(nullable: false),
|
||||||
|
AddedUserId = c.String(nullable: false, maxLength: 50),
|
||||||
|
RemovedDate = c.DateTime(),
|
||||||
|
RemovedUserId = c.String(maxLength: 50),
|
||||||
|
Comments = c.String(),
|
||||||
|
OnAssignmentExpressionResult = c.String(),
|
||||||
|
OnUnassignmentExpressionResult = c.String(),
|
||||||
|
})
|
||||||
|
.PrimaryKey(t => t.Id)
|
||||||
|
.ForeignKey("dbo.DeviceFlags", t => t.DeviceFlagId)
|
||||||
|
.ForeignKey("dbo.Devices", t => t.DeviceSerialNumber)
|
||||||
|
.ForeignKey("dbo.Users", t => t.AddedUserId)
|
||||||
|
.ForeignKey("dbo.Users", t => t.RemovedUserId)
|
||||||
|
.Index(t => t.DeviceFlagId)
|
||||||
|
.Index(t => t.DeviceSerialNumber)
|
||||||
|
.Index(t => t.AddedUserId)
|
||||||
|
.Index(t => t.RemovedUserId);
|
||||||
|
|
||||||
|
CreateTable(
|
||||||
|
"dbo.DeviceFlags",
|
||||||
|
c => new
|
||||||
|
{
|
||||||
|
Id = c.Int(nullable: false, identity: true),
|
||||||
|
Name = c.String(nullable: false, maxLength: 100),
|
||||||
|
Description = c.String(maxLength: 500),
|
||||||
|
Icon = c.String(nullable: false, maxLength: 25),
|
||||||
|
IconColour = c.String(nullable: false, maxLength: 10),
|
||||||
|
DevicesLinkedGroup = c.String(),
|
||||||
|
DeviceUsersLinkedGroup = c.String(),
|
||||||
|
OnAssignmentExpression = c.String(),
|
||||||
|
OnUnassignmentExpression = c.String(),
|
||||||
|
})
|
||||||
|
.PrimaryKey(t => t.Id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Down()
|
||||||
|
{
|
||||||
|
DropIndex("dbo.DeviceFlagAssignments", new[] { "RemovedUserId" });
|
||||||
|
DropIndex("dbo.DeviceFlagAssignments", new[] { "AddedUserId" });
|
||||||
|
DropIndex("dbo.DeviceFlagAssignments", new[] { "DeviceSerialNumber" });
|
||||||
|
DropIndex("dbo.DeviceFlagAssignments", new[] { "DeviceFlagId" });
|
||||||
|
DropForeignKey("dbo.DeviceFlagAssignments", "RemovedUserId", "dbo.Users");
|
||||||
|
DropForeignKey("dbo.DeviceFlagAssignments", "AddedUserId", "dbo.Users");
|
||||||
|
DropForeignKey("dbo.DeviceFlagAssignments", "DeviceSerialNumber", "dbo.Devices");
|
||||||
|
DropForeignKey("dbo.DeviceFlagAssignments", "DeviceFlagId", "dbo.DeviceFlags");
|
||||||
|
DropTable("dbo.DeviceFlags");
|
||||||
|
DropTable("dbo.DeviceFlagAssignments");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,9 +1,6 @@
|
|||||||
using System;
|
using Disco.Models.Repository;
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Data.Entity;
|
using System.Data.Entity;
|
||||||
using Disco.Models.Repository;
|
|
||||||
using System.Data.Entity.ModelConfiguration.Conventions;
|
using System.Data.Entity.ModelConfiguration.Conventions;
|
||||||
|
|
||||||
namespace Disco.Data.Repository
|
namespace Disco.Data.Repository
|
||||||
@@ -38,6 +35,8 @@ namespace Disco.Data.Repository
|
|||||||
public virtual DbSet<DeviceBatchAttachment> DeviceBatchAttachments { get; set; }
|
public virtual DbSet<DeviceBatchAttachment> DeviceBatchAttachments { get; set; }
|
||||||
public virtual DbSet<DeviceComponent> DeviceComponents { get; set; }
|
public virtual DbSet<DeviceComponent> DeviceComponents { get; set; }
|
||||||
public virtual DbSet<DeviceAttachment> DeviceAttachments { get; set; }
|
public virtual DbSet<DeviceAttachment> DeviceAttachments { get; set; }
|
||||||
|
public virtual DbSet<DeviceFlag> DeviceFlags { get; set; }
|
||||||
|
public virtual DbSet<DeviceFlagAssignment> DeviceFlagAssignments { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<DeviceCertificate> DeviceCertificates { get; set; }
|
public virtual DbSet<DeviceCertificate> DeviceCertificates { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,8 @@
|
|||||||
<Compile Include="Exporting\ExportFieldMetadata.cs" />
|
<Compile Include="Exporting\ExportFieldMetadata.cs" />
|
||||||
<Compile Include="Exporting\ExportFormat.cs" />
|
<Compile Include="Exporting\ExportFormat.cs" />
|
||||||
<Compile Include="Exporting\IExportRecord.cs" />
|
<Compile Include="Exporting\IExportRecord.cs" />
|
||||||
|
<Compile Include="Repository\Device\Flag\DeviceFlag.cs" />
|
||||||
|
<Compile Include="Repository\Device\Flag\DeviceFlagAssignment.cs" />
|
||||||
<Compile Include="Services\Expressions\Extensions\ImageExpressionFormat.cs" />
|
<Compile Include="Services\Expressions\Extensions\ImageExpressionFormat.cs" />
|
||||||
<Compile Include="ClientServices\EnrolmentInformation\BaseBoard.cs" />
|
<Compile Include="ClientServices\EnrolmentInformation\BaseBoard.cs" />
|
||||||
<Compile Include="ClientServices\EnrolmentInformation\Battery.cs" />
|
<Compile Include="ClientServices\EnrolmentInformation\Battery.cs" />
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ namespace Disco.Models.Repository
|
|||||||
|
|
||||||
[InverseProperty("DeviceSerialNumber")]
|
[InverseProperty("DeviceSerialNumber")]
|
||||||
public virtual IList<Job> Jobs { get; set; }
|
public virtual IList<Job> Jobs { get; set; }
|
||||||
|
public virtual IList<DeviceFlagAssignment> DeviceFlagAssignments { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace Disco.Models.Repository
|
||||||
|
{
|
||||||
|
public class DeviceFlag
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required, StringLength(100)]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[StringLength(500), DataType(DataType.MultilineText)]
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
[Required, StringLength(25)]
|
||||||
|
public string Icon { get; set; }
|
||||||
|
[Required, StringLength(10)]
|
||||||
|
public string IconColour { get; set; }
|
||||||
|
|
||||||
|
public string DevicesLinkedGroup { get; set; }
|
||||||
|
public string DeviceUsersLinkedGroup { get; set; }
|
||||||
|
|
||||||
|
[DataType(DataType.MultilineText)]
|
||||||
|
public string OnAssignmentExpression { get; set; }
|
||||||
|
[DataType(DataType.MultilineText)]
|
||||||
|
public string OnUnassignmentExpression { get; set; }
|
||||||
|
|
||||||
|
public virtual IList<DeviceFlagAssignment> DeviceFlagAssignments { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Disco.Models.Repository
|
||||||
|
{
|
||||||
|
public class DeviceFlagAssignment
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int DeviceFlagId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string DeviceSerialNumber { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public DateTime AddedDate { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string AddedUserId { get; set; }
|
||||||
|
public DateTime? RemovedDate { get; set; }
|
||||||
|
public string RemovedUserId { get; set; }
|
||||||
|
|
||||||
|
public string Comments { get; set; }
|
||||||
|
|
||||||
|
public string OnAssignmentExpressionResult { get; set; }
|
||||||
|
public string OnUnassignmentExpressionResult { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(DeviceFlagId)), InverseProperty("DeviceFlagAssignments")]
|
||||||
|
public virtual DeviceFlag DeviceFlag { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(DeviceSerialNumber)), InverseProperty("DeviceFlagAssignments")]
|
||||||
|
public virtual Device Device { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("AddedUserId")]
|
||||||
|
public virtual User AddedUser { get; set; }
|
||||||
|
[ForeignKey("RemovedUserId")]
|
||||||
|
public virtual User RemovedUser { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"Device Flag Id: {DeviceFlagId}; Device Serial Number: {DeviceSerialNumber}; Added: {AddedDate:s}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user