Fix refresh view: spostata in try/catch

This commit is contained in:
Samuele Locatelli
2024-06-27 18:20:45 +02:00
parent cd6e98a59c
commit e7467b19d0
@@ -76,8 +76,10 @@ namespace EgtBEAMWALL.DataLayer.Controllers
{
bool answ = false;
// in primis refresh delle view
string sqlCommand = @"CREATE OR REPLACE VIEW v_expProdRaw AS
try
{
// 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,
@@ -92,20 +94,26 @@ 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)
{
string errMessage = $"EXCEPTION on DbController.refreshViews: {Environment.NewLine}{exc}";
Console.WriteLine(errMessage);
Log.Error(errMessage);
}
return answ;
}