diff --git a/EgtBEAMWALL.DataLayer/Controllers/BTLPartController.cs b/EgtBEAMWALL.DataLayer/Controllers/BTLPartController.cs index 2776084f..59838928 100644 --- a/EgtBEAMWALL.DataLayer/Controllers/BTLPartController.cs +++ b/EgtBEAMWALL.DataLayer/Controllers/BTLPartController.cs @@ -1,29 +1,16 @@ -using System; +using EgtBEAMWALL.DataLayer.DatabaseModels; +using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using EgtBEAMWALL.DataLayer.DatabaseModels; namespace EgtBEAMWALL.DataLayer.Controllers { public class BTLPartController : IDisposable { - #region Private Fields - -#if false - private DatabaseContext localDbCtx; -#endif - - #endregion Private Fields - #region Public Constructors public BTLPartController() { -#if false - // Initialize database context - localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING); -#endif } #endregion Public Constructors @@ -115,9 +102,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers localDbCtx.BTLPartList.AddRange(partData); // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } } catch (Exception exc) @@ -162,9 +146,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers localDbCtx.BTLPartList.AddRange(partData); // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } } catch (Exception exc) @@ -182,7 +163,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers /// public bool Delete(int PartDbId) { - bool done = false; using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING)) { @@ -196,9 +176,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers localDbCtx.BTLPartList.Remove(item2del); // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; } catch (Exception exc) @@ -228,9 +205,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers localDbCtx.BTLPartList.RemoveRange(items2del); // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; } catch (Exception exc) @@ -243,10 +217,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers public void Dispose() { -#if false - // Clear database context - localDbCtx.Dispose(); -#endif } /// @@ -386,17 +356,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers return answ; } -#if false - /// - /// Reinizializzaizone del controller - /// - public void ResetController() - { - // Re-Initialize database context - localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING); - } -#endif - /// /// Update single BTLPart /// @@ -428,10 +387,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers { Console.WriteLine($"EXCEPTION on Update: {exc}"); } -#if false - // reset... - ResetController(); -#endif } return done; } diff --git a/EgtBEAMWALL.DataLayer/Controllers/LogMachineController.cs b/EgtBEAMWALL.DataLayer/Controllers/LogMachineController.cs index a515bced..b2b960f2 100644 --- a/EgtBEAMWALL.DataLayer/Controllers/LogMachineController.cs +++ b/EgtBEAMWALL.DataLayer/Controllers/LogMachineController.cs @@ -7,18 +7,10 @@ namespace EgtBEAMWALL.DataLayer.Controllers { public class LogMachineController : IDisposable { -#if false - private DatabaseContext localDbCtx; -#endif - #region Public Constructors public LogMachineController() { -#if false - // Initialize database context - localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING); -#endif } #endregion Public Constructors @@ -84,9 +76,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers locallocalDbCtx.LogMachineList.Add(newLogMac); // Commit changes locallocalDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } } catch (Exception exc) @@ -129,9 +118,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers localDbCtx.LogMachineList.RemoveRange(items2del); // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; } catch (Exception exc) @@ -144,10 +130,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers public void Dispose() { -#if false - // Clear database context - localDbCtx.Dispose(); -#endif } /// @@ -204,17 +186,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers } } -#if false - /// - /// Reinizializzaizone del controller - /// - public void ResetController() - { - // Re-Initialize database context - localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING); - } -#endif - /// /// Update single LogMachineModel /// @@ -236,9 +207,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; } catch (Exception exc) diff --git a/EgtBEAMWALL.DataLayer/Controllers/LogSupportController.cs b/EgtBEAMWALL.DataLayer/Controllers/LogSupportController.cs index 2841a805..de12ee27 100644 --- a/EgtBEAMWALL.DataLayer/Controllers/LogSupportController.cs +++ b/EgtBEAMWALL.DataLayer/Controllers/LogSupportController.cs @@ -10,9 +10,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers { #region Private Fields -#if false - private DatabaseContext localDbCtx; -#endif #endregion Private Fields @@ -20,10 +17,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers public LogSupportController() { -#if false - // Initialize database context - localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING); -#endif } #endregion Public Constructors @@ -56,9 +49,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers localDbCtx.LogSupportList.Add(newItem); // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } catch (Exception exc) { @@ -90,9 +80,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers localDbCtx.LogSupportList.RemoveRange(items2del); // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; } catch (Exception exc) @@ -105,10 +92,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers public void Dispose() { -#if false - // Clear database context - localDbCtx.Dispose(); -#endif } /// @@ -165,17 +148,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers } } -#if false - /// - /// Reinizializzaizone del controller - /// - public void ResetController() - { - // Re-Initialize database context - localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING); - } -#endif - /// /// Update single LogMachineModel /// @@ -197,9 +169,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; } catch (Exception exc) diff --git a/EgtBEAMWALL.DataLayer/Controllers/MachGroupController.cs b/EgtBEAMWALL.DataLayer/Controllers/MachGroupController.cs index 4186ad80..e862282a 100644 --- a/EgtBEAMWALL.DataLayer/Controllers/MachGroupController.cs +++ b/EgtBEAMWALL.DataLayer/Controllers/MachGroupController.cs @@ -207,10 +207,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers public void Dispose() { -#if false - // Clear database context - dbCtx.Dispose(); -#endif } /// diff --git a/EgtBEAMWALL.DataLayer/Controllers/PartController .cs b/EgtBEAMWALL.DataLayer/Controllers/PartController .cs index 17b8a18e..93fa7522 100644 --- a/EgtBEAMWALL.DataLayer/Controllers/PartController .cs +++ b/EgtBEAMWALL.DataLayer/Controllers/PartController .cs @@ -1,21 +1,11 @@ -using System; -using System.Collections.Generic; +using EgtBEAMWALL.DataLayer.DatabaseModels; +using System; using System.Linq; -using System.Text; -using EgtBEAMWALL.DataLayer.DatabaseModels; namespace EgtBEAMWALL.DataLayer.Controllers { public class PartController : IDisposable { - #region Private Fields - -#if false - private DatabaseContext localDbCtx; -#endif - - #endregion Private Fields - #region Public Fields public static PartController man = new PartController(); @@ -26,10 +16,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers public PartController() { -#if false - // Initialize database context - localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING); -#endif } #endregion Public Constructors @@ -151,9 +137,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers localDbCtx.PartList.Remove(item2del); // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; // aggiorno info sullo status StatusMapController.man.UpdateAction("", ProdId, MachGroupId, Core.StatusMapItemType.MachGroup, Core.StatusMapOpType.MachGroupMod, ""); @@ -186,9 +169,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers localDbCtx.PartList.Remove(item2del); // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; } catch (Exception exc) @@ -218,9 +198,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers localDbCtx.PartList.RemoveRange(items2del); // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; } catch (Exception exc) @@ -233,10 +210,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers public void Dispose() { -#if false - // Clear database context - localDbCtx.Dispose(); -#endif } /// @@ -273,17 +246,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers return answ; } -#if false - /// - /// Reinizializzaizone del controller - /// - public void ResetController() - { - // Re-Initialize database context - localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING); - } -#endif - /// /// Update single Part /// diff --git a/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs b/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs index be457c58..0ebbbb4d 100644 --- a/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs +++ b/EgtBEAMWALL.DataLayer/Controllers/ProdController.cs @@ -11,9 +11,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers { #region Private Fields -#if false - private DatabaseContext localDbCtx; -#endif #endregion Private Fields @@ -27,10 +24,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers public ProdController() { -#if false - // Initialize database context - localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING); -#endif } #endregion Public Constructors @@ -110,9 +103,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // salvo localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } return done; } @@ -162,9 +152,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers localDbCtx.ProdList.Remove(currProd); // salvo localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; } catch (Exception exc) @@ -177,10 +164,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers public void Dispose() { -#if false - // Clear database context - localDbCtx.Dispose(); -#endif } /// @@ -197,13 +180,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers .ProdList .Where(x => x.ProdDbId == ProdDbId) .SingleOrDefault(); -#if false - // forzo rilettura - if (answ != null) - { - localDbCtx.Entry(answ).Reload(); - } -#endif } return answ; } @@ -222,13 +198,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers .ProdList .Where(x => x.ProdId == ProdId) .SingleOrDefault(); -#if false - // forzo rilettura - if (answ != null) - { - localDbCtx.Entry(answ).Reload(); - } -#endif } return answ; } @@ -368,9 +337,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers } localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } return currProd; } @@ -414,10 +380,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers /// public void ResetController() { -#if false - // Re-Initialize database context - localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING); -#endif } /// @@ -445,9 +407,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; } catch @@ -482,12 +441,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // cerco le MG esistenti --> aggiorno foreach (var item in MachGroupList) { -#if false - var currMG = localDbCtx - .MachGroupList - .Where(x => x.Prod.ProdId == ProdId && x.MachGroupId == item.Id) - .SingleOrDefault(); -#endif var currMG = MachGroupController.man.FindByMachGroupId(ProdId, item.Id); var convCurrMG = MachGroupController.ConvertFromCore(item, currData.ProdDbId); if (currMG != null) @@ -588,9 +541,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } catch (Exception exc) { @@ -620,9 +570,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } return coreConv(currData); } @@ -647,9 +594,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } return coreConv(currData); } diff --git a/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs b/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs index e018d69b..2a53c9b3 100644 --- a/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs +++ b/EgtBEAMWALL.DataLayer/Controllers/ProjController.cs @@ -9,12 +9,8 @@ namespace EgtBEAMWALL.DataLayer.Controllers { public class ProjController : IDisposable { - private object dbCtx; #region Private Fields -#if false - private DatabaseContext dbCtx; -#endif #endregion Private Fields @@ -22,10 +18,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers public ProjController() { -#if false - // Initialize database context - dbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING); -#endif } #endregion Public Constructors @@ -147,9 +139,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers localDbCtx.ProjList.Remove(currProj); // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; } catch (Exception exc) @@ -162,10 +151,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers public void Dispose() { -#if false - // Clear database context - dbCtx.Dispose(); -#endif } /// @@ -227,13 +212,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers .ProjList .Where(x => x.ProjDbId == ProjDbId) .SingleOrDefault(); -#if false - // forzo rilettura - if (answ != null) - { - localDbCtx.Entry(answ).Reload(); - } -#endif } return answ; } @@ -252,13 +230,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers .ProjList .Where(x => x.ProjId == ProjId) .SingleOrDefault(); -#if false - // forzo rilettura - if (answ != null) - { - dbCtx.Entry(answ).Reload(); - } -#endif } return answ; } @@ -483,9 +454,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers } // salvataggio localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } return coreConv(currProj); } @@ -495,10 +463,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers /// public void ResetController() { -#if false - // Re-Initialize database context - dbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING); -#endif } /// @@ -520,9 +484,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // aggiorno stato currProj.IsNew = false; localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } return coreConv(currProj); } @@ -553,9 +514,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif done = true; } catch (Exception ex) @@ -642,9 +600,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } return currData; } @@ -709,9 +664,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } return coreConv(currData); @@ -728,9 +680,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers ProjModel currData; using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING)) { -#if false - var currData = FindByProjId(ProjId); -#endif currData = localDbCtx .ProjList .Where(x => x.ProjId == ProjId) @@ -740,9 +689,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } return coreConv(currData); } @@ -758,9 +704,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers ProjModel currData; using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING)) { -#if false - var currData = FindByProjId(ProjId); -#endif currData = localDbCtx .ProjList .Where(x => x.ProjId == ProjId) @@ -770,9 +713,6 @@ namespace EgtBEAMWALL.DataLayer.Controllers // Commit changes localDbCtx.SaveChanges(); -#if false - ResetController(); -#endif } return coreConv(currData); }