Merge remote-tracking branch 'gitlab.seriate/DataLayer' into Selection&Highlight

This commit is contained in:
Emmanuele Sassi
2022-07-06 15:43:10 +02:00
28 changed files with 568 additions and 282 deletions
+66 -10
View File
@@ -1,26 +1,21 @@
using System;
using System.Collections.Generic;
using EgtBEAMWALL.DataLayer.DatabaseModels;
using EgtBEAMWALL.DataLayer.Migrations;
using MySql.Data.Entity;
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using MySql.Data.Entity;
using System.Linq;
using System.Text;
using EgtBEAMWALL.DataLayer.DatabaseModels;
using EgtBEAMWALL.DataLayer.Migrations;
using System.ServiceProcess;
using System.IO;
using System.Data.Entity.Infrastructure;
namespace EgtBEAMWALL.DataLayer
{
[DbConfigurationType(typeof(MySqlEFConfiguration))]
//[DbConfigurationType(typeof(aMySqlConfiguration))]
public class AdminContext : DbContext
{
#region Public Constructors
[Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")]
public AdminContext() : base("DefaultConnection")
public AdminContext() : base(DbConfig.ADMIN_CONNECTION_STRING)
{
}
@@ -38,5 +33,66 @@ namespace EgtBEAMWALL.DataLayer
public DbSet<UserPriv> UserList { get; set; }
#endregion Public Properties
#region Public Methods
public bool SetUpDbConnectionAndDbConfig()
{
try
{
String serviceName = getDbServiceName();
if (serviceName.Equals(""))
{
return false;
}
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromSeconds(DbConfig.DATABASE_PROCESS_TIMEOUT);
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
}
catch (Exception)
{
return false;
}
//Database.SetInitializer<DatabaseContext>(null);
Database.SetInitializer(new MigrateDatabaseToLatestVersion<DatabaseContext, Configuration>());
var migrator = new DbMigrator(new Configuration());
if (migrator.GetPendingMigrations().Any())
{
// Run migrations and seed.
migrator.Update();
}
}
catch (Exception exc)
{
return false;
}
return true;
}
#endregion Public Methods
#region Private Methods
private static string getDbServiceName()
{
ServiceController[] services = ServiceController.GetServices();
var service = services.FirstOrDefault(s => s.ServiceName == "MariaDB");
if (service != null)
return service.DisplayName;
service = services.FirstOrDefault(s => s.ServiceName == "MySQL");
if (service != null)
return service.DisplayName;
return "";
}
#endregion Private Methods
}
}
+1 -1
View File
@@ -12,7 +12,7 @@
</providers>
</entityFramework>
<connectionStrings>
<add name="DefaultConnection" connectionString="server=localhost;port=3306;User Id=EgtUser;password=viacremasca;Persist Security Info=True;database=EgtBwDb;SslMode=none" providerName="MySql.Data.MySqlClient" />
<add name="DefaultConnection" connectionString="server=localhost;port=3306;User Id=steamware;password=Egalware_24068!;Persist Security Info=True;database=EgtBwDb_000470;SslMode=none" providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
@@ -1,4 +1,5 @@
using EgtBEAMWALL.DataLayer.DatabaseModels;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -408,7 +409,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Istanza logger
/// </summary>
private NLog.Logger Log;
private NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
@@ -1,4 +1,5 @@
using System;
using NLog;
using System;
using System.Linq;
using System.Threading;
@@ -69,12 +70,25 @@ namespace EgtBEAMWALL.DataLayer.Controllers
return answ;
}
/// <summary>
/// Migrazione esplicita del DB da parte dell'admin controller
/// </summary>
/// <returns></returns>
public bool checkMigrateDb()
{
return adbCtx.SetUpDbConnectionAndDbConfig();
}
public void Dispose()
{
// Clear database context
adbCtx.Dispose();
}
/// <summary>
/// ATTENZIONE!!!! Procedura di Reset del DB
/// </summary>
/// <returns></returns>
public bool ResetDb()
{
bool answ = false;
@@ -107,7 +121,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Istanza logger
/// </summary>
private NLog.Logger Log;
private NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
@@ -1,4 +1,5 @@
using EgtBEAMWALL.DataLayer.DatabaseModels;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -256,7 +257,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Istanza logger
/// </summary>
private NLog.Logger Log;
private NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
@@ -1,4 +1,5 @@
using EgtBEAMWALL.DataLayer.DatabaseModels;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -186,7 +187,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Istanza logger
/// </summary>
private NLog.Logger Log;
private NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
@@ -1,4 +1,5 @@
using EgtBEAMWALL.DataLayer.DatabaseModels;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -725,7 +726,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Istanza logger
/// </summary>
private NLog.Logger Log;
private NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
@@ -1,4 +1,5 @@
using EgtBEAMWALL.DataLayer.DatabaseModels;
using NLog;
using System;
using System.Linq;
@@ -405,7 +406,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Istanza logger
/// </summary>
private NLog.Logger Log;
private NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
@@ -1,4 +1,5 @@
using EgtBEAMWALL.DataLayer.DatabaseModels;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -18,6 +19,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
public ProdController()
{
Log.Info("ProdController istance Started");
}
#endregion Public Constructors
@@ -27,10 +29,11 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Aggiunta di un PROJ ad un PROD
/// </summary>
/// <param name="ProdId"></param>
/// <param name="ProjId"></param>
/// <param name="ProdId">ID Prod</param>
/// <param name="ProjId">ID Proj</param>
/// <param name="UserKey">User ID / Key number</param>
/// <returns></returns>
public bool AddProj(int ProdId, int ProjId)
public bool AddProj(int ProdId, int ProjId, string UserKey = "USER01")
{
bool done = false;
@@ -51,6 +54,8 @@ namespace EgtBEAMWALL.DataLayer.Controllers
// lo aggiorno
currProj.ProdDbId = currProd.ProdDbId;
currProj.Locked = true;
currProj.LockDate = DateTime.Now;
currProj.LockedBy = UserKey;
// salvo
localDbCtx.SaveChanges();
@@ -190,9 +195,10 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Fornisce nuovo indice VUOTO da usare (allocando sul DB)
/// </summary>
/// <param name="ProjId"></param>
/// <param name="ProjId">ID Proj</param>
/// <param name="UserKey">User ID / Key number</param>
/// <returns></returns>
public int GetNextIndex(int ProjId)
public int GetNextIndex(int ProjId, string UserKey = "USER01")
{
int nextId = 0;
@@ -230,6 +236,8 @@ namespace EgtBEAMWALL.DataLayer.Controllers
// aggiungo proj-prod
currProj.ProdDbId = newProd.ProdDbId;
currProj.Locked = true;
currProj.LockDate = DateTime.Now;
currProj.LockedBy = UserKey;
// Commit changes
localDbCtx.SaveChanges();
@@ -257,8 +265,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
return numAssigned > 0;
}
/// <summary> Return Lock by ProdId (proj & prod) </summary> <param
/// name="ProdId">ProjID</param> <returns></returns>
/// <summary> Return Lock by ProdId (proj & prod) </summary> <param name="ProdId"></param> <returns></returns>
public bool IsLockByProdId(int ProdId)
{
bool bIsLock = false;
@@ -288,9 +295,10 @@ namespace EgtBEAMWALL.DataLayer.Controllers
return bIsLock;
}
/// <summary> Manage Lock by ProdId (proj & prod) </summary> <param
/// name="ProdId">ProjID</param> <param name="Locked">Stato Lock da impostare</param> <returns></returns>
public ProdModel LockByProdId(int ProdId, bool Locked)
/// <summary> Manage Lock by ProdId (proj & prod) </summary> <param name="ProdId"></param>
/// <param name="Locked">Stato Lock da impostare</param> <param name="UserKey">User ID / Key
/// number</param> <returns></returns>
public ProdModel LockByProdId(int ProdId, bool Locked, string UserKey = "USER01")
{
ProdModel currProd;
// seleziono il prod...
@@ -304,6 +312,8 @@ namespace EgtBEAMWALL.DataLayer.Controllers
if (currProd != null)
{
currProd.Locked = Locked;
currProd.LockDate = DateTime.Now;
currProd.LockedBy = Locked ? UserKey : "";
localDbCtx.Entry(currProd).State = System.Data.Entity.EntityState.Modified;
var currProj = localDbCtx
@@ -315,6 +325,8 @@ namespace EgtBEAMWALL.DataLayer.Controllers
foreach (var item in currProj)
{
item.Locked = Locked;
item.LockDate = DateTime.Now;
item.LockedBy = Locked ? UserKey : "";
localDbCtx.Entry(item).State = System.Data.Entity.EntityState.Modified;
}
}
@@ -553,6 +565,37 @@ namespace EgtBEAMWALL.DataLayer.Controllers
return coreConv(currData);
}
/// <summary> Return User Code/Key that Locks by ProdId (proj & prod) </summary> <param
/// name="ProdId"></param> <returns></returns>
public string UserLockByProdId(int ProdId)
{
string LockBy = "";
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
{
// seleziono il prod...
var currProd = localDbCtx
.ProdList
.Where(x => x.ProdId == ProdId)
.FirstOrDefault();
if (currProd != null)
{
LockBy = currProd.LockedBy;
var currProj = localDbCtx
.ProjList
.Where(x => x.ProdDbId == currProd.ProdDbId)
.ToList();
if (currProj != null && string.IsNullOrEmpty(LockBy))
{
LockBy = currProj.FirstOrDefault(x => !string.IsNullOrEmpty(x.LockedBy)).LockedBy;
}
}
}
return LockBy;
}
#endregion Public Methods
#region Protected Methods
@@ -603,7 +646,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Istanza logger
/// </summary>
private NLog.Logger Log;
private NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
@@ -1,4 +1,5 @@
using EgtBEAMWALL.DataLayer.DatabaseModels;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -20,7 +21,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Search for already imported BTL from FileName (only)
/// =0 : NOT found &gt;0 : ProjId (already rpesent) for overwrite
/// =0 : NOT found &gt;0 : ProjId (already present) for overwrite
/// </summary>
/// <param name="BTLFileName"></param>
/// <returns></returns>
@@ -43,6 +44,11 @@ namespace EgtBEAMWALL.DataLayer.Controllers
return answ;
}
/// <summary>
/// Delete Proj on DB by ProjId
/// </summary>
/// <param name="ProjId"></param>
/// <returns></returns>
public bool DeleteProj(int ProjId)
{
bool done = false;
@@ -302,8 +308,9 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Fornisce nuovo indice VUOTO da usare (allocando sul DB)
/// </summary>
/// <param name="UserKey">User ID / Key number</param>
/// <returns></returns>
public int GetNextIndex()
public int GetNextIndex(string UserKey = "USER01")
{
int nextId = 0;
@@ -330,7 +337,16 @@ namespace EgtBEAMWALL.DataLayer.Controllers
// creo nuovo...
var newRec = localDbCtx
.ProjList
.Add(new ProjModel() { ProjId = nextId, BTLFileName = "", IsNew = true, Locked = true, DtCreated = DateTime.Now });
.Add(new ProjModel()
{
ProjId = nextId,
BTLFileName = "",
IsNew = true,
Locked = true,
LockedBy = UserKey,
LockDate = DateTime.Now,
DtCreated = DateTime.Now
});
// Commit changes
localDbCtx.SaveChanges();
@@ -338,9 +354,10 @@ namespace EgtBEAMWALL.DataLayer.Controllers
return nextId;
}
/// <summary> Manage Lock by ProjId (proj & prod) </summary> <param
/// name="ProjId">ProjID</param> <param name="Locked">Stato Lock da impostare</param> <returns></returns>
public Core.ProjFileM LockByProjId(int ProjId, bool Locked)
/// <summary> Manage Lock by ProjId (proj & prod) </summary> <param name="ProjId">ID
/// Proj</param> <param name="Locked">Stato Lock da impostare</param> <param
/// name="UserKey">User ID / Key number</param> <returns></returns>
public Core.ProjFileM LockByProjId(int ProjId, bool Locked, string UserKey = "USER01")
{
ProjModel currProj;
using (DatabaseContext localDbCtx = new DatabaseContext(DbConfig.CONNECTION_STRING))
@@ -351,6 +368,8 @@ namespace EgtBEAMWALL.DataLayer.Controllers
.SingleOrDefault();
// aggiorno stato del proj
currProj.Locked = Locked;
currProj.LockDate = DateTime.Now;
currProj.LockedBy = Locked ? UserKey : "";
localDbCtx.Entry(currProj).State = System.Data.Entity.EntityState.Modified;
// seleziono il prod e lo blocco...
@@ -363,6 +382,8 @@ namespace EgtBEAMWALL.DataLayer.Controllers
{
// blocco prod corrente
currProd.Locked = Locked;
currProd.LockDate = DateTime.Now;
currProd.LockedBy = Locked ? UserKey : "";
localDbCtx.Entry(currProd).State = System.Data.Entity.EntityState.Modified;
// ora blocco altri proj del prod...
@@ -376,6 +397,8 @@ namespace EgtBEAMWALL.DataLayer.Controllers
{
//item.ProdDbId = currProd.ProdDbId;
item.Locked = Locked;
item.LockDate = DateTime.Now;
item.LockedBy = Locked ? UserKey : "";
localDbCtx.Entry(item).State = System.Data.Entity.EntityState.Modified;
}
}
@@ -723,7 +746,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Istanza logger
/// </summary>
private NLog.Logger Log;
private NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
@@ -1,4 +1,5 @@
using EgtBEAMWALL.DataLayer.DatabaseModels;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -271,7 +272,7 @@ namespace EgtBEAMWALL.DataLayer.Controllers
/// <summary>
/// Istanza logger
/// </summary>
private NLog.Logger Log;
private NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
}
+6 -70
View File
@@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using EgtBEAMWALL.DataLayer.DatabaseModels;
using MySql.Data.Entity;
using System.Linq;
using System.Text;
using EgtBEAMWALL.DataLayer.DatabaseModels;
using EgtBEAMWALL.DataLayer.Migrations;
using System.ServiceProcess;
using System.IO;
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.IO;
namespace EgtBEAMWALL.DataLayer
{
@@ -33,15 +27,13 @@ namespace EgtBEAMWALL.DataLayer
#region Public Constructors
[Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")]
public DatabaseContext() : base("DefaultConnection")
public DatabaseContext() : base(DbConfig.CONNECTION_STRING)
{
}
public DatabaseContext(string connectionString) : base(connectionString)
{
//Database.CreateIfNotExists();
////Database.SetInitializer(new MigrateDatabaseToLatestVersion<StratonLocalizerDatabase, Migrations.Configuration>());
//Database.Initialize(false);
Database.CreateIfNotExists();
}
#endregion Public Constructors
@@ -90,24 +82,6 @@ namespace EgtBEAMWALL.DataLayer
#endregion Public Properties
#region Private Methods
private static string getDbServiceName()
{
ServiceController[] services = ServiceController.GetServices();
var service = services.FirstOrDefault(s => s.ServiceName == "MariaDB");
if (service != null)
return service.DisplayName;
service = services.FirstOrDefault(s => s.ServiceName == "MySQL");
if (service != null)
return service.DisplayName;
return "";
}
#endregion Private Methods
#region Public Methods
public static DatabaseContext Create()
@@ -115,44 +89,6 @@ namespace EgtBEAMWALL.DataLayer
return new DatabaseContext(DbConfig.CONNECTION_STRING);
}
public static bool SetUpDbConnectionAndDbConfig()
{
try
{
String serviceName = getDbServiceName();
if (serviceName.Equals(""))
{
return false;
}
ServiceController service = new ServiceController(serviceName);
try
{
TimeSpan timeout = TimeSpan.FromSeconds(DbConfig.DATABASE_PROCESS_TIMEOUT);
service.WaitForStatus(ServiceControllerStatus.Running, timeout);
}
catch (Exception)
{
return false;
}
System.Data.Entity.Database.SetInitializer<DatabaseContext>(null);
var migrator = new DbMigrator(new Configuration());
if (migrator.GetPendingMigrations().Any())
{
// Run migrations and seed.
migrator.Update();
}
}
catch (Exception)
{
return false;
}
return true;
}
#endregion Public Methods
}
}
@@ -98,12 +98,5 @@ namespace EgtBEAMWALL.DataLayer.DatabaseModels
#endregion Public Properties
#if false
/// <summary>
/// MachineId del BTL
/// </summary>
[Column("MachineId")]
public string MachineId { get; set; } = "";
#endif
}
}
@@ -32,11 +32,23 @@ namespace EgtBEAMWALL.DataLayer.DatabaseModels
public bool IsNew { get; set; } = true;
/// <summary>
/// Stato locked (quando aperto da un dispositivo in rete)
/// Stato locked, quando aperto da un dispositivo in rete
/// </summary>
[Column("Lock")]
public bool Locked { get; set; } = false;
/// <summary>
/// ID utente che ha bloccato (NumKey), quando aperto da un dispositivo in rete
/// </summary>
[Column("LockedBy")]
public string LockedBy { get; set; } = "";
/// <summary>
/// DataOra ultima operazione di Lock (o di rimozione di lock), quando aperto da un dispositivo in rete
/// </summary>
[Column("LockDate")]
public DateTime LockDate { get; set; } = DateTime.MinValue;
/// <summary>
/// Macchina
/// </summary>
@@ -49,6 +49,18 @@ namespace EgtBEAMWALL.DataLayer.DatabaseModels
[Column("Lock")]
public bool Locked { get; set; } = false;
/// <summary>
/// ID utente che ha bloccato (NumKey), quando aperto da un dispositivo in rete
/// </summary>
[Column("LockedBy")]
public string LockedBy { get; set; } = "";
/// <summary>
/// DataOra ultima operazione di Lock (o di rimozione di lock), quando aperto da un dispositivo in rete
/// </summary>
[Column("LockDate")]
public DateTime LockDate { get; set; } = DateTime.MinValue;
/// <summary>
/// Macchina
/// </summary>
+20 -26
View File
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.IO;
using System.Reflection;
using System.Text;
namespace EgtBEAMWALL.DataLayer
{
@@ -39,24 +35,28 @@ namespace EgtBEAMWALL.DataLayer
#region Public Methods
#if false
/// <summary>
/// Metodo di init standard per DB locale
/// Effettua migrazione esplicita del DB
/// </summary>
/// <param name="server">Indirizzo del server (tipicamente localhost/127.0.0.1)</param>
/// <param name="nKey">Numero chiave</param>
/// <param name="sKey">Codice/pwd associato a chaive</param>
public static void InitDb(string server, string nKey, string sKey)
/// <returns></returns>
public static bool CheckMigrateDb()
{
DATABASE_SERV = server;
DATABASE_NAME = $"EgtBwDb_{nKey}";
DATABASE_USER = $"user_{nKey}";
DATABASE_PWD = $"pwd_{sKey}";
CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database={DATABASE_NAME};uid={DATABASE_USER};pwd={DATABASE_PWD};sslmode=None";
// stringa admin con utente root egalware...
ADMIN_CONNECTION_STRING = $"server={DATABASE_SERV};port=3306;database=mysql;uid=root;pwd=Egalware_24068!;sslmode=None;CHARSET=utf8";
}
#endif
// esecuzione script di migrations del DB
return Controllers.DbController.man.checkMigrateDb();
}
/// <summary>
/// Effettua verifica presenza utente
/// </summary>
/// <param name="nKey"></param>
/// <param name="sKey"></param>
/// <param name="isNetwork"></param>
/// <returns></returns>
public static bool CheckUser(string nKey, string sKey, bool isNetwork)
{
// esecuzione script di install locale
return Controllers.DbController.man.checkCreateUser(DATABASE_USER, DATABASE_PWD, isNetwork);
}
/// <summary>
/// Metodo di init standard per DB in rete con Master_Key
@@ -96,12 +96,6 @@ namespace EgtBEAMWALL.DataLayer
File.WriteAllText(filePath, rawData);
}
public static bool CheckUser(string nKey, string sKey, bool isNetwork)
{
// esecuzione script di install locale
return Controllers.DbController.man.checkCreateUser(DATABASE_USER, DATABASE_PWD, isNetwork);
}
#endregion Public Methods
}
}
@@ -125,6 +125,10 @@
<Compile Include="Migrations\202109141058345_AddMachine2ProjProd.designer.cs">
<DependentUpon>202109141058345_AddMachine2ProjProd.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\202207051703296_UpgradeLockModel.cs" />
<Compile Include="Migrations\202207051703296_UpgradeLockModel.designer.cs">
<DependentUpon>202207051703296_UpgradeLockModel.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils.cs" />
@@ -161,6 +165,9 @@
<EmbeddedResource Include="Migrations\202109141058345_AddMachine2ProjProd.resx">
<DependentUpon>202109141058345_AddMachine2ProjProd.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\202207051703296_UpgradeLockModel.resx">
<DependentUpon>202207051703296_UpgradeLockModel.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
@@ -0,0 +1,29 @@
// <auto-generated />
namespace EgtBEAMWALL.DataLayer.Migrations
{
using System.CodeDom.Compiler;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
[GeneratedCode("EntityFramework.Migrations", "6.4.4")]
public sealed partial class UpgradeLockModel : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(UpgradeLockModel));
string IMigrationMetadata.Id
{
get { return "202207051703296_UpgradeLockModel"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,24 @@
namespace EgtBEAMWALL.DataLayer.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class UpgradeLockModel : DbMigration
{
public override void Up()
{
AddColumn("dbo.ProjList", "LockedBy", c => c.String(unicode: false));
AddColumn("dbo.ProjList", "LockDate", c => c.DateTime(nullable: false, precision: 0));
AddColumn("dbo.ProdList", "LockedBy", c => c.String(unicode: false));
AddColumn("dbo.ProdList", "LockDate", c => c.DateTime(nullable: false, precision: 0));
}
public override void Down()
{
DropColumn("dbo.ProdList", "LockDate");
DropColumn("dbo.ProdList", "LockedBy");
DropColumn("dbo.ProjList", "LockDate");
DropColumn("dbo.ProjList", "LockedBy");
}
}
}
File diff suppressed because one or more lines are too long
@@ -1,9 +1,6 @@
namespace EgtBEAMWALL.DataLayer.Migrations
{
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
internal sealed class Configuration : DbMigrationsConfiguration<EgtBEAMWALL.DataLayer.DatabaseContext>
{
@@ -12,7 +9,6 @@ namespace EgtBEAMWALL.DataLayer.Migrations
public Configuration()
{
AutomaticMigrationsEnabled = true;
//AutomaticMigrationsEnabled = false;
}
#endregion Public Constructors
@@ -21,18 +17,14 @@ namespace EgtBEAMWALL.DataLayer.Migrations
protected override void Seed(EgtBEAMWALL.DataLayer.DatabaseContext context)
{
// This method will be called after migrating to the latest version.
// This method will be called after migrating to the latest version.
// You can use the DbSet<T>.AddOrUpdate() helper extension method
// to avoid creating duplicate seed data. E.g.
//
// context.People.AddOrUpdate(
// p => p.FullName,
// new Person { FullName = "Andrew Peters" },
// new Person { FullName = "Brice Lambson" },
// new Person { FullName = "Rowan Miller" }
// );
// You can use the DbSet<T>.AddOrUpdate() helper extension method to avoid creating
// duplicate seed data. E.g.
//
// context.People.AddOrUpdate( p => p.FullName, new Person { FullName = "Andrew Peters"
// }, new Person { FullName = "Brice Lambson" }, new Person { FullName = "Rowan Miller"
// } );
}
#endregion Protected Methods
@@ -35,8 +35,20 @@
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="EgtUILib, Version=2.4.6.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EgtWPFLib5.2.4.7.1\lib\EgtUILib.dll</HintPath>
</Reference>
<Reference Include="EgtWPFLib, Version=2.4.5.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EgtWPFLib5.2.4.7.1\lib\EgtWPFLib.dll</HintPath>
</Reference>
<Reference Include="EgtWPFLib5, Version=2.4.7.1, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\EgtWPFLib5.2.4.7.1\lib\EgtWPFLib5.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\EgtWPFLib5.2.4.7.1\lib\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
@@ -71,6 +83,7 @@
<DependentUpon>StressTest.cs</DependentUpon>
</EmbeddedResource>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
+2 -2
View File
@@ -79,7 +79,7 @@ namespace EgtBEAMWALL.StressTest
List<DataLayer.DatabaseModels.BTLPartModel> currPartList = new List<DataLayer.DatabaseModels.BTLPartModel>();
List<Core.MyMachGroupM> currMachGroupList = new List<Core.MyMachGroupM>();
List<Core.PartM> currMGPartList = new List<Core.PartM>();
ProjCtr.UpdateInfo(currProjId, $"{DateTime.Now:yyyyMMdd_HHmmssfff}", $"LN_{DateTime.Now:yyyyMMdd_HHmm}", DateTime.Now.AddSeconds(15));
ProjCtr.UpdateInfo(currProjId, $"{DateTime.Now:yyyyMMdd_HHmmssfff}", $"LN_{DateTime.Now:yyyyMMdd_HHmm}", DateTime.Now.AddSeconds(15), Core.ConstBeam.BWType.BEAM, "SIM01");
// genero le BTLParts ed assegno..
for (int j = 0; j < currRandom.BtlPart2Proj; j++)
{
@@ -109,7 +109,7 @@ namespace EgtBEAMWALL.StressTest
{
// FixME!!! non può creare x loop in CreateBeamDL che vuole nParentMachGroup
// genero le Part x MachGroup ed assegno
Core.PartM currPart = Core.BeamM.CreateBeamDL(null, currPartList[BPIdx].PartId, 1);
Core.PartM currPart = Core.PartM.CreatePart(Core.ConstBeam.BWType.BEAM, currMachGroupList.FirstOrDefault(), currPartList[BPIdx].PartId, 1);
currMGPartList.Add(currPart);
//currMGPartList.Add(new DataLayer.DatabaseModels.PartModel() { BTLPartDbId = currBTLPart.BTLPartDbId, PDN = l * k * currRandom.Part2MachGroup, PartId = l, H = 10 * l, L = 50 * l, W = 5 * l });
}
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EgtWPFLib5" version="2.4.7.1" targetFramework="net452" />
</packages>
+65 -64
View File
@@ -4,80 +4,81 @@ Imports EgtBEAMWALL.Core
Module DbControllers
Friend m_SupervisorId As String = "1"
Public ReadOnly Property SupervisorId As String
Get
Return m_SupervisorId
End Get
End Property
Friend m_SupervisorId As String = "1"
Public ReadOnly Property SupervisorId As String
Get
Return m_SupervisorId
End Get
End Property
Public m_ProjController As DataLayer.Controllers.ProjController
Public m_ProdController As DataLayer.Controllers.ProdController
Public m_MachGroupController As DataLayer.Controllers.MachGroupController
Public m_PartController As DataLayer.Controllers.PartController
Public m_LogMachineController As DataLayer.Controllers.LogMachineController
Public m_StatusMapController As DataLayer.Controllers.StatusMapController
Public m_ProjController As DataLayer.Controllers.ProjController
Public m_ProdController As DataLayer.Controllers.ProdController
Public m_MachGroupController As DataLayer.Controllers.MachGroupController
Public m_PartController As DataLayer.Controllers.PartController
Public m_LogMachineController As DataLayer.Controllers.LogMachineController
Public m_StatusMapController As DataLayer.Controllers.StatusMapController
Sub New()
Sub New()
' se demo--> server = db.steamware.net, nKey e sKey come le hai...
' se demo--> server = db.steamware.net, nKey e sKey come le hai...
Dim sKey = "", sUser = "", sPwd = ""
Dim sKey = "", sUser = "", sPwd = ""
EgtGetKeyInfo(sKey)
sKey = sKey.Replace(" ", "")
If Not IsNothing(sKey) AndAlso sKey.Length > 11 Then
sUser = sKey.Substring(3, 6)
sPwd = sKey.Substring(10, sKey.Length - 10).Replace("(", "").Replace(")", "")
End If
Try
Dim DbAddress As String = "127.0.0.1"
Dim DbMasterKey As Integer = 0
Dim sDbMasterKey As String = ""
Dim sSharedFolder As String = ""
Dim bNetwork As Boolean = False
If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK) Then
GetMainPrivateProfileString(S_GENERAL, K_DBADDRESS, "", DbAddress)
DbMasterKey = GetMainPrivateProfileInt(S_GENERAL, K_DBMASTERKEY, 0)
If DbMasterKey > 0 Then
sDbMasterKey = DbMasterKey.ToString("000000")
EgtGetKeyInfo(sKey)
sKey = sKey.Replace(" ", "")
If Not IsNothing(sKey) AndAlso sKey.Length > 11 Then
sUser = sKey.Substring(3, 6)
sPwd = sKey.Substring(10, sKey.Length - 10).Replace("(", "").Replace(")", "")
End If
Try
Dim DbAddress As String = "127.0.0.1"
Dim DbMasterKey As Integer = 0
Dim sDbMasterKey As String = ""
Dim sSharedFolder As String = ""
Dim bNetwork As Boolean = False
If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK) Then
GetMainPrivateProfileString(S_GENERAL, K_DBADDRESS, "", DbAddress)
DbMasterKey = GetMainPrivateProfileInt(S_GENERAL, K_DBMASTERKEY, 0)
If DbMasterKey > 0 Then
sDbMasterKey = DbMasterKey.ToString("000000")
End If
If String.IsNullOrWhiteSpace(DbAddress) OrElse DbMasterKey <= 0 Then
DbAddress = "127.0.0.1"
DbMasterKey = 0
Else
bNetwork = True
End If
End If
If String.IsNullOrWhiteSpace(DbAddress) OrElse DbMasterKey <= 0 Then
DbAddress = "127.0.0.1"
DbMasterKey = 0
Else
bNetwork = True
DataLayer.DbConfig.InitDb(DbAddress, sUser, sPwd, sDbMasterKey)
DataLayer.DbConfig.SetupLogDir(Map.refMainWindowVM.MainWindowM.sTempDir)
DataLayer.DbConfig.CheckMigrateDb()
DataLayer.DbConfig.CheckUser(sUser, sPwd, Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK))
If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK) And bNetwork Then
' imposto cartella condivisa
GetMainPrivateProfileString(S_GENERAL, K_SHAREDFOLDER, Map.refMainWindowVM.MainWindowM.sDataRoot, sSharedFolder)
Map.refMainWindowVM.MainWindowM.UpdatePathForNetwork(sSharedFolder)
Dim sSupervisorMachName As String = ""
GetMainPrivateProfileString(S_MACH, K_SUPERVISORMACH, "", sSupervisorMachName)
If Not String.IsNullOrWhiteSpace(sSupervisorMachName) Then m_SupervisorId = sSupervisorMachName
End If
End If
DataLayer.DbConfig.InitDb(DbAddress, sUser, sPwd, sDbMasterKey)
DataLayer.DbConfig.SetupLogDir(Map.refMainWindowVM.MainWindowM.sTempDir)
DataLayer.DbConfig.CheckUser(sUser, sPwd, Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK))
If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK) And bNetwork Then
' imposto cartella condivisa
GetMainPrivateProfileString(S_GENERAL, K_SHAREDFOLDER, Map.refMainWindowVM.MainWindowM.sDataRoot, sSharedFolder)
Map.refMainWindowVM.MainWindowM.UpdatePathForNetwork(sSharedFolder)
Catch ex As Exception
EgtOutLog("InitDb error: " & ex.ToString())
MessageBox.Show(Application.Current.MainWindow, "Db connection error!!", "Error")
End
End Try
If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK) Then
Dim sSupervisorMachName As String = ""
GetMainPrivateProfileString(S_MACH, K_SUPERVISORMACH, "", sSupervisorMachName)
If Not String.IsNullOrWhiteSpace(sSupervisorMachName) Then m_SupervisorId = sSupervisorMachName
End If
Catch ex As Exception
EgtOutLog("InitDb error: " & ex.ToString())
MessageBox.Show(Application.Current.MainWindow, "Db connection error!!", "Error")
End
End Try
End If
If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK) Then
Dim sSupervisorMachName As String = ""
GetMainPrivateProfileString(S_MACH, K_SUPERVISORMACH, "", sSupervisorMachName)
If Not String.IsNullOrWhiteSpace(sSupervisorMachName) Then m_SupervisorId = sSupervisorMachName
End If
m_ProjController = New DataLayer.Controllers.ProjController
m_ProdController = New DataLayer.Controllers.ProdController
m_MachGroupController = New DataLayer.Controllers.MachGroupController
m_PartController = New DataLayer.Controllers.PartController
m_LogMachineController = New DataLayer.Controllers.LogMachineController
m_StatusMapController = New DataLayer.Controllers.StatusMapController
End Sub
m_ProjController = New DataLayer.Controllers.ProjController
m_ProdController = New DataLayer.Controllers.ProdController
m_MachGroupController = New DataLayer.Controllers.MachGroupController
m_PartController = New DataLayer.Controllers.PartController
m_LogMachineController = New DataLayer.Controllers.LogMachineController
m_StatusMapController = New DataLayer.Controllers.StatusMapController
End Sub
End Module
@@ -5,75 +5,76 @@ Imports EgtBEAMWALL.ViewerOptimizer
Public Module DbControllers
Friend m_SupervisorId As String = "1"
Private m_bNetwork As Boolean = False
Friend ReadOnly Property bNetwork As Boolean
Get
Return m_bNetwork
End Get
End Property
Friend m_SupervisorId As String = "1"
Private m_bNetwork As Boolean = False
Friend ReadOnly Property bNetwork As Boolean
Get
Return m_bNetwork
End Get
End Property
Public m_ProjController As DataLayer.Controllers.ProjController
Public m_ProdController As DataLayer.Controllers.ProdController
Public m_MachGroupController As DataLayer.Controllers.MachGroupController
Public m_StatusMapController As DataLayer.Controllers.StatusMapController
Public m_PartController As DataLayer.Controllers.PartController
Public m_ProjController As DataLayer.Controllers.ProjController
Public m_ProdController As DataLayer.Controllers.ProdController
Public m_MachGroupController As DataLayer.Controllers.MachGroupController
Public m_StatusMapController As DataLayer.Controllers.StatusMapController
Public m_PartController As DataLayer.Controllers.PartController
Sub Init()
End Sub
Sub Init()
End Sub
Sub New()
Sub New()
' se demo--> server = db.steamware.net, nKey e sKey come le hai...
' se demo--> server = db.steamware.net, nKey e sKey come le hai...
Dim sKey = "", sUser = "", sPwd = ""
Dim sKey = "", sUser = "", sPwd = ""
EgtGetKeyInfo(sKey)
sKey = sKey.Replace(" ", "")
If Not IsNothing(sKey) AndAlso sKey.Length > 11 Then
sUser = sKey.Substring(3, 6)
sPwd = sKey.Substring(10, sKey.Length - 10).Replace("(", "").Replace(")", "")
End If
Try
Dim DbAddress As String = "127.0.0.1"
Dim DbMasterKey As Integer = 0
Dim sDbMasterKey As String = ""
Dim sSharedFolder As String = ""
If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK) Then
GetMainPrivateProfileString(S_GENERAL, K_DBADDRESS, "", DbAddress)
DbMasterKey = GetMainPrivateProfileInt(S_GENERAL, K_DBMASTERKEY, 0)
If DbMasterKey > 0 Then
sDbMasterKey = DbMasterKey.ToString("000000")
EgtGetKeyInfo(sKey)
sKey = sKey.Replace(" ", "")
If Not IsNothing(sKey) AndAlso sKey.Length > 11 Then
sUser = sKey.Substring(3, 6)
sPwd = sKey.Substring(10, sKey.Length - 10).Replace("(", "").Replace(")", "")
End If
Try
Dim DbAddress As String = "127.0.0.1"
Dim DbMasterKey As Integer = 0
Dim sDbMasterKey As String = ""
Dim sSharedFolder As String = ""
If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK) Then
GetMainPrivateProfileString(S_GENERAL, K_DBADDRESS, "", DbAddress)
DbMasterKey = GetMainPrivateProfileInt(S_GENERAL, K_DBMASTERKEY, 0)
If DbMasterKey > 0 Then
sDbMasterKey = DbMasterKey.ToString("000000")
End If
If String.IsNullOrWhiteSpace(DbAddress) OrElse DbMasterKey <= 0 Then
DbAddress = "127.0.0.1"
DbMasterKey = 0
Else
m_bNetwork = True
End If
End If
If String.IsNullOrWhiteSpace(DbAddress) OrElse DbMasterKey <= 0 Then
DbAddress = "127.0.0.1"
DbMasterKey = 0
Else
m_bNetwork = True
DataLayer.DbConfig.InitDb(DbAddress, sUser, sPwd, sDbMasterKey)
DataLayer.DbConfig.SetupLogDir(Map.refMainWindowVM.MainWindowM.sTempDir)
DataLayer.DbConfig.CheckMigrateDb()
DataLayer.DbConfig.CheckUser(sUser, sPwd, Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK))
If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK) And bNetwork Then
' imposto cartella condivisa
GetMainPrivateProfileString(S_GENERAL, K_SHAREDFOLDER, Map.refMainWindowVM.MainWindowM.sDataDir, sSharedFolder)
Map.refMainWindowVM.MainWindowM.UpdatePathForNetwork(sSharedFolder)
Dim sSupervisorMachName As String = ""
GetMainPrivateProfileString(S_MACH, K_SUPERVISORMACH, "", sSupervisorMachName)
If Not String.IsNullOrWhiteSpace(sSupervisorMachName) Then m_SupervisorId = sSupervisorMachName
End If
End If
DataLayer.DbConfig.InitDb(DbAddress, sUser, sPwd, sDbMasterKey)
DataLayer.DbConfig.SetupLogDir(Map.refMainWindowVM.MainWindowM.sTempDir)
DataLayer.DbConfig.CheckUser(sUser, sPwd, Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK))
If Map.refMainWindowVM.MainWindowM.GetKeyOption(KEY_OPT.NETWORK) And bNetwork Then
' imposto cartella condivisa
GetMainPrivateProfileString(S_GENERAL, K_SHAREDFOLDER, Map.refMainWindowVM.MainWindowM.sDataDir, sSharedFolder)
Map.refMainWindowVM.MainWindowM.UpdatePathForNetwork(sSharedFolder)
Dim sSupervisorMachName As String = ""
GetMainPrivateProfileString(S_MACH, K_SUPERVISORMACH, "", sSupervisorMachName)
If Not String.IsNullOrWhiteSpace(sSupervisorMachName) Then m_SupervisorId = sSupervisorMachName
End If
Catch ex As Exception
EgtOutLog("InitDb error: " & ex.ToString())
MessageBox.Show(Application.Current.MainWindow, "Db connection error!!", "Error")
End
End Try
Catch ex As Exception
EgtOutLog("InitDb error: " & ex.ToString())
MessageBox.Show(Application.Current.MainWindow, "Db connection error!!", "Error")
End
End Try
m_ProjController = New DataLayer.Controllers.ProjController
m_ProdController = New DataLayer.Controllers.ProdController
m_MachGroupController = New DataLayer.Controllers.MachGroupController
m_StatusMapController = New DataLayer.Controllers.StatusMapController
m_PartController = New DataLayer.Controllers.PartController
End Sub
m_ProjController = New DataLayer.Controllers.ProjController
m_ProdController = New DataLayer.Controllers.ProdController
m_MachGroupController = New DataLayer.Controllers.MachGroupController
m_StatusMapController = New DataLayer.Controllers.StatusMapController
m_PartController = New DataLayer.Controllers.PartController
End Sub
End Module
Binary file not shown.
Binary file not shown.