Merge remote-tracking branch 'gitlab.seriate/DataLayer' into feature/NewWarehouseTest
This commit is contained in:
@@ -32,6 +32,10 @@ namespace EgtBEAMWALL.DataLayer
|
||||
/// </summary>
|
||||
public DbSet<UserPriv> UserList { get; set; }
|
||||
|
||||
public DbSet<MigrationHistoryModel> MigrList { get; set; }
|
||||
|
||||
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -78,8 +78,18 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
|
||||
try
|
||||
{
|
||||
// in primis refresh delle view
|
||||
string sqlCommand = @"CREATE OR REPLACE VIEW v_expProdRaw AS
|
||||
// migrazione minima x eseguire refresh viste
|
||||
string minMigration = "202404261445205_UpdateLogMachineTable";
|
||||
// cerco se ho la migration minima per proseguire...
|
||||
var numRec = dbCtx
|
||||
.MigrList
|
||||
.Where(x => x.MigrationId == minMigration)
|
||||
.ToList()
|
||||
.Count;
|
||||
if (numRec == 0)
|
||||
{
|
||||
// in primis refresh delle view
|
||||
string sqlCommand = @"CREATE OR REPLACE VIEW v_expProdRaw AS
|
||||
SELECT DbId, DtEvent, VarValue,
|
||||
SUBSTRING_INDEX(VarValue, ';', 1) AS Prod,
|
||||
SUBSTRING_INDEX(SUBSTRING_INDEX(VarValue, ';', 2), ';', -1) AS MachGroupId,
|
||||
@@ -94,18 +104,19 @@ namespace EgtBEAMWALL.DataLayer.Controllers
|
||||
FROM v_expProdRaw AS vp
|
||||
INNER JOIN MachGroupList mgl ON vp.MachGroupId = mgl.Id
|
||||
INNER JOIN partlist pl ON vp.PartId = pl.Id;";
|
||||
dbCtx.Database.ExecuteSqlCommand(System.Data.Entity.TransactionalBehavior.DoNotEnsureTransaction, sqlCommand);
|
||||
Thread.Sleep(100);
|
||||
dbCtx.Database.ExecuteSqlCommand(System.Data.Entity.TransactionalBehavior.DoNotEnsureTransaction, sqlCommand);
|
||||
Thread.Sleep(100);
|
||||
|
||||
// ora setup parametri x utente
|
||||
string domain = "%";
|
||||
// ora setup parametri x utente
|
||||
string domain = "%";
|
||||
|
||||
// ora controllo utente con diritti
|
||||
answ = doCheckCreate(username, pwd, answ, domain, true);
|
||||
if (answ)
|
||||
{
|
||||
doGrantPriv(username, domain, "USAGE ON *.*");
|
||||
doGrantPriv(username, domain, $"SELECT ON {dbName}.v_expProd");
|
||||
// ora controllo utente con diritti
|
||||
answ = doCheckCreate(username, pwd, answ, domain, true);
|
||||
if (answ)
|
||||
{
|
||||
doGrantPriv(username, domain, "USAGE ON *.*");
|
||||
doGrantPriv(username, domain, $"SELECT ON {dbName}.v_expProd");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
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 EgtBEAMWALL.DataLayer.DatabaseModels
|
||||
{
|
||||
/// <summary>
|
||||
/// Tabella migrations del DB
|
||||
/// </summary>
|
||||
[NotMapped]
|
||||
public class MigrationHistoryModel
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public string MigrationId { get; set; } = "";
|
||||
|
||||
public string ProductVersion { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -163,6 +163,7 @@
|
||||
<Compile Include="DatabaseModels\AliasModel.cs" />
|
||||
<Compile Include="DatabaseModels\MagmanSyncModel.cs" />
|
||||
<Compile Include="DatabaseModels\MaterialModel.cs" />
|
||||
<Compile Include="DatabaseModels\MigrationHistoryModel.cs" />
|
||||
<Compile Include="DatabaseModels\RawItemModel.cs" />
|
||||
<Compile Include="DatabaseModels\UserPrivModel.cs" />
|
||||
<Compile Include="DbConfig.cs" />
|
||||
|
||||
Reference in New Issue
Block a user