This commit is contained in:
91
server/AyaNova/models/AyContext.cs
Normal file
91
server/AyaNova/models/AyContext.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using AyaNova.Util;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
public partial class AyContext : DbContext
|
||||
{
|
||||
public virtual DbSet<User> User { get; set; }
|
||||
public virtual DbSet<License> License { get; set; }
|
||||
public virtual DbSet<Widget> Widget { get; set; }
|
||||
public virtual DbSet<FileAttachment> FileAttachment { get; set; }
|
||||
public virtual DbSet<Tag> Tag { get; set; }
|
||||
public virtual DbSet<TagMap> TagMap { get; set; }
|
||||
public virtual DbSet<OpsJob> OpsJob { get; set; }
|
||||
public virtual DbSet<OpsJobLog> OpsJobLog { get; set; }
|
||||
public virtual DbSet<Locale> Locale { get; set; }
|
||||
public virtual DbSet<LocaleItem> LocaleItem { get; set; }
|
||||
|
||||
//Note: had to add this constructor to work with the code in startup.cs that gets the connection string from the appsettings.json file
|
||||
//and commented out the above on configuring
|
||||
public AyContext(DbContextOptions<AyContext> options) : base(options)
|
||||
{ }
|
||||
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
||||
//https://andrewlock.net/customising-asp-net-core-identity-ef-core-naming-conventions-for-postgresql/
|
||||
foreach (var entity in modelBuilder.Model.GetEntityTypes())
|
||||
{
|
||||
// Replace table names
|
||||
entity.Relational().TableName = "a" + entity.Relational().TableName.ToLowerInvariant();
|
||||
|
||||
// Replace column names
|
||||
foreach (var property in entity.GetProperties())
|
||||
{
|
||||
//Any object that has a concurrencytoken field
|
||||
//set it up to work properly with PostgreSQL
|
||||
if (property.Name == "ConcurrencyToken")
|
||||
{
|
||||
property.Relational().ColumnName = "xmin";
|
||||
property.Relational().ColumnType = "xid";
|
||||
property.ValueGenerated = ValueGenerated.OnAddOrUpdate;
|
||||
property.IsConcurrencyToken = true;
|
||||
}
|
||||
else
|
||||
property.Relational().ColumnName = property.Name.ToLowerInvariant();
|
||||
|
||||
}
|
||||
|
||||
foreach (var key in entity.GetKeys())
|
||||
{
|
||||
key.Relational().Name = key.Relational().Name.ToLowerInvariant();
|
||||
}
|
||||
|
||||
foreach (var key in entity.GetForeignKeys())
|
||||
{
|
||||
key.Relational().Name = key.Relational().Name.ToLowerInvariant();
|
||||
}
|
||||
|
||||
foreach (var index in entity.GetIndexes())
|
||||
{
|
||||
index.Relational().Name = index.Relational().Name.ToLowerInvariant();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Indexes must be specified through fluent api unfortunately
|
||||
modelBuilder.Entity<FileAttachment>().HasIndex(p => p.StoredFileName);
|
||||
|
||||
|
||||
//Relationships
|
||||
modelBuilder.Entity<Locale>()
|
||||
.HasMany(c => c.LocaleItems)
|
||||
.WithOne(e => e.Locale)
|
||||
.IsRequired();//default delete behaviour is cascade when set to isrequired
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
37
server/AyaNova/models/FileAttachment.cs
Normal file
37
server/AyaNova/models/FileAttachment.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using AyaNova.Biz;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public partial class FileAttachment
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
public DateTime Created { get; set; }//time it was uploaded not original file creation time, we don't have that
|
||||
[Required]
|
||||
public long OwnerId { get; set; }
|
||||
//-----------------------------------------
|
||||
[Required]
|
||||
public long AttachToObjectId { get; set; }
|
||||
[Required]
|
||||
public AyaType AttachToObjectType { get; set; }//int
|
||||
[Required]
|
||||
public string StoredFileName { get; set; }
|
||||
[Required]
|
||||
public string DisplayFileName { get; set; }
|
||||
[Required]
|
||||
public string ContentType { get; set; }//mime type
|
||||
public string Notes { get; set; }
|
||||
|
||||
|
||||
public FileAttachment()
|
||||
{
|
||||
Created = System.DateTime.UtcNow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//"AttachToObjectType and / or AttachToObjectId public AuthorizationRoles Roles { get; set; }
|
||||
20
server/AyaNova/models/License.cs
Normal file
20
server/AyaNova/models/License.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AyaNova.Biz;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public partial class License
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Key { get; set; }
|
||||
public Guid DbId { get; set; }
|
||||
public int LastFetchStatus { get; set; }
|
||||
public string LastFetchMessage { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
52
server/AyaNova/models/Locale.cs
Normal file
52
server/AyaNova/models/Locale.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AyaNova.Biz;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
// [JsonObject(IsReference = true)]
|
||||
public partial class Locale
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
[Required]
|
||||
public long OwnerId { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public bool? Stock { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
|
||||
public Locale()
|
||||
{
|
||||
Created = System.DateTime.UtcNow;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Relationship
|
||||
//was this but..
|
||||
// public ICollection<LocaleItem> LocaleItems { get; set; }
|
||||
|
||||
//Not perhaps so useful here but this is a good way to lazy initialize collections which
|
||||
//is more efficient when there are many child collections (workorder) and means no need to null check the collection
|
||||
//https://stackoverflow.com/a/20773057/8939
|
||||
|
||||
private ICollection<LocaleItem> _localeItem;
|
||||
public virtual ICollection<LocaleItem> LocaleItems
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._localeItem ?? (this._localeItem = new HashSet<LocaleItem>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
28
server/AyaNova/models/LocaleItem.cs
Normal file
28
server/AyaNova/models/LocaleItem.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AyaNova.Biz;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public partial class LocaleItem
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Key { get; set; }
|
||||
[Required]
|
||||
public string Display { get; set; }
|
||||
|
||||
public long LocaleId { get; set; }
|
||||
|
||||
//Relation
|
||||
[JsonIgnore]
|
||||
public Locale Locale { get; set; }
|
||||
}
|
||||
}
|
||||
60
server/AyaNova/models/OpsJob.cs
Normal file
60
server/AyaNova/models/OpsJob.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AyaNova.Biz;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Operations job
|
||||
/// </summary>
|
||||
public partial class OpsJob
|
||||
{
|
||||
[Key]
|
||||
public Guid GId { get; set; }
|
||||
|
||||
[Required]
|
||||
public DateTime Created { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
|
||||
[Required]
|
||||
public long OwnerId { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
//------------------------
|
||||
[Required]
|
||||
public bool Exclusive { get; set; }//true lock api and don't run other jobs until completed / false=run any time with other jobs async
|
||||
public DateTime StartAfter { get; set; }
|
||||
[Required]
|
||||
public JobType JobType { get; set; }
|
||||
public long ObjectId { get; set; }
|
||||
public AyaType ObjectType { get; set; }
|
||||
[Required]
|
||||
public JobStatus JobStatus { get; set; }
|
||||
/// <summary>
|
||||
/// Json string of any required extra info for job
|
||||
/// </summary>
|
||||
public string JobInfo { get; set; }//json as string of any required extra info for job
|
||||
|
||||
|
||||
public OpsJob(){
|
||||
GId=new Guid();
|
||||
Created=DateTime.UtcNow;
|
||||
OwnerId=1;
|
||||
Name="new job";
|
||||
Exclusive=false;
|
||||
StartAfter=Created;
|
||||
JobType=JobType.NotSet;
|
||||
ObjectId=0;
|
||||
ObjectType=AyaType.NotValid;
|
||||
JobStatus=JobStatus.Sleeping;
|
||||
JobInfo=null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
35
server/AyaNova/models/OpsJobLog.cs
Normal file
35
server/AyaNova/models/OpsJobLog.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AyaNova.Biz;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Operations job log
|
||||
/// </summary>
|
||||
public partial class OpsJobLog
|
||||
{
|
||||
[Key]
|
||||
public Guid GId { get; set; }
|
||||
|
||||
[Required]
|
||||
public Guid JobId { get; set; }
|
||||
[Required]
|
||||
public DateTime Created { get; set; }
|
||||
[Required]
|
||||
public string StatusText { get; set; }
|
||||
|
||||
|
||||
|
||||
public OpsJobLog(){
|
||||
GId=new Guid();
|
||||
Created=DateTime.UtcNow;
|
||||
StatusText="default / not set";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
30
server/AyaNova/models/Tag.cs
Normal file
30
server/AyaNova/models/Tag.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AyaNova.Biz;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public partial class Tag
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
|
||||
[Required]
|
||||
public long OwnerId { get; set; }
|
||||
[Required]
|
||||
public string Name { get; set; }//max 35 characters ascii set
|
||||
|
||||
|
||||
public Tag()
|
||||
{
|
||||
Created = System.DateTime.UtcNow;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
33
server/AyaNova/models/TagMap.cs
Normal file
33
server/AyaNova/models/TagMap.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AyaNova.Biz;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public partial class TagMap
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
[Required]
|
||||
public long OwnerId { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
[Required]
|
||||
public long TagId { get; set; }
|
||||
[Required]
|
||||
public long TagToObjectId { get; set; }
|
||||
[Required]
|
||||
public AyaType TagToObjectType { get; set; }
|
||||
|
||||
|
||||
public TagMap()
|
||||
{
|
||||
Created = System.DateTime.UtcNow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
32
server/AyaNova/models/User.cs
Normal file
32
server/AyaNova/models/User.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AyaNova.Biz;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public partial class User
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
[Required]
|
||||
public long OwnerId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Login { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Salt { get; set; }
|
||||
public AuthorizationRoles Roles { get; set; }
|
||||
public string DlKey { get; set; }
|
||||
public DateTime? DlKeyExpire { get; set; }
|
||||
public long LocaleId { get; set; }
|
||||
|
||||
|
||||
public User()
|
||||
{
|
||||
Created = System.DateTime.UtcNow;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
35
server/AyaNova/models/Widget.cs
Normal file
35
server/AyaNova/models/Widget.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AyaNova.Biz;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
//Test class for development
|
||||
public partial class Widget
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
|
||||
[Required]
|
||||
public long OwnerId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public decimal? DollarAmount { get; set; }
|
||||
public bool? Active { get; set; }
|
||||
public AuthorizationRoles Roles { get; set; }
|
||||
public DateTime? StartDate { get; set; }
|
||||
public DateTime? EndDate { get; set; }
|
||||
|
||||
|
||||
public Widget()
|
||||
{
|
||||
Created = System.DateTime.UtcNow;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
20
server/AyaNova/models/dto/ImportV7MapItem.cs
Normal file
20
server/AyaNova/models/dto/ImportV7MapItem.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using AyaNova.Biz;
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Provides mapping during import
|
||||
/// </summary>
|
||||
public partial class ImportAyaNova7MapItem
|
||||
{
|
||||
public AyaTypeId NewObject { get; set; }
|
||||
public Guid V7ObjectId { get; set; }
|
||||
|
||||
public ImportAyaNova7MapItem(Guid v7Guid, AyaType ayaType, long newId){
|
||||
NewObject=new AyaTypeId(ayaType,newId);
|
||||
V7ObjectId=v7Guid;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
40
server/AyaNova/models/dto/JobOperationsFetchInfo.cs
Normal file
40
server/AyaNova/models/dto/JobOperationsFetchInfo.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using AyaNova.Biz;
|
||||
using System;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Job info fetch data
|
||||
/// </summary>
|
||||
public class JobOperationsFetchInfo
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Identity of the job
|
||||
/// </summary>
|
||||
/// <returns> id value of job, can be used to fetch logs</returns>
|
||||
public Guid GId { get; set; }
|
||||
/// <summary>
|
||||
/// Date job was submitted
|
||||
/// </summary>
|
||||
/// <returns>UTC date/time</returns>
|
||||
public DateTime Created { get; set; }
|
||||
/// <summary>
|
||||
/// Date of the most recent operation for this job
|
||||
/// </summary>
|
||||
/// <returns>UTC date/time</returns>
|
||||
public DateTime LastAction { get; set; }
|
||||
/// <summary>
|
||||
/// Descriptive name of the job
|
||||
/// </summary>
|
||||
/// <returns>string</returns>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// Status of the job
|
||||
/// </summary>
|
||||
/// <returns>Job status as string</returns>
|
||||
public string JobStatus { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
26
server/AyaNova/models/dto/JobOperationsLogInfoItem.cs
Normal file
26
server/AyaNova/models/dto/JobOperationsLogInfoItem.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using AyaNova.Biz;
|
||||
using System;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Job log item
|
||||
/// </summary>
|
||||
public class JobOperationsLogInfoItem
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Date of log entry
|
||||
/// </summary>
|
||||
/// <returns>UTC date/time</returns>
|
||||
public DateTime Created { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Log text
|
||||
/// </summary>
|
||||
/// <returns>string</returns>
|
||||
public string StatusText { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
12
server/AyaNova/models/dto/NameIdActiveItem.cs
Normal file
12
server/AyaNova/models/dto/NameIdActiveItem.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public partial class NameIdActiveItem
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool? Active { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
10
server/AyaNova/models/dto/NameIdItem.cs
Normal file
10
server/AyaNova/models/dto/NameIdItem.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public partial class NameIdItem
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
12
server/AyaNova/models/dto/NameItem.cs
Normal file
12
server/AyaNova/models/dto/NameItem.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Dto object for name only parameters in routes
|
||||
/// </summary>
|
||||
public partial class NameItem
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
11
server/AyaNova/models/dto/NewTextIdConcurrencyTokenItem.cs
Normal file
11
server/AyaNova/models/dto/NewTextIdConcurrencyTokenItem.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public partial class NewTextIdConcurrencyTokenItem
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public string NewText { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
14
server/AyaNova/models/dto/TagMapInfo.cs
Normal file
14
server/AyaNova/models/dto/TagMapInfo.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using AyaNova.Biz;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public class TagMapInfo
|
||||
{
|
||||
public long TagId { get; set; }
|
||||
public long TagToObjectId { get; set; }
|
||||
public AyaType TagToObjectType { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
13
server/AyaNova/models/dto/TypeAndIdInfo.cs
Normal file
13
server/AyaNova/models/dto/TypeAndIdInfo.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using AyaNova.Biz;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public class TypeAndIdInfo
|
||||
{
|
||||
public long ObjectId { get; set; }
|
||||
public AyaType ObjectType { get; set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
14
server/AyaNova/models/dto/UploadedFileInfo.cs
Normal file
14
server/AyaNova/models/dto/UploadedFileInfo.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Uploaded file info in it's temporary state
|
||||
/// </summary>
|
||||
public class UploadedFileInfo
|
||||
{
|
||||
public string InitialUploadedPathName { get; set; }
|
||||
public string OriginalFileName { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user