diff --git a/WebDoorCreator.Core/ConfigItem.cs b/WebDoorCreator.Core/ConfigItem.cs new file mode 100644 index 0000000..e85b846 --- /dev/null +++ b/WebDoorCreator.Core/ConfigItem.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebDoorCreator.Core +{ + public class ConfigItem + { + /// + /// Nome dell'item + /// + public string Name { get; set; } = ""; + + /// + /// Tipo dell'item (es: string, int, double, list...) + /// + public string Type { get; set; } = ""; + + /// + /// Valore dell'item + /// + public string ValString { get; set; } = ""; + + public int ValInt + { + get + { + int answ = 0; + int.TryParse(ValString, out answ); + return answ; + } + } + public double ValDouble + { + get + { + double answ = 0; + double.TryParse(ValString, out answ); + return answ; + } + } + + } +} diff --git a/WebDoorCreator.Core/Enum.cs b/WebDoorCreator.Core/Enum.cs index f374775..e869fc4 100644 --- a/WebDoorCreator.Core/Enum.cs +++ b/WebDoorCreator.Core/Enum.cs @@ -2,6 +2,18 @@ { public class Enum { + #region Public Enums + + public enum OrderStatus + { + NA = 0, + DoorDef, + Sent, + ApprovedByMaker, + ApprovedByCustomer, + InProduction + } + public enum UserLevel { ND = 0, @@ -12,14 +24,13 @@ User = 5 } - public enum OrderStatus + public enum DoorDefStep { - NA=0, - DoorDef, - Sent, - ApprovedByMaker, - ApprovedByCustomer, - InProduction + Door = 0, + Hardware, + report } + + #endregion Public Enums } } \ No newline at end of file diff --git a/WebDoorCreator.Core/IniFile.cs b/WebDoorCreator.Core/IniFile.cs new file mode 100644 index 0000000..5bf73a2 --- /dev/null +++ b/WebDoorCreator.Core/IniFile.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace WebDoorCreator.Core +{ + public class IniFile + { + public string FileName; + + /// + /// Constructor + /// + /// + public IniFile(string INIPath) + { + FileName = INIPath; + } + + /// + /// Read data from the Ini file + /// + /// + /// + /// + public string ReadString(string Section, string Key) + { + StringBuilder temp = new StringBuilder(255); + int i = GetPrivateProfileString(Section, Key, "", temp, 255, FileName); + return temp.ToString(); + } + + /// + /// Read a string. If not found use default value + /// + /// + /// + /// + /// + public string ReadString(string Section, string Key, string DefaultVal) + { + string temp = ReadString(Section, Key); + if (temp == "") temp = DefaultVal; + return temp; + } + + /// + /// GetPrivateProfileString: import windows dll functions + /// + /// + /// + /// + /// + /// + /// + /// + [DllImport("kernel32")] + private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); + + /// + /// GetPrivateProfileSection: import windows dll functions + /// + /// + /// + /// + /// + /// + [DllImport("kernel32")] + private static extern int GetPrivateProfileSection(string section, IntPtr retVal, uint size, string filePath); + + /// + /// Read a complete section (keys=values) + /// + /// + /// Section name + /// + /// restituisce delle stringhe keys=values da suddividere appunto come key/val successivamente + /// + public string[] ReadSection(string Section) + { + const int bufferSize = 2048; // max is 32767 + + StringBuilder returnedString = new StringBuilder(); + + IntPtr pReturnedString = Marshal.AllocCoTaskMem(bufferSize); + try + { + int bytesReturned = GetPrivateProfileSection(Section, pReturnedString, bufferSize, FileName); + if (bytesReturned > 0) + { + //bytesReturned -1 to remove trailing \0 + for (int i = 0; i < bytesReturned - 1; i++) + { + var currPointer = IntPtr.Add(pReturnedString, i); + var currChar = (char)Marshal.ReadByte(currPointer); + returnedString.Append(currChar); + } + } + } + finally + { + Marshal.FreeCoTaskMem(pReturnedString); + } + + string sectionData = returnedString.ToString(); + return sectionData.Split('\0'); + } + } +} diff --git a/WebDoorCreator.Core/WebDoorCreator.Core.csproj b/WebDoorCreator.Core/WebDoorCreator.Core.csproj index 1f04627..969c0c7 100644 --- a/WebDoorCreator.Core/WebDoorCreator.Core.csproj +++ b/WebDoorCreator.Core/WebDoorCreator.Core.csproj @@ -7,6 +7,7 @@ + diff --git a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs index e227521..94ce7c1 100644 --- a/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs +++ b/WebDoorCreator.Data/Controllers/WebDoorCreatorController.cs @@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using NLog; +using System.Data; using WebDoorCreator.Data.DbModels; using WebDoorCreator.Data.DTO; @@ -9,63 +10,16 @@ namespace WebDoorCreator.Data.Controllers { public class WebDoorCreatorController : IDisposable { - private static IConfiguration _configuration; - private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + #region Public Constructors public WebDoorCreatorController(IConfiguration configuration) { _configuration = configuration; } - public void Dispose() - { - // Clear database context - //Log.Info("Dispose di GWMSController"); - } + #endregion Public Constructors - #region Company methods - - /// - /// Company list (All) - /// - /// - public List CompanyGetByKey(int id) - { - List dbResult = new List(); - // cerco su DB recuperando set di dati.... - using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) - { - try - { - if (id == 0) - { - - // extracting entire set - dbResult = localDbCtx - .DbSetCompany - .OrderBy(x => x.CompanyName) - .ToList(); - } - else - { - var risultato = localDbCtx - .DbSetCompany - .Where(x => x.CompanyId == id) - .OrderBy(x => x.CompanyName) - .ToList(); - if (risultato != null) - { - dbResult = risultato; - } - } - } - catch (Exception exc) - { - Log.Error($"Error in CompanyAll:{Environment.NewLine}{exc}"); - } - } - return dbResult; - } + #region Public Methods /// /// Adding a new company @@ -115,206 +69,53 @@ namespace WebDoorCreator.Data.Controllers return fatto; } - #endregion Company methods - - #region User methods - /// - /// Populating DTO to handle users - /// - /// User id to search for - /// - public List GetUserRoleClaimByUserId() - { - List dbResult = new List(); - using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) - { - var users = localDbCtx.DbSetUsers.ToList(); - - foreach (var item in users) - { - var userRoles = localDbCtx.DbSetUserRoles - .Where(x => x.UserId == item.Id) - .Include(u => u.UsersNav) - .Include(u => u.RolesNav) - .ToList(); - - //UserRoleClaimDTO userDTO = new UserRoleClaimDTO() - //{ - // userName = item.UserName, - // rolesName = userRoles - //}; - //dbResult.Add(userDTO); - } - } - return dbResult; - } - - /// - /// Retrieving data from user/roles relation + /// Company list (All) /// /// - public List GetUserView() + public List CompanyGetByKey(int id) { - List dbResult = new List(); + List dbResult = new List(); + // cerco su DB recuperando set di dati.... using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) { try { - // extracting entire set - dbResult = localDbCtx - .DbSetUsersView - .OrderBy(x => x.UserId) - .ToList(); - } - catch (Exception exc) - { - Log.Error($"Error in GetUserRole:{Environment.NewLine}{exc}"); - } - } - return dbResult; - } - - /// - /// Retrieving data from users table - /// - /// - public List GetUsersAll() - { - List dbResult = new List(); - using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) - { - try - { - // extracting entire set - dbResult = localDbCtx - .DbSetUsers - .OrderBy(x => x.Id) - .ToList(); - } - catch (Exception exc) - { - Log.Error($"Error in GetUserRole:{Environment.NewLine}{exc}"); - } - } - return dbResult; - } - - /// - /// Retrieving data from users table filtered by id - /// - /// - public AspNetUsers GetUsersById(string userId) - { - AspNetUsers dbResult = new AspNetUsers(); - using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) - { - try - { - // extracting entire set - var risultato = localDbCtx - .DbSetUsers - .Where(x => x.Id == userId) - .AsNoTracking() - .OrderBy(x => x.Id) - .FirstOrDefault(); - - if (risultato != null) + if (id == 0) { - dbResult = risultato; + // extracting entire set + dbResult = localDbCtx + .DbSetCompany + .OrderBy(x => x.CompanyName) + .ToList(); } else { - dbResult = new AspNetUsers(); + var risultato = localDbCtx + .DbSetCompany + .Where(x => x.CompanyId == id) + .OrderBy(x => x.CompanyName) + .ToList(); + if (risultato != null) + { + dbResult = risultato; + } } } catch (Exception exc) { - Log.Error($"Error in GetUsersById:{Environment.NewLine}{exc}"); + Log.Error($"Error in CompanyAll:{Environment.NewLine}{exc}"); } } return dbResult; } - #endregion User methods - - #region Roles methods - /// - /// Retrieving data from roles table - /// - /// - public List GetRolesAll() - { - List dbResult = new List(); - using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) - { - try - { - // extracting entire set - dbResult = localDbCtx - .DbSetRoles - .OrderBy(x => x.Name) - .ToList(); - } - catch (Exception exc) - { - Log.Error($"Error in GetRolesAll:{Environment.NewLine}{exc}"); - } - } - return dbResult; - } - - #endregion Roles methods - - #region Order status methods - - /// - /// Order status - /// - /// - /// - /// - /// - /// - public List GetOrderStatus(int companyId, int orderStatus, DateTime dataFrom, DateTime dataTo) - { - List dbResult = new List(); - using (var dbCtx = new WDCDataContext(_configuration)) - { - try - { - var CompanyId = new SqlParameter("@CompanyId", companyId); - var OrderStatus = new SqlParameter("@OrderStatus", orderStatus); - var DataFrom = new SqlParameter("@DataFrom", dataFrom.Date); - var DataTo = new SqlParameter("@DataTo", dataTo.Date); - - var k = $"exec dbo.stp_OrderList_getFilt {companyId}, {orderStatus}, '{dataFrom.Date.ToString("yyyy/MM/dd")}', '{dataTo.Date.ToString("yyyy/MM/dd")}'"; - - dbResult = dbCtx - .DbSetOrderStatus - .FromSqlRaw("exec dbo.stp_OrderList_getFilt @CompanyId, @OrderStatus, @DataFrom, @DataTo", CompanyId, OrderStatus, DataFrom, DataTo) - .AsNoTracking() - .ToList(); - } - catch (Exception exc) - { - Log.Error($"Error in GetOrderStatus:{Environment.NewLine}{exc}"); - } - } - return dbResult; - } - - #endregion Order status methods - - #region Order methods - - /// - /// Adding a new order + /// Adding a new Compo /// /// Record to add /// - public async Task OrderAdd(OrderModel addRec) + public async Task CompoAdd(HardwareModel addRec) { bool fatto = false; using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) @@ -322,89 +123,93 @@ namespace WebDoorCreator.Data.Controllers try { localDbCtx - .DbSetOrders + .DbSetHardware .Add(addRec); await localDbCtx.SaveChangesAsync(); fatto = true; } catch (Exception exc) { - Log.Error($"Eccezione durante OrderAd: {Environment.NewLine}{exc}"); + Log.Error($"Eccezione durante CompoAdd: {Environment.NewLine}{exc}"); } } return fatto; } - #endregion Order methods - - #region Door methods - - /// - /// Getting door data by orderId - /// - /// - public List DoorsGetByOrderId(int orderId) + public void Dispose() { - List dbResult = new List(); - // retrieving data from db - using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) - { - try - { - // extracting entire set - dbResult = localDbCtx - .DbSetDoor - .Where(x => x.OrderId == orderId) - .OrderBy(x => x.DoorId) - .ToList(); - } - catch (Exception exc) - { - Log.Error($"Error in DoorsGetByOrderId:{Environment.NewLine}{exc}"); - } - } - return dbResult; + // Clear database context + //Log.Info("Dispose di GWMSController"); } /// - /// Modifying or adding a new door + /// Remove door /// - /// Record to edit or add + /// ID da eliminare /// - public async Task DoorUpsert(DoorModel addEditRec) + public async Task DoorDelete(int DoorId) { bool fatto = false; - //List dbResult = new List(); using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) { try { var currRec = localDbCtx .DbSetDoor - .Where(x => x.DoorId == addEditRec.DoorId) + .Where(x => x.DoorId == DoorId) .FirstOrDefault(); - if (currRec != null) //if is not null edit the record found + // procedo solo se c'è + if (currRec != null) { - currRec.Quantity = addEditRec.Quantity; - localDbCtx.Entry(currRec).State = EntityState.Modified; + var newDbRec = localDbCtx + .DbSetDoor + .Remove(currRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; } - else //if is null add the record as new in the table - { - localDbCtx - .DbSetDoor - .Add(addEditRec); - } - await localDbCtx.SaveChangesAsync(); - fatto = true; } catch (Exception exc) { - Log.Error($"Eccezione durante DoorsAddMod: {Environment.NewLine}{exc}"); + Log.Error($"Eccezione durante DoorDelete: {Environment.NewLine}{exc}"); } } return fatto; } + /// + /// Adding a new door + /// + /// Record to edit or add + /// + public async Task DoorInsert(DoorModel newRec) + { + int newId = 0; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetDoor + .Where(x => x.DoorId == newRec.DoorId) + .FirstOrDefault(); + // procedo solo se non c'è già + if (currRec == null) + { + var newDbRec = localDbCtx + .DbSetDoor + .Add(newRec); + await localDbCtx.SaveChangesAsync(); + newId = newRec.DoorId; + } + } + catch (Exception exc) + { + Log.Error($"Eccezione durante DoorInsert: {Environment.NewLine}{exc}"); + } + } + return newId; + } + /// /// Adding or removing a single door /// @@ -447,9 +252,248 @@ namespace WebDoorCreator.Data.Controllers return fatto; } - #endregion Door methods + /// + /// Retrieving current data from door + /// + /// + public List DoorOpGetByDoorId(int doorId) + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + // extracting entire set + dbResult = localDbCtx + .DbSetDoorOp + .Where(x => x.DoorId == doorId) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Error in DoorOpGetByDoorId:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } - #region ListValues Methods + /// + /// Adding door's OP + /// + /// Records to add + /// + public async Task DoorOpInsert(List newOpRec) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + localDbCtx + .DbSetDoorOp + .AddRange(newOpRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante DoorInsert: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Adding a new DoorOpType + /// + /// Record to add + /// + public async Task DoorOpTypeAdd(DoorOpTypeModel addRec) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + localDbCtx + .DbSetDoorOpType + .Add(addRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante DoorOpTypeAdd:{Environment.NewLine}{exc}"); + } + } + + return fatto; + } + + /// + /// Adding a new DoorOpType + /// + /// Record to add + /// + public async Task DoorOpTypeAddRange(List listRec) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + localDbCtx + .DbSetDoorOpType + .AddRange(listRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante DoorOpTypeAddRange:{Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Retrieving data from door operation type table + /// + /// + public List DoorOpTypeGetAll() + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + // extracting entire set + dbResult = localDbCtx + .DbSetDoorOpType + .OrderBy(x => x.DoorOpTypId) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Error in DoorOpTypeGetAll:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + public async Task> DoorOpTypeGetDefault() + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + dbResult = localDbCtx + .DbSetDoorOpType + .Where(x => x.IsDefault) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante DoorOpTypeGetDefault: {Environment.NewLine}{exc}"); + } + } + await Task.Delay(1); + return dbResult; + } + + /// + /// Getting door data by orderId + /// + /// + public List DoorsGetByOrderId(int orderId) + { + List dbResult = new List(); + // retrieving data from db + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + // extracting entire set + dbResult = localDbCtx + .DbSetDoor + .Where(x => x.OrderId == orderId) + .Include(o => o.OrderNav) + .Include(t => t.TypeNav) + .OrderBy(x => x.DoorId) + .AsNoTracking() + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Error in DoorsGetByOrderId:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + /// + /// Modifying or adding a new door + /// + /// Record to edit or add + /// + public async Task DoorUpsert(DoorModel addEditRec) + { + bool fatto = false; + //List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + var currRec = localDbCtx + .DbSetDoor + .Where(x => x.DoorId == addEditRec.DoorId) + .FirstOrDefault(); + if (currRec != null) //if is not null edit the record found + { + currRec.Quantity = addEditRec.Quantity; + localDbCtx.Entry(currRec).State = EntityState.Modified; + } + else //if is null add the record as new in the table + { + localDbCtx + .DbSetDoor + .Add(addEditRec); + } + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante DoorUpsert: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Estraggo tutte le lingue disponibili per questa applicazione + /// + /// + public List LanguageGetAll() + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + // extracting entire set + dbResult = localDbCtx + .DbSetLanguages + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Error in LanguageGetAll:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } /// /// ListValues list (All) @@ -478,6 +522,436 @@ namespace WebDoorCreator.Data.Controllers return dbResult; } - #endregion ListValues Methods + /// + /// Adding a new list value + /// + /// Record to add + /// + public async Task ListValuesAdd(List addList) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + + // stored di reset ListValues + var storedRes = localDbCtx + .Database + .ExecuteSqlRaw("exec dbo.stp_ListVal_Prepare"); + await localDbCtx.SaveChangesAsync(); + + // import massivo dati in tab temp + localDbCtx + .DbSetValuesTemp + .AddRange(addList); + await localDbCtx.SaveChangesAsync(); + + // stored di merge dati in vocabolario + storedRes = localDbCtx + .Database + .ExecuteSqlRaw("exec dbo.stp_ListVal_Import"); + + fatto = true; + + + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ListValuesAdd: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Adding a new order + /// + /// Record to add + /// + public async Task OrderAdd(OrderModel addRec) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + localDbCtx + .DbSetOrders + .Add(addRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OrderAd: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Remove order + /// + /// Record to add + /// + public async Task OrderRem(int OrdId) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + var selRec = localDbCtx + .DbSetOrders + .Where(x => x.OrderId == OrdId) + .FirstOrDefault(); + if (selRec != null) + { + localDbCtx.DbSetOrders.Remove(selRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OrderRem: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Order status + /// + /// + /// + /// + /// + /// + public List OrderStatusGetAll(int companyId, int orderStatus, DateTime dataFrom, DateTime dataTo) + { + List dbResult = new List(); + using (var dbCtx = new WDCDataContext(_configuration)) + { + try + { + var CompanyId = new SqlParameter("@CompanyId", companyId); + var OrderStatus = new SqlParameter("@OrderStatus", orderStatus); + var DataFrom = new SqlParameter("@DataFrom", dataFrom); + var DataTo = new SqlParameter("@DataTo", dataTo); + + dbResult = dbCtx + .DbSetOrderStatus + .FromSqlRaw("exec dbo.stp_OrderList_getFilt @CompanyId, @OrderStatus, @DataFrom, @DataTo", CompanyId, OrderStatus, DataFrom, DataTo) + .AsNoTracking() + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Error in GetOrderStatus:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + /// + /// Adding a new graphic param + /// + /// Record to add + /// + public async Task ParamAdd(GraphicParamsModel addRec) + { + bool fatto = false; + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + localDbCtx + .DbSetGraphicParams + .Add(addRec); + await localDbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ParamAdd: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + + /// + /// Getting all the graphic parameters by hw id + /// + /// Hardware's id to search for + /// + public List ParamGetByHwId(int hwId) + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + dbResult = localDbCtx + .DbSetGraphicParams + .Where(x => x.compoId == hwId) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ParamGetByHwId: {Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + /// + /// Retrieving data from roles table + /// + /// + public List RolesGetAll() + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + // extracting entire set + dbResult = localDbCtx + .DbSetRoles + .OrderBy(x => x.Name) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Error in GetRolesAll:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + /// + /// truncate tables for testing purposes + /// + /// + public bool TestTablesTruncate() + { + bool dbResult = false; + using (var dbCtx = new WDCDataContext(_configuration)) + { + try + { + dbCtx + .Database + .ExecuteSqlRaw("EXEC man.[stp_TruncTables]"); + + dbResult = true; + } + catch (Exception exc) + { + Log.Error($"Error in TablesTruncate:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + /// + /// Populating DTO to handle users + /// + /// User id to search for + /// + public List UserRoleClaimGetByUserId() + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + var users = localDbCtx.DbSetUsers.ToList(); + + foreach (var item in users) + { + var userRoles = localDbCtx.DbSetUserRoles + .Where(x => x.UserId == item.Id) + .Include(u => u.UsersNav) + .Include(u => u.RolesNav) + .ToList(); + } + } + return dbResult; + } + + /// + /// Retrieving data from users table + /// + /// + public List UsersGetAll() + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + // extracting entire set + dbResult = localDbCtx + .DbSetUsers + .OrderBy(x => x.Id) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Error in GetUserRole:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + /// + /// Retrieving data from users table filtered by id + /// + /// + public AspNetUsers UsersGetById(string userId) + { + AspNetUsers dbResult = new AspNetUsers(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + // extracting entire set + var risultato = localDbCtx + .DbSetUsers + .Where(x => x.Id == userId) + .AsNoTracking() + .OrderBy(x => x.Id) + .FirstOrDefault(); + + if (risultato != null) + { + dbResult = risultato; + } + else + { + dbResult = new AspNetUsers(); + } + } + catch (Exception exc) + { + Log.Error($"Error in GetUsersById:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + + /// + /// Retrieving data from user/roles relation + /// + /// + public List UserViewGetAll() + { + List dbResult = new List(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + // extracting entire set + dbResult = localDbCtx + .DbSetUsersView + .OrderBy(x => x.UserId) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Error in GetUserRole:{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + public Dictionary> VocLemmaGetAll() + { + Dictionary> DTOResult = new Dictionary>(); + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + List lingue = new List() + { + "IT", + "EN" + }; + + // extracting entire set + var allVoc = localDbCtx + .DbSetVocabulary + .AsNoTracking() + .ToList(); + + foreach (var lingua in lingue) + { + Dictionary dict = new Dictionary(); + foreach (var lemma in allVoc.Where(x => x.Lingua == lingua)) + { + dict.Add(lemma.Lemma, lemma.Traduzione); + } + DTOResult.Add(lingua, dict); + } + } + catch (Exception exc) + { + Log.Error($"Error in VocLemmaGetAll:{Environment.NewLine}{exc}"); + } + } + return DTOResult; + } + + /// + /// Aggiunta di un nuovo set di lemmi + /// + /// + /// + public async Task VocLemmaInsert(List listNewTerms) + { + bool fatto = false; + + //var o = listNewTerms.Where(x => x.Traduzione.Length > 200).ToList(); + + using (WDCDataContext localDbCtx = new WDCDataContext(_configuration)) + { + try + { + // stored di reset vocabolario + var storedRes = localDbCtx + .Database + .ExecuteSqlRaw("exec dbo.stp_Voc_Prepare"); + await localDbCtx.SaveChangesAsync(); + + // import massivo dati in tab temp + localDbCtx + .DbSetVocabularyTemp + .AddRange(listNewTerms); + await localDbCtx.SaveChangesAsync(); + + // stored di merge dati in vocabolario + storedRes = localDbCtx + .Database + .ExecuteSqlRaw("exec dbo.stp_Voc_Import"); + + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante VocLemmaInsert: {Environment.NewLine}{exc}"); + } + } + return fatto; + } + + #endregion Public Methods + + #region Private Fields + + private static IConfiguration _configuration; + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields } } \ No newline at end of file diff --git a/WebDoorCreator.Data/DbModels/DoorModel.cs b/WebDoorCreator.Data/DbModels/DoorModel.cs index c5853c1..6a65e06 100644 --- a/WebDoorCreator.Data/DbModels/DoorModel.cs +++ b/WebDoorCreator.Data/DbModels/DoorModel.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace WebDoorCreator.Data.DbModels { /// - /// Tabella dati Orders + /// Tabella dati Door /// [Table("Door")] public class DoorModel @@ -25,6 +25,11 @@ namespace WebDoorCreator.Data.DbModels /// public int OrderId { get; set; } + /// + /// Unità di misura + /// + public string MeasureUnit { get; set; } = ""; + /// /// Door's Type /// @@ -71,6 +76,16 @@ namespace WebDoorCreator.Data.DbModels public decimal UnitCost { get; set; } = 0; + /// + /// Data scadenza Lock + /// + public DateTime DateLockExpiry { get; set; } = DateTime.Now; + + /// + /// Codice utente che ha bloccato record + /// + public string UserIdLock { get; set; } = ""; + [ForeignKey("OrderId")] public virtual OrderModel? OrderNav { get; set; } diff --git a/WebDoorCreator.Data/DbModels/DoorOpModel.cs b/WebDoorCreator.Data/DbModels/DoorOpModel.cs new file mode 100644 index 0000000..ac10a90 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/DoorOpModel.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Tabella dati operation CONCRETE collegate alla porta + /// + [Table("DoorOp")] + public class DoorOpModel + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int DoorOpId { get; set; } + + /// + /// porta di riferimento + /// + public int DoorId { get; set; } = 0; + /// + /// Tipo astratto di riferimento + /// + public int DoorOpTypId { get; set; } = 0; + + /// + /// Descrizione + /// + public string Description { get; set; } = ""; + + /// + /// Data inserimento ordine + /// + public DateTime DateIns { get; set; } = DateTime.Now; + + /// + /// Codice utente che ha creato + /// + public string UserIdIns { get; set; } = ""; + + /// + /// Data (ultima) modifica ordine + /// + public DateTime DateMod { get; set; } = DateTime.Now; + + /// + /// Codice utente che ha creato + /// + public string UserIdMod { get; set; } = ""; + + /// + /// Oggetto Json per specifica configurazione VALORIZZATO + /// + public string JsoncConfigVal { get; set; } = ""; + + + [ForeignKey("DoorId")] + public virtual DoorModel? DoorNav { get; set; } + + [ForeignKey("DoorOpTypId")] + public virtual DoorOpTypeModel? DoorOpTypeNav { get; set; } + } +} diff --git a/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs b/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs new file mode 100644 index 0000000..2bf2aca --- /dev/null +++ b/WebDoorCreator.Data/DbModels/DoorOpTypeModel.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Tabella dati Door Operation Type (astratte) + /// + [Table("DoorOpType")] + public class DoorOpTypeModel + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int DoorOpTypId { get; set; } + + /// + /// Codice univoco dell'operazione da svolgere (calcolato, idealmente 4 char da 36 val 0..Z) + /// + public string OpCode { get; set; } = ""; + + /// + /// Descrizione + /// + public string Description { get; set; } = ""; + + /// + /// Indica se sia da creare sempre + /// + public bool IsDefault { get; set; } = false; + + /// + /// Indica se ci sia un hardware correlato all'operazione + /// + public bool HasHw { get; set; } = true; + + /// + /// Indica se sia un oggetto concreto (= con un file, che si può produrre) o abstract (ha figli, è un gruppo logico) + /// + public bool IsConcrete { get; set; } = true; + + /// + /// Codice dell'HW collegato + /// + public string HwCode { get; set; } = ""; + + /// + /// Descrizione dell'HW collegato + /// + public string HwDescription { get; set; } = ""; + + + /// + /// URL dell'immagine/link di riferimento + /// + public string DisplayUrl { get; set; } = ""; + + /// + /// Path folder/file di riferimento + /// + public string FPath { get; set; } = ""; + + /// + /// Idx univoco dell'elemento parent (se 0 = root) + /// + public int ParentDoorOpId { get; set; } = 0; + +#if false + + /// + /// Codice tipo treeView + /// + public string TreeCode { get; set; } = ""; +#endif + + /// + /// Idx univoco dell'elemento parent (se 0 = root) + /// + public HierarchyId? DoorOpIdPathFromPatriarch { get; set; } + + + /// + /// Oggetto Json per specifica configurazione (template) + /// + public string JsoncConfig { get; set; } = ""; + + /// + /// Codice esterno (opzionale) + /// + public string ExtOpCode { get; set; } = ""; + + /// + /// Descrizione esterna (opzionale) + /// + public string ExtDescript { get; set; } = ""; + + /// + /// Revisione dell'item + /// + public string Rev { get; set; } = ""; + + /// + /// Inizio validità item + /// + public DateTime ValidFrom { get; set; } = new DateTime(2000, 1, 1); + + /// + /// Fine validità item + /// + public DateTime ValidUntil { get; set; } = new DateTime(3000, 1, 1); + + /// + /// Check validità item + /// + [NotMapped] + public bool IsActive + { + get => DateTime.Today >= ValidFrom && DateTime.Today <= ValidUntil; + } + + /// + /// Numero massimo associabile a singola Door + /// + public int MaxAllowed { get; set; } = 1; + +#if false + [ForeignKey("ParentDoorOpId")] + public virtual DoorOpModel? ParentNav { get; set; } +#endif + } +} diff --git a/WebDoorCreator.Data/DbModels/DoorTypeModel.cs b/WebDoorCreator.Data/DbModels/DoorTypeModel.cs index 624cae5..c219731 100644 --- a/WebDoorCreator.Data/DbModels/DoorTypeModel.cs +++ b/WebDoorCreator.Data/DbModels/DoorTypeModel.cs @@ -12,7 +12,7 @@ using System.Threading.Tasks; namespace WebDoorCreator.Data.DbModels { /// - /// Tabella dati Orders + /// Tabella dati Door Type /// [Table("DoorType")] public class DoorTypeModel diff --git a/WebDoorCreator.Data/DbModels/Edges.cs b/WebDoorCreator.Data/DbModels/Edges.cs new file mode 100644 index 0000000..48b2b84 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/Edges.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebDoorCreator.Data.DbModels +{ + public class Edges + { + public string lockEdge { get; set; } = "BV"; + public string hingeEdge { get; set; } = "BV"; + public string topEdge { get; set; } = "SQ"; + public string bottomEdge { get; set; } = "SQ"; + } +} diff --git a/WebDoorCreator.Data/DbModels/GraphicParamsModel.cs b/WebDoorCreator.Data/DbModels/GraphicParamsModel.cs new file mode 100644 index 0000000..8c4dde8 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/GraphicParamsModel.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Tabella dati Hardware + /// + [Table("GraphicParams")] + public class GraphicParamsModel + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int GraphicParamId { get; set; } + + /// + /// Id del componente di riferimento + /// + public int compoId { get; set; } = 0; + + /// + /// Testata del gruppo di parametri + /// + public string graphicParamsN { get; set; } = ""; + + /// + /// Titolo del parametro + /// + public string graphicParamKey { get; set; } = ""; + + /// + /// Nome del parametro scritto nel file DDF + /// + public string graphicParamName { get; set; } = ""; + + /// + /// Nome del parametro visualizzato dall'utente + /// + public string graphicParamAlias { get; set; } = ""; + + /// + /// Tipo del parametro + /// + public string graphicParamType { get; set; } = ""; + + /// + /// Tipo del parametro + /// + public string graphicParamDefaultVal { get; set; } = ""; + } +} diff --git a/WebDoorCreator.Data/DbModels/HardwareModel.cs b/WebDoorCreator.Data/DbModels/HardwareModel.cs new file mode 100644 index 0000000..53da97e --- /dev/null +++ b/WebDoorCreator.Data/DbModels/HardwareModel.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Tabella dati Hardware + /// + [Table("Hardware")] + public class HardwareModel + { + [Key] + public int HardwareId { get; set; } + + /// + /// Nome del componente che verrà scritto nel file DDF + /// + public string compoName { get; set; } = ""; + /// + /// Nome del componente che verrà visualizzato a schermo (pescato dal file di sinonimi) + /// + public string compoAlias { get; set; } = ""; + /// + /// Nome del layer legato al componente + /// + public string compoLayerName { get; set; } = ""; + /// + /// Indica se il il componente deve risultare utilizzabile dal cliente + /// + public bool compoTemplateIsActive { get; set; } = true; + } +} diff --git a/WebDoorCreator.Data/DbModels/LanguageModel.cs b/WebDoorCreator.Data/DbModels/LanguageModel.cs new file mode 100644 index 0000000..d6d3f9d --- /dev/null +++ b/WebDoorCreator.Data/DbModels/LanguageModel.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static WebDoorCreator.Core.Enum; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Lingue conosciute per il programma + /// + [Table("Languages")] + public class LanguageModel + { + /// + /// codice lingua + /// + [Key, MaxLength(5)] + public string CodLingua { get; set; } = ""; + + /// + /// Descrizione della lingua (Lingua per esteso) + /// + [MaxLength(50)] + public string DescrizioneLingua { get; set; } = ""; + } +} diff --git a/WebDoorCreator.Data/DbModels/ListValuesTempModel.cs b/WebDoorCreator.Data/DbModels/ListValuesTempModel.cs new file mode 100644 index 0000000..80b9714 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/ListValuesTempModel.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebDoorCreator.Data.DbModels +{ +#nullable disable + // + // This is here so CodeMaid doesn't reorganize this document + // + [Table("ListValuesTemp")] + public partial class ListValuesTempModel + { + #region Public Properties + + [MaxLength(50)] + public string TableName { get; set; } + + [MaxLength(50)] + public string FieldName { get; set; } + + [MaxLength(50)] + public string value { get; set; } + + [MaxLength(50)] + public string label { get; set; } + + public int ordinal { get; set; } + + #endregion Public Properties + } +} diff --git a/WebDoorCreator.Data/DbModels/Opening.cs b/WebDoorCreator.Data/DbModels/Opening.cs new file mode 100644 index 0000000..fddd4f9 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/Opening.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebDoorCreator.Data.DbModels +{ + public class Opening + { + public string swing { get; set; } = "RH"; + } +} diff --git a/WebDoorCreator.Data/DbModels/Sizing.cs b/WebDoorCreator.Data/DbModels/Sizing.cs new file mode 100644 index 0000000..0068b75 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/Sizing.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WebDoorCreator.Data.DbModels +{ + public class Sizing + { + public string width { get; set; } = "33.8125"; + public string height { get; set; } = "81.25"; + public string thickness { get; set; } = "1.75"; + } +} diff --git a/WebDoorCreator.Data/DbModels/VocabularyModel.cs b/WebDoorCreator.Data/DbModels/VocabularyModel.cs new file mode 100644 index 0000000..140bf92 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/VocabularyModel.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static WebDoorCreator.Core.Enum; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Vocabolario termini + /// + [Table("Vocabulary")] + public class VocabularyModel + { + /// + /// Lingua del lemma + /// + [MaxLength(5)] + public string Lingua { get; set; } = ""; + + /// + /// Lemma del termine + /// + [MaxLength(50)] + public string Lemma { get; set; } = ""; + + /// + /// Traduzione del lemma + /// + [MaxLength(500)] + public string Traduzione { get; set; } = ""; + } +} diff --git a/WebDoorCreator.Data/DbModels/VocabularyTempModel.cs b/WebDoorCreator.Data/DbModels/VocabularyTempModel.cs new file mode 100644 index 0000000..1ba7024 --- /dev/null +++ b/WebDoorCreator.Data/DbModels/VocabularyTempModel.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static WebDoorCreator.Core.Enum; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace WebDoorCreator.Data.DbModels +{ + /// + /// Vocabolario termini + /// + [Table("VocabularyTemp")] + public class VocabularyTempModel + { + /// + /// Lingua del lemma + /// + [MaxLength(5)] + public string Lingua { get; set; } = ""; + + /// + /// Lemma del termine + /// + [MaxLength(50)] + public string Lemma { get; set; } = ""; + + /// + /// Traduzione del lemma + /// + [MaxLength(500)] + public string Traduzione { get; set; } = ""; + } +} diff --git a/WebDoorCreator.Data/DoorOpConfiguration.cs b/WebDoorCreator.Data/DoorOpConfiguration.cs new file mode 100644 index 0000000..590fbbe --- /dev/null +++ b/WebDoorCreator.Data/DoorOpConfiguration.cs @@ -0,0 +1,45 @@ +using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using WebDoorCreator.Data.DbModels; + +namespace WebDoorCreator.Data +{ + public class DoorOpConfiguration : IEntityTypeConfiguration + { + + + #region Public Methods + + public void Configure(EntityTypeBuilder builder) + { + + // Default seeded users + + } + + #endregion Public Methods + + #region Protected Fields + + #endregion Protected Fields + + #region Protected Methods + + //protected DoorOpModel getNewDoorOP(int DoorOpId, int DoorId, int DoorOpTypId, string Description, DateTime DateIns, string UserIdIns, DateTime DateMod, string UserIdMod, string JsoncConfigVal) + //{ + // var newRec = new IdentityUser + // { + // UserName = email, + // NormalizedUserName = email.ToUpper(), + // Email = email, + // NormalizedEmail = email.ToUpper(), + // EmailConfirmed = true, + // PasswordHash = hasher.HashPassword(null!, passwd), + // }; + // return newRec; + //} + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/WebDoorCreator.Data/LanguageConfiguration.cs b/WebDoorCreator.Data/LanguageConfiguration.cs new file mode 100644 index 0000000..6cb29af --- /dev/null +++ b/WebDoorCreator.Data/LanguageConfiguration.cs @@ -0,0 +1,38 @@ +using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using WebDoorCreator.Data.DbModels; +using Org.BouncyCastle.Utilities.Collections; + +namespace WebDoorCreator.Data +{ + public class LanguageConfiguration : IEntityTypeConfiguration + { + #region Public Methods + + public void Configure(EntityTypeBuilder builder) + { + builder.HasData( + getNewLang("EN", "English"), + getNewLang("IT", "Italiano") + ); + } + + #endregion Public Methods + + protected LanguageModel getNewLang(string codeLang, string descLang) + { + var newRec = new LanguageModel + { + CodLingua = codeLang, + DescrizioneLingua = descLang + }; + return newRec; + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.Designer.cs new file mode 100644 index 0000000..c8b72ff --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.Designer.cs @@ -0,0 +1,635 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230322163704_DoorOpModelCreation")] + partial class DoorOpModelCreation + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TreeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.cs b/WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.cs new file mode 100644 index 0000000..6c7e23d --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230322163704_DoorOpModelCreation.cs @@ -0,0 +1,91 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class DoorOpModelCreation : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "DoorOpType", + columns: table => new + { + DoorOpTypId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OpCode = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + HasHw = table.Column(type: "bit", nullable: false), + IsConcrete = table.Column(type: "bit", nullable: false), + HwCode = table.Column(type: "nvarchar(max)", nullable: false), + HwDescription = table.Column(type: "nvarchar(max)", nullable: false), + FPath = table.Column(type: "nvarchar(max)", nullable: false), + ParentDoorOpId = table.Column(type: "int", nullable: false), + TreeCode = table.Column(type: "nvarchar(max)", nullable: false), + JsoncConfig = table.Column(type: "nvarchar(max)", nullable: false), + ExtOpCode = table.Column(type: "nvarchar(max)", nullable: false), + ExtDescript = table.Column(type: "nvarchar(max)", nullable: false), + Rev = table.Column(type: "nvarchar(max)", nullable: false), + ValidFrom = table.Column(type: "datetime2", nullable: false), + ValidUntil = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DoorOpType", x => x.DoorOpTypId); + }); + + migrationBuilder.CreateTable( + name: "DoorOp", + columns: table => new + { + DoorOpId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + DoorId = table.Column(type: "int", nullable: false), + DoorOpTypId = table.Column(type: "int", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + DateIns = table.Column(type: "datetime2", nullable: false), + UserIdIns = table.Column(type: "nvarchar(max)", nullable: false), + DateMod = table.Column(type: "datetime2", nullable: false), + UserIdMod = table.Column(type: "nvarchar(max)", nullable: false), + JsoncConfigVal = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_DoorOp", x => x.DoorOpId); + table.ForeignKey( + name: "FK_DoorOp_Door_DoorId", + column: x => x.DoorId, + principalTable: "Door", + principalColumn: "DoorId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_DoorOp_DoorOpType_DoorOpTypId", + column: x => x.DoorOpTypId, + principalTable: "DoorOpType", + principalColumn: "DoorOpTypId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_DoorOp_DoorId", + table: "DoorOp", + column: "DoorId"); + + migrationBuilder.CreateIndex( + name: "IX_DoorOp_DoorOpTypId", + table: "DoorOp", + column: "DoorOpTypId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "DoorOp"); + + migrationBuilder.DropTable( + name: "DoorOpType"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.Designer.cs new file mode 100644 index 0000000..07df1ad --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.Designer.cs @@ -0,0 +1,649 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230323075059_DoorOpMigr")] + partial class DoorOpMigr + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TreeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.HasIndex("ParentDoorOpId") + .IsUnique(); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpModel", "ParentNav") + .WithOne() + .HasForeignKey("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "ParentDoorOpId") + .OnDelete(DeleteBehavior.NoAction) + .IsRequired(); + + b.Navigation("ParentNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.cs b/WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.cs new file mode 100644 index 0000000..312cd75 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230323075059_DoorOpMigr.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class DoorOpMigr : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_DoorOpType_ParentDoorOpId", + table: "DoorOpType", + column: "ParentDoorOpId", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_DoorOpType_DoorOp_ParentDoorOpId", + table: "DoorOpType", + column: "ParentDoorOpId", + principalTable: "DoorOp", + principalColumn: "DoorOpId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DoorOpType_DoorOp_ParentDoorOpId", + table: "DoorOpType"); + + migrationBuilder.DropIndex( + name: "IX_DoorOpType_ParentDoorOpId", + table: "DoorOpType"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.Designer.cs new file mode 100644 index 0000000..dcab92a --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.Designer.cs @@ -0,0 +1,699 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230328135646_HWHandle")] + partial class HWHandle + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.cs b/WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.cs new file mode 100644 index 0000000..28cd089 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230328135646_HWHandle.cs @@ -0,0 +1,110 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class HWHandle : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DoorOpType_DoorOp_ParentDoorOpId", + table: "DoorOpType"); + + migrationBuilder.DropIndex( + name: "IX_DoorOpType_ParentDoorOpId", + table: "DoorOpType"); + + migrationBuilder.DropColumn( + name: "ParentDoorOpId", + table: "DoorOpType"); + + migrationBuilder.DropColumn( + name: "TreeCode", + table: "DoorOpType"); + + migrationBuilder.AddColumn( + name: "DoorOpIdPathFromPatriarch", + table: "DoorOpType", + type: "hierarchyid", + nullable: true); + + migrationBuilder.CreateTable( + name: "GraphicParams", + columns: table => new + { + GraphicParamId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + compoId = table.Column(type: "int", nullable: false), + graphicParamsN = table.Column(type: "nvarchar(max)", nullable: false), + graphicParamKey = table.Column(type: "nvarchar(max)", nullable: false), + graphicParamName = table.Column(type: "nvarchar(max)", nullable: false), + graphicParamAlias = table.Column(type: "nvarchar(max)", nullable: false), + graphicParamType = table.Column(type: "nvarchar(max)", nullable: false), + graphicParamDefaultVal = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GraphicParams", x => x.GraphicParamId); + }); + + migrationBuilder.CreateTable( + name: "Hardware", + columns: table => new + { + HardwareId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + compoName = table.Column(type: "nvarchar(max)", nullable: false), + compoAlias = table.Column(type: "nvarchar(max)", nullable: false), + compoLayerName = table.Column(type: "nvarchar(max)", nullable: false), + compoTemplateIsActive = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Hardware", x => x.HardwareId); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "GraphicParams"); + + migrationBuilder.DropTable( + name: "Hardware"); + + migrationBuilder.DropColumn( + name: "DoorOpIdPathFromPatriarch", + table: "DoorOpType"); + + migrationBuilder.AddColumn( + name: "ParentDoorOpId", + table: "DoorOpType", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TreeCode", + table: "DoorOpType", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + + migrationBuilder.CreateIndex( + name: "IX_DoorOpType_ParentDoorOpId", + table: "DoorOpType", + column: "ParentDoorOpId", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_DoorOpType_DoorOp_ParentDoorOpId", + table: "DoorOpType", + column: "ParentDoorOpId", + principalTable: "DoorOp", + principalColumn: "DoorOpId"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.Designer.cs new file mode 100644 index 0000000..4d76d75 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.Designer.cs @@ -0,0 +1,710 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230330102212_DoorLockAndMeasure")] + partial class DoorLockAndMeasure + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.cs b/WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.cs new file mode 100644 index 0000000..0b08579 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230330102212_DoorLockAndMeasure.cs @@ -0,0 +1,49 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class DoorLockAndMeasure : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "DateLockExpiry", + table: "Door", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "MeasureUnit", + table: "Door", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "UserIdLock", + table: "Door", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DateLockExpiry", + table: "Door"); + + migrationBuilder.DropColumn( + name: "MeasureUnit", + table: "Door"); + + migrationBuilder.DropColumn( + name: "UserIdLock", + table: "Door"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230330111904_DoorOpTypeinit.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230330111904_DoorOpTypeinit.Designer.cs new file mode 100644 index 0000000..a74343c --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230330111904_DoorOpTypeinit.Designer.cs @@ -0,0 +1,713 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230330111904_DoorOpTypeinit")] + partial class DoorOpTypeinit + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("Isdefault") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230330111904_DoorOpTypeinit.cs b/WebDoorCreator.Data/Migrations/WDCData/20230330111904_DoorOpTypeinit.cs new file mode 100644 index 0000000..b2c2e09 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230330111904_DoorOpTypeinit.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class DoorOpTypeinit : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Isdefault", + table: "DoorOpType", + type: "bit", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Isdefault", + table: "DoorOpType"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.Designer.cs new file mode 100644 index 0000000..37a15bf --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.Designer.cs @@ -0,0 +1,723 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230331131556_DoorOpTypeExtend01")] + partial class DoorOpTypeExtend01 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MaxAllowed") + .HasColumnType("int"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.cs b/WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.cs new file mode 100644 index 0000000..ed3c2d3 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230331131556_DoorOpTypeExtend01.cs @@ -0,0 +1,58 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class DoorOpTypeExtend01 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Isdefault", + table: "DoorOpType", + newName: "IsDefault"); + + migrationBuilder.AddColumn( + name: "DisplayUrl", + table: "DoorOpType", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "MaxAllowed", + table: "DoorOpType", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ParentDoorOpId", + table: "DoorOpType", + type: "int", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DisplayUrl", + table: "DoorOpType"); + + migrationBuilder.DropColumn( + name: "MaxAllowed", + table: "DoorOpType"); + + migrationBuilder.DropColumn( + name: "ParentDoorOpId", + table: "DoorOpType"); + + migrationBuilder.RenameColumn( + name: "IsDefault", + table: "DoorOpType", + newName: "Isdefault"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230403143539_VocabularyAndTempAdd.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230403143539_VocabularyAndTempAdd.Designer.cs new file mode 100644 index 0000000..c998595 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230403143539_VocabularyAndTempAdd.Designer.cs @@ -0,0 +1,763 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230403143539_VocabularyAndTempAdd")] + partial class VocabularyAndTempAdd + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MaxAllowed") + .HasColumnType("int"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("Vocabulary"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("VocabularyTemp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230403143539_VocabularyAndTempAdd.cs b/WebDoorCreator.Data/Migrations/WDCData/20230403143539_VocabularyAndTempAdd.cs new file mode 100644 index 0000000..f0afdc9 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230403143539_VocabularyAndTempAdd.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class VocabularyAndTempAdd : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Vocabulary", + columns: table => new + { + Lingua = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), + Lemma = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Traduzione = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Vocabulary", x => new { x.Lingua, x.Lemma }); + }); + + migrationBuilder.CreateTable( + name: "VocabularyTemp", + columns: table => new + { + Lingua = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), + Lemma = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Traduzione = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VocabularyTemp", x => new { x.Lingua, x.Lemma }); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Vocabulary"); + + migrationBuilder.DropTable( + name: "VocabularyTemp"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.Designer.cs new file mode 100644 index 0000000..231133a --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.Designer.cs @@ -0,0 +1,791 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230404072710_AddLanguagePack")] + partial class AddLanguagePack + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MaxAllowed") + .HasColumnType("int"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.LanguageModel", b => + { + b.Property("CodLingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("DescrizioneLingua") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("CodLingua"); + + b.ToTable("Languages"); + + b.HasData( + new + { + CodLingua = "EN", + DescrizioneLingua = "English" + }, + new + { + CodLingua = "IT", + DescrizioneLingua = "Italiano" + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("Vocabulary"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("VocabularyTemp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.cs b/WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.cs new file mode 100644 index 0000000..8844c45 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230404072710_AddLanguagePack.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class AddLanguagePack : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Languages", + columns: table => new + { + CodLingua = table.Column(type: "nvarchar(5)", maxLength: 5, nullable: false), + DescrizioneLingua = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Languages", x => x.CodLingua); + }); + + migrationBuilder.InsertData( + table: "Languages", + columns: new[] { "CodLingua", "DescrizioneLingua" }, + values: new object[] { "EN", "English" }); + + migrationBuilder.InsertData( + table: "Languages", + columns: new[] { "CodLingua", "DescrizioneLingua" }, + values: new object[] { "IT", "Italiano" }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Languages"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.Designer.cs b/WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.Designer.cs new file mode 100644 index 0000000..b008afd --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.Designer.cs @@ -0,0 +1,817 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using WebDoorCreator.Data; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + [DbContext(typeof(WDCDataContext))] + [Migration("20230404153616_AddListValuesTemp")] + partial class AddListValuesTemp + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("Latin1_General_CI_AS") + .HasAnnotation("ProductVersion", "6.0.14") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetRoles", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUsers", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("nvarchar(450)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("NormalizedEmail") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NormalizedUserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("AspNetUsers", null, t => t.ExcludeFromMigrations()); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.CompanyModel", b => + { + b.Property("CompanyId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("CompanyId"), 1L, 1); + + b.Property("Address") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("City") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CompanyExtCode") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("CompanyName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CompanyToken") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("PrivateNote") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("State") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("VAT") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ZipCode") + .HasColumnType("int"); + + b.HasKey("CompanyId"); + + b.ToTable("Company"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.Property("DoorId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("DoorDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TypeId") + .HasColumnType("int"); + + b.Property("UnitCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorId"); + + b.HasIndex("OrderId"); + + b.HasIndex("TypeId"); + + b.ToTable("Door"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MaxAllowed") + .HasColumnType("int"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => + { + b.Property("TypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TypeId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TypeCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("TypeId"); + + b.ToTable("DoorType"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.LanguageModel", b => + { + b.Property("CodLingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("DescrizioneLingua") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("CodLingua"); + + b.ToTable("Languages"); + + b.HasData( + new + { + CodLingua = "EN", + DescrizioneLingua = "English" + }, + new + { + CodLingua = "IT", + DescrizioneLingua = "Italiano" + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValues"); + + b.HasData( + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LH", + label = "Left Handed", + ordinal = 1 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RH", + label = "Right Handed", + ordinal = 2 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "LHR", + label = "Left Handed Reverse", + ordinal = 3 + }, + new + { + TableName = "Opening", + FieldName = "Swing", + value = "RHR", + label = "Right Handed Reverse", + ordinal = 4 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "BV", + label = "Bevel", + ordinal = 1 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "SQ", + label = "Squared", + ordinal = 2 + }, + new + { + TableName = "Edges", + FieldName = "EdgeType", + value = "1B", + label = "Bull Nose 1", + ordinal = 3 + }); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesTempModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValuesTemp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.Property("OrderId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.HasIndex("CompanyId"); + + b.ToTable("Order"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderStatusViewModel", b => + { + b.Property("OrderId") + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OrderId"), 1L, 1); + + b.Property("CompanyId") + .HasColumnType("int"); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("NumDoors") + .HasColumnType("int"); + + b.Property("NumType") + .HasColumnType("int"); + + b.Property("OrderDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderExtCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderStatus") + .HasColumnType("int"); + + b.Property("TotCost") + .HasColumnType("decimal(18,2)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OrderId"); + + b.ToView("OrderStatusViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.UsersViewModel", b => + { + b.Property("UserId") + .HasColumnType("nvarchar(450)"); + + b.Property("RoleId") + .HasColumnType("nvarchar(450)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "RoleId"); + + b.ToView("UsersViewModel"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("Vocabulary"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("VocabularyTemp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.AspNetUsers", "UsersNav") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RolesNav"); + + b.Navigation("UsersNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.OrderModel", "OrderNav") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorTypeModel", "TypeNav") + .WithMany() + .HasForeignKey("TypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("OrderNav"); + + b.Navigation("TypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") + .WithMany() + .HasForeignKey("CompanyId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CompanyNav"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.cs b/WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.cs new file mode 100644 index 0000000..0e06ed8 --- /dev/null +++ b/WebDoorCreator.Data/Migrations/WDCData/20230404153616_AddListValuesTemp.cs @@ -0,0 +1,33 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace WebDoorCreator.Data.Migrations.WDCData +{ + public partial class AddListValuesTemp : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ListValuesTemp", + columns: table => new + { + TableName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + FieldName = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + value = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + label = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + ordinal = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ListValuesTemp", x => new { x.TableName, x.FieldName, x.value }); + }); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ListValuesTemp"); + } + } +} diff --git a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs index f58247e..c613b03 100644 --- a/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs +++ b/WebDoorCreator.Data/Migrations/WDCData/WDCDataContextModelSnapshot.cs @@ -188,6 +188,9 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.Property("DateIns") .HasColumnType("datetime2"); + b.Property("DateLockExpiry") + .HasColumnType("datetime2"); + b.Property("DateMod") .HasColumnType("datetime2"); @@ -199,6 +202,10 @@ namespace WebDoorCreator.Data.Migrations.WDCData .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("MeasureUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + b.Property("OrderId") .HasColumnType("int"); @@ -215,6 +222,10 @@ namespace WebDoorCreator.Data.Migrations.WDCData .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("UserIdLock") + .IsRequired() + .HasColumnType("nvarchar(max)"); + b.Property("UserIdMod") .IsRequired() .HasColumnType("nvarchar(max)"); @@ -228,6 +239,128 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.ToTable("Door"); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.Property("DoorOpId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpId"), 1L, 1); + + b.Property("DateIns") + .HasColumnType("datetime2"); + + b.Property("DateMod") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorId") + .HasColumnType("int"); + + b.Property("DoorOpTypId") + .HasColumnType("int"); + + b.Property("JsoncConfigVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdIns") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserIdMod") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("DoorOpId"); + + b.HasIndex("DoorId"); + + b.HasIndex("DoorOpTypId"); + + b.ToTable("DoorOp"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpTypeModel", b => + { + b.Property("DoorOpTypId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("DoorOpTypId"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DoorOpIdPathFromPatriarch") + .HasColumnType("hierarchyid"); + + b.Property("ExtDescript") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtOpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FPath") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HasHw") + .HasColumnType("bit"); + + b.Property("HwCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HwDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsConcrete") + .HasColumnType("bit"); + + b.Property("IsDefault") + .HasColumnType("bit"); + + b.Property("JsoncConfig") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MaxAllowed") + .HasColumnType("int"); + + b.Property("OpCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ParentDoorOpId") + .HasColumnType("int"); + + b.Property("Rev") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ValidFrom") + .HasColumnType("datetime2"); + + b.Property("ValidUntil") + .HasColumnType("datetime2"); + + b.HasKey("DoorOpTypId"); + + b.ToTable("DoorOpType"); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorTypeModel", b => { b.Property("TypeId") @@ -249,6 +382,102 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.ToTable("DoorType"); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.GraphicParamsModel", b => + { + b.Property("GraphicParamId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("GraphicParamId"), 1L, 1); + + b.Property("compoId") + .HasColumnType("int"); + + b.Property("graphicParamAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamDefaultVal") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("graphicParamsN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("GraphicParamId"); + + b.ToTable("GraphicParams"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.HardwareModel", b => + { + b.Property("HardwareId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("HardwareId"), 1L, 1); + + b.Property("compoAlias") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoLayerName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("compoTemplateIsActive") + .HasColumnType("bit"); + + b.HasKey("HardwareId"); + + b.ToTable("Hardware"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.LanguageModel", b => + { + b.Property("CodLingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("DescrizioneLingua") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("CodLingua"); + + b.ToTable("Languages"); + + b.HasData( + new + { + CodLingua = "EN", + DescrizioneLingua = "English" + }, + new + { + CodLingua = "IT", + DescrizioneLingua = "Italiano" + }); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesModel", b => { b.Property("TableName") @@ -333,6 +562,32 @@ namespace WebDoorCreator.Data.Migrations.WDCData }); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.ListValuesTempModel", b => + { + b.Property("TableName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("FieldName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("value") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("label") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ordinal") + .HasColumnType("int"); + + b.HasKey("TableName", "FieldName", "value"); + + b.ToTable("ListValuesTemp"); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => { b.Property("OrderId") @@ -447,6 +702,46 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.ToView("UsersViewModel"); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("Vocabulary"); + }); + + modelBuilder.Entity("WebDoorCreator.Data.DbModels.VocabularyTempModel", b => + { + b.Property("Lingua") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("Lemma") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Traduzione") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.HasKey("Lingua", "Lemma"); + + b.ToTable("VocabularyTemp"); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.AspNetUserRoles", b => { b.HasOne("WebDoorCreator.Data.DbModels.AspNetRoles", "RolesNav") @@ -485,6 +780,25 @@ namespace WebDoorCreator.Data.Migrations.WDCData b.Navigation("TypeNav"); }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.DoorOpModel", b => + { + b.HasOne("WebDoorCreator.Data.DbModels.DoorModel", "DoorNav") + .WithMany() + .HasForeignKey("DoorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("WebDoorCreator.Data.DbModels.DoorOpTypeModel", "DoorOpTypeNav") + .WithMany() + .HasForeignKey("DoorOpTypId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DoorNav"); + + b.Navigation("DoorOpTypeNav"); + }); + modelBuilder.Entity("WebDoorCreator.Data.DbModels.OrderModel", b => { b.HasOne("WebDoorCreator.Data.DbModels.CompanyModel", "CompanyNav") diff --git a/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Import.sql b/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Import.sql new file mode 100644 index 0000000..9cfa50c --- /dev/null +++ b/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Import.sql @@ -0,0 +1,29 @@ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +-- ============================================= +-- Author: S.E.L. +-- Create date: 2023.04.03 +-- Description: Esecuzione upsert vocabolario +-- ============================================= +ALTER PROCEDURE [dbo].[stp_Voc_Import] +AS +BEGIN + SET NOCOUNT ON; + + BEGIN tran + + -- effettua merge dati vocabolario + MERGE Vocabulary as tgt + USING (SELECT Lingua, Lemma, Traduzione FROM VocabularyTemp) as src + ON tgt.Lemma = src.Lemma AND tgt.Lingua = src.Lingua + WHEN MATCHED THEN + UPDATE SET Traduzione = src.Traduzione + WHEN NOT MATCHED THEN + INSERT (Lingua, Lemma, Traduzione) + VALUES (Lingua, Lemma, Traduzione); + + COMMIT tran + +END \ No newline at end of file diff --git a/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Prepare.sql b/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Prepare.sql new file mode 100644 index 0000000..4dce251 --- /dev/null +++ b/WebDoorCreator.Data/SqlScripts/Stored/stp_Voc_Prepare.sql @@ -0,0 +1,22 @@ +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +-- ============================================= +-- Author: S.E.L. +-- Create date: 2023.04.03 +-- Description: Esecuzione preparazione tab temp x import vocabolario +-- ============================================= +ALTER PROCEDURE [dbo].[stp_Voc_Prepare] +AS +BEGIN + SET NOCOUNT ON; + + BEGIN tran + + -- effettua preparazione tab appoggio + TRUNCATE TABLE VocabularyTemp + + COMMIT tran + +END \ No newline at end of file diff --git a/WebDoorCreator.Data/WDCDataContext.cs b/WebDoorCreator.Data/WDCDataContext.cs index e663ae1..cb57ac1 100644 --- a/WebDoorCreator.Data/WDCDataContext.cs +++ b/WebDoorCreator.Data/WDCDataContext.cs @@ -66,6 +66,15 @@ namespace WebDoorCreator.Data public virtual DbSet DbSetUsers { get; set; } = null!; public virtual DbSet DbSetUsersView { get; set; } = null!; public virtual DbSet DbSetValues { get; set; } = null!; + public virtual DbSet DbSetValuesTemp { get; set; } = null!; + + public virtual DbSet DbSetDoorOpType { get; set; } = null!; + public virtual DbSet DbSetDoorOp { get; set; } = null!; + public virtual DbSet DbSetHardware { get; set; } = null!; + public virtual DbSet DbSetGraphicParams { get; set; } = null!; + public virtual DbSet DbSetVocabulary { get; set; } = null!; + public virtual DbSet DbSetVocabularyTemp { get; set; } = null!; + public virtual DbSet DbSetLanguages { get; set; } = null!; #endregion Public Properties @@ -101,11 +110,11 @@ namespace WebDoorCreator.Data string connString = _configuration.GetConnectionString("WDC.DB"); if (!string.IsNullOrEmpty(connString)) { - optionsBuilder.UseSqlServer(connString); + optionsBuilder.UseSqlServer(connString, e => e.UseHierarchyId()); } else { - optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=WebDoorCreator;Trusted_Connection=True;"); + optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=WebDoorCreator;Trusted_Connection=True;", e => e.UseHierarchyId()); } } } @@ -128,15 +137,33 @@ namespace WebDoorCreator.Data modelBuilder.Entity().HasKey(c => new { c.UserId, c.RoleId }); modelBuilder.Entity().HasKey(c => new { c.UserId, c.RoleId }); modelBuilder.Entity().HasKey(c => new { c.TableName, c.FieldName, c.value }); + modelBuilder.Entity().HasKey(c => new { c.TableName, c.FieldName, c.value }); + modelBuilder.Entity().HasKey(c => new { c.Lingua, c.Lemma }); + modelBuilder.Entity().HasKey(c => new { c.Lingua, c.Lemma }); + + // gestione onCascade DoorOp <--> parent + //modelBuilder.Entity().HasOne(e => e.ParentNav).WithOne().OnDelete(DeleteBehavior.NoAction); +#if false +#endif + // verifico SE devo eseguire la migration del DB IDENT... - bool disableMigrate = _configuration.GetValue("SetupOpt:DisableWDCMigrate"); + bool disableMigrate = false; + if (_configuration != null && _configuration.GetValue("SetupOpt:DisableWDCMigrate") != null) + { + try + { + _configuration.GetValue("SetupOpt:DisableWDCMigrate"); + } + catch + { } + } if (!disableMigrate) { modelBuilder.ApplyConfiguration(new ListValuesConfiguration()); + modelBuilder.ApplyConfiguration(new LanguageConfiguration()); - //modelBuilder.ApplyConfiguration(new RoleConfiguration()); - //modelBuilder.Seed(); } + //modelBuilder.Seed(); OnModelCreatingPartial(modelBuilder); } diff --git a/WebDoorCreator.Data/WebDoorCreator.Data.csproj b/WebDoorCreator.Data/WebDoorCreator.Data.csproj index 12c8b7f..92c6d6d 100644 --- a/WebDoorCreator.Data/WebDoorCreator.Data.csproj +++ b/WebDoorCreator.Data/WebDoorCreator.Data.csproj @@ -13,6 +13,7 @@ + @@ -30,6 +31,12 @@ + + Always + + + Always + Always diff --git a/WebDoorCreator.UI/Components/Buttons/ButtonAddRemDoor.razor.cs b/WebDoorCreator.UI/Components/Buttons/ButtonAddRemDoor.razor.cs index 00ff629..3745d70 100644 --- a/WebDoorCreator.UI/Components/Buttons/ButtonAddRemDoor.razor.cs +++ b/WebDoorCreator.UI/Components/Buttons/ButtonAddRemDoor.razor.cs @@ -17,7 +17,9 @@ namespace WebDoorCreator.UI.Components.Buttons protected NavigationManager NavManager { get; set; } = null!; [Parameter] - public int doorId { get; set; } = 0; + public int DoorId { get; set; } = 0; + [Parameter] + public int OrderId { get; set; } = 0; [Parameter] public bool isAdd { get; set; } @@ -31,7 +33,7 @@ namespace WebDoorCreator.UI.Components.Buttons { //var door = new DoorModel(); doorChange = false; - var done = await WDService.DoorModQty(doorId, isAdd); + var done = await WDService.DoorModQty(OrderId, DoorId, isAdd); if (done) { doorChange = true; diff --git a/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor b/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor new file mode 100644 index 0000000..39428c4 --- /dev/null +++ b/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor @@ -0,0 +1,13 @@ +
+ @if (change) + { + + } + else + { + + } + +
+ + diff --git a/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor.cs b/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor.cs new file mode 100644 index 0000000..fe1af83 --- /dev/null +++ b/WebDoorCreator.UI/Components/Buttons/ButtonsDoorDef.razor.cs @@ -0,0 +1,37 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; + +namespace WebDoorCreator.UI.Components.Buttons +{ + public partial class ButtonsDoorDef + { + [Parameter] + public bool paramsChanged { get; set; } + + [Parameter] + public int idOrd { get; set; } = 0; + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + protected bool change { get;set; } + + protected async Task toOrderPage() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Do you really want to return to the order page without saving current work?")) + return; + + await Task.Delay(1); + NavManager.NavigateTo($"OrderDetails?idOrd={idOrd}"); + } + + protected override async Task OnParametersSetAsync() + { + await Task.Delay(1); + change = paramsChanged; + } + } +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor b/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor new file mode 100644 index 0000000..4460ef1 --- /dev/null +++ b/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor @@ -0,0 +1,4 @@ +@if(ListGraphicParams != null){ + +} + diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor.cs b/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor.cs new file mode 100644 index 0000000..ae3c766 --- /dev/null +++ b/WebDoorCreator.UI/Components/DoorDef/DoorDefHwStep.razor.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Components; +using WebDoorCreator.Data.DbModels; +using WebDoorCreator.UI.Data; + +namespace WebDoorCreator.UI.Components.DoorDef +{ + public partial class DoorDefHwStep + { + + [Inject] + protected WebDoorCreatorService WDService { get; set; } = null!; + + List? ListGraphicParams { get; set; } = null; + + + protected async override Task OnInitializedAsync() + { + ListGraphicParams = await WDService.ParamGetByHwId(6); + } + } +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorDefOrderTopRow.razor.cs b/WebDoorCreator.UI/Components/DoorDef/DoorDefOrderTopRow.razor.cs index d26782b..c6b3ef4 100644 --- a/WebDoorCreator.UI/Components/DoorDef/DoorDefOrderTopRow.razor.cs +++ b/WebDoorCreator.UI/Components/DoorDef/DoorDefOrderTopRow.razor.cs @@ -7,5 +7,6 @@ namespace WebDoorCreator.UI.Components.DoorDef { [Parameter] public OrderStatusViewModel? currOrderStatus { get; set; } = null; + } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor index 415a7cb..c7debcc 100644 --- a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor +++ b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor @@ -10,22 +10,22 @@ {
Width
- +
Height
- +
Thickness
- +
} - else if(isOpening) + else if (isOpening) {
Swing
- @if (ListSwings != null) { @foreach (var item in ListSwings) @@ -40,7 +40,7 @@ {
Lock edge
- @if (ListEdges != null) { @foreach (var item in ListEdges) @@ -52,7 +52,7 @@
Hinge edge
- @if (ListEdges != null) { @foreach (var item in ListEdges) @@ -64,7 +64,7 @@
Top edge
- @if (ListEdges != null) { @foreach (var item in ListEdges) @@ -76,7 +76,7 @@
Bottom edge
- @if (ListEdges != null) { @foreach (var item in ListEdges) diff --git a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs index dcdf55a..7b04e9c 100644 --- a/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs +++ b/WebDoorCreator.UI/Components/DoorDef/DoorSizingStep.razor.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Components; +using Newtonsoft.Json; using WebDoorCreator.Data.DbModels; using WebDoorCreator.UI.Data; @@ -9,9 +10,19 @@ namespace WebDoorCreator.UI.Components.DoorDef [Inject] protected WebDoorCreatorService WDService { get; set; } = null!; + [Parameter] + public int DoorId { get; set; } = 0; + + [Parameter] + public EventCallback E_paramChanged { get; set; } + protected bool isSizing { get; set; } = true; protected List? ListSwings { get; set; } = null; protected List? ListEdges { get; set; } = null; + protected List? ListDoorOp { get; set; } = null; + protected Edges? DefaultEdges { get; set; } = null; + protected Opening? DefaultOpening { get; set; } = null; + protected Sizing? DefaultSizing { get; set; } = null; protected string isSizingActive { @@ -26,6 +37,7 @@ namespace WebDoorCreator.UI.Components.DoorDef } protected bool isEdges { get; set; } = false; + protected bool paramIsChanged { get; set; } = false; protected string isEdgesActive { @@ -53,15 +65,142 @@ namespace WebDoorCreator.UI.Components.DoorDef isEdges = true; } + protected string _lockEdge { get; set; } = ""; + + protected string lockEdge + { + get => _lockEdge; + set + { + _lockEdge = value; + if (DefaultEdges != null) + { + if (_lockEdge != DefaultEdges.lockEdge) + { + paramIsChanged = true; + var pUpd = Task.Run(async () => await E_paramChanged.InvokeAsync(paramIsChanged)); + } + } + } + } + protected string _hingeEdge { get; set; } = ""; + + protected string hingeEdge + { + get => _hingeEdge; + set => _hingeEdge = value; + } + + protected string _topEdge { get; set; } = ""; + + protected string topEdge + { + get => _topEdge; + set => _topEdge = value; + } + + protected string _bottomEdge { get; set; } = ""; + + protected string bottomEdge + { + get => _bottomEdge; + set => _bottomEdge = value; + } + + protected double _width { get; set; } = 0.0; + + protected double width + { + get => _width; + set => _width = value; + } + + protected double _height { get; set; } = 0.0; + + protected double height + { + get => _height; + set => _height = value; + } + protected double _thickness { get; set; } = 0.0; + + protected double thickness + { + get => _thickness; + set => _thickness = value; + } + + protected string _swing { get; set; } = ""; + + protected string swing + { + get => _swing; + set => _swing = value; + } + protected async Task ReloadData() { ListSwings = await WDService.ListValuesGetAll("Opening", "Swing"); ListEdges = await WDService.ListValuesGetAll("Edges", "EdgeType"); + + ListDoorOp = await WDService.DoorOpGetByDoorId(DoorId); + if (ListDoorOp != null) + { + foreach (var doorOp in ListDoorOp) + { + if (doorOp.DoorOpTypId == 19) + { + var edges = JsonConvert.DeserializeObject>(doorOp.JsoncConfigVal); + if (edges != null) + { + DefaultEdges = edges.FirstOrDefault(); + if (DefaultEdges != null) + { + lockEdge = DefaultEdges.lockEdge; + hingeEdge = DefaultEdges.hingeEdge; + topEdge = DefaultEdges.topEdge; + bottomEdge = DefaultEdges.bottomEdge; + + } + } + } + if (doorOp.DoorOpTypId == 20) + { + var sizing = JsonConvert.DeserializeObject>(doorOp.JsoncConfigVal); + if (sizing != null) + { + DefaultSizing = sizing.FirstOrDefault(); + if (DefaultSizing != null) + { + width = double.Parse(DefaultSizing.width); + height = double.Parse(DefaultSizing.height); + thickness = double.Parse(DefaultSizing.thickness); + } + } + } + if (doorOp.DoorOpTypId == 21) + { + var opening = JsonConvert.DeserializeObject>(doorOp.JsoncConfigVal); + if (opening != null) + { + DefaultOpening = opening.FirstOrDefault(); + if (DefaultOpening != null) + { + swing = DefaultOpening.swing; + } + } + } + } + } } - protected override async Task OnInitializedAsync() + protected override async Task OnParametersSetAsync() { - await ReloadData(); + if (!paramIsChanged) + { + await ReloadData(); + } } + } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/StepsList.razor b/WebDoorCreator.UI/Components/DoorDef/StepsList.razor index 88e5581..65c5325 100644 --- a/WebDoorCreator.UI/Components/DoorDef/StepsList.razor +++ b/WebDoorCreator.UI/Components/DoorDef/StepsList.razor @@ -1,5 +1,5 @@ 
-
Door
-
Hardware
-
Report
+
Door
+
Hardware
+
Report
\ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorDef/StepsList.razor.cs b/WebDoorCreator.UI/Components/DoorDef/StepsList.razor.cs index 68e83de..88d0b83 100644 --- a/WebDoorCreator.UI/Components/DoorDef/StepsList.razor.cs +++ b/WebDoorCreator.UI/Components/DoorDef/StepsList.razor.cs @@ -1,6 +1,36 @@ +using Microsoft.AspNetCore.Components; + namespace WebDoorCreator.UI.Components.DoorDef { public partial class StepsList { + [Parameter] + public Core.Enum.DoorDefStep DoorDefStep { get; set; } = Core.Enum.DoorDefStep.Door; + + protected string doorCSS { get; set; } = "btn-secondary"; + protected string hwCSS { get; set; } = "btn-secondary"; + protected string reportCSS { get; set; } = "btn-secondary"; + + + protected override async Task OnParametersSetAsync() + { + await Task.Delay(1); + + if(DoorDefStep == Core.Enum.DoorDefStep.Door) + { + doorCSS = "btn-success"; + } + else if (DoorDefStep == Core.Enum.DoorDefStep.Hardware) + { + doorCSS = "btn-success"; + hwCSS = "btn-success"; + } + else if(DoorDefStep == Core.Enum.DoorDefStep.report) + { + doorCSS = "btn-success"; + hwCSS = "btn-success"; + reportCSS = "btn-success"; + } + } } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/DoorMan/DoorList.razor b/WebDoorCreator.UI/Components/DoorMan/DoorList.razor index e72df58..d3acde5 100644 --- a/WebDoorCreator.UI/Components/DoorMan/DoorList.razor +++ b/WebDoorCreator.UI/Components/DoorMan/DoorList.razor @@ -3,25 +3,45 @@ - + + + + @foreach (var door in DoorsList) { - + + + + } diff --git a/WebDoorCreator.UI/Components/DoorMan/DoorList.razor.cs b/WebDoorCreator.UI/Components/DoorMan/DoorList.razor.cs index cabf8a4..cd4ba07 100644 --- a/WebDoorCreator.UI/Components/DoorMan/DoorList.razor.cs +++ b/WebDoorCreator.UI/Components/DoorMan/DoorList.razor.cs @@ -1,5 +1,4 @@ using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Identity; using Microsoft.JSInterop; using WebDoorCreator.Data.DbModels; using WebDoorCreator.UI.Data; @@ -8,14 +7,7 @@ namespace WebDoorCreator.UI.Components.DoorMan { public partial class DoorList { - [Inject] - protected WebDoorCreatorService WDService { get; set; } = null!; - - [Inject] - protected IJSRuntime JSRuntime { get; set; } = null!; - - [Inject] - protected NavigationManager NavManager { get; set; } = null!; + #region Public Properties [Parameter] public int currOrderId { get; set; } = 0; @@ -23,19 +15,26 @@ namespace WebDoorCreator.UI.Components.DoorMan [Parameter] public EventCallback E_DoorChanged { get; set; } - protected bool IsChanged { get; set; } = false; + #endregion Public Properties + + #region Protected Properties protected List? DoorsList { get; set; } = null; - protected override async Task OnParametersSetAsync() - { - await ReloadData(); - } + protected bool IsChanged { get; set; } = false; - protected async Task ReloadData() - { - DoorsList = await WDService.DoorsGetByOrderId(currOrderId); - } + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + [Inject] + protected WebDoorCreatorService WDService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods protected async Task catchDoorChange(bool isChanged) { @@ -47,5 +46,33 @@ namespace WebDoorCreator.UI.Components.DoorMan } await E_DoorChanged.InvokeAsync(isChanged); } + + protected async Task deleteRecord(DoorModel currRec) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Door Deletion requested: are you sure to remove {currRec.DoorDescript}?")) + return; + + await WDService.DoorDelete(currRec); + await Task.Delay(1); + await ReloadData(); + } + + protected async Task editRec(int doorId) + { + await Task.Delay(1); + NavManager.NavigateTo($"/DoorDefinition?idOrd={currOrderId}&idDoor={doorId}"); + } + + protected override async Task OnParametersSetAsync() + { + await ReloadData(); + } + + protected async Task ReloadData() + { + DoorsList = await WDService.DoorGetByOrderId(currOrderId); + } + + #endregion Protected Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor index 2ba0dca..893b3f9 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor @@ -40,7 +40,7 @@
-
+
Hello, @context.User.Identity?.Name!
@if (listCompanies != null) @@ -63,6 +63,12 @@ } }
+
+ +
@@ -76,7 +82,7 @@ diff --git a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs index 1e643c9..49c5373 100644 --- a/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs +++ b/WebDoorCreator.UI/Components/Gen/NavMenuHorizontal.razor.cs @@ -17,6 +17,9 @@ namespace WebDoorCreator.UI.Components.Gen public EventCallback E_UserCurrCompany { get; set; } public EventCallback E_UserRole { get; set; } + public EventCallback E_UserId { get; set; } + + public EventCallback>> E_VocLemmas { get; set; } public List listCompanies { get; set; } = new List(); @@ -64,6 +67,31 @@ namespace WebDoorCreator.UI.Components.Gen } } + public string userId + { + get + { + return WDCUService.userId; + } + set + { + WDCUService.userId = value; + reportUserId(); + } + } + public Dictionary>? listVocLemmas + { + get + { + return WDCVService.VocabularyLemmas; + } + set + { + WDCVService.VocabularyLemmas = value; + reportVocLemmas(); + } + } + #endregion Public Properties #region Public Methods @@ -72,6 +100,7 @@ namespace WebDoorCreator.UI.Components.Gen { WDCUService.EA_UserClaims -= OnNewUserClaims; WDCUService.EA_UserCurrCompany -= OnNewUserCurrComp; + WDCUService.EA_UserId -= OnNewUserId; } public async void OnNewUserClaims() @@ -90,6 +119,14 @@ namespace WebDoorCreator.UI.Components.Gen }); } + public async void OnNewUserId() + { + await InvokeAsync(() => + { + StateHasChanged(); + }); + } + public async void OnNewUserRole() { await InvokeAsync(() => @@ -98,8 +135,22 @@ namespace WebDoorCreator.UI.Components.Gen }); } + public async void OnNewVocLemma() + { + await InvokeAsync(() => + { + StateHasChanged(); + }); + } + #endregion Public Methods + protected string userLang + { + get => WDCUService.currLanguage ?? "NA"; + set => WDCUService.currLanguage = value; + } + #region Protected Properties [Inject] @@ -108,9 +159,6 @@ namespace WebDoorCreator.UI.Components.Gen [Inject] protected AuthenticationStateProvider ASProvider { get; set; } = null!; - [Inject] - protected AuthenticationStateProvider AuthenticationStateProvider { get; set; } = null!; - protected string currUser { get; set; } = ""; [Inject] @@ -118,6 +166,8 @@ namespace WebDoorCreator.UI.Components.Gen [Inject] protected WDCUserService WDCUService { get; set; } = null!; + [Inject] + protected WDCVocabularyService WDCVService { get; set; } = null!; #endregion Protected Properties @@ -150,8 +200,20 @@ namespace WebDoorCreator.UI.Components.Gen await Task.Delay(1); WDCUService.EA_UserClaims += OnNewUserClaims; WDCUService.EA_UserCurrCompany += OnNewUserCurrComp; + WDCUService.EA_UserId += OnNewUserId; + //WDCVService.EA_VocabularyLemmas += OnNewVocLemma; } + //protected override async Task OnAfterRenderAsync(bool firstRender) + //{ + // if (firstRender) + // { + // listVocLemmas = new Dictionary>(); + + // listVocLemmas = await WDCService.VocLemmaGetAll(); + // } + //} + protected override async Task OnParametersSetAsync() { await Task.Delay(1); @@ -159,6 +221,7 @@ namespace WebDoorCreator.UI.Components.Gen if (userCheck != null && userCheck.IsAuthenticated) { currUser = userCheck?.Name!; + await ReloadData(); } else @@ -173,8 +236,12 @@ namespace WebDoorCreator.UI.Components.Gen // reset preliminare listRecord = new List(); listCompanies = new List(); - //await WDCService.FlushRedisCache(); + var user = await _userManager.FindByNameAsync(currUser); + if (user != null) + { + userId = user.Id; + } var roleList = await _userManager.GetRolesAsync(user); if (roleList != null) { @@ -239,6 +306,16 @@ namespace WebDoorCreator.UI.Components.Gen E_UserRole.InvokeAsync(userRole); } + private void reportUserId() + { + E_UserId.InvokeAsync(userId); + } + + private void reportVocLemmas() + { + E_VocLemmas.InvokeAsync(); + } + #endregion Private Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor new file mode 100644 index 0000000..a176926 --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor @@ -0,0 +1,37 @@ +@if (doorOpType != null) +{ + + @if (doorOpToShow != null) + { +
+
+
+
+ @(translate(doorOpToShow.HwCode)) +
+
+
+
+ + +
+ +
+ +
+ } + else + { +
+ @foreach (var item in doorOpType) + { +
+
+ @(translate(item.HwCode)) +
+
+
+ } +
+ } +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs new file mode 100644 index 0000000..1ccc032 --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.cs @@ -0,0 +1,111 @@ +using Microsoft.AspNetCore.Components; +using WebDoorCreator.Data.DbModels; +using WebDoorCreator.UI.Components.DoorMan; +using WebDoorCreator.UI.Data; + +namespace WebDoorCreator.UI.Components.Hardware +{ + public partial class HardwareList + { + #region Public Properties + + [Parameter] + public string Lingua { get; set; } = "NA"; + [Parameter] + public int DoorId { get; set; } = 0; + [Parameter] + public string UserId { get; set; } = ""; + + #endregion Public Properties + + #region Protected Properties + + protected List? doorOpType { get; set; } = null; + protected DoorOpTypeModel? doorOpToShow { get; set; } = null; + protected List? doorOp { get; set; } = null; + protected bool hwAdd { get; set; } = false; + + [Inject] + protected WebDoorCreatorService WDService { get; set; } = null!; + + [Inject] + protected WDCVocabularyService WDVService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected int hwCodeToShow { get; set; } = 0; + protected override async Task OnParametersSetAsync() + { + await ReloadData(); + } + + private async Task ReloadData() + { + var listRecord = await WDService.DoorOpTypeGetAll(); + if (listRecord != null) + { + doorOpType = listRecord.Where(x => !(x.IsDefault)).ToList(); + } + } + + //CultureInfo ci = CultureInfo.InstalledUICulture; + protected string translate(string lemma) + { + string answ = ""; + + answ = WDVService.Traduci(Lingua, lemma); + + return answ; + } + + protected async Task hwToChoose(string hwCode) + { + await Task.Delay(1); + if (hwCode != "" && doorOpType != null) + { + doorOpToShow = doorOpType.Where(x => x.HwCode == hwCode).FirstOrDefault(); + } + } + + protected async Task hwToAdd() + { + await Task.Delay(1); + DateTime adesso = DateTime.Now; + List listOp = new List(); + + if (doorOpToShow != null) + { + DoorOpModel doorOpToAdd = new DoorOpModel() + { + DateIns = adesso, + DateMod = adesso, + UserIdIns = UserId, + UserIdMod = UserId, + DoorOpTypId = doorOpToShow.DoorOpTypId, + DoorId = DoorId, + JsoncConfigVal = doorOpToShow.JsoncConfig + }; + listOp.Add(doorOpToAdd); + // salvo Door OP associate + bool fatto = await WDService.DoorOpInsert(DoorId, listOp); + + if (fatto) + { + hwAdd = fatto; + await InvokeAsync(StateHasChanged); + } + } + + } + + protected async Task backToList() + { + await Task.Delay(1); + doorOpToShow = null; + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css new file mode 100644 index 0000000..a092c98 --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.css @@ -0,0 +1,53 @@ +.rectangle { + height: 2.75rem; + width: 75%; + background: #CFD8DC; + position: relative; + margin-bottom: 4rem; + margin-top: 1.25rem; + border-radius: 0.8rem; + display: flex; + flex-wrap: wrap; + align-items: center; + color: #000; + font-weight: bold; +} +.circle { + position: absolute; + height: 6.25rem; + width: 6.25rem; + border-radius: 50%; + border: 4px solid #CFD8DC; + left: 100%; + margin-left: -1.563rem; + top: -1.5rem; + background: black; +} +.rectangleDetail { + height: 2.75rem; + width: 75%; + background: #CFD8DC; + position: relative; + margin-bottom: 4rem; + margin-top: 1.25rem; + border-radius: 0.8rem; + display: flex; + flex-wrap: wrap; + align-items: center; + color: #000; + font-weight: bold; +} +.circleDetail { + position: absolute; + height: 6.25rem; + width: 6.25rem; + border-radius: 50%; + border: 4px solid #CFD8DC; + left: 100%; + margin-left: -1.563rem; + top: -1.5rem; + background: black; +} +.all { + width: 72rem; +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less new file mode 100644 index 0000000..7713e3f --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.less @@ -0,0 +1,58 @@ +.rectangle { + height: 2.75rem; + width: 75%; + background: #CFD8DC; + position: relative; + margin-bottom: 4rem; + margin-top: 1.25rem; + border-radius: 0.8rem; + display: flex; + flex-wrap: wrap; + align-items: center; + color: #000; + font-weight: bold; +} + +.circle { + position: absolute; + height: 6.25rem; + width: 6.25rem; + border-radius: 50%; + border: 4px solid #CFD8DC; + left: 100%; + margin-left: -1.563rem; + top: -1.5rem; + background: black; +} + + +.rectangleDetail { + height: 2.75rem; + width: 75%; + background: #CFD8DC; + position: relative; + margin-bottom: 4rem; + margin-top: 1.25rem; + border-radius: 0.8rem; + display: flex; + flex-wrap: wrap; + align-items: center; + color: #000; + font-weight: bold; +} + +.circleDetail { + position: absolute; + height: 6.25rem; + width: 6.25rem; + border-radius: 50%; + border: 4px solid #CFD8DC; + left: 100%; + margin-left: -1.563rem; + top: -1.5rem; + background: black; +} + +.all { + width: 72rem; +} diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css new file mode 100644 index 0000000..eb050cf --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareList.razor.min.css @@ -0,0 +1 @@ +.rectangle{height:2.75rem;width:75%;background:#cfd8dc;position:relative;margin-bottom:4rem;margin-top:1.25rem;border-radius:.8rem;display:flex;flex-wrap:wrap;align-items:center;color:#000;font-weight:bold;}.circle{position:absolute;height:6.25rem;width:6.25rem;border-radius:50%;border:4px solid #cfd8dc;left:100%;margin-left:-1.563rem;top:-1.5rem;background:#000;}.rectangleDetail{height:2.75rem;width:75%;background:#cfd8dc;position:relative;margin-bottom:4rem;margin-top:1.25rem;border-radius:.8rem;display:flex;flex-wrap:wrap;align-items:center;color:#000;font-weight:bold;}.circleDetail{position:absolute;height:6.25rem;width:6.25rem;border-radius:50%;border:4px solid #cfd8dc;left:100%;margin-left:-1.563rem;top:-1.5rem;background:#000;}.all{width:72rem;} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor new file mode 100644 index 0000000..ac94497 --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor @@ -0,0 +1,23 @@ +@if (DoorOp != null) +{ + +
+ @foreach (var item in DoorOp) + { +
+ @foreach (var graph in getGraphicParams(item)) + { + @if (graph.graphicParamType == "TextBox") + { +
+ @(translate(graph.graphicParamAlias)) + +
+ } + } +
+ + } +
+} + diff --git a/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor.cs b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor.cs new file mode 100644 index 0000000..065ab86 --- /dev/null +++ b/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor.cs @@ -0,0 +1,68 @@ +using Microsoft.AspNetCore.Components; +using Newtonsoft.Json; +using WebDoorCreator.Data; +using WebDoorCreator.Data.DbModels; +using WebDoorCreator.UI.Data; + +namespace WebDoorCreator.UI.Components.Hardware +{ + public partial class HardwareNewPanel + { + [Parameter] + public int DoorTypeTypeId { get; set; } = 0; + + [Parameter] + public int DoorId { get; set; } = 0; + + [Parameter] + public bool HwAdded { get; set; } = false; + + [Parameter] + public string Lingua { get; set; } = "EN"; + + [Inject] + protected WebDoorCreatorService WDCService { get; set; } = null!; + + [Inject] + protected WDCVocabularyService WDVService { get; set; } = null!; + + protected List? ListRecord { get; set; } = null!; + protected List? DoorOp { get; set; } = null!; + //protected DoorOpModel? DoorOp { get; set; } = null!; + protected List graphicParams { get; set; } = null!; + + protected override async Task OnParametersSetAsync() + { + ListRecord = await WDCService.DoorOpGetByDoorId(DoorId); + if (ListRecord != null) + { + DoorOp = ListRecord.Where(x => (x.DoorId == DoorId) && (x.DoorOpTypId == DoorTypeTypeId)).ToList(); + } + } + + public List getGraphicParams(DoorOpModel currDoorOp) + { + if (DoorOp != null) + { + var param = currDoorOp.JsoncConfigVal; + var deserialized = JsonConvert.DeserializeObject>(param); + + if (deserialized != null) + { + graphicParams = deserialized; + } + } + + return graphicParams; + } + + protected string translate(string lemma) + { + string answ = ""; + + answ = WDVService.Traduci(Lingua, lemma); + + return answ; + } + } +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Order/OrderList.razor b/WebDoorCreator.UI/Components/Order/OrderList.razor index a91963d..8a3df44 100644 --- a/WebDoorCreator.UI/Components/Order/OrderList.razor +++ b/WebDoorCreator.UI/Components/Order/OrderList.razor @@ -14,7 +14,8 @@ else
- @* *@ + @**@ + @@ -29,10 +30,16 @@ else @**@ +
+
+
+ *@ + } diff --git a/WebDoorCreator.UI/Components/Order/OrderList.razor.cs b/WebDoorCreator.UI/Components/Order/OrderList.razor.cs index 8a310f2..20a8fc9 100644 --- a/WebDoorCreator.UI/Components/Order/OrderList.razor.cs +++ b/WebDoorCreator.UI/Components/Order/OrderList.razor.cs @@ -1,7 +1,9 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Identity; using Microsoft.JSInterop; +using NLog.LayoutRenderers; using WebDoorCreator.Data.DbModels; using WebDoorCreator.UI.Data; @@ -100,12 +102,12 @@ namespace WebDoorCreator.UI.Components.Order } private async Task ReloadData() { - var adesso = DateTime.Now.Date; + var domani = DateTime.Today.AddDays(1); ListOrdersStatus = null; await Task.Delay(1); if (userClaims != null) { - ListOrdersStatus = await WDService.GetOrderStatus(userCurrCompany, 0, adesso.AddYears(-2), adesso); + ListOrdersStatus = await WDService.OrderStatusGetFilt(userCurrCompany, 0, domani.AddYears(-2), domani); } await Task.Delay(1); await InvokeAsync(StateHasChanged); @@ -117,6 +119,18 @@ namespace WebDoorCreator.UI.Components.Order await E_currOrderStatus.InvokeAsync(currOrd); } + protected async Task deleteRecord(OrderStatusViewModel currRec) + { + + if (!await JSRuntime.InvokeAsync("confirm", $"Order Deletion requested: are you sure to remove {currRec.OrderExtCode}?")) + return; + + await Task.Delay(1); + var done = await WDService.OrderRem(currRec.OrderId); + await WDService.OrdersFlushCache(); + await ReloadData(); + } + #endregion Private Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Components/Users/UserList.razor.cs b/WebDoorCreator.UI/Components/Users/UserList.razor.cs index 418afe5..687e9ac 100644 --- a/WebDoorCreator.UI/Components/Users/UserList.razor.cs +++ b/WebDoorCreator.UI/Components/Users/UserList.razor.cs @@ -48,8 +48,8 @@ namespace WebDoorCreator.UI.Components.Users { //ListRecords = null; await Task.Delay(1); - UsersList = await WDService.GetUserView(); - RolesList = await WDService.GetRolesAll(); + UsersList = await WDService.UserViewGetAll(); + RolesList = await WDService.RolesGetAll(); await Task.Delay(1); await InvokeAsync(StateHasChanged); } @@ -57,7 +57,7 @@ namespace WebDoorCreator.UI.Components.Users private async Task setCurrUser(string userId) { await Task.Delay(1); - currUser = await WDService.GetUsersById(userId); + currUser = await WDService.UsersGetById(userId); } //private async Task editRec(CompanyModel currComp) diff --git a/WebDoorCreator.UI/Data/WDCUserService.cs b/WebDoorCreator.UI/Data/WDCUserService.cs index b8d90ce..1af9414 100644 --- a/WebDoorCreator.UI/Data/WDCUserService.cs +++ b/WebDoorCreator.UI/Data/WDCUserService.cs @@ -4,7 +4,7 @@ { #region Public Events - public event Action EA_UserName = null!; + public event Action EA_UserId = null!; public event Action EA_UserClaims = null!; @@ -12,19 +12,22 @@ public event Action EA_UserCurrCompany = null!; + public event Action EA_CurrLanguage = null!; + + #endregion Public Events #region Public Properties - public string newUserName + public string userId { - get => _newUserName; + get => _userId; set { - if (_newUserName != value) + if (_userId != value) { - _newUserName = value; - reportUserName(); + _userId = value; + reportUserId(); } } } @@ -67,16 +70,27 @@ } } } - + public string? currLanguage + { + get => _currLanguage; + set + { + if (_currLanguage != value) + { + _currLanguage = value; + reportCurrentLanguage(); + } + } + } #endregion Public Properties #region Protected Methods - protected void reportUserName() + protected void reportUserId() { - if (EA_UserName != null) + if (EA_UserId != null) { - EA_UserName?.Invoke(); + EA_UserId?.Invoke(); } } @@ -103,15 +117,22 @@ EA_UserCurrCompany?.Invoke(); } } - + protected void reportCurrentLanguage() + { + if (EA_CurrLanguage != null) + { + EA_CurrLanguage?.Invoke(); + } + } #endregion Protected Methods #region Private Properties - private string _newUserName { get; set; } = ""; + private string _userId { get; set; } = ""; private List? _userClaims { get; set; } = null; private string _userRole { get; set; } = ""; private int _userCurrComp { get; set; } //= -1; + private string? _currLanguage { get; set; } = null; #endregion Private Properties } diff --git a/WebDoorCreator.UI/Data/WDCVocabularyService.cs b/WebDoorCreator.UI/Data/WDCVocabularyService.cs new file mode 100644 index 0000000..fca3140 --- /dev/null +++ b/WebDoorCreator.UI/Data/WDCVocabularyService.cs @@ -0,0 +1,159 @@ +using Microsoft.AspNetCore.Identity.UI.Services; +using Newtonsoft.Json; +using NLog; +using Org.BouncyCastle.Asn1.X500; +using StackExchange.Redis; +using System.Diagnostics; +using WebDoorCreator.Data.Controllers; + +namespace WebDoorCreator.UI.Data +{ + public class WDCVocabularyService + { + public static WebDoorCreatorController dbController = null!; + + public WDCVocabularyService(IConfiguration configuration, IConnectionMultiplexer redisConnMult, IEmailSender emailSender) + { + _configuration = configuration; + _emailSender = emailSender; + // Conf cache + redisConn = redisConnMult; + redisDb = this.redisConn.GetDatabase(); + + // json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/ + JSSettings = new JsonSerializerSettings() + { + ReferenceLoopHandling = ReferenceLoopHandling.Ignore + }; + + // cod app + CodApp = _configuration["CodApp"]; + // Conf DB + string connStr = _configuration.GetConnectionString("WDC.DB"); + if (string.IsNullOrEmpty(connStr)) + { + Log.Info("ConnString empty!"); + } + else + { + dbController = new WebDoorCreatorController(configuration); + } + if (dbController != null) + { + if (VocabularyLemmas == null) + { + VocabularyLemmas = Task.Run(async () => await VocLemmaGetAll()).Result; + } + } + + Log.Info("Avviata classe WDCVocabularyService"); + } + + + + public Dictionary>? VocabularyLemmas + { + get => _vocabularyLemmas; + set + { + if (_vocabularyLemmas != value) + { + _vocabularyLemmas = value; + } + } + } + + + private Dictionary>? _vocabularyLemmas { get; set; } = null; + + private TimeSpan UltraLongCache + { + get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000); + } + + public string Traduci(string lingua, string lemma) + { + string answ = $"[{lemma}]"; + + if (VocabularyLemmas != null && VocabularyLemmas.ContainsKey(lingua)) + { + if (VocabularyLemmas[lingua].ContainsKey(lemma)) + { + answ = VocabularyLemmas[lingua][lemma]; + } + } + + return answ; + } + + public async Task>?> VocLemmaGetAll() + { + string source = "DB"; + Dictionary>? dbResult = new Dictionary>(); + // cerco da cache + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string currKey = $"{rKeyVocLemma}"; + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>>(rawData); + if (tempResult == null) + { + dbResult = new Dictionary>(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.VocLemmaGetAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new Dictionary>(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"VocLemmaGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + + /// + /// Durata cache lunga IN SECONDI + /// + private int cacheTtlLong = 60 * 5; + + /// + /// Oggetto per connessione a REDIS + /// + private IConnectionMultiplexer redisConn; + + /// + /// Oggetto DB redis da impiegare x chiamate R/W + /// + private IDatabase redisDb = null!; + + protected const string redisBaseAddr = "WDC"; + + protected const string rKeyVocLemma = $"{redisBaseAddr}:Cache:VocLemma"; + + protected Random rnd = new Random(); + + private static IConfiguration _configuration = null!; + + private static JsonSerializerSettings? JSSettings; + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + private readonly IEmailSender _emailSender; + + public string CodApp { get; set; } = ""; + } +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs index cbaf4d6..fa0dbe7 100644 --- a/WebDoorCreator.UI/Data/WebDoorCreatorService.cs +++ b/WebDoorCreator.UI/Data/WebDoorCreatorService.cs @@ -1,9 +1,12 @@ using EgwCoreLib.Razor.Data; using Microsoft.AspNetCore.Identity.UI.Services; +using Microsoft.EntityFrameworkCore; using Newtonsoft.Json; using NLog; using StackExchange.Redis; using System.Diagnostics; +using System.Security.AccessControl; +using WebDoorCreator.Core; using WebDoorCreator.Data.Controllers; using WebDoorCreator.Data.DbModels; @@ -58,9 +61,21 @@ namespace WebDoorCreator.UI.Data #region Public Methods - #region Company methods + /// + /// Update company + /// + /// + /// + public async Task CompanyAddMod(CompanyModel currRec) + { + var dbResult = await dbController.CompanyAddMod(currRec); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{rKeyCompany}"); + bool answ = await ExecFlushRedisPattern(pattern); + await Task.Delay(1); + return dbResult; + } - /// /// Company list filtered by company id /// @@ -105,340 +120,272 @@ namespace WebDoorCreator.UI.Data return dbResult; } - /// - /// Update company - /// - /// - /// - public async Task CompanyAddMod(CompanyModel currRec) - { - var dbResult = await dbController.CompanyAddMod(currRec); - // elimino cache redis... - RedisValue pattern = new RedisValue($"{rKeyCompany}"); - bool answ = await ExecFlushRedisPattern(pattern); - await Task.Delay(1); - return dbResult; - } - - #endregion Company methods - /*----------------------------------------------------------------------------------------------------------------------*/ - #region Cache methods + /// + /// Getting a list of all the active components + /// + /// Path to start + /// + public async Task> CompoGetAllActive(string rootPath) + { + await Task.Delay(1); + List listActiveCompo = new List(); + + //estraggo la lista di componenti che sono attive per il cliente + IniFile fIni = new IniFile(rootPath); + string compoDDF = fIni.ReadString("CompoOrder", "CompoDDFOrder", "CONFIG"); + var compoDDFList = compoDDF.Split(","); + foreach (string compo in compoDDFList) + { + listActiveCompo.Add(compo.Trim()); + } + + return listActiveCompo; + } /// - /// Esegue flush memoria redis dato pattern + /// Setting all the component list /// - /// + /// Path to start /// - private async Task ExecFlushRedisPattern(RedisValue pattern) + public async Task CompoListSetAll(string rootPath) { - bool answ = false; - var listEndpoints = redisConn.GetEndPoints(); - foreach (var endPoint in listEndpoints) + bool fatto = false; + string compoName = ""; + int numHier = 1; + List listGraphicParams = new List(); + + dbController.TestTablesTruncate(); + + List listActiveCompo = await CompoGetAllActive(Path.Combine(rootPath, @"Default.ini")); + List listCompoS = new List(); + //estraggo tutte le sotto directory della cartella \EgtData\Doors\EgtCompoBase\Compo + string[] dirs = Directory.GetDirectories(rootPath, "*", SearchOption.TopDirectoryOnly); + + // elenco obj da inserire + List ListObjDOT = new List(); + + // parto con obj base + List edges = new List(); + edges.Add(new Edges()); + List sizing = new List(); + sizing.Add(new Sizing()); + List opening = new List(); + opening.Add(new Opening()); + Guid opCodeEdges = Guid.NewGuid(); + Guid opCodeSizing = Guid.NewGuid(); + Guid opCodeOpening = Guid.NewGuid(); + DoorOpTypeModel doorOpTypeEdges = new DoorOpTypeModel() { - //var server = redisConnAdmin.GetServer(listEndpoints[0]); - var server = redisConn.GetServer(endPoint); - if (server != null) + Description = "DOOR OPERATION TYPE FOR Edges", + OpCode = opCodeEdges.ToString(), + HasHw = false, + IsConcrete = true, + DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier}/"), + IsDefault = true, + JsoncConfig = JsonConvert.SerializeObject(edges), + DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", + MaxAllowed = 1 + }; + numHier++; + DoorOpTypeModel doorOpTypeSizing = new DoorOpTypeModel() + { + Description = "DOOR OPERATION TYPE FOR Sizing", + OpCode = opCodeSizing.ToString(), + HasHw = false, + IsConcrete = true, + DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier}/"), + IsDefault = true, + JsoncConfig = JsonConvert.SerializeObject(sizing), + DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", + MaxAllowed = 1 + }; + numHier++; + DoorOpTypeModel doorOpTypeOpening = new DoorOpTypeModel() + { + Description = "DOOR OPERATION TYPE FOR Opening", + OpCode = opCodeOpening.ToString(), + HasHw = false, + IsConcrete = true, + DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier}/"), + IsDefault = true, + JsoncConfig = JsonConvert.SerializeObject(opening), + DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", + MaxAllowed = 1 + }; + numHier++; + + //await dbController.DoorOpTypeAdd(doorOpTypeEdges); + //await dbController.DoorOpTypeAdd(doorOpTypeSizing); + //await dbController.DoorOpTypeAdd(doorOpTypeOpening); + ListObjDOT.Add(doorOpTypeEdges); + ListObjDOT.Add(doorOpTypeSizing); + ListObjDOT.Add(doorOpTypeOpening); + + foreach (string dir in dirs) + { + int numPar = 1; + int numHead = 1; + // scansione della directory... + string[] files = Directory.GetFiles(dir, "Config.ini"); + + compoName = ""; + //iterazione per cercare tutti numPar file "Config.ini" nelle sotto directory + foreach (string file in files) { - var keyList = server.Keys(redisDb.Database, pattern); - foreach (var item in keyList) + //leggo tutte le linee del file + List lines = File.ReadAllLines(file).ToList(); + IniFile fIni = new IniFile(file); + Guid opCode = Guid.NewGuid(); + //cerco la sezione del file ed estraggo il nome del componente + compoName = fIni.ReadString("Compo", "Name", "COMPONAME"); + //cerco la sezione del file ed estraggo se numPar template sono attivi per il seguente componente + var isActive = fIni.ReadString("Template", "IsActive", "1"); + bool compoTemplateIsActive = true; + string layerName = fIni.ReadString("Layer", "LayerName", "LAYER"); + if (isActive == "0") { - await redisDb.KeyDeleteAsync(item); + compoTemplateIsActive = false; } - answ = true; + // lo slash indica l'alias + var compoNameSplit = compoName.Split("/"); + if (listActiveCompo.Contains(compoNameSplit[0].ToString())) + { + //creo il componente (padre) + HardwareModel compoConfig = new HardwareModel() { compoName = $"{compoNameSplit[0]}", compoAlias = compoNameSplit[1].ToString(), compoLayerName = layerName, compoTemplateIsActive = compoTemplateIsActive }; + await dbController.CompoAdd(compoConfig); + listCompoS.Add(compoConfig); + //cerco all'interno del file tutte le sezioni che contengono "[Graphic" così da poter prendere il nome della sezione ES: [Graphic parameters1] = Graphic parameters1 + var lineToSearch = lines.Where(x => x.Contains("[Graphic")).ToList(); + numHead = 1; + foreach (var match in lineToSearch) + { + listGraphicParams = await GraphicParamsGetAll(file, match, numHead, numPar); + numHead++; + } + + DoorOpTypeModel doorOpType = new DoorOpTypeModel() + { + Description = $"DOOR OPERATION TYPE FOR {compoNameSplit[0]}", + OpCode = opCode.ToString(), + HasHw = true, + IsConcrete = true, + HwCode = $"{compoNameSplit[1]}", + DoorOpIdPathFromPatriarch = HierarchyId.Parse($"/{numHier}/"), + JsoncConfig = JsonConvert.SerializeObject(listGraphicParams), + DisplayUrl = $"DoorOpTypeImg/{numHier}.svg", + MaxAllowed = 2 + }; + numHier++; + + ListObjDOT.Add(doorOpType); + //await dbController.DoorOpTypeAdd(doorOpType); + } + numPar++; } } - return answ; + fatto = await dbController.DoorOpTypeAddRange(ListObjDOT); + + return fatto; } - public async Task FlushRedisCache() + public async Task VocLemmaInsert(string rootPath) { - await Task.Delay(1); - RedisValue pattern = new RedisValue($"{redisBaseAddr}"); - bool answ = await ExecFlushRedisPattern(pattern); - return answ; + bool fatto = false; + + List VocLemmas = new List(); + + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + + string[] files = Directory.GetFiles(rootPath, "*"); + string lang = ""; + foreach (string file in files) + { + var fileName = file.Split("."); + + lang = fileName[0].Substring(fileName[0].Length - 2, 2); + + //leggo tutte le linee del file + List lines = File.ReadAllLines(file).ToList(); + + foreach (var line in lines) + { + if (!line.StartsWith("//") && line != "") + { + string[] lineSplit = line.Split("="); + //string trad = ""; + if (lineSplit.Length != 1) + { + VocabularyTempModel newVocLemma = new VocabularyTempModel() + { + Lingua = lang, + Lemma = lineSplit[0], + Traduzione = lineSplit[1] + }; + VocLemmas.Add(newVocLemma); + } + } + } + } + fatto = await dbController.VocLemmaInsert(VocLemmas); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"VocLemmaInsert in: {ts.TotalMilliseconds} ms"); + return fatto; } - #endregion Cache methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region Security Methods - public string DecriptData(string encData) { return SteamCrypto.DecryptString(encData, passPhrase); } - public string EncriptData(string rawData) - { - return SteamCrypto.EncryptString(rawData, passPhrase); - } - - #endregion Security Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region User Methods - /// - /// Users roles list - /// - public async Task?> GetUserView() - { - string source = "DB"; - - List? dbResult = new List(); - // cerco da cache - string currKey = rKeyUsersView; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult == null) - { - dbResult = new List(); - } - else - { - dbResult = tempResult; - } - } - else - { - dbResult = dbController.GetUserView(); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"GetUserView | {source} in: {ts.TotalMilliseconds} ms"); - return dbResult; - } - - /// - /// Users roles list - /// - public async Task?> GetUsersAll() - { - string source = "DB"; - - List? dbResult = new List(); - // cerco da cache - string currKey = rKeyUsers; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult == null) - { - dbResult = new List(); - } - else - { - dbResult = tempResult; - } - } - else - { - dbResult = dbController.GetUsersAll(); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"GetUsersAll | {source} in: {ts.TotalMilliseconds} ms"); - return dbResult; - } - - /// - /// Users roles list - /// - public async Task GetUsersById(string userId) - { - string source = "DB"; - - AspNetUsers dbResult = new AspNetUsers(); - // cerco da cache - string currKey = $"{rKeyUsers}:{userId}"; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject(rawData); - if (tempResult == null) - { - dbResult = new AspNetUsers(); - } - else - { - dbResult = tempResult; - } - } - else - { - dbResult = dbController.GetUsersById(userId); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); - } - if (dbResult == null) - { - dbResult = new AspNetUsers(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"GetUsersById | {source} in: {ts.TotalMilliseconds} ms"); - return dbResult; - } - - #endregion User Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region Roles Methods - - /// - /// roles list - /// - public async Task?> GetRolesAll() - { - string source = "DB"; - - List? dbResult = new List(); - // cerco da cache - string currKey = rKeyRoles; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult == null) - { - dbResult = new List(); - } - else - { - dbResult = tempResult; - } - } - else - { - dbResult = dbController.GetRolesAll(); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"GetRolesAll | {source} in: {ts.TotalMilliseconds} ms"); - return dbResult; - } - - #endregion Roles Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region Order status Methods - - public async Task?> GetOrderStatus(int companyId, int orderStatus, DateTime dataFrom, DateTime dataTo) - { - string source = "DB"; - - List? dbResult = new List(); - // cerco da cache - string currKey = $"{rKeyOrderStatus}:{companyId}:{orderStatus}:{dataFrom:yyyyMMdd}:{dataTo:yyyyMMdd}"; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject>(rawData); - if (tempResult == null) - { - dbResult = new List(); - } - else - { - dbResult = tempResult; - } - } - else - { - dbResult = dbController.GetOrderStatus(companyId, orderStatus, dataFrom, dataTo); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); - } - if (dbResult == null) - { - dbResult = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"GetOrderStatus | {source} in: {ts.TotalMilliseconds} ms"); - return dbResult; - } - - #endregion Order status Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region Order Methods - - /// - /// Add new order + /// CElimina record posta /// /// /// - public async Task OrderAdd(OrderModel currRec) + public async Task DoorDelete(DoorModel currRec) { - var dbResult = await dbController.OrderAdd(currRec); - // elimino cache redis... - RedisValue pattern = new RedisValue($"{rKeyOrderStatus}:*"); - bool answ = await ExecFlushRedisPattern(pattern); - await Task.Delay(1); - return dbResult; + int DoorId = currRec.DoorId; + int OrderId = currRec.OrderId; + // elimino sul DB + bool answ = await dbController.DoorDelete(DoorId); + // svuoto cache + await DoorFlushCache(DoorId); + await DoorOpFlushCache(DoorId); + await OrderDetailFlushCache(OrderId); + await OrdersFlushCache(); + return answ; } - #endregion Order Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region Door Methods + /// + /// Clean redis DOORS cache + /// + /// 0 = all + /// + public async Task DoorFlushCache(int DoorId) + { + RedisValue pattern = new RedisValue($"{rKeyDoor}:*"); + if (DoorId > 0) + { + pattern = new RedisValue($"{rKeyDoor}:{DoorId}:*"); + } + bool answ = await ExecFlushRedisPattern(pattern); + return answ; + } /// /// Doors list by orderId /// - public async Task?> DoorsGetByOrderId(int orderId) + public async Task?> DoorGetByOrderId(int orderId) { string source = "DB"; - List? dbResult = new List(); // cerco da cache - string currKey = $"{rKeyDoor}:{orderId}"; + string currKey = $"{rKeyOrderDetail}:{orderId}"; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string? rawData = await redisDb.StringGetAsync(currKey); @@ -467,7 +414,290 @@ namespace WebDoorCreator.UI.Data } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"DoorsGetByOrderId | {source} in: {ts.TotalMilliseconds} ms"); + Log.Debug($"DoorGetByOrderId | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// Add door + /// + /// + /// + public async Task DoorInsert(DoorModel newRec) + { + var dbResult = await dbController.DoorInsert(newRec); + // elimino cache redis dati ordine... + await OrderDetailFlushCache(newRec.OrderId); + await OrdersFlushCache(); + return dbResult; + } + + /// + /// Adding or removing a single door + /// + /// Record id to edit or add + /// States if it has to be added or removing a door + /// + public async Task DoorModQty(int OrderId, int DoorId, bool isAdd) + { + var dbResult = await dbController.DoorModQty(DoorId, isAdd); + // svuoto cache + await DoorFlushCache(DoorId); + await DoorOpFlushCache(DoorId); + await OrderDetailFlushCache(OrderId); + await OrdersFlushCache(); + return dbResult; + } + + /// + /// Clean redis DOORS OP cache + /// + /// 0 = all + /// + public async Task DoorOpFlushCache(int DoorId) + { + RedisValue pattern = new RedisValue($"{rKeyDoorOp}*"); + if (DoorId > 0) + { + pattern = new RedisValue($"{rKeyDoorOp}:{DoorId}*"); + } + bool answ = await ExecFlushRedisPattern(pattern); + return answ; + } + + /// + /// Doors list by orderId + /// + public async Task?> DoorOpGetByDoorId(int doorId) + { + string source = "DB"; + List? dbResult = new List(); + // cerco da cache + string currKey = $"{rKeyDoorOp}:{doorId}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.DoorOpGetByDoorId(doorId); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"DoorOpGetByDoorId | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + public async Task>?> VocLemmaGetAll() + { + string source = "DB"; + Dictionary>? dbResult = new Dictionary>(); + // cerco da cache + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string currKey = $"{rKeyVocLemma}"; + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>>(rawData); + if (tempResult == null) + { + dbResult = new Dictionary>(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.VocLemmaGetAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new Dictionary>(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"VocLemmaGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + public async Task ListValuesInsert(string rootPath) + { + List values = new List(); + string[] dirs = Directory.GetDirectories(rootPath); + foreach (string dir in dirs) + { + int ordin = 1; + string compoCode = ""; + string[] templateDirectories = Directory.GetDirectories(dir); + + string[] iniFiles = Directory.GetFiles(dir, "Config.ini"); + + + foreach (string templateDirectory in templateDirectories) + { + foreach (var file in iniFiles) + { + List lines = File.ReadAllLines(file).ToList(); + IniFile fIni = new IniFile(file); + + var compoName = fIni.ReadString("Compo", "Name", "COMPONAME"); + compoCode = compoName.Split("/")[1]; + } + string[] templateFiles = Directory.GetFiles(templateDirectory); + foreach (string templateFile in templateFiles) + { + var tName = templateDirectory.Split("\\"); + var fName = templateDirectory.Split("\\"); + + ListValuesTempModel temp = new ListValuesTempModel() + { + TableName = $"{tName[tName.Length - 1]}_{compoCode}".Replace(" ", "_"), + FieldName = "Compo", + value = Path.GetFileName(templateFile), + label = Path.GetFileName(templateFile).Split(".")[0], + ordinal = ordin + }; + + values.Add(temp); + ordin++; + } + } + } + + bool fatto = await dbController.ListValuesAdd(values); + + return fatto; + } + + + + /// + /// Doors list by orderId + /// + public async Task?> DoorOpTypeGetAll() + { + string source = "DB"; + List? dbResult = new List(); + // cerco da cache + string currKey = $"{rKeyDoorOpType}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); +#if false + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } +#endif + dbResult = dbController.DoorOpTypeGetAll(); + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"DoorOpTypeGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// lista DoorOp necessarie all'init + /// + /// + public async Task> DoorOpGetDefault() + { + List? dbResult = new List(); + string source = "DB"; + // cerco da cache + string currKey = $"{rKeyDoorOpType}:DEFAULT"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); +#if false + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { +#endif + dbResult = await dbController.DoorOpTypeGetDefault(); +#if false + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } +#endif + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"DoorOpGetDefault | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// Add doorOP list + /// + /// + /// + /// + public async Task DoorOpInsert(int DoorId, List newOpList) + { + var dbResult = await dbController.DoorOpInsert(newOpList); + // elimino cache redis dati porta... + bool answ = await DoorOpFlushCache(DoorId); + answ = answ && await DoorFlushCache(DoorId); + // elimino cache redis dati ordine... + answ = answ && await OrdersFlushCache(); return dbResult; } @@ -480,42 +710,76 @@ namespace WebDoorCreator.UI.Data { var dbResult = await dbController.DoorUpsert(currRec); // elimino cache redis dati porta... - RedisValue pattern = new RedisValue($"{rKeyDoor}:{currRec.DoorId}:*"); - bool answ = await ExecFlushRedisPattern(pattern); + bool answ = await DoorFlushCache(currRec.DoorId); // elimino cache redis dati ordine... - pattern = new RedisValue($"{rKeyOrderStatus}:*"); - answ = await ExecFlushRedisPattern(pattern); - await Task.Delay(1); + answ = answ && await OrdersFlushCache(); return dbResult; } - /// - /// Adding or removing a single door - /// - /// Record id to edit or add - /// States if it has to be added or removing a door - /// - public async Task DoorModQty(int doorId, bool isAdd) + public string EncriptData(string rawData) { - var dbResult = await dbController.DoorModQty(doorId, isAdd); - // elimino cache redis dati porta... - RedisValue pattern = new RedisValue($"{rKeyDoor}:*"); - bool answ = await ExecFlushRedisPattern(pattern); - // elimino cache redis dati ordine... - pattern = new RedisValue($"{rKeyOrderStatus}:*"); - answ = await ExecFlushRedisPattern(pattern); - await Task.Delay(1); - return dbResult; + return SteamCrypto.EncryptString(rawData, passPhrase); } - #endregion Door Methods - - /*----------------------------------------------------------------------------------------------------------------------*/ - - #region ListValues Methods + public async Task FlushRedisCache() + { + await Task.Delay(1); + RedisValue pattern = new RedisValue($"{redisBaseAddr}*"); + bool answ = await ExecFlushRedisPattern(pattern); + return answ; + } /// - /// Company list + /// Setting the graphic parameters for components + /// + /// + /// + /// + /// + /// + public async Task> GraphicParamsGetAll(string file, string match, int n, int i) + { + await Task.Delay(1); + List listGraphicParams = new List(); + + IniFile fIni = new IniFile(file); + //estraggo la lista di componenti che sono attive per il cliente + var graphicParamsName = fIni.ReadSection(match.Substring(1, match.Length - 2)); //cerco il contenuto delle sezioni + if (int.Parse(match.Substring(match.Length - 2, 1)) == n) //controllo se tra numPar numeri di graphic params vi è un buco ES: Graphic parameters1 Graphic parameters3 se il buco c'è salto tutti numPar parametri che stanno dopo il buco ==> tengo conto solo di Graphic parameters1 + { + foreach (string param in graphicParamsName) + { + string compoParams = fIni.ReadString(match.Substring(1, match.Length - 2), $"{param.Split("=")[0]}", "CONFIG"); //cerco il parametro nella sezione + var compoParamsSplit = compoParams.Split(";"); + + string CompoParamName = ""; + string CompoParamAlias = ""; + if (param.Split("=")[0].StartsWith("Param")) + { + if (compoParamsSplit[1].Contains("/")) + { + CompoParamName = compoParamsSplit[1].Split("/")[0]; + CompoParamAlias = compoParamsSplit[1].Split("/")[1]; + } + + GraphicParamsModel graphicParams = new GraphicParamsModel() { compoId = i, graphicParamsN = match.Substring(1, match.Length - 2), graphicParamKey = param.Split("=")[0], graphicParamName = CompoParamName, graphicParamAlias = CompoParamAlias, graphicParamType = compoParamsSplit[0], graphicParamDefaultVal = compoParamsSplit[2] }; + listGraphicParams.Add(graphicParams); //creo nuovo oggetto parametro che conterrà anche il nome del componente per creare relazione + await dbController.ParamAdd(graphicParams); + } + else + { + GraphicParamsModel graphicParams = new GraphicParamsModel() { compoId = i, graphicParamsN = match.Substring(1, match.Length - 2), graphicParamKey = param.Split("=")[0], graphicParamName = compoParams }; + listGraphicParams.Add(graphicParams); //creo nuovo oggetto parametro che conterrà anche il nome del componente per creare relazione + await dbController.ParamAdd(graphicParams); + } + } + } + + return listGraphicParams; + } + + /// + /// List values /// public async Task?> ListValuesGetAll(string tableName, string fieldName) { @@ -556,55 +820,430 @@ namespace WebDoorCreator.UI.Data return dbResult; } - #endregion ListValues Methods + /// + /// Estraggo tutte le lingue disponibili per questa applicazione + /// + /// + public async Task?> LanguageGetAll() + { + string source = "DB"; + + List? dbResult = new List(); + // cerco da cache + string currKey = $"{rKeyLanguage}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.LanguageGetAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"LanguageGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// Add new order + /// + /// + /// + public async Task OrderAdd(OrderModel currRec) + { + var dbResult = await dbController.OrderAdd(currRec); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{rKeyOrderStatus}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + return dbResult; + } + + /// + /// Clean REDIS order detail data in cache + /// + /// 0 = all + /// + public async Task OrderDetailFlushCache(int OrderId) + { + RedisValue pattern = new RedisValue($"{rKeyOrderDetail}:*"); + if (OrderId > 0) + { + pattern = new RedisValue($"{rKeyOrderDetail}:{OrderId}"); + } + bool answ = await ExecFlushRedisPattern(pattern); + return answ; + } + + /// + /// Remove order + /// + /// + /// + public async Task OrderRem(int OrdId) + { + var dbResult = await dbController.OrderRem(OrdId); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{rKeyOrderStatus}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + return dbResult; + } + + /// + /// Clean redis ORDERS cache + /// + /// + /// + public async Task OrdersFlushCache() + { + RedisValue pattern = new RedisValue($"{rKeyOrderStatus}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + return answ; + } + + public async Task?> OrderStatusGetFilt(int companyId, int orderStatus, DateTime dataFrom, DateTime dataTo) + { + string source = "DB"; + + List? dbResult = new List(); + // cerco da cache + string currKey = $"{rKeyOrderStatus}:{companyId}:{orderStatus}:{dataFrom:yyyyMMdd}:{dataTo:yyyyMMdd}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.OrderStatusGetAll(companyId, orderStatus, dataFrom, dataTo); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"OrderStatusGetFilt | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// Graphic parameters list by hw id + /// + public async Task?> ParamGetByHwId(int hwId) + { + string source = "DB"; + + List? dbResult = new List(); + // cerco da cache + string currKey = $"{rKeyGraphicParameters}:{hwId}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.ParamGetByHwId(hwId); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ParamGetByHwId | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// Graphic parameters list by hw id + /// + //public async Task?> HardwareGetAll() + //{ + // string source = "DB"; + + // List? dbResult = new List(); + // // cerco da cache + // string currKey = $"{rKeyGraphicParameters}"; + // Stopwatch stopWatch = new Stopwatch(); + // stopWatch.Start(); + // string? rawData = await redisDb.StringGetAsync(currKey); + // if (!string.IsNullOrEmpty(rawData)) + // { + // source = "REDIS"; + // var tempResult = JsonConvert.DeserializeObject>(rawData); + // if (tempResult == null) + // { + // dbResult = new List(); + // } + // else + // { + // dbResult = tempResult; + // } + // } + // else + // { + // dbResult = dbController.HardwareGetAll(); + // rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + // await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + // } + // if (dbResult == null) + // { + // dbResult = new List(); + // } + // stopWatch.Stop(); + // TimeSpan ts = stopWatch.Elapsed; + // Log.Debug($"HardwareGetAll | {source} in: {ts.TotalMilliseconds} ms"); + // return dbResult; + //} + + /// + /// roles list + /// + public async Task?> RolesGetAll() + { + string source = "DB"; + + List? dbResult = new List(); + // cerco da cache + string currKey = rKeyRoles; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.RolesGetAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"RolesGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// Users roles list + /// + public async Task?> UsersGetAll() + { + string source = "DB"; + + List? dbResult = new List(); + // cerco da cache + string currKey = rKeyUsers; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.UsersGetAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"UsersGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// Users roles list + /// + public async Task UsersGetById(string userId) + { + string source = "DB"; + + AspNetUsers dbResult = new AspNetUsers(); + // cerco da cache + string currKey = $"{rKeyUsers}:{userId}"; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject(rawData); + if (tempResult == null) + { + dbResult = new AspNetUsers(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.UsersGetById(userId); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new AspNetUsers(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"UsersGetById | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } + + /// + /// Users roles list + /// + public async Task?> UserViewGetAll() + { + string source = "DB"; + + List? dbResult = new List(); + // cerco da cache + string currKey = rKeyUsersView; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject>(rawData); + if (tempResult == null) + { + dbResult = new List(); + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.UserViewGetAll(); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (dbResult == null) + { + dbResult = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"UserViewGetAll | {source} in: {ts.TotalMilliseconds} ms"); + return dbResult; + } #endregion Public Methods #region Protected Fields - #region Private Properties - - /// - /// Durata cache lunga (+ perturbazione percentuale +/-10%) - /// - private TimeSpan FastCache - { - get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000); - } - - /// - /// Durata cache lunga (+ perturbazione percentuale +/-10%) - /// - private TimeSpan LongCache - { - get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000); - } - - /// - /// Durata cache lunga (+ perturbazione percentuale +/-10%) - /// - private TimeSpan UltraLongCache - { - get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000); - } - - #endregion Private Properties - protected const string passPhrase = "9eb4660f-8753-46bc-b23b-08759ba03fe9"; - //#region Protected Fields protected const string redisBaseAddr = "WDC"; - //#endregion Public Methods protected const string rKeyCompany = $"{redisBaseAddr}:Cache:Company"; - protected const string rKeyOrderStatus = $"{redisBaseAddr}:Cache:OrderStatus"; - protected const string rKeyUsers = $"{redisBaseAddr}:Cache:Users"; - protected const string rKeyUsersView = $"{redisBaseAddr}:Cache:UsersView"; - protected const string rKeyRoles = $"{redisBaseAddr}:Cache:Roles"; - protected const string rKeyDoor = $"{redisBaseAddr}:Cache:Doors"; + protected const string rKeyDoor = $"{redisBaseAddr}:Cache:Door"; + + protected const string rKeyDoorOp = $"{redisBaseAddr}:Cache:DoorOp"; + + protected const string rKeyDoorOpType = $"{redisBaseAddr}:Cache:DoorOpType"; + + protected const string rKeyGraphicParameters = $"{redisBaseAddr}:Cache:GraphicParameters"; + protected const string rKeyListValues = $"{redisBaseAddr}:Cache:ListValues"; + protected const string rKeyOrderDetail = $"{redisBaseAddr}:Cache:OrderDetail"; + + protected const string rKeyOrderStatus = $"{redisBaseAddr}:Cache:OrderStatus"; + + protected const string rKeyRoles = $"{redisBaseAddr}:Cache:Roles"; + + protected const string rKeyUsers = $"{redisBaseAddr}:Cache:Users"; + + protected const string rKeyUsersView = $"{redisBaseAddr}:Cache:UsersView"; + + protected const string rKeyVocLemma = $"{redisBaseAddr}:Cache:VocLemma"; + + protected const string rKeyLanguage = $"{redisBaseAddr}:Cache:Languages"; + protected Random rnd = new Random(); #endregion Protected Fields @@ -634,12 +1273,70 @@ namespace WebDoorCreator.UI.Data /// private IConnectionMultiplexer redisConn; - //ISubscriber sub = redis.GetSubscriber(); /// /// Oggetto DB redis da impiegare x chiamate R/W /// private IDatabase redisDb = null!; #endregion Private Fields + + #region Private Properties + + /// + /// Durata cache lunga (+ perturbazione percentuale +/-10%) + /// + private TimeSpan FastCache + { + get => TimeSpan.FromSeconds(cacheTtlShort * rnd.Next(900, 1100) / 1000); + } + + /// + /// Durata cache lunga (+ perturbazione percentuale +/-10%) + /// + private TimeSpan LongCache + { + get => TimeSpan.FromSeconds(cacheTtlLong * rnd.Next(900, 1100) / 1000); + } + + /// + /// Durata cache lunga (+ perturbazione percentuale +/-10%) + /// + private TimeSpan UltraLongCache + { + get => TimeSpan.FromSeconds(cacheTtlLong * 10 * rnd.Next(900, 1100) / 1000); + } + + #endregion Private Properties + + #region Private Methods + + /// + /// Esegue flush memoria redis dato pattern + /// + /// + /// + private async Task ExecFlushRedisPattern(RedisValue pattern) + { + bool answ = false; + var listEndpoints = redisConn.GetEndPoints(); + foreach (var endPoint in listEndpoints) + { + //var server = redisConnAdmin.GetServer(listEndpoints[0]); + var server = redisConn.GetServer(endPoint); + if (server != null) + { + var keyList = server.Keys(redisDb.Database, pattern); + foreach (var item in keyList) + { + await redisDb.KeyDeleteAsync(item); + } + answ = true; + } + } + + return answ; + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor b/WebDoorCreator.UI/Pages/DoorDefinition.razor index 77305cd..2983889 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor @@ -1,7 +1,11 @@ @page "/DoorDefinition" -

Door Definition

- +
+
+

Door Definition

+
+ +
@@ -10,7 +14,9 @@
- + @**@ + @**@ +
diff --git a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs index 618b5c0..d81115f 100644 --- a/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs +++ b/WebDoorCreator.UI/Pages/DoorDefinition.razor.cs @@ -1,44 +1,95 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.WebUtilities; +using Microsoft.JSInterop; +using Newtonsoft.Json; using WebDoorCreator.Data.DbModels; using WebDoorCreator.UI.Data; namespace WebDoorCreator.UI.Pages { - public partial class DoorDefinition + public partial class DoorDefinition : IDisposable { + #region Protected Properties + + protected int idOrd { get; set; } = 0; + protected int idDoor { get; set; } = 0; + protected bool paramChanged { get; set; } = false; + + [Inject] - protected NavigationManager navManager { get; set; } = null!; + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + protected OrderStatusViewModel? orderStatus { get; set; } = null; [Inject] protected WebDoorCreatorService WDService { get; set; } = null!; + [Inject] + protected WDCUserService WDCUService { get; set; } = null!; - protected int idOrd { get; set; } = 0; - protected OrderStatusViewModel? orderStatus { get; set; } = null; - private List? ListOrdersStatus = null; + #endregion Protected Properties + + protected string userLang { get; set; } = "EN"; + + #region Protected Methods protected override async Task OnInitializedAsync() { await Task.Delay(1); - var uri = navManager.ToAbsoluteUri(navManager.Uri); - if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("idOrd", out var _idOrd)) + var uri = NavManager.ToAbsoluteUri(NavManager.Uri); + if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("idOrd", out var _idOrd) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("idDoor", out var _idDoor)) { idOrd = int.Parse(_idOrd); - await reloadData(); + idDoor = int.Parse(_idDoor); + await ReloadData(); } + userLang = WDCUService.currLanguage ?? "EN"; + WDCUService.EA_CurrLanguage += WDUService_EA_CurrLanguage; } - protected async Task reloadData() + public void Dispose() { - var adesso = DateTime.Now.Date; + WDCUService.EA_CurrLanguage -= WDUService_EA_CurrLanguage; + } + + private void WDUService_EA_CurrLanguage() + { + userLang = WDCUService.currLanguage ?? "EN"; + StateHasChanged(); + //Task.Run(async () => await ReloadData()); + } + + protected async Task ReloadData() + { + var domani = DateTime.Today.AddDays(1); ListOrdersStatus = null; await Task.Delay(1); - ListOrdersStatus = await WDService.GetOrderStatus(0, 0, adesso.AddYears(-2), adesso); + ListOrdersStatus = await WDService.OrderStatusGetFilt(0, 0, domani.AddYears(-2), domani); if (ListOrdersStatus != null) { orderStatus = ListOrdersStatus.Where(x => x.OrderId == idOrd).FirstOrDefault(); } await Task.Delay(1); } + + protected async Task catchParamChange(bool ParamChanged) + { + await Task.Delay(1); + paramChanged = ParamChanged; + await InvokeAsync(() => + { + StateHasChanged(); + }); + } + + #endregion Protected Methods + + #region Private Fields + + private List? ListOrdersStatus = null; + + #endregion Private Fields } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/ForceReload.razor b/WebDoorCreator.UI/Pages/ForceReload.razor new file mode 100644 index 0000000..e45c89e --- /dev/null +++ b/WebDoorCreator.UI/Pages/ForceReload.razor @@ -0,0 +1,3 @@ +@page "/ForceReload" + + diff --git a/WebDoorCreator.UI/Pages/ForceReload.razor.cs b/WebDoorCreator.UI/Pages/ForceReload.razor.cs new file mode 100644 index 0000000..79045d5 --- /dev/null +++ b/WebDoorCreator.UI/Pages/ForceReload.razor.cs @@ -0,0 +1,40 @@ +using Microsoft.AspNetCore.Components; +using WebDoorCreator.UI.Data; + +namespace WebDoorCreator.UI.Pages +{ + public partial class ForceReload + { + #region Public Methods + + public async Task flushCache() + { + await Task.Delay(1); + await WDService.FlushRedisCache(); + await Task.Delay(1); + // rimando a pagina corrente + NavManager.NavigateTo("/", true); + } + + #endregion Public Methods + + #region Protected Properties + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + [Inject] + protected WebDoorCreatorService WDService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + await flushCache(); + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/Index.razor b/WebDoorCreator.UI/Pages/Index.razor index e80f637..baa924b 100644 --- a/WebDoorCreator.UI/Pages/Index.razor +++ b/WebDoorCreator.UI/Pages/Index.razor @@ -2,6 +2,8 @@ Index -
-

Web Door Creator

+
+
+
Web Door Creator
+
\ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/Index.razor.css b/WebDoorCreator.UI/Pages/Index.razor.css index 9f0b44a..04befb6 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.css +++ b/WebDoorCreator.UI/Pages/Index.razor.css @@ -6,5 +6,17 @@ /* Do not repeat the image */ background-size: cover; /* Resize the background image to cover the entire container */ - height: 35rem; + height: 45rem; + display: flex; + flex-wrap: wrap; + align-items: end; +} +.transpLayer { + color: #DEDEDE; + background-image: linear-gradient(to right, rgba(30, 30, 30, 0.9), rgba(255, 255, 255, 0.1)); + width: 100%; + height: 5rem; + display: flex; + flex-wrap: wrap; + align-items: end; } \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/Index.razor.less b/WebDoorCreator.UI/Pages/Index.razor.less index 3ba62d8..111d2cf 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.less +++ b/WebDoorCreator.UI/Pages/Index.razor.less @@ -3,6 +3,18 @@ background-position: center; /* Center the image */ background-repeat: no-repeat; /* Do not repeat the image */ background-size: cover; /* Resize the background image to cover the entire container */ - height: 35rem; - + height: 45rem; + display: flex; + flex-wrap: wrap; + align-items: end; +} + +.transpLayer { + color: #DEDEDE; + background-image: linear-gradient(to right, rgba(30,30,30,0.9), rgba(255,255,255,0.1)); + width: 100%; + height: 5rem; + display: flex; + flex-wrap: wrap; + align-items: end; } diff --git a/WebDoorCreator.UI/Pages/Index.razor.min.css b/WebDoorCreator.UI/Pages/Index.razor.min.css index 77ad80d..9e5b8bb 100644 --- a/WebDoorCreator.UI/Pages/Index.razor.min.css +++ b/WebDoorCreator.UI/Pages/Index.razor.min.css @@ -1 +1 @@ -.bgbg{background-image:url("images/DOORBG.png");background-position:center;background-repeat:no-repeat;background-size:cover;height:35rem;} \ No newline at end of file +.bgbg{background-image:url("images/DOORBG.png");background-position:center;background-repeat:no-repeat;background-size:cover;height:45rem;display:flex;flex-wrap:wrap;align-items:end;}.transpLayer{color:#dedede;background-image:linear-gradient(to right,rgba(30,30,30,.9),rgba(255,255,255,.1));width:100%;height:5rem;display:flex;flex-wrap:wrap;align-items:end;} \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/OrderDetails.razor b/WebDoorCreator.UI/Pages/OrderDetails.razor index 9cdca43..25c32ab 100644 --- a/WebDoorCreator.UI/Pages/OrderDetails.razor +++ b/WebDoorCreator.UI/Pages/OrderDetails.razor @@ -2,11 +2,20 @@
- LIST DOORS IN ORDER @idOrd - + Add new door +
+ LIST DOORS IN ORDER @idOrd +
+
+
+ + +
+
-
diff --git a/WebDoorCreator.UI/Pages/OrderDetails.razor.cs b/WebDoorCreator.UI/Pages/OrderDetails.razor.cs index e4415e8..8583cdc 100644 --- a/WebDoorCreator.UI/Pages/OrderDetails.razor.cs +++ b/WebDoorCreator.UI/Pages/OrderDetails.razor.cs @@ -1,59 +1,109 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using Microsoft.AspNetCore.Components; -using System.Net.Http; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Components.Authorization; -using Microsoft.AspNetCore.Components.Forms; -using Microsoft.AspNetCore.Components.Routing; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components.Web.Virtualization; -using Microsoft.JSInterop; -using WebDoorCreator.UI; -using WebDoorCreator.UI.Components; -using WebDoorCreator.UI.Components.Buttons; -using WebDoorCreator.UI.Components.CompMan; -using WebDoorCreator.UI.Components.DoorMan; -using WebDoorCreator.UI.Components.DoorDef; -using WebDoorCreator.UI.Components.Gen; -using WebDoorCreator.UI.Components.Order; -using WebDoorCreator.UI.Components.Users; -using WebDoorCreator.UI.Shared; -using WebDoorCreator.Data.DbModels; -using Microsoft.AspNetCore.WebUtilities; -using WebDoorCreator.UI.Data; using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.WebUtilities; +using System.Collections.Specialized; +using WebDoorCreator.Data.DbModels; +using WebDoorCreator.UI.Data; namespace WebDoorCreator.UI.Pages { public partial class OrderDetails { + #region Protected Properties + [Inject] - protected NavigationManager navManager { get; set; } = null!; + protected UserManager _userManager { get; set; } = null!; + + protected DoorModel? currDoor { get; set; } = null; + + protected int currDoorType { get; set; } = 0; + + /// + /// Unità di misura selezionata + /// + protected string currMeaUnit { get; set; } = "mm"; + + protected List? DoorsList { get; set; } = null; + + protected int idOrd { get; set; } = -1; + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + protected OrderStatusViewModel? OrderStatus { get; set; } = null; [Inject] protected WebDoorCreatorService WDService { get; set; } = null!; - protected int idOrd { get; set; } = 0; - protected OrderStatusViewModel? orderStatus { get; set; } = null; - private List? ListOrdersStatus = null; + [Inject] + protected WDCUserService WDCUService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods protected override async Task OnInitializedAsync() { await Task.Delay(1); - var uri = navManager.ToAbsoluteUri(navManager.Uri); + var uri = NavManager.ToAbsoluteUri(NavManager.Uri); if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("idOrd", out var _idOrd)) { idOrd = int.Parse(_idOrd); } } + #endregion Protected Methods - protected int currDoorType { get; set; } = 0; - protected DoorModel? currDoor { get; set; } = null; - protected List? DoorsList { get; set; } = null; - [Inject] - protected UserManager _userManager { get; set; } = null!; + #region Private Fields + + private List?ListOrdersStatus = null; + + protected async Task createDoor() + { + // conto le porte x questo ordine e uso x chiamata successiva... + var door4ord = await WDService.DoorGetByOrderId(idOrd); + int numDoors = door4ord?.Count + 1 ?? 1; + DateTime adesso = DateTime.Now; + // creo una nuova porta... + DoorModel newDoor = new DoorModel() + { + OrderId = idOrd, + MeasureUnit = currMeaUnit, + UserIdIns = WDCUService.userId, + UserIdMod = WDCUService.userId, + UserIdLock = WDCUService.userId, + DateIns = adesso, + DateMod = adesso, + DateLockExpiry = adesso.AddHours(1), + DoorDescript = $"ORD {idOrd} | Door {numDoors:00}", + DoorExtCode = $"ORD {idOrd} | Ext Code --", + Quantity = 1, + UnitCost = 0, + TypeId = 1 + }; + // chiamo metodo x insert... + var doorId = await WDService.DoorInsert(newDoor); + // aggiungo le lavorazioni standard... + var doorOpList = await WDService.DoorOpGetDefault(); + + List listOp = doorOpList + .Select(x => new DoorOpModel() + { + DateIns = adesso, + DateMod = adesso, + UserIdIns = WDCUService.userId, + UserIdMod = WDCUService.userId, + DoorOpTypId = x.DoorOpTypId, + DoorId = doorId, + JsoncConfigVal = x.JsoncConfig + }) + .ToList(); + // salvo Door OP associate + await WDService.DoorOpInsert(doorId, listOp); + + // rimando alla pagina... dettaglio... + NavManager.NavigateTo($"/DoorDefinition?idOrd={idOrd}&idDoor={doorId}"); + } + + #endregion Private Fields } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Pages/OrdersHomePage.razor b/WebDoorCreator.UI/Pages/OrdersHomePage.razor index cc5bbaf..7e0370b 100644 --- a/WebDoorCreator.UI/Pages/OrdersHomePage.razor +++ b/WebDoorCreator.UI/Pages/OrdersHomePage.razor @@ -42,7 +42,7 @@ @if (orderCodExt != "") { - + }
diff --git a/WebDoorCreator.UI/Pages/OrdersHomePage.razor.cs b/WebDoorCreator.UI/Pages/OrdersHomePage.razor.cs index e136921..eb6daff 100644 --- a/WebDoorCreator.UI/Pages/OrdersHomePage.razor.cs +++ b/WebDoorCreator.UI/Pages/OrdersHomePage.razor.cs @@ -6,7 +6,7 @@ using WebDoorCreator.UI.Data; namespace WebDoorCreator.UI.Pages { - public partial class OrdersHomePage:IDisposable + public partial class OrdersHomePage : IDisposable { #region Protected Properties @@ -116,7 +116,13 @@ namespace WebDoorCreator.UI.Pages if (done) { - NavManager.NavigateTo(NavManager.Uri, true); + // flush dati ordine + reload + await WDService.OrdersFlushCache(); + orderCodExt = ""; + orderDescr = ""; + doorChange = true; + //// da eliminare... + //NavManager.NavigateTo(NavManager.Uri, true); } } @@ -189,7 +195,7 @@ namespace WebDoorCreator.UI.Pages protected int userCurrCompany { get; set; } protected async Task ReloadData() { - DoorsList = await WDService.DoorsGetByOrderId(currOrderId); + DoorsList = await WDService.DoorGetByOrderId(currOrderId); } #endregion Private Methods diff --git a/WebDoorCreator.UI/Pages/SuperAdmin.razor b/WebDoorCreator.UI/Pages/SuperAdmin.razor index 91f9863..a2661f0 100644 --- a/WebDoorCreator.UI/Pages/SuperAdmin.razor +++ b/WebDoorCreator.UI/Pages/SuperAdmin.razor @@ -4,13 +4,23 @@
-
-
- Company management +
+
+
+ Company management +
+
+ Users Management +
-
- Users Management +
+ + +
+ + +
diff --git a/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs b/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs index d6c91b3..9ccb2c3 100644 --- a/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs +++ b/WebDoorCreator.UI/Pages/SuperAdmin.razor.cs @@ -132,6 +132,10 @@ namespace WebDoorCreator.UI.Pages set { _passwordConfirm = value; } } + protected string _defaultPath = ""; + + protected string defaultPath { get; set; } = ""; + protected bool isCompShow { get; set; } = true; protected async Task addModNewCompany() @@ -285,5 +289,20 @@ namespace WebDoorCreator.UI.Pages await Task.Delay(1); isCompShow = false; } + protected async Task refreshHw() + { + await Task.Delay(1); + await WDService.CompoListSetAll(@$"{defaultPath}"); + } + protected async Task refreshVoc() + { + await Task.Delay(1); + await WDService.VocLemmaInsert(@$"{defaultPath}"); + } + protected async Task refreshFiles() + { + await Task.Delay(1); + await WDService.ListValuesInsert(@$"{defaultPath}"); + } } } \ No newline at end of file diff --git a/WebDoorCreator.UI/Program.cs b/WebDoorCreator.UI/Program.cs index 395ead3..6f93052 100644 --- a/WebDoorCreator.UI/Program.cs +++ b/WebDoorCreator.UI/Program.cs @@ -51,6 +51,7 @@ builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); builder.Services.AddScoped(); +builder.Services.AddSingleton(); builder.Services.AddScoped>(); builder.Services.AddHttpContextAccessor(); builder.Services.AddSingleton(redisMultiplexer); diff --git a/WebDoorCreator.UI/WebDoorCreator.UI.csproj b/WebDoorCreator.UI/WebDoorCreator.UI.csproj index 660abd9..4406b62 100644 --- a/WebDoorCreator.UI/WebDoorCreator.UI.csproj +++ b/WebDoorCreator.UI/WebDoorCreator.UI.csproj @@ -16,6 +16,7 @@ + @@ -38,6 +39,7 @@ + diff --git a/WebDoorCreator.UI/_Imports.razor b/WebDoorCreator.UI/_Imports.razor index d72ff7c..8faa1ad 100644 --- a/WebDoorCreator.UI/_Imports.razor +++ b/WebDoorCreator.UI/_Imports.razor @@ -15,6 +15,7 @@ @using WebDoorCreator.UI.Components.Gen @using WebDoorCreator.UI.Components.Order @using WebDoorCreator.UI.Components.Users +@using WebDoorCreator.UI.Components.Hardware @using WebDoorCreator.UI.Shared @using WebDoorCreator.Data.DbModels diff --git a/WebDoorCreator.UI/compilerconfig.json b/WebDoorCreator.UI/compilerconfig.json index f41598d..5ac6e93 100644 --- a/WebDoorCreator.UI/compilerconfig.json +++ b/WebDoorCreator.UI/compilerconfig.json @@ -22,5 +22,9 @@ { "outputFile": "Pages/Index.razor.css", "inputFile": "Pages/Index.razor.less" + }, + { + "outputFile": "Components/Hardware/HardwareList.razor.css", + "inputFile": "Components/Hardware/HardwareList.razor.less" } ] \ No newline at end of file
Door TypeDoor TypeDescription Door external code Doors Number
@door.TypeId + + @(door.TypeNav?.Description ?? "-")@door.DoorDescript @door.DoorExtCode @door.Quantity - + @if (door.Quantity > 1) + { + + } + else + { + + } - + + + @if (door.OrderNav?.Status < Core.Enum.OrderStatus.Sent) + { + + }
Doors Number Model Number TOTAL COSTPROGRESSPROGRESS
@item.NumType @($"{item.TotCost:C2}") -
-
-
-
+ @if (item.OrderStatus < (int)Core.Enum.OrderStatus.Sent) + { + + } +