diff --git a/MP.MONO.DECODER/Program.cs b/MP.MONO.DECODER/Program.cs index 8bef300..dc5043a 100644 --- a/MP.MONO.DECODER/Program.cs +++ b/MP.MONO.DECODER/Program.cs @@ -53,7 +53,7 @@ if (string.IsNullOrEmpty(connStringDB)) } else { - dbController = new MpDbController(config); + dbController = new MpDbController(); Log.Info("DbController OK"); Console.WriteLine("DbController OK"); } diff --git a/MP.MONO.Data/AdminContext.cs b/MP.MONO.Data/AdminContext.cs index b0ae830..7470031 100644 --- a/MP.MONO.Data/AdminContext.cs +++ b/MP.MONO.Data/AdminContext.cs @@ -17,8 +17,6 @@ namespace MP.MONO.Data { #region Private Fields - private IConfiguration _configuration; - #endregion Private Fields #region Public Constructors @@ -27,14 +25,6 @@ namespace MP.MONO.Data { } - public AdminContext(IConfiguration configuration) - { - _configuration = configuration; - } - - public AdminContext(DbContextOptions options) : base(options) - { - } #endregion Public Constructors @@ -43,7 +33,7 @@ namespace MP.MONO.Data /// /// User management /// - public DbSet UserList { get; set; } + public DbSet UserList { get; set; } = null!; #endregion Public Properties @@ -60,8 +50,6 @@ namespace MP.MONO.Data string connString = DbConfig.ADMIN_CONNECTION_STRING; if (!optionsBuilder.IsConfigured) { - //connString = _configuration.GetConnectionString("GWMS.Data"); - //connString = "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;"; var serverVersion = ServerVersion.AutoDetect(connString); optionsBuilder.UseMySql(connString, serverVersion); } diff --git a/MP.MONO.Data/Controllers/MpDbController.cs b/MP.MONO.Data/Controllers/MpDbController.cs index 24767ef..4bda399 100644 --- a/MP.MONO.Data/Controllers/MpDbController.cs +++ b/MP.MONO.Data/Controllers/MpDbController.cs @@ -14,13 +14,10 @@ namespace MP.MONO.Data.Controllers { public class MpDbController : IDisposable { - private static IConfiguration _configuration; private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); - public MpDbController(IConfiguration configuration) - { - _configuration = configuration; - } + public MpDbController() + { } public void Dispose() { @@ -38,7 +35,7 @@ namespace MP.MONO.Data.Controllers public List AlarmLogGetFilt(int MachineId, int skipRec, int numRec) { List dbResult = new List(); - using (MapoMonoContext localDbCtx = new MapoMonoContext(_configuration)) + using (MapoMonoContext localDbCtx = new MapoMonoContext()) { try { @@ -67,7 +64,7 @@ namespace MP.MONO.Data.Controllers public async Task AlarmLogInsert(AlarmLogModel newItem) { bool fatto = false; - using (MapoMonoContext localDbCtx = new MapoMonoContext(_configuration)) + using (MapoMonoContext localDbCtx = new MapoMonoContext()) { try { @@ -115,58 +112,6 @@ namespace MP.MONO.Data.Controllers // !!!FIXME TODO... รจ fake... Random rand = new Random(); - int stdCycle = 5; - -#if false - var currVal = rand.NextDouble(); - DisplayDataDTO displ01 = new DisplayDataDTO() - { - Order = 0, - Title = "OEE", - ValueNum = currVal, - IsNumeric = true, - Value = currVal.ToString("P1"), - Type = "OEE-75-90" - }; - answ.Add(displ01); - - currVal = rand.NextDouble(); - DisplayDataDTO displ02 = new DisplayDataDTO() - { - Order = 0, - Title = "Avail", - ValueNum = currVal, - IsNumeric = true, - Value = currVal.ToString("P1"), - Type = "AVAIL-50-80" - }; - answ.Add(displ02); - - currVal = rand.NextDouble(); - DisplayDataDTO displ03 = new DisplayDataDTO() - { - Order = 0, - Title = "Order fulfill", - ValueNum = currVal, - IsNumeric = true, - Value = currVal.ToString("P1"), - Type = "ORDER" - }; - answ.Add(displ03); - - double minTCiclo = stdCycle * rand.NextDouble(); - TimeSpan durTCycle = TimeSpan.FromMinutes(minTCiclo); - DisplayDataDTO displ04 = new DisplayDataDTO() - { - Order = 0, - Title = "Cycle time", - ValueNum = 0, - IsNumeric = false, - Value = $"{durTCycle.Hours:00}:{durTCycle.Minutes:00}:{durTCycle.Seconds:00}", - Type = "TCycle" - }; - answ.Add(displ04); -#endif double currVal = 0; currVal = rand.Next(10, 120) * 100; DisplayDataDTO displ01 = new DisplayDataDTO() @@ -204,7 +149,7 @@ namespace MP.MONO.Data.Controllers }; answ.Add(displ03); - currVal = rand.NextDouble() *5000; + currVal = rand.NextDouble() * 5000; DisplayDataDTO displ04 = new DisplayDataDTO() { Order = 0, diff --git a/MP.MONO.Data/DbModels/TableCount.cs b/MP.MONO.Data/DbModels/TableCount.cs index 15d8c83..edd5a4c 100644 --- a/MP.MONO.Data/DbModels/TableCount.cs +++ b/MP.MONO.Data/DbModels/TableCount.cs @@ -18,8 +18,8 @@ namespace MP.MONO.Data.DbModels { #region Public Properties - public int Count { get; set; } - public string TableName { get; set; } + public int Count { get; set; } = 0; + public string TableName { get; set; } = ""; #endregion Public Properties } diff --git a/MP.MONO.Data/MailKitEmailSenderOptions.cs b/MP.MONO.Data/MailKitEmailSenderOptions.cs index 40e806e..ed8f0f7 100644 --- a/MP.MONO.Data/MailKitEmailSenderOptions.cs +++ b/MP.MONO.Data/MailKitEmailSenderOptions.cs @@ -15,16 +15,16 @@ namespace MP.MONO.Data #region Public Properties - public string Host_Address { get; set; } + public string Host_Address { get; set; } = ""; - public string Host_Password { get; set; } - public int Host_Port { get; set; } + public string Host_Password { get; set; } = ""; + public int Host_Port { get; set; } = 0; - public SecureSocketOptions Host_SecureSocketOptions { get; set; } - public string Host_Username { get; set; } - public string Sender_EMail { get; set; } + public SecureSocketOptions Host_SecureSocketOptions { get; set; } = SecureSocketOptions.None; + public string Host_Username { get; set; } = ""; + public string Sender_EMail { get; set; } = ""; - public string Sender_Name { get; set; } + public string Sender_Name { get; set; } = ""; #endregion Public Properties } diff --git a/MP.MONO.Data/MapoMonoContext.cs b/MP.MONO.Data/MapoMonoContext.cs index 7cf3c25..7093684 100644 --- a/MP.MONO.Data/MapoMonoContext.cs +++ b/MP.MONO.Data/MapoMonoContext.cs @@ -13,37 +13,16 @@ namespace MP.MONO.Data private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); - private IConfiguration _configuration; #endregion Private Fields #region Public Constructors - - public MapoMonoContext(IConfiguration configuration) - { - _configuration = configuration; - } public MapoMonoContext() { //connString = "server=10.74.82.230;port=3306;database=MAPO.MONO;uid=steamware;pwd=Egalware_24068!;sslmode=None;"; } -#if false - - public MapoMonoContext(DbContextOptions options) : base(options) - { - try - { - // se non ci fosse... crea o migra! - Database.Migrate(); - } - catch (Exception exc) - { - Log.Error(exc, "Exception during context initialization 02"); - } - } -#endif #endregion Public Constructors @@ -124,12 +103,6 @@ namespace MP.MONO.Data } catch { } - // se vuoto sistemo... - if (string.IsNullOrEmpty(connString)) - { - connString = "server=10.74.82.230;port=3306;database=MAPO.MONO;uid=steamware;pwd=Egalware_24068!;sslmode=None;"; - //connString = "server=localhost;port=3306;database=MAPO.MONO;uid=root;pwd=Egalware_24068!;sslmode=None;"; - } if (!optionsBuilder.IsConfigured) { var serverVersion = ServerVersion.AutoDetect(connString); diff --git a/MP.MONO.Data/UserIdentityDbContext.cs b/MP.MONO.Data/UserIdentityDbContext.cs index 47ae428..da9b8e7 100644 --- a/MP.MONO.Data/UserIdentityDbContext.cs +++ b/MP.MONO.Data/UserIdentityDbContext.cs @@ -15,23 +15,18 @@ namespace MP.MONO.Data // se non ci fosse... crea o migra! Database.Migrate(); } - catch (Exception exc) + catch { } } - public UserIdentityDbContext(DbContextOptions options) - : base(options) + public UserIdentityDbContext(DbContextOptions options) : base(options) { -#if false - // se non ci fosse... crea! - Database.EnsureCreated(); -#endif try { // se non ci fosse... crea o migra! Database.Migrate(); } - catch (Exception exc) + catch { } } @@ -39,7 +34,7 @@ namespace MP.MONO.Data #region Public Properties - public DbSet DbSetCounts { get; set; } + public DbSet DbSetCounts { get; set; } = null!; #endregion Public Properties diff --git a/MP.MONO.UI/Data/CurrentDataService.cs b/MP.MONO.UI/Data/CurrentDataService.cs index f32a0b3..31bb577 100644 --- a/MP.MONO.UI/Data/CurrentDataService.cs +++ b/MP.MONO.UI/Data/CurrentDataService.cs @@ -70,7 +70,7 @@ namespace MP.MONO.UI.Data } else { - dbController = new MpDbController(configuration); + dbController = new MpDbController(); _logger.LogInformation("DbController OK"); } } diff --git a/MP.MONO.UI/Pages/Alarms.razor.cs b/MP.MONO.UI/Pages/Alarms.razor.cs index 21e172c..edff81f 100644 --- a/MP.MONO.UI/Pages/Alarms.razor.cs +++ b/MP.MONO.UI/Pages/Alarms.razor.cs @@ -113,7 +113,7 @@ namespace MP.MONO.UI.Pages { isLoading = true; ListRecords = null; - await Task.Delay(100); + await Task.Delay(300); await ReloadData(); await Task.Delay(1); await InvokeAsync(() =>