Merge branch 'release/V_0.8'

This commit is contained in:
Samuele Locatelli
2021-06-30 10:20:13 +02:00
176 changed files with 13790 additions and 206 deletions
+43 -50
View File
@@ -7,7 +7,7 @@ variables:
# NEW_REL: ''
VERS_MAIN: '0.9'
NEXUS_PATH: 'GWMS'
APP_NAME: 'GWMS'
APP_NAME: 'GWMS.UI'
# helper x fix pacchetti nuget da repo locale nexus.steamware.net
.nuget-fix: &nuget-fix
@@ -64,8 +64,7 @@ variables:
stages:
- build
- test
- staging
- deploy
# - deploy
- installer
- release
@@ -77,16 +76,16 @@ build:
script:
- dotnet build
# test:
# stage: test
# only:
# - develop
# needs: ["build"]
# script:
# - dotnet test
test:
stage: test
only:
- develop
needs: ["build"]
script:
- dotnet test
# staging:
# stage: staging
# IIS01:deploy:
# stage: deploy
# only:
# - develop
# needs: ["test"]
@@ -94,10 +93,10 @@ build:
# # - *nuget-fix
# # - dotnet restore
# script:
# - dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true MP.Stats/MP.Stats.csproj
# - dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true GWMS.UI/GWMS.UI.csproj
# staging:
# IIS02:deploy:
# stage: deploy
# only:
# - master
@@ -106,41 +105,35 @@ build:
# # - *nuget-fix
# # - dotnet restore
# script:
# - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true MP.Stats/MP.Stats.csproj
# - dotnet publish -p:PublishProfile=W2019-IIS-DEVProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true MP.Stats/MP.Stats.csproj
# staging:
# stage: installer
# only:
# - develop
# - master
# needs: ["build"]
# before_script:
# # - *nuget-fix
# # - dotnet restore
# # - '& "$env:NUGET_PATH" restore LPA.sln' # path alla solution corrente
# # - *version-fix
# # - *cleanup-zip
# script:
# - dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release MP.Stats/MP.Stats.csproj
# # da fare qui il deploy su nexus...
# # - *zipper
# - *hashBuild
# - *nexusUpload
# release:
# stage: release
# only:
# #- feature/Deploy_CI_CD
# # - master
# - tags
# except:
# - branches
# needs: ["build"]
# artifacts:
# paths:
# - publish/
# script:
# - dotnet publish -c Release -o ./publish MP.Stats/MP.Stats.csproj
# - dotnet publish -p:PublishProfile=IIS02.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true GWMS.UI/GWMS.UI.csproj
# - dotnet publish -p:PublishProfile=W2019-IIS-DEVProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=viadante16 -p:AllowUntrustedCertificate=true GWMS.UI/GWMS.UI.csproj
installer:
stage: installer
only:
- develop
- master
needs: ["build"]
before_script:
# - *nuget-fix
# - dotnet restore
script:
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release GWMS.UI/GWMS.UI.csproj -o:publish
# qui il deploy su nexus...
- *hashBuild
- *nexusUpload
release:
stage: release
only:
#- feature/Deploy_CI_CD
# - master
- tags
except:
- branches
needs: ["build"]
artifacts:
paths:
- publish/
script:
- dotnet publish -c Release -o ./publish GWMS.UI/GWMS.UI.csproj
@@ -0,0 +1,39 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GWMS.API.Controllers
{
[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
private readonly ILogger<WeatherForecastController> _logger;
public WeatherForecastController(ILogger<WeatherForecastController> logger)
{
_logger = logger;
}
[HttpGet]
public IEnumerable<WeatherForecast> Get()
{
var rng = new Random();
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),
TemperatureC = rng.Next(-20, 55),
Summary = Summaries[rng.Next(Summaries.Length)]
})
.ToArray();
}
}
}
+11
View File
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
</Project>
+26
View File
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GWMS.API
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
+31
View File
@@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:31282",
"sslPort": 44346
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"GWMS.API": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
+59
View File
@@ -0,0 +1,59 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GWMS.API
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "GWMS.API", Version = "v1" });
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "GWMS.API v1"));
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
+15
View File
@@ -0,0 +1,15 @@
using System;
namespace GWMS.API
{
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string Summary { get; set; }
}
}
+9
View File
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
+75
View File
@@ -0,0 +1,75 @@
using GWMS.Data.DatabaseModels;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GWMS.Data
{
public partial class AdminContext : DbContext
{
#region Private Fields
private IConfiguration _configuration;
#endregion Private Fields
#region Public Constructors
public AdminContext()
{
}
public AdminContext(IConfiguration configuration)
{
_configuration = configuration;
}
public AdminContext(DbContextOptions<GWMSContext> options) : base(options)
{
}
#endregion Public Constructors
#region Public Properties
/// <summary>
/// User management
/// </summary>
public DbSet<UserPriv> UserList { get; set; }
#endregion Public Properties
#region Private Methods
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
#endregion Private Methods
#region Protected Methods
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
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);
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<UserPriv>().HasKey(c => new { c.Host, c.User });
OnModelCreatingPartial(modelBuilder);
}
#endregion Protected Methods
}
}
-8
View File
@@ -1,8 +0,0 @@
using System;
namespace GWMS.UI.Data
{
public class Class1
{
}
}
+12
View File
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GWMS.Data
{
public class Constants
{
}
}
+579
View File
@@ -0,0 +1,579 @@
using GWMS.Data.DatabaseModels;
using GWMS.Data.DTO;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GWMS.Data.Controllers
{
public class GWMSController : IDisposable
{
#region Private Fields
private static IConfiguration _configuration;
private static GWMSContext dbCtx;
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Public Constructors
public GWMSController(IConfiguration configuration)
{
_configuration = configuration;
dbCtx = new GWMSContext(configuration);
Log.Info("Avviata classe GWMSController");
}
#endregion Public Constructors
#region Private Methods
private void CreateSimData(int numDays, int stepMin, int maxHourRate)
{
ResetController();
// generazione dati casuale
Random rnd = new Random();
foreach (var plant in GetPlants())
{
var currPlant = GetPlant(plant.PlantId);
// imposto limiti e valori attuali...
//currPlant.LevelMax = rnd.Next(24, 28) * 1000;
int simLevel = rnd.Next(1, (int)currPlant.LevelMax);
double simPress = (double)rnd.Next((int)(currPlant.PressMax - 50) * 10, (int)currPlant.PressMax * 10) / 10;
double simPressH = (double)rnd.Next((int)(currPlant.PressBHMax - 70) * 10, (int)currPlant.PressBHMax * 10) / 10;
double simPressL = (double)rnd.Next((int)(currPlant.PressBLMax - 70) * 10, (int)currPlant.PressBLMax * 10) / 10;
currPlant.LevelAct = simLevel;
currPlant.PressAct = simPress;
currPlant.PressBHAct = simPressH;
currPlant.PressBLAct = simPressL;
dbCtx.SaveChanges();
// genero random le soglie x simulare rilievi e ordini
int soglia01 = rnd.Next((int)currPlant.LevelMax * 60 / 100, (int)currPlant.LevelMax * 75 / 100);
int soglia02 = rnd.Next((int)currPlant.LevelMax * 5 / 100, (int)currPlant.LevelMax * 35 / 100);
List<PlantLogModel> LogLevels = new List<PlantLogModel>();
List<PlantLogModel> LogPressures = new List<PlantLogModel>();
List<OrderModel> LogOrders = new List<OrderModel>();
DateTime adesso = DateTime.Now;
int lastLevel = simLevel;
int lastOrder = 0;
int anticipo = 0;
double lastPress = simPress;
double lastPressH = simPressH;
double lastPressL = simPressL;
// simulo numDays gg...
for (int i = numDays * 24 * (60 / stepMin); i > 0; i--)
{
anticipo = i * stepMin;
lastLevel = lastLevel - rnd.Next(0, maxHourRate / (60 / stepMin));
// se inferiore a soglia 1 --> ordine
if (lastLevel + lastOrder < soglia01)
{
lastOrder = rnd.Next((int)currPlant.LevelMax - soglia01, (int)currPlant.LevelMax - soglia02);
LogOrders.Add(new OrderModel() { DtOrder = adesso.AddMinutes(-anticipo), OrderQty = lastOrder, PlantId = plant.PlantId, OrderCode = $"ORD{i:000000}", OrderDesc = "SIM Order", SupplierId = 1, TransporterId = 1 });
}
// se inferiore a soglia 2 --> refill
if (lastLevel < soglia02)
{
lastLevel += lastOrder;
lastOrder = 0;
}
LogLevels.Add(new PlantLogModel() { DtEvent = adesso.AddMinutes(-anticipo), FluxType = "Level", PlantId = plant.PlantId, ValNumber = lastLevel });
// pressioni!
lastPress = lastPress - (double)rnd.Next(-30, 25) / 10;
lastPressH = lastPressH - (double)rnd.Next(-25, 20) / 10;
lastPressL = lastPressL - (double)rnd.Next(-25, 20) / 10;
LogPressures.Add(new PlantLogModel() { DtEvent = adesso.AddMinutes(-anticipo), FluxType = "MainPress", PlantId = plant.PlantId, ValNumber = lastPress });
LogPressures.Add(new PlantLogModel() { DtEvent = adesso.AddMinutes(-anticipo), FluxType = "PressBH", PlantId = plant.PlantId, ValNumber = lastPressH });
LogPressures.Add(new PlantLogModel() { DtEvent = adesso.AddMinutes(-anticipo), FluxType = "PressBL", PlantId = plant.PlantId, ValNumber = lastPressL });
}
try
{
dbCtx
.DbSetPlantLog
.AddRange(LogLevels);
dbCtx
.DbSetPlantLog
.AddRange(LogPressures);
// salvo sul DB!
dbCtx.SaveChanges();
Log.Info($"Effettuato inserimento {LogLevels.Count} record PlantLog");
}
catch (Exception exc)
{
Log.Error($"Eccezione in salvataggio PlantLog{Environment.NewLine}{exc}");
}
try
{
dbCtx
.DbSetOrders
.AddRange(LogOrders);
// salvo sul DB!
dbCtx.SaveChanges();
Log.Info($"Effettuato inserimento {LogOrders.Count} record Orders");
}
catch (Exception exc)
{
Log.Error($"Eccezione in salvataggio Orders{Environment.NewLine}{exc}");
}
}
}
#endregion Private Methods
#region Public Methods
public void Dispose()
{
// Clear database context
dbCtx.Dispose();
}
public List<ConfigModel> GetConfig()
{
var dbResult = dbCtx
.DbSetConfig
.ToList();
return dbResult;
}
public List<ItemModel> GetItems()
{
var dbResult = dbCtx
.DbSetItems
.ToList();
return dbResult;
}
public List<OrderModel> GetOrdersFilt(int PlantId, int SupplierId, int TransporterId, DateTime DtStart, DateTime DtEnd)
{
var dbResult = dbCtx
.DbSetOrders
.Where(x => (x.PlantId == PlantId || PlantId == 0) && (x.SupplierId == SupplierId || SupplierId == 0) && (x.TransporterId == TransporterId || TransporterId == 0) && (x.DtOrder >= DtStart && x.DtOrder <= DtEnd))
.Include(p => p.Plant)
.Include(s => s.Supplier)
.Include(t => t.Transporter)
.OrderByDescending(x => x.DtOrder)
.ToList();
return dbResult;
}
public PlantDetailModel GetPlant(int PlantId)
{
var dbResult = dbCtx
.DbSetPlant
.Where(x => x.PlantId == PlantId)
.FirstOrDefault();
return dbResult;
}
/// <summary>
/// Elenco log registrati x plant
/// </summary>
/// <param name="PlantId">se 0 = tutto</param>
/// <param name="DtMaxDate">consigliato arrotondamento al minuto o multiplo</param>
/// <param name="numRec">num rec max da recuperare</param>
/// <returns></returns>
public List<PlantLogModel> GetPlantLog(int PlantId, DateTime DtMaxDate, int numRec)
{
var dbResult = dbCtx
.DbSetPlantLog
.Where(x => (x.PlantId == PlantId || PlantId == 0) && x.DtEvent <= DtMaxDate)
.OrderByDescending(x => x.DtEvent)
.Take(numRec)
.ToList();
return dbResult;
}
public List<PlantDetailModel> GetPlants()
{
var dbResult = dbCtx
.DbSetPlant
.ToList();
return dbResult;
}
public List<PlantDTO> GetPlantsDTO()
{
var plantList = dbCtx
.DbSetPlant
.ToList();
var dbResult = plantList
.Select(x => PlantDTO(x.PlantId))
.ToList();
return dbResult;
}
public List<SupplierModel> GetSuppliers()
{
var dbResult = dbCtx
.DbSetSupplier
.ToList();
return dbResult;
}
public List<TransporterModel> GetTransporters()
{
var dbResult = dbCtx
.DbSetTransporter
.ToList();
return dbResult;
}
public List<UserModel> GetUsersFilt(UserLevel UsrLvl, int PlantId, int SupplierId, int TransporterId)
{
var dbResult = dbCtx
.DbSetUser
.Where(x => (x.Livello == UsrLvl || UsrLvl == UserLevel.ND) && (x.MaskPlantId == PlantId || PlantId == 0) && (x.MaskSupplierId == SupplierId || SupplierId == 0) && (x.MaskTranspId == TransporterId || TransporterId == 0))
.OrderBy(x => x.Livello)
.ThenBy(x => x.UserName)
.ToList();
return dbResult;
}
public List<WeekPlanModel> GetWeekPlan()
{
var dbResult = dbCtx
.DbSetPlantSupplWeekPlan
.ToList();
return dbResult;
}
public bool HasPlantLog()
{
bool answ = false;
try
{
var numRecord = dbCtx
.DbSetPlantLog
.Count();
answ = numRecord > 0;
}
catch
{ }
return answ;
}
/// <summary>
/// Aggiorna un Ordine
/// </summary>
/// <param name="updItem"></param>
/// <returns></returns>
public bool OrderUpdate(OrderModel updItem)
{
bool done = false;
try
{
var currData = dbCtx
.DbSetOrders
.Where(x => x.OrderId == updItem.OrderId)
.FirstOrDefault();
if (currData != null)
{
dbCtx.Entry(updItem).State = EntityState.Modified;
}
else
{
dbCtx
.DbSetOrders
.Add(updItem);
}
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{ }
return done;
}
/// <summary>
/// Recupero info PLANT modalità DTO
/// </summary>
/// <param name="PlantId"></param>
/// <returns></returns>
public PlantDTO PlantDTO(int PlantId)
{
var currPlant = GetPlant(PlantId);
List<TSData> LevelTS = new List<TSData>();
Dictionary<string, double> PressAct = new Dictionary<string, double>();
Dictionary<string, List<TSData>> PressTS = new Dictionary<string, List<TSData>>();
List<TSData> PressMainTS = new List<TSData>();
List<TSData> PressBHTS = new List<TSData>();
List<TSData> PressBLTS = new List<TSData>();
List<TSData> OrderTS = new List<TSData>();
// recupero dal DB
var rawLevelData = dbCtx
.DbSetPlantLog
.Where(x => x.FluxType == "Level" && x.PlantId == PlantId)
.OrderBy(x => x.DtEvent)
.ToList();
var rawMainPressData = dbCtx
.DbSetPlantLog
.Where(x => x.FluxType == "MainPress" && x.PlantId == PlantId)
.OrderBy(x => x.DtEvent)
.ToList();
var rawBHPressData = dbCtx
.DbSetPlantLog
.Where(x => x.FluxType == "PressBH" && x.PlantId == PlantId)
.OrderBy(x => x.DtEvent)
.ToList();
var rawBLPressData = dbCtx
.DbSetPlantLog
.Where(x => x.FluxType == "PressBL" && x.PlantId == PlantId)
.OrderBy(x => x.DtEvent)
.ToList();
var rawOrderData = dbCtx
.DbSetOrders
.Where(x => x.PlantId == PlantId)
.OrderBy(x => x.DtOrder)
.ToList();
LevelTS = rawLevelData
.Select(x => new TSData() { DtEvent = x.DtEvent, ValDouble = x.ValNumber }).ToList();
OrderTS = rawOrderData
.Select(x => new TSData() { DtEvent = x.DtOrder, ValDouble = x.OrderQty }).ToList();
PressMainTS = rawMainPressData
.Select(x => new TSData() { DtEvent = x.DtEvent, ValDouble = x.ValNumber }).ToList();
PressBHTS = rawBHPressData
.Select(x => new TSData() { DtEvent = x.DtEvent, ValDouble = x.ValNumber }).ToList();
PressBLTS = rawBLPressData
.Select(x => new TSData() { DtEvent = x.DtEvent, ValDouble = x.ValNumber }).ToList();
PressTS.Add("Main", PressMainTS);
PressTS.Add("BH", PressBHTS);
PressTS.Add("BL", PressBLTS);
PressAct.Add("Main", PressMainTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble);
PressAct.Add("BH", PressBHTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble);
PressAct.Add("BL", PressBLTS.OrderByDescending(x => x.DtEvent).Take(1).FirstOrDefault().ValDouble);
PlantDTO answ = new PlantDTO()
{
PlantId = PlantId,
PlantCode = currPlant.PlantCode,
PlantDesc = currPlant.PlantDesc,
LevelAct = currPlant.LevelAct,
LevelMax = currPlant.LevelMax,
PressAct = PressAct,
LevelTS = LevelTS,
PressTS = PressTS,
OrderTS = OrderTS
};
return answ;
}
/// <summary>
/// Inserimento di un novo record x plant log
/// </summary>
/// <param name="PlantLogModel">Record da inserire (senza ID...)</param>
/// <returns></returns>
public bool PlantLogInsertNew(List<PlantLogModel> newItems)
{
bool fatto = false;
//List<PlantLogModel> newList = new List<PlantLogModel>();
//foreach (var item in newItems)
//{
// newList.Add(new PlantLogModel()
// {
// DtEvent = item.DtEvent,
// FluxType = item.FluxType,
// PlantId = item.PlantId,
// ValNumber = item.ValNumber,
// ValString = item.ValString
// });
//}
try
{
dbCtx
.DbSetPlantLog
.AddRange(newItems);
//.AddRange(newList);
dbCtx.SaveChanges();
fatto = true;
}
catch (Exception exc)
{
Log.Error(exc, $"Eccezione durante PlantLogInsertNew per {newItems.Count} rec");
}
return fatto;
}
/// <summary>
/// Rigenera intero DB se riceve ID di un plant SIM...
/// </summary>
/// <param name="PlantId"></param>
public bool RegenDB(int PlantId, int numDays, int stepMin, int maxHourRate)
{
bool answ = false;
var currPlant = GetPlant(PlantId);
if (currPlant.PlantCode.StartsWith("PIZ"))
{
Log.Info("Inizio RegenDB");
DbAdmin.resetPlantLogTable();
ResetController();
CreateSimData(numDays, stepMin, maxHourRate);
Log.Info("Dati SIM generati");
answ = true;
}
return answ;
}
public void ResetController()
{
dbCtx = new GWMSContext(_configuration);
}
/// <summary>
/// Annulla modifiche su una specifica entity (cancel update)
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool rollBackEntity(object item)
{
bool answ = false;
try
{
if (dbCtx.Entry(item).State == EntityState.Deleted || dbCtx.Entry(item).State == EntityState.Modified)
{
dbCtx.Entry(item).Reload();
}
}
catch (Exception exc)
{
Log.Error($"Eccezione in rollBackEntity{Environment.NewLine}{exc}");
}
return answ;
}
/// <summary>
/// Aggiorna un User
/// </summary>
/// <param name="updItem"></param>
/// <returns></returns>
public bool UserUpdate(UserModel updItem)
{
bool done = false;
try
{
var currData = dbCtx
.DbSetUser
.Where(x => x.UserId == updItem.UserId)
.FirstOrDefault();
if (currData != null)
{
dbCtx.Entry(updItem).State = EntityState.Modified;
}
else
{
dbCtx
.DbSetUser
.Add(updItem);
}
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{ }
return done;
}
/// <summary>
/// Elimina un item WeekPlan
/// </summary>
/// <param name="selRecord"></param>
/// <returns></returns>
public bool WeekPlanDelete(WeekPlanModel selRecord)
{
bool done = false;
try
{
var item2del = dbCtx
.DbSetPlantSupplWeekPlan
.Where(x => x.WeekPlanId == selRecord.WeekPlanId)
.FirstOrDefault();
dbCtx.DbSetPlantSupplWeekPlan.Remove(item2del);
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{ }
return done;
}
/// <summary>
/// Aggiorna un item WeekPlan
/// </summary>
/// <param name="updItem"></param>
/// <returns></returns>
public bool WeekPlanUpdate(WeekPlanModel updItem)
{
bool done = false;
try
{
var currData = dbCtx
.DbSetPlantSupplWeekPlan
.Where(x => x.WeekPlanId == updItem.WeekPlanId)
.FirstOrDefault();
if (currData != null)
{
dbCtx.Entry(updItem).State = EntityState.Modified;
}
else
{
dbCtx
.DbSetPlantSupplWeekPlan
.Add(updItem);
}
dbCtx.SaveChanges();
done = true;
}
catch (Exception exc)
{ }
return done;
}
#endregion Public Methods
}
}
+53
View File
@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DTO
{
public class PlantDTO
{
#region Public Properties
public int PlantId { get; set; }
public string PlantCode { get; set; } = "";
public string PlantDesc { get; set; } = "";
public double LevelMax { get; set; } = 9999;
public double LevelAct { get; set; } = 0;
public int LevelRatio
{
get
{
int answ = 0;
double denom = LevelMax == 0 ? 1 : LevelMax;
answ = (int)(LevelAct *100/ denom);
return answ;
}
}
public List<TSData> LevelTS { get; set; } = new List<TSData>();
public List<TSData> OrderTS { get; set; } = new List<TSData>();
public double TempMax { get; set; } = 40;
public double TempAct { get; set; } = 0;
public List<TSData> TempTS { get; set; } = new List<TSData>();
public Dictionary<string, double> PressAct { get; set; } = new Dictionary<string, double>();
public Dictionary<string, List<TSData>> PressTS { get; set; } = new Dictionary<string, List<TSData>>();
#endregion Public Properties
}
}
+38
View File
@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella AnKeyVal
/// </summary>
[Table("AnKeyVal")]
public class AnKeyValModel
{
#region Public Properties
[Key, Column(Order = 0), MaxLength(50)]
public string KeyName { get; set; }
[Column(Order = 1)]
public int ValInt { get; set; } = 0;
[Column(Order = 2)]
public int ValFloat { get; set; } = 0;
[Column(Order = 3), MaxLength(250)]
public string ValString { get; set; } = "";
[Column(Order = 4), Comment("Descrizione dell'item"), MaxLength(250)]
public string Descript { get; set; } = "";
#endregion Public Properties
}
}
+34
View File
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella Config
/// </summary>
[Table("Config")]
public class ConfigModel
{
#region Public Properties
[Key, Column(Order = 0), MaxLength(50)]
public string KeyName { get; set; }
[Column(Order = 1), MaxLength(50)]
public string Val { get; set; } = "";
[Column(Order = 2), MaxLength(50)]
public string ValStd { get; set; } = "";
[Column(Order = 3), MaxLength(250)]
public string Note { get; set; } = "";
#endregion Public Properties
}
}
+37
View File
@@ -0,0 +1,37 @@
using System;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella Articoli/Items
/// </summary>
[Table("Items")]
public class ItemModel
{
#region Public Properties
[Key, Column(Order = 0), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int ItemId { get; set; }
[Column(Order = 1), MaxLength(100)]
public string ItemCode { get; set; } = "";
[Column(Order = 2), MaxLength(250)]
public string ItemDesc { get; set; } = "";
[Column(Order = 3), MaxLength(50)]
public string ItemType { get; set; } = "";
[Column(Order = 4), MaxLength(50)]
public string UM { get; set; } = "";
#endregion Public Properties
}
}
+37
View File
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella ListVal
/// </summary>
[Table("ListVal")]
public class ListValModel
{
#region Public Properties
[Column("TabName", Order = 0), MaxLength(50)]
public string TabName { get; set; } = "";
[Column("FieldName", Order = 1), MaxLength(50)]
public string FieldName { get; set; } = "";
[Column("Val", Order = 2), MaxLength(50)]
public string Val { get; set; } = "";
[Column("Descript", Order = 3), MaxLength(250)]
public string Descript { get; set; } = "";
[Column("Ordinal", Order = 4)]
public int Ordinal { get; set; } = 1;
#endregion Public Properties
}
}
+58
View File
@@ -0,0 +1,58 @@
using System;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella Ordini
/// </summary>
[Table("Order")]
public class OrderModel
{
#region Public Properties
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int OrderId { get; set; }
public DateTime DtOrder { get; set; } = DateTime.Now;
public int PlantId { get; set; }
public int SupplierId { get; set; }
public int TransporterId { get; set; }
[MaxLength(100)]
public string OrderCode { get; set; } = "";
[MaxLength(250)]
public string OrderDesc { get; set; } = "";
public double OrderQty { get; set; } = 0;
public DateTime DtETA { get; set; }
public DateTime DtExecStart { get; set; }
public DateTime DtExecEnd { get; set; }
public double ExecutionQty { get; set; } = 0;
[ForeignKey("PlantId")]
public virtual PlantDetailModel Plant { get; set; }
[ForeignKey("SupplierId")]
public virtual SupplierModel Supplier { get; set; }
[ForeignKey("TransporterId")]
public virtual TransporterModel Transporter { get; set; }
#endregion Public Properties
}
}
@@ -0,0 +1,46 @@
using System;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella Plants
/// </summary>
[Table("PlantDetail")]
public class PlantDetailModel
{
#region Public Properties
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int PlantId { get; set; }
[MaxLength(100)]
public string PlantCode { get; set; } = "";
[MaxLength(250)]
public string PlantDesc { get; set; } = "";
public double LevelMax { get; set; } = 9999;
public double LevelAct { get; set; } = 0;
public double PressMax { get; set; } = 9999;
public double PressAct { get; set; } = 0;
public double PressBHMax { get; set; } = 9999;
public double PressBHAct { get; set; } = 0;
public double PressBLMax { get; set; } = 9999;
public double PressBLAct { get; set; } = 0;
#endregion Public Properties
}
}
+44
View File
@@ -0,0 +1,44 @@
using System;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella dati Plant (log storico)
/// </summary>
[Table("PlantLog")]
public class PlantLogModel
{
#region Public Properties
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int PlantDataId { get; set; }
public DateTime DtEvent { get; set; } = DateTime.Now;
/// <summary>
/// Tipologia di Flusso dati (per poter salvare "ultimo di ogni flusso" come "current status")
/// </summary>
[MaxLength(250)]
public string FluxType { get; set; } = "ND";
public int PlantId { get; set; }
public double ValNumber { get; set; } = 0;
[MaxLength(250)]
public string ValString { get; set; } = "";
[ForeignKey("PlantId")]
public virtual PlantDetailModel Plant { get; set; }
#endregion Public Properties
}
}
@@ -0,0 +1,41 @@
using System;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella dati Plant (status attuale x flussi gestiti)
/// </summary>
[Table("PlantStatus")]
public class PlantStatusModel
{
#region Public Properties
public int PlantId { get; set; }
/// <summary>
/// Tipologia di Flusso dati (per poter salvare "ultimo di ogni flusso" come "current status")
/// </summary>
[MaxLength(250)]
public string FluxType { get; set; } = "ND";
public DateTime DtEvent { get; set; } = DateTime.Now;
public double ValNumber { get; set; }
[MaxLength(250)]
public string ValString { get; set; }
[ForeignKey("PlantId")]
public virtual PlantDetailModel Plant { get; set; }
#endregion Public Properties
}
}
+31
View File
@@ -0,0 +1,31 @@
using System;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella Fornitori
/// </summary>
[Table("Supplier")]
public class SupplierModel
{
#region Public Properties
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int SupplierId { get; set; }
[MaxLength(100)]
public string SupplierCode { get; set; } = "";
[MaxLength(250)]
public string SupplierDesc { get; set; } = "";
#endregion Public Properties
}
}
+20
View File
@@ -0,0 +1,20 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GWMS.Data.DatabaseModels
{
[Keyless]
public class TableCount
{
#region Public Properties
public int Count { get; set; }
public string TableName { get; set; }
#endregion Public Properties
}
}
@@ -0,0 +1,37 @@
using System;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella Trasportatori
/// </summary>
[Table("Transporter")]
public class TransporterModel
{
#region Public Properties
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int TransporterId { get; set; }
[MaxLength(100)]
public string TransporterCode { get; set; } = "";
[MaxLength(250)]
public string TransporterDesc { get; set; } = "";
public double PositionLatitude { get; set; }
public double PositionLongitude { get; set; }
public DateTime PositionUpdated { get; set; } = DateTime.Now;
#endregion Public Properties
}
}
+64
View File
@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella Users
/// </summary>
[Table("Users")]
public class UserModel
{
#region Public Properties
[Key, Column(Order = 0), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
[Column(Order = 1), MaxLength(50)]
public string UserName { get; set; } = "";
[Column(Order = 1), MaxLength(250)]
public string SaltPasswd { get; set; } = "";
[Column(Order = 3), MaxLength(50)]
public string Lastname { get; set; } = "";
[Column(Order = 4), MaxLength(50)]
public string Firstname { get; set; } = "";
[Column(Order = 5), MaxLength(250)]
public string Email { get; set; } = "";
[Column(Order = 6), MaxLength(10)]
public string Lang { get; set; } = "IT";
[Column(Order = 7), MaxLength(100)]
public string AuthKey { get; set; } = "";
[Column(Order = 8)]
public bool IsActive { get; set; } = true;
[Column(Order = 9)]
public UserLevel Livello { get; set; } = UserLevel.ND;
[Column(Order = 10)]
public int MaskPlantId { get; set; } = 9999;
[Column(Order = 11)]
public int MaskSupplierId { get; set; } = 9999;
[Column(Order = 12)]
public int MaskTranspId { get; set; } = 9999;
#endregion Public Properties
}
}
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella dei USER di MySql
/// </summary>
[Table("user")]
public class UserPriv
{
#region Public Properties
[Column("Host", Order = 1)]
public string Host { get; set; } = "";
[Column("User", Order = 2)]
public string User { get; set; } = "";
#endregion Public Properties
}
}
+47
View File
@@ -0,0 +1,47 @@
using System;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace GWMS.Data.DatabaseModels
{
/// <summary>
/// Tabella struttura consegne settimanali Plant + Supplier + Transp
/// </summary>
[Table("WeekPlan")]
public class WeekPlanModel
{
#region Public Properties
[Key, Column(Order = 0), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int WeekPlanId { get; set; }
public int PlantId { get; set; }
public int SupplierId { get; set; }
public int TransporterId { get; set; }
public DayOfWeek DayNum { get; set; } = DayOfWeek.Monday;
public int DeliveryHour { get; set; }
[MaxLength(250)]
public string Note { get; set; } = "";
[ForeignKey("PlantId")]
public virtual PlantDetailModel Plant { get; set; }
[ForeignKey("SupplierId")]
public virtual SupplierModel Supplier { get; set; }
[ForeignKey("TransporterId")]
public virtual TransporterModel Transporter { get; set; }
#endregion Public Properties
}
}
+115
View File
@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using NLog;
namespace GWMS.Data
{
public class DbAdmin : IDisposable
{
#if false
private AdminContext adbCtx;
#endif
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#if false
/// <summary>
/// Singleton gestione
/// </summary>
public static DbAdmin man = new DbAdmin();
#endif
#region Public Constructors
public DbAdmin()
{
#if false
// Initialize database context for ADMIN
adbCtx = new AdminContext();
#endif
}
#endregion Public Constructors
#region Public Methods
public static bool checkCreateUser(string username, string pwd)
{
bool answ = false;
using (AdminContext adbCtx = new AdminContext())
{
// ricerca utente...
var numUser = adbCtx
.UserList
.Where(x => x.User == username)
.ToList()
.Count;
if (numUser > 0)
{
answ = true;
}
if (!answ)
{
// creo utente
string sqlCommand = "FLUSH PRIVILEGES;";
adbCtx.Database.ExecuteSqlRaw(sqlCommand);
sqlCommand = $"CREATE USER '{username}'@'localhost' IDENTIFIED BY '{pwd}';";
adbCtx.Database.ExecuteSqlRaw(sqlCommand);
sqlCommand = $"GRANT ALL ON *.* TO '{username}'@'localhost';";
adbCtx.Database.ExecuteSqlRaw(sqlCommand);
sqlCommand = "FLUSH PRIVILEGES;";
adbCtx.Database.ExecuteSqlRaw(sqlCommand);
}
}
return answ;
}
public static async Task<bool> migrateDbIdentity()
{
bool answ = false;
using (UserIdentityDbContext dbCtx = new UserIdentityDbContext())
{
await dbCtx.Database.MigrateAsync();
answ = true;
}
return answ;
}
public static async Task<bool> migrateDbMain()
{
bool answ = false;
using (GWMSContext dbCtx = new GWMSContext())
{
await dbCtx.Database.MigrateAsync();
answ = true;
}
return answ;
}
public static bool resetPlantLogTable()
{
bool answ = false;
using (GWMSContext dbCtx = new GWMSContext())
{
string sqlCommand = "TRUNCATE TABLE PlantLog;";
dbCtx.Database.ExecuteSqlRaw(sqlCommand);
answ = true;
}
return answ;
}
public void Dispose()
{
}
#endregion Public Methods
}
}
+80
View File
@@ -0,0 +1,80 @@
using GWMS.Data.DatabaseModels;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GWMS.Data
{
public static class DbConfig
{
#region Public Fields
public static string DATABASE_NAME = "GWMS";
public static int DATABASE_PROCESS_TIMEOUT = 5;
public static string DATABASE_PWD = "viadante16";
// Database config
public static string DATABASE_SERV = "127.0.0.1";
public static string DATABASE_USER = "GWMS_User";
#endregion Public Fields
#region Public Properties
/// <summary>
/// DB Connection string per azioni amministrative
/// </summary>
public static string ADMIN_CONNECTION_STRING { get; set; } = "";
/// <summary>
/// DB Connection string
/// </summary>
public static string CONNECTION_STRING { get; set; } = "";
#endregion Public Properties
#region Public Methods
public static bool CheckUser(string nKey, string sKey)
{
// esecuzione script di install locale
return DbAdmin.checkCreateUser(DATABASE_USER, DATABASE_PWD);
}
public static async Task<bool> ExecMigrationIdentity()
{
// esecuzione migrazione
return await DbAdmin.migrateDbIdentity();
}
public static async Task<bool> ExecMigrationMain()
{
// esecuzione migrazione
return await DbAdmin.migrateDbMain();
}
public static void InitDb(string server, string nKey, string sKey)
{
DATABASE_SERV = server;
DATABASE_NAME = $"GWMS_{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";
}
public static ServerVersion MysqlServerVersion(string connString)
{
ServerVersion serverVersion = ServerVersion.AutoDetect(connString);
return serverVersion;
}
#endregion Public Methods
}
}
+13
View File
@@ -0,0 +1,13 @@
using System;
namespace GWMS.Data
{
public enum UserLevel
{
ND = 0,
SuperAdmin = 1,
Admin = 2,
User = 3,
UserExt = 4
}
}
+19 -4
View File
@@ -5,14 +5,29 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.6">
<Compile Remove="Controllers\GWMS.Data.DbController.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="5.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="5.0.1" />
<PackageReference Include="NLog" Version="4.7.10" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
</Project>
+122
View File
@@ -0,0 +1,122 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.Extensions.Configuration;
using GWMS.Data.DatabaseModels;
using NLog;
using System.Linq;
using GWMS.Data.Controllers;
namespace GWMS.Data
{
public partial class GWMSContext : DbContext
{
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private IConfiguration _configuration;
#endregion Private Fields
#region Public Constructors
public GWMSContext()
{
}
public GWMSContext(IConfiguration configuration)
{
_configuration = configuration;
// se non ci fosse... crea!
Database.EnsureCreated();
}
public GWMSContext(DbContextOptions<GWMSContext> options) : base(options)
{
// se non ci fosse... crea!
Database.EnsureCreated();
}
#endregion Public Constructors
#region Public Properties
public virtual DbSet<ConfigModel> DbSetConfig { get; set; }
public virtual DbSet<ItemModel> DbSetItems { get; set; }
public virtual DbSet<AnKeyValModel> DbSetKeyVal { get; set; }
public virtual DbSet<ListValModel> DbSetListVal { get; set; }
public virtual DbSet<OrderModel> DbSetOrders { get; set; }
public virtual DbSet<PlantDetailModel> DbSetPlant { get; set; }
public virtual DbSet<PlantLogModel> DbSetPlantLog { get; set; }
public virtual DbSet<PlantStatusModel> DbSetPlantStatus { get; set; }
public virtual DbSet<WeekPlanModel> DbSetPlantSupplWeekPlan { get; set; }
public virtual DbSet<SupplierModel> DbSetSupplier { get; set; }
public virtual DbSet<TransporterModel> DbSetTransporter { get; set; }
public virtual DbSet<UserModel> DbSetUser { get; set; }
#endregion Public Properties
#region Private Methods
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
#endregion Private Methods
#region Protected Methods
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// default
string connString = "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;";
// tento setup da config
try
{
//string server = _configuration["DbConfig:Server"];
//string nKey = _configuration["DbConfig:nKey"];
//string sKey = _configuration["DbConfig:sKey"];
//DbConfig.InitDb(server, nKey, sKey);
//DbConfig.CheckUser(nKey, sKey);
// uso conn string calcolata
connString = DbConfig.CONNECTION_STRING;
}
catch
{ }
if (!optionsBuilder.IsConfigured)
{
//connString = "Server=localhost;port=3306;database=GWMS;user=GWMS;pwd=GWMS_secret_pwd;sslmode=None;";
var serverVersion = ServerVersion.AutoDetect(connString);
optionsBuilder.UseMySql(connString, serverVersion);
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
foreach (var relationship in modelBuilder.Model.GetEntityTypes().SelectMany(e => e.GetForeignKeys()))
{
relationship.DeleteBehavior = DeleteBehavior.Restrict;
}
modelBuilder.Entity<ConfigModel>(entity =>
{
entity.Property(e => e.ValStd)
.HasComment("Valore di default/riferimento per la variabile");
});
modelBuilder.Entity<ListValModel>().HasKey(c => new { c.TabName, c.FieldName, c.Val });
modelBuilder.Entity<PlantStatusModel>().HasKey(c => new { c.PlantId, c.FluxType });
modelBuilder.Seed();
OnModelCreatingPartial(modelBuilder);
}
#endregion Protected Methods
}
}
+796
View File
@@ -0,0 +1,796 @@
// <auto-generated />
using System;
using GWMS.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace GWMS.Data.Migrations
{
[DbContext(typeof(GWMSContext))]
[Migration("20210623174246_InitDb")]
partial class InitDb
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.6");
modelBuilder.Entity("GWMS.Data.DatabaseModels.AnKeyValModel", b =>
{
b.Property<string>("KeyName")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("Descript")
.HasMaxLength(250)
.HasColumnType("varchar(250)")
.HasComment("Descrizione dell'item");
b.Property<int>("ValFloat")
.HasColumnType("int");
b.Property<int>("ValInt")
.HasColumnType("int");
b.Property<string>("ValString")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("KeyName");
b.ToTable("AnKeyVal");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.ConfigModel", b =>
{
b.Property<string>("KeyName")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("Note")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<string>("Val")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("ValStd")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasComment("Valore di default/riferimento per la variabile");
b.HasKey("KeyName");
b.ToTable("Config");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.ItemModel", b =>
{
b.Property<int>("ItemId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ItemCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("ItemDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<string>("ItemType")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("UM")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.HasKey("ItemId");
b.ToTable("Items");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.ListValModel", b =>
{
b.Property<string>("TabName")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnName("TabName");
b.Property<string>("FieldName")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnName("FieldName");
b.Property<string>("Val")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnName("Val");
b.Property<string>("Descript")
.HasMaxLength(250)
.HasColumnType("varchar(250)")
.HasColumnName("Descript");
b.Property<int>("Ordinal")
.HasColumnType("int")
.HasColumnName("Ordinal");
b.HasKey("TabName", "FieldName", "Val");
b.ToTable("ListVal");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b =>
{
b.Property<int>("OrderId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtETA")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtExecEnd")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtExecStart")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtOrder")
.HasColumnType("datetime(6)");
b.Property<double>("ExecutionQty")
.HasColumnType("double");
b.Property<string>("OrderCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("OrderDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<double>("OrderQty")
.HasColumnType("double");
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<int>("SupplierId")
.HasColumnType("int");
b.Property<int>("TransporterId")
.HasColumnType("int");
b.HasKey("OrderId");
b.HasIndex("PlantId");
b.HasIndex("SupplierId");
b.HasIndex("TransporterId");
b.ToTable("Order");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantDetailModel", b =>
{
b.Property<int>("PlantId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<double>("LevelAct")
.HasColumnType("double");
b.Property<double>("LevelMax")
.HasColumnType("double");
b.Property<string>("PlantCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("PlantDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<double>("PressAct")
.HasColumnType("double");
b.Property<double>("PressBHAct")
.HasColumnType("double");
b.Property<double>("PressBHMax")
.HasColumnType("double");
b.Property<double>("PressBLAct")
.HasColumnType("double");
b.Property<double>("PressBLMax")
.HasColumnType("double");
b.Property<double>("PressMax")
.HasColumnType("double");
b.HasKey("PlantId");
b.ToTable("PlantDetail");
b.HasData(
new
{
PlantId = 1,
LevelAct = 0.0,
LevelMax = 28000.0,
PlantCode = "PIZ03",
PlantDesc = "Collecchio",
PressAct = 0.0,
PressBHAct = 0.0,
PressBHMax = 270.0,
PressBLAct = 0.0,
PressBLMax = 270.0,
PressMax = 19.0
},
new
{
PlantId = 2,
LevelAct = 0.0,
LevelMax = 28000.0,
PlantCode = "PIZ04",
PlantDesc = "Noceto",
PressAct = 0.0,
PressBHAct = 0.0,
PressBHMax = 270.0,
PressBLAct = 0.0,
PressBLMax = 270.0,
PressMax = 19.0
},
new
{
PlantId = 3,
LevelAct = 0.0,
LevelMax = 24000.0,
PlantCode = "PIZ05",
PlantDesc = "Baganzola",
PressAct = 0.0,
PressBHAct = 0.0,
PressBHMax = 270.0,
PressBLAct = 0.0,
PressBLMax = 270.0,
PressMax = 19.0
},
new
{
PlantId = 4,
LevelAct = 0.0,
LevelMax = 24000.0,
PlantCode = "PIZ08",
PlantDesc = "Pilastrello",
PressAct = 0.0,
PressBHAct = 0.0,
PressBHMax = 270.0,
PressBLAct = 0.0,
PressBLMax = 270.0,
PressMax = 19.0
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b =>
{
b.Property<int>("PlantDataId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtEvent")
.HasColumnType("datetime(6)");
b.Property<string>("FluxType")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<double>("ValNumber")
.HasColumnType("double");
b.Property<string>("ValString")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("PlantDataId");
b.HasIndex("PlantId");
b.ToTable("PlantLog");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b =>
{
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<string>("FluxType")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<DateTime>("DtEvent")
.HasColumnType("datetime(6)");
b.Property<double>("ValNumber")
.HasColumnType("double");
b.Property<string>("ValString")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("PlantId", "FluxType");
b.ToTable("PlantStatus");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.SupplierModel", b =>
{
b.Property<int>("SupplierId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("SupplierCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("SupplierDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("SupplierId");
b.ToTable("Supplier");
b.HasData(
new
{
SupplierId = 1,
SupplierCode = "LIQUIGAS",
SupplierDesc = "Fornitore Liquigas"
},
new
{
SupplierId = 2,
SupplierCode = "VULKANGAS",
SupplierDesc = "Fornitore Vulkangas"
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.TransporterModel", b =>
{
b.Property<int>("TransporterId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<double>("PositionLatitude")
.HasColumnType("double");
b.Property<double>("PositionLongitude")
.HasColumnType("double");
b.Property<DateTime>("PositionUpdated")
.HasColumnType("datetime(6)");
b.Property<string>("TransporterCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("TransporterDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("TransporterId");
b.ToTable("Transporter");
b.HasData(
new
{
TransporterId = 1,
PositionLatitude = 0.0,
PositionLongitude = 0.0,
PositionUpdated = new DateTime(2021, 6, 23, 19, 42, 46, 138, DateTimeKind.Local).AddTicks(1840),
TransporterCode = "LEVO",
TransporterDesc = "Trasportatore Levorato"
},
new
{
TransporterId = 2,
PositionLatitude = 0.0,
PositionLongitude = 0.0,
PositionUpdated = new DateTime(2021, 6, 23, 19, 42, 46, 138, DateTimeKind.Local).AddTicks(2413),
TransporterCode = "TRAF",
TransporterDesc = "Trasportatore Traffik"
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.UserModel", b =>
{
b.Property<int>("UserId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("AuthKey")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("Email")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<string>("Firstname")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<string>("Lang")
.HasMaxLength(10)
.HasColumnType("varchar(10)");
b.Property<string>("Lastname")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<int>("Livello")
.HasColumnType("int");
b.Property<int>("MaskPlantId")
.HasColumnType("int");
b.Property<int>("MaskSupplierId")
.HasColumnType("int");
b.Property<int>("MaskTranspId")
.HasColumnType("int");
b.Property<string>("SaltPasswd")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<string>("UserName")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.HasKey("UserId");
b.ToTable("Users");
b.HasData(
new
{
UserId = 1,
AuthKey = "th1sIsTh3R1vrOfThNgt98",
Email = "samuele@steamware.net",
Firstname = "Samuele",
IsActive = true,
Lang = "IT",
Lastname = "Locatelli",
Livello = 1,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "samuele.locatelli"
},
new
{
UserId = 2,
AuthKey = "th1sIsTh3R1vrOfThNgt91",
Email = "giancarlo@steamware.net",
Firstname = "Giancarlo",
IsActive = true,
Lang = "IT",
Lastname = "Rottoli",
Livello = 1,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "giancarlo.rottoli"
},
new
{
UserId = 3,
AuthKey = "th1sIsTh3R1vrOfThNgt93",
Email = "info@steamware.net",
Firstname = "Steamware",
IsActive = true,
Lang = "IT",
Lastname = "Admin",
Livello = 1,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "steamw.admin"
},
new
{
UserId = 4,
AuthKey = "th1sIsTh3R1vrOfThNgt97",
Email = "a.pizzaferri@pizzaferripetroli.it",
Firstname = "Angelo",
IsActive = true,
Lang = "IT",
Lastname = "Pizzaferri",
Livello = 2,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "angelo.pizzaferri"
},
new
{
UserId = 5,
AuthKey = "th1sIsTh3R1vrOfThNgt99",
Email = "andrei.valeanu@winnlab.it",
Firstname = "Andrei",
IsActive = true,
Lang = "IT",
Lastname = "Valeanu",
Livello = 2,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "andrei.valeanu"
},
new
{
UserId = 6,
AuthKey = "th1sIsTh3R1vrOfThNgt92",
Email = "info@steamware.net",
Firstname = "User",
IsActive = true,
Lang = "IT",
Lastname = "LIQUIGAS",
Livello = 4,
MaskPlantId = 0,
MaskSupplierId = 1,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "liquigas.user01"
},
new
{
UserId = 7,
AuthKey = "th1sIsTh3R1vrOfThNgt94",
Email = "info@steamware.net",
Firstname = "User",
IsActive = true,
Lang = "IT",
Lastname = "VULKANGAS",
Livello = 4,
MaskPlantId = 0,
MaskSupplierId = 2,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "vulkangas.user01"
},
new
{
UserId = 8,
AuthKey = "th1sIsTh3R1vrOfThNgt95",
Email = "info@steamware.net",
Firstname = "User",
IsActive = true,
Lang = "IT",
Lastname = "LEVORATO",
Livello = 4,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 1,
SaltPasswd = "",
UserName = "levorato.user01"
},
new
{
UserId = 9,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "User",
IsActive = true,
Lang = "IT",
Lastname = "TRAFFIK",
Livello = 4,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 2,
SaltPasswd = "",
UserName = "traffik.user01"
},
new
{
UserId = 10,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "Stazione",
IsActive = true,
Lang = "IT",
Lastname = "Collecchio",
Livello = 3,
MaskPlantId = 1,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "piz03.user01"
},
new
{
UserId = 11,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "Stazione",
IsActive = true,
Lang = "IT",
Lastname = "Noceto",
Livello = 3,
MaskPlantId = 2,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "piz04.user01"
},
new
{
UserId = 12,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "Stazione",
IsActive = true,
Lang = "IT",
Lastname = "Baganzola",
Livello = 3,
MaskPlantId = 3,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "piz05.user01"
},
new
{
UserId = 13,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "Stazione",
IsActive = true,
Lang = "IT",
Lastname = "Pilastrello",
Livello = 3,
MaskPlantId = 4,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "piz08.user01"
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.WeekPlanModel", b =>
{
b.Property<int>("WeekPlanId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("DayNum")
.HasColumnType("int");
b.Property<int>("DeliveryHour")
.HasColumnType("int");
b.Property<string>("Note")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<int>("SupplierId")
.HasColumnType("int");
b.Property<int>("TransporterId")
.HasColumnType("int");
b.HasKey("WeekPlanId");
b.HasIndex("PlantId");
b.HasIndex("SupplierId");
b.HasIndex("TransporterId");
b.ToTable("WeekPlan");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b =>
{
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier")
.WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter")
.WithMany()
.HasForeignKey("TransporterId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Plant");
b.Navigation("Supplier");
b.Navigation("Transporter");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b =>
{
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Plant");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b =>
{
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Plant");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.WeekPlanModel", b =>
{
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier")
.WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter")
.WithMany()
.HasForeignKey("TransporterId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Plant");
b.Navigation("Supplier");
b.Navigation("Transporter");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,443 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace GWMS.Data.Migrations
{
public partial class InitDb : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AnKeyVal",
columns: table => new
{
KeyName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ValInt = table.Column<int>(type: "int", nullable: false),
ValFloat = table.Column<int>(type: "int", nullable: false),
ValString = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Descript = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true, comment: "Descrizione dell'item")
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AnKeyVal", x => x.KeyName);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Config",
columns: table => new
{
KeyName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Val = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ValStd = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, comment: "Valore di default/riferimento per la variabile")
.Annotation("MySql:CharSet", "utf8mb4"),
Note = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Config", x => x.KeyName);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Items",
columns: table => new
{
ItemId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ItemCode = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ItemDesc = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ItemType = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
UM = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Items", x => x.ItemId);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "ListVal",
columns: table => new
{
TabName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
FieldName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Val = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Descript = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Ordinal = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ListVal", x => new { x.TabName, x.FieldName, x.Val });
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "PlantDetail",
columns: table => new
{
PlantId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PlantCode = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PlantDesc = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
LevelMax = table.Column<double>(type: "double", nullable: false),
LevelAct = table.Column<double>(type: "double", nullable: false),
PressMax = table.Column<double>(type: "double", nullable: false),
PressAct = table.Column<double>(type: "double", nullable: false),
PressBHMax = table.Column<double>(type: "double", nullable: false),
PressBHAct = table.Column<double>(type: "double", nullable: false),
PressBLMax = table.Column<double>(type: "double", nullable: false),
PressBLAct = table.Column<double>(type: "double", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PlantDetail", x => x.PlantId);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Supplier",
columns: table => new
{
SupplierId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
SupplierCode = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
SupplierDesc = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Supplier", x => x.SupplierId);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Transporter",
columns: table => new
{
TransporterId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
TransporterCode = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
TransporterDesc = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PositionLatitude = table.Column<double>(type: "double", nullable: false),
PositionLongitude = table.Column<double>(type: "double", nullable: false),
PositionUpdated = table.Column<DateTime>(type: "datetime(6)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Transporter", x => x.TransporterId);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
UserId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
SaltPasswd = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Lastname = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Firstname = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Email = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Lang = table.Column<string>(type: "varchar(10)", maxLength: 10, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
AuthKey = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
Livello = table.Column<int>(type: "int", nullable: false),
MaskPlantId = table.Column<int>(type: "int", nullable: false),
MaskSupplierId = table.Column<int>(type: "int", nullable: false),
MaskTranspId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.UserId);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "PlantLog",
columns: table => new
{
PlantDataId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DtEvent = table.Column<DateTime>(type: "datetime(6)", nullable: false),
FluxType = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PlantId = table.Column<int>(type: "int", nullable: false),
ValNumber = table.Column<double>(type: "double", nullable: false),
ValString = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_PlantLog", x => x.PlantDataId);
table.ForeignKey(
name: "FK_PlantLog_PlantDetail_PlantId",
column: x => x.PlantId,
principalTable: "PlantDetail",
principalColumn: "PlantId",
onDelete: ReferentialAction.Restrict);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "PlantStatus",
columns: table => new
{
PlantId = table.Column<int>(type: "int", nullable: false),
FluxType = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
DtEvent = table.Column<DateTime>(type: "datetime(6)", nullable: false),
ValNumber = table.Column<double>(type: "double", nullable: false),
ValString = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_PlantStatus", x => new { x.PlantId, x.FluxType });
table.ForeignKey(
name: "FK_PlantStatus_PlantDetail_PlantId",
column: x => x.PlantId,
principalTable: "PlantDetail",
principalColumn: "PlantId",
onDelete: ReferentialAction.Restrict);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "Order",
columns: table => new
{
OrderId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
DtOrder = table.Column<DateTime>(type: "datetime(6)", nullable: false),
PlantId = table.Column<int>(type: "int", nullable: false),
SupplierId = table.Column<int>(type: "int", nullable: false),
TransporterId = table.Column<int>(type: "int", nullable: false),
OrderCode = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
OrderDesc = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
OrderQty = table.Column<double>(type: "double", nullable: false),
DtETA = table.Column<DateTime>(type: "datetime(6)", nullable: false),
DtExecStart = table.Column<DateTime>(type: "datetime(6)", nullable: false),
DtExecEnd = table.Column<DateTime>(type: "datetime(6)", nullable: false),
ExecutionQty = table.Column<double>(type: "double", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Order", x => x.OrderId);
table.ForeignKey(
name: "FK_Order_PlantDetail_PlantId",
column: x => x.PlantId,
principalTable: "PlantDetail",
principalColumn: "PlantId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Order_Supplier_SupplierId",
column: x => x.SupplierId,
principalTable: "Supplier",
principalColumn: "SupplierId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Order_Transporter_TransporterId",
column: x => x.TransporterId,
principalTable: "Transporter",
principalColumn: "TransporterId",
onDelete: ReferentialAction.Restrict);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "WeekPlan",
columns: table => new
{
WeekPlanId = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
PlantId = table.Column<int>(type: "int", nullable: false),
SupplierId = table.Column<int>(type: "int", nullable: false),
TransporterId = table.Column<int>(type: "int", nullable: false),
DayNum = table.Column<int>(type: "int", nullable: false),
DeliveryHour = table.Column<int>(type: "int", nullable: false),
Note = table.Column<string>(type: "varchar(250)", maxLength: 250, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_WeekPlan", x => x.WeekPlanId);
table.ForeignKey(
name: "FK_WeekPlan_PlantDetail_PlantId",
column: x => x.PlantId,
principalTable: "PlantDetail",
principalColumn: "PlantId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_WeekPlan_Supplier_SupplierId",
column: x => x.SupplierId,
principalTable: "Supplier",
principalColumn: "SupplierId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_WeekPlan_Transporter_TransporterId",
column: x => x.TransporterId,
principalTable: "Transporter",
principalColumn: "TransporterId",
onDelete: ReferentialAction.Restrict);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.InsertData(
table: "PlantDetail",
columns: new[] { "PlantId", "LevelAct", "LevelMax", "PlantCode", "PlantDesc", "PressAct", "PressBHAct", "PressBHMax", "PressBLAct", "PressBLMax", "PressMax" },
values: new object[,]
{
{ 1, 0.0, 28000.0, "PIZ03", "Collecchio", 0.0, 0.0, 270.0, 0.0, 270.0, 19.0 },
{ 2, 0.0, 28000.0, "PIZ04", "Noceto", 0.0, 0.0, 270.0, 0.0, 270.0, 19.0 },
{ 3, 0.0, 24000.0, "PIZ05", "Baganzola", 0.0, 0.0, 270.0, 0.0, 270.0, 19.0 },
{ 4, 0.0, 24000.0, "PIZ08", "Pilastrello", 0.0, 0.0, 270.0, 0.0, 270.0, 19.0 }
});
migrationBuilder.InsertData(
table: "Supplier",
columns: new[] { "SupplierId", "SupplierCode", "SupplierDesc" },
values: new object[,]
{
{ 1, "LIQUIGAS", "Fornitore Liquigas" },
{ 2, "VULKANGAS", "Fornitore Vulkangas" }
});
migrationBuilder.InsertData(
table: "Transporter",
columns: new[] { "TransporterId", "PositionLatitude", "PositionLongitude", "PositionUpdated", "TransporterCode", "TransporterDesc" },
values: new object[,]
{
{ 1, 0.0, 0.0, new DateTime(2021, 6, 23, 19, 42, 46, 138, DateTimeKind.Local).AddTicks(1840), "LEVO", "Trasportatore Levorato" },
{ 2, 0.0, 0.0, new DateTime(2021, 6, 23, 19, 42, 46, 138, DateTimeKind.Local).AddTicks(2413), "TRAF", "Trasportatore Traffik" }
});
migrationBuilder.InsertData(
table: "Users",
columns: new[] { "UserId", "AuthKey", "Email", "Firstname", "IsActive", "Lang", "Lastname", "Livello", "MaskPlantId", "MaskSupplierId", "MaskTranspId", "SaltPasswd", "UserName" },
values: new object[,]
{
{ 11, "th1sIsTh3R1vrOfThNgt96", "info@steamware.net", "Stazione", true, "IT", "Noceto", 3, 2, 0, 0, "", "piz04.user01" },
{ 10, "th1sIsTh3R1vrOfThNgt96", "info@steamware.net", "Stazione", true, "IT", "Collecchio", 3, 1, 0, 0, "", "piz03.user01" },
{ 9, "th1sIsTh3R1vrOfThNgt96", "info@steamware.net", "User", true, "IT", "TRAFFIK", 4, 0, 0, 2, "", "traffik.user01" },
{ 8, "th1sIsTh3R1vrOfThNgt95", "info@steamware.net", "User", true, "IT", "LEVORATO", 4, 0, 0, 1, "", "levorato.user01" },
{ 7, "th1sIsTh3R1vrOfThNgt94", "info@steamware.net", "User", true, "IT", "VULKANGAS", 4, 0, 2, 0, "", "vulkangas.user01" },
{ 3, "th1sIsTh3R1vrOfThNgt93", "info@steamware.net", "Steamware", true, "IT", "Admin", 1, 0, 0, 0, "", "steamw.admin" },
{ 5, "th1sIsTh3R1vrOfThNgt99", "andrei.valeanu@winnlab.it", "Andrei", true, "IT", "Valeanu", 2, 0, 0, 0, "", "andrei.valeanu" },
{ 4, "th1sIsTh3R1vrOfThNgt97", "a.pizzaferri@pizzaferripetroli.it", "Angelo", true, "IT", "Pizzaferri", 2, 0, 0, 0, "", "angelo.pizzaferri" },
{ 12, "th1sIsTh3R1vrOfThNgt96", "info@steamware.net", "Stazione", true, "IT", "Baganzola", 3, 3, 0, 0, "", "piz05.user01" },
{ 2, "th1sIsTh3R1vrOfThNgt91", "giancarlo@steamware.net", "Giancarlo", true, "IT", "Rottoli", 1, 0, 0, 0, "", "giancarlo.rottoli" },
{ 1, "th1sIsTh3R1vrOfThNgt98", "samuele@steamware.net", "Samuele", true, "IT", "Locatelli", 1, 0, 0, 0, "", "samuele.locatelli" },
{ 6, "th1sIsTh3R1vrOfThNgt92", "info@steamware.net", "User", true, "IT", "LIQUIGAS", 4, 0, 1, 0, "", "liquigas.user01" },
{ 13, "th1sIsTh3R1vrOfThNgt96", "info@steamware.net", "Stazione", true, "IT", "Pilastrello", 3, 4, 0, 0, "", "piz08.user01" }
});
migrationBuilder.CreateIndex(
name: "IX_Order_PlantId",
table: "Order",
column: "PlantId");
migrationBuilder.CreateIndex(
name: "IX_Order_SupplierId",
table: "Order",
column: "SupplierId");
migrationBuilder.CreateIndex(
name: "IX_Order_TransporterId",
table: "Order",
column: "TransporterId");
migrationBuilder.CreateIndex(
name: "IX_PlantLog_PlantId",
table: "PlantLog",
column: "PlantId");
migrationBuilder.CreateIndex(
name: "IX_WeekPlan_PlantId",
table: "WeekPlan",
column: "PlantId");
migrationBuilder.CreateIndex(
name: "IX_WeekPlan_SupplierId",
table: "WeekPlan",
column: "SupplierId");
migrationBuilder.CreateIndex(
name: "IX_WeekPlan_TransporterId",
table: "WeekPlan",
column: "TransporterId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AnKeyVal");
migrationBuilder.DropTable(
name: "Config");
migrationBuilder.DropTable(
name: "Items");
migrationBuilder.DropTable(
name: "ListVal");
migrationBuilder.DropTable(
name: "Order");
migrationBuilder.DropTable(
name: "PlantLog");
migrationBuilder.DropTable(
name: "PlantStatus");
migrationBuilder.DropTable(
name: "Users");
migrationBuilder.DropTable(
name: "WeekPlan");
migrationBuilder.DropTable(
name: "PlantDetail");
migrationBuilder.DropTable(
name: "Supplier");
migrationBuilder.DropTable(
name: "Transporter");
}
}
}
@@ -0,0 +1,271 @@
// <auto-generated />
using System;
using GWMS.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace GWMS.User.Migrations
{
[DbContext(typeof(UserIdentityDbContext))]
[Migration("20210624134343_CreateIdentitySchema")]
partial class CreateIdentitySchema
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.7");
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("varchar(255)");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("tinyint(1)");
b.Property<bool>("LockoutEnabled")
.HasColumnType("tinyint(1)");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetime(6)");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("longtext");
b.Property<string>("PhoneNumber")
.HasColumnType("longtext");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("tinyint(1)");
b.Property<string>("SecurityStamp")
.HasColumnType("longtext");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("tinyint(1)");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("varchar(255)");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<string>("ProviderKey")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("longtext");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("varchar(255)");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("varchar(255)");
b.Property<string>("RoleId")
.HasColumnType("varchar(255)");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("varchar(255)");
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<string>("Name")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<string>("Value")
.HasColumnType("longtext");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,257 @@
using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace GWMS.User.Migrations
{
public partial class CreateIdentitySchema : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterDatabase()
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
UserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedUserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Email = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
NormalizedEmail = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
EmailConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false),
PasswordHash = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
SecurityStamp = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PhoneNumber = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
PhoneNumberConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false),
TwoFactorEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true),
LockoutEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false),
AccessFailedCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
RoleId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ClaimType = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ClaimValue = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
UserId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ClaimType = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
ClaimValue = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
LoginProvider = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ProviderKey = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ProviderDisplayName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
UserId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
RoleId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
UserId = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
LoginProvider = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Value = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_UserId",
table: "AspNetUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserLogins_UserId",
table: "AspNetUserLogins",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserRoles_RoleId",
table: "AspNetUserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AspNetRoleClaims");
migrationBuilder.DropTable(
name: "AspNetUserClaims");
migrationBuilder.DropTable(
name: "AspNetUserLogins");
migrationBuilder.DropTable(
name: "AspNetUserRoles");
migrationBuilder.DropTable(
name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "AspNetRoles");
migrationBuilder.DropTable(
name: "AspNetUsers");
}
}
}
@@ -0,0 +1,888 @@
// <auto-generated />
using System;
using GWMS.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace GWMS.Data.Migrations
{
[DbContext(typeof(GWMSContext))]
[Migration("20210625141536_SeedWeekPlan")]
partial class SeedWeekPlan
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.7");
modelBuilder.Entity("GWMS.Data.DatabaseModels.AnKeyValModel", b =>
{
b.Property<string>("KeyName")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("Descript")
.HasMaxLength(250)
.HasColumnType("varchar(250)")
.HasComment("Descrizione dell'item");
b.Property<int>("ValFloat")
.HasColumnType("int");
b.Property<int>("ValInt")
.HasColumnType("int");
b.Property<string>("ValString")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("KeyName");
b.ToTable("AnKeyVal");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.ConfigModel", b =>
{
b.Property<string>("KeyName")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("Note")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<string>("Val")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("ValStd")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasComment("Valore di default/riferimento per la variabile");
b.HasKey("KeyName");
b.ToTable("Config");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.ItemModel", b =>
{
b.Property<int>("ItemId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ItemCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("ItemDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<string>("ItemType")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("UM")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.HasKey("ItemId");
b.ToTable("Items");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.ListValModel", b =>
{
b.Property<string>("TabName")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnName("TabName");
b.Property<string>("FieldName")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnName("FieldName");
b.Property<string>("Val")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnName("Val");
b.Property<string>("Descript")
.HasMaxLength(250)
.HasColumnType("varchar(250)")
.HasColumnName("Descript");
b.Property<int>("Ordinal")
.HasColumnType("int")
.HasColumnName("Ordinal");
b.HasKey("TabName", "FieldName", "Val");
b.ToTable("ListVal");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b =>
{
b.Property<int>("OrderId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtETA")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtExecEnd")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtExecStart")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtOrder")
.HasColumnType("datetime(6)");
b.Property<double>("ExecutionQty")
.HasColumnType("double");
b.Property<string>("OrderCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("OrderDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<double>("OrderQty")
.HasColumnType("double");
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<int>("SupplierId")
.HasColumnType("int");
b.Property<int>("TransporterId")
.HasColumnType("int");
b.HasKey("OrderId");
b.HasIndex("PlantId");
b.HasIndex("SupplierId");
b.HasIndex("TransporterId");
b.ToTable("Order");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantDetailModel", b =>
{
b.Property<int>("PlantId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<double>("LevelAct")
.HasColumnType("double");
b.Property<double>("LevelMax")
.HasColumnType("double");
b.Property<string>("PlantCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("PlantDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<double>("PressAct")
.HasColumnType("double");
b.Property<double>("PressBHAct")
.HasColumnType("double");
b.Property<double>("PressBHMax")
.HasColumnType("double");
b.Property<double>("PressBLAct")
.HasColumnType("double");
b.Property<double>("PressBLMax")
.HasColumnType("double");
b.Property<double>("PressMax")
.HasColumnType("double");
b.HasKey("PlantId");
b.ToTable("PlantDetail");
b.HasData(
new
{
PlantId = 1,
LevelAct = 0.0,
LevelMax = 28000.0,
PlantCode = "PIZ03",
PlantDesc = "Collecchio",
PressAct = 0.0,
PressBHAct = 0.0,
PressBHMax = 270.0,
PressBLAct = 0.0,
PressBLMax = 270.0,
PressMax = 19.0
},
new
{
PlantId = 2,
LevelAct = 0.0,
LevelMax = 28000.0,
PlantCode = "PIZ04",
PlantDesc = "Noceto",
PressAct = 0.0,
PressBHAct = 0.0,
PressBHMax = 270.0,
PressBLAct = 0.0,
PressBLMax = 270.0,
PressMax = 19.0
},
new
{
PlantId = 3,
LevelAct = 0.0,
LevelMax = 24000.0,
PlantCode = "PIZ05",
PlantDesc = "Baganzola",
PressAct = 0.0,
PressBHAct = 0.0,
PressBHMax = 270.0,
PressBLAct = 0.0,
PressBLMax = 270.0,
PressMax = 19.0
},
new
{
PlantId = 4,
LevelAct = 0.0,
LevelMax = 24000.0,
PlantCode = "PIZ08",
PlantDesc = "Pilastrello",
PressAct = 0.0,
PressBHAct = 0.0,
PressBHMax = 270.0,
PressBLAct = 0.0,
PressBLMax = 270.0,
PressMax = 19.0
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b =>
{
b.Property<int>("PlantDataId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtEvent")
.HasColumnType("datetime(6)");
b.Property<string>("FluxType")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<double>("ValNumber")
.HasColumnType("double");
b.Property<string>("ValString")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("PlantDataId");
b.HasIndex("PlantId");
b.ToTable("PlantLog");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b =>
{
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<string>("FluxType")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<DateTime>("DtEvent")
.HasColumnType("datetime(6)");
b.Property<double>("ValNumber")
.HasColumnType("double");
b.Property<string>("ValString")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("PlantId", "FluxType");
b.ToTable("PlantStatus");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.SupplierModel", b =>
{
b.Property<int>("SupplierId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("SupplierCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("SupplierDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("SupplierId");
b.ToTable("Supplier");
b.HasData(
new
{
SupplierId = 1,
SupplierCode = "LIQUIGAS",
SupplierDesc = "Liquigas"
},
new
{
SupplierId = 2,
SupplierCode = "VULKANGAS",
SupplierDesc = "Vulkangas"
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.TransporterModel", b =>
{
b.Property<int>("TransporterId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<double>("PositionLatitude")
.HasColumnType("double");
b.Property<double>("PositionLongitude")
.HasColumnType("double");
b.Property<DateTime>("PositionUpdated")
.HasColumnType("datetime(6)");
b.Property<string>("TransporterCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("TransporterDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("TransporterId");
b.ToTable("Transporter");
b.HasData(
new
{
TransporterId = 1,
PositionLatitude = 0.0,
PositionLongitude = 0.0,
PositionUpdated = new DateTime(2021, 6, 25, 16, 15, 35, 940, DateTimeKind.Local).AddTicks(7402),
TransporterCode = "LEVO",
TransporterDesc = "Levorato"
},
new
{
TransporterId = 2,
PositionLatitude = 0.0,
PositionLongitude = 0.0,
PositionUpdated = new DateTime(2021, 6, 25, 16, 15, 35, 940, DateTimeKind.Local).AddTicks(8022),
TransporterCode = "TRAF",
TransporterDesc = "Traffik"
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.UserModel", b =>
{
b.Property<int>("UserId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("AuthKey")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("Email")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<string>("Firstname")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<string>("Lang")
.HasMaxLength(10)
.HasColumnType("varchar(10)");
b.Property<string>("Lastname")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<int>("Livello")
.HasColumnType("int");
b.Property<int>("MaskPlantId")
.HasColumnType("int");
b.Property<int>("MaskSupplierId")
.HasColumnType("int");
b.Property<int>("MaskTranspId")
.HasColumnType("int");
b.Property<string>("SaltPasswd")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<string>("UserName")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.HasKey("UserId");
b.ToTable("Users");
b.HasData(
new
{
UserId = 1,
AuthKey = "th1sIsTh3R1vrOfThNgt98",
Email = "samuele@steamware.net",
Firstname = "Samuele",
IsActive = true,
Lang = "IT",
Lastname = "Locatelli",
Livello = 1,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "samuele.locatelli"
},
new
{
UserId = 2,
AuthKey = "th1sIsTh3R1vrOfThNgt91",
Email = "giancarlo@steamware.net",
Firstname = "Giancarlo",
IsActive = true,
Lang = "IT",
Lastname = "Rottoli",
Livello = 1,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "giancarlo.rottoli"
},
new
{
UserId = 3,
AuthKey = "th1sIsTh3R1vrOfThNgt93",
Email = "info@steamware.net",
Firstname = "Steamware",
IsActive = true,
Lang = "IT",
Lastname = "Admin",
Livello = 1,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "steamw.admin"
},
new
{
UserId = 4,
AuthKey = "th1sIsTh3R1vrOfThNgt97",
Email = "a.pizzaferri@pizzaferripetroli.it",
Firstname = "Angelo",
IsActive = true,
Lang = "IT",
Lastname = "Pizzaferri",
Livello = 2,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "angelo.pizzaferri"
},
new
{
UserId = 5,
AuthKey = "th1sIsTh3R1vrOfThNgt99",
Email = "andrei.valeanu@winnlab.it",
Firstname = "Andrei",
IsActive = true,
Lang = "IT",
Lastname = "Valeanu",
Livello = 2,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "andrei.valeanu"
},
new
{
UserId = 6,
AuthKey = "th1sIsTh3R1vrOfThNgt92",
Email = "info@steamware.net",
Firstname = "User",
IsActive = true,
Lang = "IT",
Lastname = "LIQUIGAS",
Livello = 4,
MaskPlantId = 0,
MaskSupplierId = 1,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "liquigas.user01"
},
new
{
UserId = 7,
AuthKey = "th1sIsTh3R1vrOfThNgt94",
Email = "info@steamware.net",
Firstname = "User",
IsActive = true,
Lang = "IT",
Lastname = "VULKANGAS",
Livello = 4,
MaskPlantId = 0,
MaskSupplierId = 2,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "vulkangas.user01"
},
new
{
UserId = 8,
AuthKey = "th1sIsTh3R1vrOfThNgt95",
Email = "info@steamware.net",
Firstname = "User",
IsActive = true,
Lang = "IT",
Lastname = "LEVORATO",
Livello = 4,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 1,
SaltPasswd = "",
UserName = "levorato.user01"
},
new
{
UserId = 9,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "User",
IsActive = true,
Lang = "IT",
Lastname = "TRAFFIK",
Livello = 4,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 2,
SaltPasswd = "",
UserName = "traffik.user01"
},
new
{
UserId = 10,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "Stazione",
IsActive = true,
Lang = "IT",
Lastname = "Collecchio",
Livello = 3,
MaskPlantId = 1,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "piz03.user01"
},
new
{
UserId = 11,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "Stazione",
IsActive = true,
Lang = "IT",
Lastname = "Noceto",
Livello = 3,
MaskPlantId = 2,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "piz04.user01"
},
new
{
UserId = 12,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "Stazione",
IsActive = true,
Lang = "IT",
Lastname = "Baganzola",
Livello = 3,
MaskPlantId = 3,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "piz05.user01"
},
new
{
UserId = 13,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "Stazione",
IsActive = true,
Lang = "IT",
Lastname = "Pilastrello",
Livello = 3,
MaskPlantId = 4,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "piz08.user01"
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.WeekPlanModel", b =>
{
b.Property<int>("WeekPlanId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("DayNum")
.HasColumnType("int");
b.Property<int>("DeliveryHour")
.HasColumnType("int");
b.Property<string>("Note")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<int>("SupplierId")
.HasColumnType("int");
b.Property<int>("TransporterId")
.HasColumnType("int");
b.HasKey("WeekPlanId");
b.HasIndex("PlantId");
b.HasIndex("SupplierId");
b.HasIndex("TransporterId");
b.ToTable("WeekPlan");
b.HasData(
new
{
WeekPlanId = 1,
DayNum = 1,
DeliveryHour = 20,
Note = "18K",
PlantId = 2,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 2,
DayNum = 2,
DeliveryHour = 20,
Note = "18K",
PlantId = 2,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 3,
DayNum = 3,
DeliveryHour = 20,
Note = "18K",
PlantId = 2,
SupplierId = 1,
TransporterId = 2
},
new
{
WeekPlanId = 4,
DayNum = 4,
DeliveryHour = 15,
Note = "9K",
PlantId = 2,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 5,
DayNum = 4,
DeliveryHour = 20,
Note = "18K",
PlantId = 2,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 6,
DayNum = 6,
DeliveryHour = 20,
Note = "18K",
PlantId = 2,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 7,
DayNum = 2,
DeliveryHour = 14,
Note = "3K",
PlantId = 3,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 8,
DayNum = 2,
DeliveryHour = 15,
Note = "15K",
PlantId = 4,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 9,
DayNum = 2,
DeliveryHour = 17,
Note = "18K",
PlantId = 1,
SupplierId = 2,
TransporterId = 2
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b =>
{
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier")
.WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter")
.WithMany()
.HasForeignKey("TransporterId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Plant");
b.Navigation("Supplier");
b.Navigation("Transporter");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b =>
{
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Plant");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b =>
{
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Plant");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.WeekPlanModel", b =>
{
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier")
.WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter")
.WithMany()
.HasForeignKey("TransporterId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Plant");
b.Navigation("Supplier");
b.Navigation("Transporter");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,131 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace GWMS.Data.Migrations
{
public partial class SeedWeekPlan : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "Supplier",
keyColumn: "SupplierId",
keyValue: 1,
column: "SupplierDesc",
value: "Liquigas");
migrationBuilder.UpdateData(
table: "Supplier",
keyColumn: "SupplierId",
keyValue: 2,
column: "SupplierDesc",
value: "Vulkangas");
migrationBuilder.UpdateData(
table: "Transporter",
keyColumn: "TransporterId",
keyValue: 1,
columns: new[] { "PositionUpdated", "TransporterDesc" },
values: new object[] { new DateTime(2021, 6, 25, 16, 15, 35, 940, DateTimeKind.Local).AddTicks(7402), "Levorato" });
migrationBuilder.UpdateData(
table: "Transporter",
keyColumn: "TransporterId",
keyValue: 2,
columns: new[] { "PositionUpdated", "TransporterDesc" },
values: new object[] { new DateTime(2021, 6, 25, 16, 15, 35, 940, DateTimeKind.Local).AddTicks(8022), "Traffik" });
migrationBuilder.InsertData(
table: "WeekPlan",
columns: new[] { "WeekPlanId", "DayNum", "DeliveryHour", "Note", "PlantId", "SupplierId", "TransporterId" },
values: new object[,]
{
{ 1, 1, 20, "18K", 2, 1, 1 },
{ 2, 2, 20, "18K", 2, 1, 1 },
{ 3, 3, 20, "18K", 2, 1, 2 },
{ 4, 4, 15, "9K", 2, 1, 1 },
{ 5, 4, 20, "18K", 2, 1, 1 },
{ 6, 6, 20, "18K", 2, 1, 1 },
{ 7, 2, 14, "3K", 3, 1, 1 },
{ 8, 2, 15, "15K", 4, 1, 1 },
{ 9, 2, 17, "18K", 1, 2, 2 }
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "WeekPlan",
keyColumn: "WeekPlanId",
keyValue: 1);
migrationBuilder.DeleteData(
table: "WeekPlan",
keyColumn: "WeekPlanId",
keyValue: 2);
migrationBuilder.DeleteData(
table: "WeekPlan",
keyColumn: "WeekPlanId",
keyValue: 3);
migrationBuilder.DeleteData(
table: "WeekPlan",
keyColumn: "WeekPlanId",
keyValue: 4);
migrationBuilder.DeleteData(
table: "WeekPlan",
keyColumn: "WeekPlanId",
keyValue: 5);
migrationBuilder.DeleteData(
table: "WeekPlan",
keyColumn: "WeekPlanId",
keyValue: 6);
migrationBuilder.DeleteData(
table: "WeekPlan",
keyColumn: "WeekPlanId",
keyValue: 7);
migrationBuilder.DeleteData(
table: "WeekPlan",
keyColumn: "WeekPlanId",
keyValue: 8);
migrationBuilder.DeleteData(
table: "WeekPlan",
keyColumn: "WeekPlanId",
keyValue: 9);
migrationBuilder.UpdateData(
table: "Supplier",
keyColumn: "SupplierId",
keyValue: 1,
column: "SupplierDesc",
value: "Fornitore Liquigas");
migrationBuilder.UpdateData(
table: "Supplier",
keyColumn: "SupplierId",
keyValue: 2,
column: "SupplierDesc",
value: "Fornitore Vulkangas");
migrationBuilder.UpdateData(
table: "Transporter",
keyColumn: "TransporterId",
keyValue: 1,
columns: new[] { "PositionUpdated", "TransporterDesc" },
values: new object[] { new DateTime(2021, 6, 23, 19, 42, 46, 138, DateTimeKind.Local).AddTicks(1840), "Trasportatore Levorato" });
migrationBuilder.UpdateData(
table: "Transporter",
keyColumn: "TransporterId",
keyValue: 2,
columns: new[] { "PositionUpdated", "TransporterDesc" },
values: new object[] { new DateTime(2021, 6, 23, 19, 42, 46, 138, DateTimeKind.Local).AddTicks(2413), "Trasportatore Traffik" });
}
}
}
@@ -0,0 +1,886 @@
// <auto-generated />
using System;
using GWMS.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace GWMS.Data.Migrations
{
[DbContext(typeof(GWMSContext))]
partial class GWMSContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.7");
modelBuilder.Entity("GWMS.Data.DatabaseModels.AnKeyValModel", b =>
{
b.Property<string>("KeyName")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("Descript")
.HasMaxLength(250)
.HasColumnType("varchar(250)")
.HasComment("Descrizione dell'item");
b.Property<int>("ValFloat")
.HasColumnType("int");
b.Property<int>("ValInt")
.HasColumnType("int");
b.Property<string>("ValString")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("KeyName");
b.ToTable("AnKeyVal");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.ConfigModel", b =>
{
b.Property<string>("KeyName")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("Note")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<string>("Val")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("ValStd")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasComment("Valore di default/riferimento per la variabile");
b.HasKey("KeyName");
b.ToTable("Config");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.ItemModel", b =>
{
b.Property<int>("ItemId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ItemCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("ItemDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<string>("ItemType")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<string>("UM")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.HasKey("ItemId");
b.ToTable("Items");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.ListValModel", b =>
{
b.Property<string>("TabName")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnName("TabName");
b.Property<string>("FieldName")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnName("FieldName");
b.Property<string>("Val")
.HasMaxLength(50)
.HasColumnType("varchar(50)")
.HasColumnName("Val");
b.Property<string>("Descript")
.HasMaxLength(250)
.HasColumnType("varchar(250)")
.HasColumnName("Descript");
b.Property<int>("Ordinal")
.HasColumnType("int")
.HasColumnName("Ordinal");
b.HasKey("TabName", "FieldName", "Val");
b.ToTable("ListVal");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b =>
{
b.Property<int>("OrderId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtETA")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtExecEnd")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtExecStart")
.HasColumnType("datetime(6)");
b.Property<DateTime>("DtOrder")
.HasColumnType("datetime(6)");
b.Property<double>("ExecutionQty")
.HasColumnType("double");
b.Property<string>("OrderCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("OrderDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<double>("OrderQty")
.HasColumnType("double");
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<int>("SupplierId")
.HasColumnType("int");
b.Property<int>("TransporterId")
.HasColumnType("int");
b.HasKey("OrderId");
b.HasIndex("PlantId");
b.HasIndex("SupplierId");
b.HasIndex("TransporterId");
b.ToTable("Order");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantDetailModel", b =>
{
b.Property<int>("PlantId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<double>("LevelAct")
.HasColumnType("double");
b.Property<double>("LevelMax")
.HasColumnType("double");
b.Property<string>("PlantCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("PlantDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<double>("PressAct")
.HasColumnType("double");
b.Property<double>("PressBHAct")
.HasColumnType("double");
b.Property<double>("PressBHMax")
.HasColumnType("double");
b.Property<double>("PressBLAct")
.HasColumnType("double");
b.Property<double>("PressBLMax")
.HasColumnType("double");
b.Property<double>("PressMax")
.HasColumnType("double");
b.HasKey("PlantId");
b.ToTable("PlantDetail");
b.HasData(
new
{
PlantId = 1,
LevelAct = 0.0,
LevelMax = 28000.0,
PlantCode = "PIZ03",
PlantDesc = "Collecchio",
PressAct = 0.0,
PressBHAct = 0.0,
PressBHMax = 270.0,
PressBLAct = 0.0,
PressBLMax = 270.0,
PressMax = 19.0
},
new
{
PlantId = 2,
LevelAct = 0.0,
LevelMax = 28000.0,
PlantCode = "PIZ04",
PlantDesc = "Noceto",
PressAct = 0.0,
PressBHAct = 0.0,
PressBHMax = 270.0,
PressBLAct = 0.0,
PressBLMax = 270.0,
PressMax = 19.0
},
new
{
PlantId = 3,
LevelAct = 0.0,
LevelMax = 24000.0,
PlantCode = "PIZ05",
PlantDesc = "Baganzola",
PressAct = 0.0,
PressBHAct = 0.0,
PressBHMax = 270.0,
PressBLAct = 0.0,
PressBLMax = 270.0,
PressMax = 19.0
},
new
{
PlantId = 4,
LevelAct = 0.0,
LevelMax = 24000.0,
PlantCode = "PIZ08",
PlantDesc = "Pilastrello",
PressAct = 0.0,
PressBHAct = 0.0,
PressBHMax = 270.0,
PressBLAct = 0.0,
PressBLMax = 270.0,
PressMax = 19.0
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b =>
{
b.Property<int>("PlantDataId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<DateTime>("DtEvent")
.HasColumnType("datetime(6)");
b.Property<string>("FluxType")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<double>("ValNumber")
.HasColumnType("double");
b.Property<string>("ValString")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("PlantDataId");
b.HasIndex("PlantId");
b.ToTable("PlantLog");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b =>
{
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<string>("FluxType")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<DateTime>("DtEvent")
.HasColumnType("datetime(6)");
b.Property<double>("ValNumber")
.HasColumnType("double");
b.Property<string>("ValString")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("PlantId", "FluxType");
b.ToTable("PlantStatus");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.SupplierModel", b =>
{
b.Property<int>("SupplierId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("SupplierCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("SupplierDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("SupplierId");
b.ToTable("Supplier");
b.HasData(
new
{
SupplierId = 1,
SupplierCode = "LIQUIGAS",
SupplierDesc = "Liquigas"
},
new
{
SupplierId = 2,
SupplierCode = "VULKANGAS",
SupplierDesc = "Vulkangas"
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.TransporterModel", b =>
{
b.Property<int>("TransporterId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<double>("PositionLatitude")
.HasColumnType("double");
b.Property<double>("PositionLongitude")
.HasColumnType("double");
b.Property<DateTime>("PositionUpdated")
.HasColumnType("datetime(6)");
b.Property<string>("TransporterCode")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("TransporterDesc")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.HasKey("TransporterId");
b.ToTable("Transporter");
b.HasData(
new
{
TransporterId = 1,
PositionLatitude = 0.0,
PositionLongitude = 0.0,
PositionUpdated = new DateTime(2021, 6, 25, 16, 15, 35, 940, DateTimeKind.Local).AddTicks(7402),
TransporterCode = "LEVO",
TransporterDesc = "Levorato"
},
new
{
TransporterId = 2,
PositionLatitude = 0.0,
PositionLongitude = 0.0,
PositionUpdated = new DateTime(2021, 6, 25, 16, 15, 35, 940, DateTimeKind.Local).AddTicks(8022),
TransporterCode = "TRAF",
TransporterDesc = "Traffik"
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.UserModel", b =>
{
b.Property<int>("UserId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("AuthKey")
.HasMaxLength(100)
.HasColumnType("varchar(100)");
b.Property<string>("Email")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<string>("Firstname")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<string>("Lang")
.HasMaxLength(10)
.HasColumnType("varchar(10)");
b.Property<string>("Lastname")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.Property<int>("Livello")
.HasColumnType("int");
b.Property<int>("MaskPlantId")
.HasColumnType("int");
b.Property<int>("MaskSupplierId")
.HasColumnType("int");
b.Property<int>("MaskTranspId")
.HasColumnType("int");
b.Property<string>("SaltPasswd")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<string>("UserName")
.HasMaxLength(50)
.HasColumnType("varchar(50)");
b.HasKey("UserId");
b.ToTable("Users");
b.HasData(
new
{
UserId = 1,
AuthKey = "th1sIsTh3R1vrOfThNgt98",
Email = "samuele@steamware.net",
Firstname = "Samuele",
IsActive = true,
Lang = "IT",
Lastname = "Locatelli",
Livello = 1,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "samuele.locatelli"
},
new
{
UserId = 2,
AuthKey = "th1sIsTh3R1vrOfThNgt91",
Email = "giancarlo@steamware.net",
Firstname = "Giancarlo",
IsActive = true,
Lang = "IT",
Lastname = "Rottoli",
Livello = 1,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "giancarlo.rottoli"
},
new
{
UserId = 3,
AuthKey = "th1sIsTh3R1vrOfThNgt93",
Email = "info@steamware.net",
Firstname = "Steamware",
IsActive = true,
Lang = "IT",
Lastname = "Admin",
Livello = 1,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "steamw.admin"
},
new
{
UserId = 4,
AuthKey = "th1sIsTh3R1vrOfThNgt97",
Email = "a.pizzaferri@pizzaferripetroli.it",
Firstname = "Angelo",
IsActive = true,
Lang = "IT",
Lastname = "Pizzaferri",
Livello = 2,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "angelo.pizzaferri"
},
new
{
UserId = 5,
AuthKey = "th1sIsTh3R1vrOfThNgt99",
Email = "andrei.valeanu@winnlab.it",
Firstname = "Andrei",
IsActive = true,
Lang = "IT",
Lastname = "Valeanu",
Livello = 2,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "andrei.valeanu"
},
new
{
UserId = 6,
AuthKey = "th1sIsTh3R1vrOfThNgt92",
Email = "info@steamware.net",
Firstname = "User",
IsActive = true,
Lang = "IT",
Lastname = "LIQUIGAS",
Livello = 4,
MaskPlantId = 0,
MaskSupplierId = 1,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "liquigas.user01"
},
new
{
UserId = 7,
AuthKey = "th1sIsTh3R1vrOfThNgt94",
Email = "info@steamware.net",
Firstname = "User",
IsActive = true,
Lang = "IT",
Lastname = "VULKANGAS",
Livello = 4,
MaskPlantId = 0,
MaskSupplierId = 2,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "vulkangas.user01"
},
new
{
UserId = 8,
AuthKey = "th1sIsTh3R1vrOfThNgt95",
Email = "info@steamware.net",
Firstname = "User",
IsActive = true,
Lang = "IT",
Lastname = "LEVORATO",
Livello = 4,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 1,
SaltPasswd = "",
UserName = "levorato.user01"
},
new
{
UserId = 9,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "User",
IsActive = true,
Lang = "IT",
Lastname = "TRAFFIK",
Livello = 4,
MaskPlantId = 0,
MaskSupplierId = 0,
MaskTranspId = 2,
SaltPasswd = "",
UserName = "traffik.user01"
},
new
{
UserId = 10,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "Stazione",
IsActive = true,
Lang = "IT",
Lastname = "Collecchio",
Livello = 3,
MaskPlantId = 1,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "piz03.user01"
},
new
{
UserId = 11,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "Stazione",
IsActive = true,
Lang = "IT",
Lastname = "Noceto",
Livello = 3,
MaskPlantId = 2,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "piz04.user01"
},
new
{
UserId = 12,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "Stazione",
IsActive = true,
Lang = "IT",
Lastname = "Baganzola",
Livello = 3,
MaskPlantId = 3,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "piz05.user01"
},
new
{
UserId = 13,
AuthKey = "th1sIsTh3R1vrOfThNgt96",
Email = "info@steamware.net",
Firstname = "Stazione",
IsActive = true,
Lang = "IT",
Lastname = "Pilastrello",
Livello = 3,
MaskPlantId = 4,
MaskSupplierId = 0,
MaskTranspId = 0,
SaltPasswd = "",
UserName = "piz08.user01"
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.WeekPlanModel", b =>
{
b.Property<int>("WeekPlanId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<int>("DayNum")
.HasColumnType("int");
b.Property<int>("DeliveryHour")
.HasColumnType("int");
b.Property<string>("Note")
.HasMaxLength(250)
.HasColumnType("varchar(250)");
b.Property<int>("PlantId")
.HasColumnType("int");
b.Property<int>("SupplierId")
.HasColumnType("int");
b.Property<int>("TransporterId")
.HasColumnType("int");
b.HasKey("WeekPlanId");
b.HasIndex("PlantId");
b.HasIndex("SupplierId");
b.HasIndex("TransporterId");
b.ToTable("WeekPlan");
b.HasData(
new
{
WeekPlanId = 1,
DayNum = 1,
DeliveryHour = 20,
Note = "18K",
PlantId = 2,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 2,
DayNum = 2,
DeliveryHour = 20,
Note = "18K",
PlantId = 2,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 3,
DayNum = 3,
DeliveryHour = 20,
Note = "18K",
PlantId = 2,
SupplierId = 1,
TransporterId = 2
},
new
{
WeekPlanId = 4,
DayNum = 4,
DeliveryHour = 15,
Note = "9K",
PlantId = 2,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 5,
DayNum = 4,
DeliveryHour = 20,
Note = "18K",
PlantId = 2,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 6,
DayNum = 6,
DeliveryHour = 20,
Note = "18K",
PlantId = 2,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 7,
DayNum = 2,
DeliveryHour = 14,
Note = "3K",
PlantId = 3,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 8,
DayNum = 2,
DeliveryHour = 15,
Note = "15K",
PlantId = 4,
SupplierId = 1,
TransporterId = 1
},
new
{
WeekPlanId = 9,
DayNum = 2,
DeliveryHour = 17,
Note = "18K",
PlantId = 1,
SupplierId = 2,
TransporterId = 2
});
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.OrderModel", b =>
{
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier")
.WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter")
.WithMany()
.HasForeignKey("TransporterId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Plant");
b.Navigation("Supplier");
b.Navigation("Transporter");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantLogModel", b =>
{
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Plant");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.PlantStatusModel", b =>
{
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Plant");
});
modelBuilder.Entity("GWMS.Data.DatabaseModels.WeekPlanModel", b =>
{
b.HasOne("GWMS.Data.DatabaseModels.PlantDetailModel", "Plant")
.WithMany()
.HasForeignKey("PlantId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GWMS.Data.DatabaseModels.SupplierModel", "Supplier")
.WithMany()
.HasForeignKey("SupplierId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GWMS.Data.DatabaseModels.TransporterModel", "Transporter")
.WithMany()
.HasForeignKey("TransporterId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Plant");
b.Navigation("Supplier");
b.Navigation("Transporter");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,269 @@
// <auto-generated />
using System;
using GWMS.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace GWMS.User.Migrations
{
[DbContext(typeof(UserIdentityDbContext))]
partial class UserIdentityDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.7");
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasDatabaseName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("varchar(255)");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.HasColumnType("varchar(255)");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("longtext");
b.Property<string>("Email")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<bool>("EmailConfirmed")
.HasColumnType("tinyint(1)");
b.Property<bool>("LockoutEnabled")
.HasColumnType("tinyint(1)");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetime(6)");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("NormalizedUserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<string>("PasswordHash")
.HasColumnType("longtext");
b.Property<string>("PhoneNumber")
.HasColumnType("longtext");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("tinyint(1)");
b.Property<string>("SecurityStamp")
.HasColumnType("longtext");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("tinyint(1)");
b.Property<string>("UserName")
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasDatabaseName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasDatabaseName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b.Property<string>("ClaimType")
.HasColumnType("longtext");
b.Property<string>("ClaimValue")
.HasColumnType("longtext");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("varchar(255)");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<string>("ProviderKey")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<string>("ProviderDisplayName")
.HasColumnType("longtext");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("varchar(255)");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("varchar(255)");
b.Property<string>("RoleId")
.HasColumnType("varchar(255)");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("varchar(255)");
b.Property<string>("LoginProvider")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<string>("Name")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<string>("Value")
.HasColumnType("longtext");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
+74
View File
@@ -0,0 +1,74 @@
using GWMS.Data.DatabaseModels;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GWMS.Data
{
public static class ModelBuilderExtensions
{
#region Public Methods
/// <summary>
/// Estensione per seed iniziale dei dati nel DB
/// </summary>
/// <param name="modelBuilder"></param>
public static void Seed(this ModelBuilder modelBuilder)
{
// inizializzazione dei valori di default x USER
modelBuilder.Entity<UserModel>().HasData(
new UserModel { UserId = 1, AuthKey = "th1sIsTh3R1vrOfThNgt98", Livello = UserLevel.SuperAdmin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "samuele.locatelli", Email = "samuele@steamware.net", Firstname = "Samuele", Lastname = "Locatelli" },
new UserModel { UserId = 2, AuthKey = "th1sIsTh3R1vrOfThNgt91", Livello = UserLevel.SuperAdmin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "giancarlo.rottoli", Email = "giancarlo@steamware.net", Firstname = "Giancarlo", Lastname = "Rottoli" },
new UserModel { UserId = 3, AuthKey = "th1sIsTh3R1vrOfThNgt93", Livello = UserLevel.SuperAdmin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "steamw.admin", Email = "info@steamware.net", Firstname = "Steamware", Lastname = "Admin" },
new UserModel { UserId = 4, AuthKey = "th1sIsTh3R1vrOfThNgt97", Livello = UserLevel.Admin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "angelo.pizzaferri", Email = "a.pizzaferri@pizzaferripetroli.it", Firstname = "Angelo", Lastname = "Pizzaferri" },
new UserModel { UserId = 5, AuthKey = "th1sIsTh3R1vrOfThNgt99", Livello = UserLevel.Admin, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 0, UserName = "andrei.valeanu", Email = "andrei.valeanu@winnlab.it", Firstname = "Andrei", Lastname = "Valeanu" },
new UserModel { UserId = 6, AuthKey = "th1sIsTh3R1vrOfThNgt92", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 1, MaskTranspId = 0, UserName = "liquigas.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "LIQUIGAS" },
new UserModel { UserId = 7, AuthKey = "th1sIsTh3R1vrOfThNgt94", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 2, MaskTranspId = 0, UserName = "vulkangas.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "VULKANGAS" },
new UserModel { UserId = 8, AuthKey = "th1sIsTh3R1vrOfThNgt95", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 1, UserName = "levorato.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "LEVORATO" },
new UserModel { UserId = 9, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.UserExt, MaskPlantId = 0, MaskSupplierId = 0, MaskTranspId = 2, UserName = "traffik.user01", Email = "info@steamware.net", Firstname = "User", Lastname = "TRAFFIK" },
new UserModel { UserId = 10, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 1, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz03.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Collecchio" },
new UserModel { UserId = 11, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 2, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz04.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Noceto" },
new UserModel { UserId = 12, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 3, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz05.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Baganzola" },
new UserModel { UserId = 13, AuthKey = "th1sIsTh3R1vrOfThNgt96", Livello = UserLevel.User, MaskPlantId = 4, MaskSupplierId = 0, MaskTranspId = 0, UserName = "piz08.user01", Email = "info@steamware.net", Firstname = "Stazione", Lastname = "Pilastrello" }
);
// inizializzazione dei valori di default x Plant
modelBuilder.Entity<PlantDetailModel>().HasData(
new PlantDetailModel { PlantId = 1, PlantCode = "PIZ03", PlantDesc = "Collecchio", LevelMax = 28000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 },
new PlantDetailModel { PlantId = 2, PlantCode = "PIZ04", PlantDesc = "Noceto", LevelMax = 28000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 },
new PlantDetailModel { PlantId = 3, PlantCode = "PIZ05", PlantDesc = "Baganzola", LevelMax = 24000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 },
new PlantDetailModel { PlantId = 4, PlantCode = "PIZ08", PlantDesc = "Pilastrello", LevelMax = 24000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 }
);
// inizializzazione dei valori di default x Fornitori
modelBuilder.Entity<SupplierModel>().HasData(
new SupplierModel { SupplierId = 1, SupplierCode = "LIQUIGAS", SupplierDesc = "Liquigas" },
new SupplierModel { SupplierId = 2, SupplierCode = "VULKANGAS", SupplierDesc = "Vulkangas" }
);
// inizializzazione dei valori di default x Trasportatori
modelBuilder.Entity<TransporterModel>().HasData(
new TransporterModel { TransporterId = 1, TransporterCode = "LEVO", TransporterDesc = "Levorato" },
new TransporterModel { TransporterId = 2, TransporterCode = "TRAF", TransporterDesc = "Traffik" }
);
// init consegne...
modelBuilder.Entity<WeekPlanModel>().HasData(
new WeekPlanModel { WeekPlanId = 1, DayNum = DayOfWeek.Monday, DeliveryHour = 20, Note = "18K", PlantId = 2, SupplierId = 1, TransporterId = 1 },
new WeekPlanModel { WeekPlanId = 2, DayNum = DayOfWeek.Tuesday, DeliveryHour = 20, Note = "18K", PlantId = 2, SupplierId = 1, TransporterId = 1 },
new WeekPlanModel { WeekPlanId = 3, DayNum = DayOfWeek.Wednesday, DeliveryHour = 20, Note = "18K", PlantId = 2, SupplierId = 1, TransporterId = 2 },
new WeekPlanModel { WeekPlanId = 4, DayNum = DayOfWeek.Thursday, DeliveryHour = 15, Note = "9K", PlantId = 2, SupplierId = 1, TransporterId = 1 },
new WeekPlanModel { WeekPlanId = 5, DayNum = DayOfWeek.Thursday, DeliveryHour = 20, Note = "18K", PlantId = 2, SupplierId = 1, TransporterId = 1 },
new WeekPlanModel { WeekPlanId = 6, DayNum = DayOfWeek.Saturday, DeliveryHour = 20, Note = "18K", PlantId = 2, SupplierId = 1, TransporterId = 1 },
new WeekPlanModel { WeekPlanId = 7, DayNum = DayOfWeek.Tuesday, DeliveryHour = 14, Note = "3K", PlantId = 3, SupplierId = 1, TransporterId = 1 },
new WeekPlanModel { WeekPlanId = 8, DayNum = DayOfWeek.Tuesday, DeliveryHour = 15, Note = "15K", PlantId = 4, SupplierId = 1, TransporterId = 1 },
new WeekPlanModel { WeekPlanId = 9, DayNum = DayOfWeek.Tuesday, DeliveryHour = 17, Note = "18K", PlantId = 1, SupplierId = 2, TransporterId = 2 }
);
}
#endregion Public Methods
}
}
+98
View File
@@ -0,0 +1,98 @@
# Appunti gestione GWMS DB
Per la gestione dell'accesso al DB si opera con EFCore --> app blazor server
## Versione MsSql iniziale
Versione iniziale basata su SqlServer
### Scaffolding
Per generare le classi da un DB esistente con cui operare EFCore CodeFirst usare lo scaffolding coi seguenti comandi.
Attenzione: la classe DbContext viene creata INSIEME alle viste nella folder DatabaseModel (nell'esempio seguente...)
#### DB iniziale
Scaffold-DbContext "Server=SQL2016DEV;Database=GWMS;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir DatabaseModels
#### SOLO di tabelle/viste selezionate (con force update)
Scaffold-DbContext "Server=SQL2016DEV;Database=GWMS;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir DatabaseModels -Tables nome_tabella, nome_vista
#### Reset DB MsSql
Per resettare un db MsSql (cancellando tutto x poter ridare update) eseguire il seguente codice
-- drop constraints
DECLARE @DropConstraints NVARCHAR(max) = ''
SELECT @DropConstraints += 'ALTER TABLE ' + QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id)) + '.'
+ QUOTENAME(OBJECT_NAME(parent_object_id)) + ' ' + 'DROP CONSTRAINT' + QUOTENAME(name)
FROM sys.foreign_keys
EXECUTE sp_executesql @DropConstraints;
GO
-- drop tables
DECLARE @DropTables NVARCHAR(max) = ''
SELECT @DropTables += 'DROP TABLE ' + QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)
FROM INFORMATION_SCHEMA.TABLES
EXECUTE sp_executesql @DropTables;
GO
Il DB viene poi rigenerato dal Package Maganer console con
Update-Database
## Versione MySql in produzione
Messa variabile boolean x imporre versione MySql (si potrebbe fare una cosa più "fine-tuned" x selezione aruntime del provider)
Pensata per impiego con MariaDB /MySql in caso linux dotnet 5
Impiegato provider dotnetcore **Pomelo**:
* https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql
* https://www.tektutorialshub.com/entity-framework-core/using-mysql-mariadb-in-entity-framework-core/
### Generazione script
Sono stati ricreati gli script di generazione x MySql cancellando TUTTE le migrations + stato db (ogni file in folder Migrations) + comandi
Add-Migration InitDb
Update-Database
### Generazione DB + utente DB MySql
All'avvio applicazione, prima del seed di dati, viene eseguito un check dell'utente corrente dell'installazione x verifica se esista DB + Utente dedicati (come x applicazioni EgtBW ad esempio)
...da completare codice + descrizione...
## Impiego multi provider
In caso di scelta per impiego di più providers (MsSql, MariaDB, SqlLite, ...) è necessario gestire in modo diverso le classi di inizializzazione del DbContenxt. Non ancora verificato, ma da approfondire secondo i seguenti links:
* Multi provider: https://logu.co/efcore-multiple-providers.html
* Migrations con + providers: https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/providers?tabs=dotnet-core-cli
* Auto update all'avvio progetti (se le migrations sono state generate): https://jasonwatmore.com/post/2019/12/27/aspnet-core-automatic-ef-core-migrations-to-sql-database-on-startup
## Ottimizzazioni e spunti
Alcuni spunti da approfondire:
* Lifetime x DbCOntext secondo casi: https://docs.microsoft.com/en-us/ef/core/dbcontext-configuration/
## Migrations
Approfondimenti:
* https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli
## Approfondimenti
Qualche link di approfondimento:
- https://docs.microsoft.com/en-us/ef/core/
- https://docs.microsoft.com/en-us/ef/core/extensions/
- https://www.entityframeworktutorial.net/efcore/create-model-for-existing-database-in-ef-core.aspx
- https://entityframework.net/ef-code-first
Binary file not shown.
+19
View File
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GWMS.Data
{
public class TSData
{
#region Public Properties
public DateTime DtEvent { get; set; } = DateTime.Now;
public double ValDouble { get; set; } = 0;
#endregion Public Properties
}
}
+48
View File
@@ -0,0 +1,48 @@
using GWMS.Data.DatabaseModels;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GWMS.Data
{
public class UserIdentityDbContext : IdentityDbContext
{
#region Public Constructors
public UserIdentityDbContext()
{
}
public UserIdentityDbContext(DbContextOptions<UserIdentityDbContext> options)
: base(options)
{
// se non ci fosse... crea!
Database.EnsureCreated();
}
#endregion Public Constructors
#region Public Properties
public DbSet<TableCount> DbSetCounts { get; set; }
#endregion Public Properties
#region Protected Methods
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
string connString = DbConfig.CONNECTION_STRING;
if (!optionsBuilder.IsConfigured)
{
var serverVersion = ServerVersion.AutoDetect(connString);
optionsBuilder.UseMySql(connString, serverVersion);
}
}
#endregion Protected Methods
}
}
+5
View File
@@ -0,0 +1,5 @@
{
"version": 1,
"isRoot": true,
"tools": {}
}
@@ -0,0 +1,15 @@
@page
@using Microsoft.AspNetCore.Identity
@attribute [IgnoreAntiforgeryToken]
@inject SignInManager<IdentityUser> SignInManager
@functions {
public async Task<IActionResult> OnPost()
{
if (SignInManager.IsSignedIn(User))
{
await SignInManager.SignOutAsync();
}
return Redirect("~/");
}
}
@@ -0,0 +1,27 @@
@using Microsoft.AspNetCore.Identity
@inject SignInManager<IdentityUser> SignInManager
@inject UserManager<IdentityUser> UserManager
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<ul class="navbar-nav">
@if (SignInManager.IsSignedIn(User))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity.Name!</a>
</li>
<li class="nav-item">
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="/" method="post">
<button type="submit" class="nav-link btn btn-link text-dark">Logout</button>
</form>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Register">Register</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Login">Login</a>
</li>
}
</ul>
@@ -0,0 +1,95 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Server;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
namespace GWMS.UI.Areas.Identity
{
public class RevalidatingIdentityAuthenticationStateProvider<TUser>
: RevalidatingServerAuthenticationStateProvider where TUser : class
{
#region Private Fields
private readonly IdentityOptions _options;
private readonly IServiceScopeFactory _scopeFactory;
#endregion Private Fields
#region Public Constructors
public RevalidatingIdentityAuthenticationStateProvider(
ILoggerFactory loggerFactory,
IServiceScopeFactory scopeFactory,
IOptions<IdentityOptions> optionsAccessor)
: base(loggerFactory)
{
_scopeFactory = scopeFactory;
_options = optionsAccessor.Value;
}
#endregion Public Constructors
#region Protected Properties
protected override TimeSpan RevalidationInterval => TimeSpan.FromMinutes(30);
#endregion Protected Properties
#region Private Methods
private async Task<bool> ValidateSecurityStampAsync(UserManager<TUser> userManager, ClaimsPrincipal principal)
{
var user = await userManager.GetUserAsync(principal);
if (user == null)
{
return false;
}
else if (!userManager.SupportsUserSecurityStamp)
{
return true;
}
else
{
var principalStamp = principal.FindFirstValue(_options.ClaimsIdentity.SecurityStampClaimType);
var userStamp = await userManager.GetSecurityStampAsync(user);
return principalStamp == userStamp;
}
}
#endregion Private Methods
#region Protected Methods
protected override async Task<bool> ValidateAuthenticationStateAsync(
AuthenticationState authenticationState, CancellationToken cancellationToken)
{
// Get the user manager from a new scope to ensure it fetches fresh data
var scope = _scopeFactory.CreateScope();
try
{
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<TUser>>();
return await ValidateSecurityStampAsync(userManager, authenticationState.User);
}
finally
{
if (scope is IAsyncDisposable asyncDisposable)
{
await asyncDisposable.DisposeAsync();
}
else
{
scope.Dispose();
}
}
}
#endregion Protected Methods
}
}
+4
View File
@@ -9,6 +9,7 @@
<div class="row pt-3">
<div class="col-3">
<i class="fas fa-user-alt"></i> <b>@userName</b>
@*<LoginDisplay />*@
</div>
<div class="col-6 text-center h4">
<span class="@PageIcon" aria-hidden="true"></span> @PageName
@@ -23,6 +24,9 @@
@code {
[CascadingParameter]
private Task<AuthenticationState> AuthenticationStateTask { get; set; }
[CascadingParameter(Name = "ShowSearch")]
private bool ShowSearch { get; set; }
+56 -52
View File
@@ -1,46 +1,40 @@
<div class="row">
<div class="col-6 col-lg-10 text-left">
<div class="col-12 col-lg-9 text-left">
<div class="row">
<div class="col-9 small">
<div class="col-12 small">
@if (totalCount > 0)
{
<Pagination>
<PaginationItem>
<PaginationLink Clicked="@HandlePaginationItemClick" Page="1">
<i class="fas fa-angle-double-left"></i>
</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink Clicked="@HandlePaginationItemClick" Page="@prevBlock.ToString()">
<span aria-hidden="true"><i class="fas fa-angle-left"></i></span>
</PaginationLink>
</PaginationItem>
@for (int i = @startPage; i <= endPage; ++i)
<Pagination>
<PaginationItem>
<PaginationLink Clicked="@HandlePaginationItemClick" Page="1">
<i class="fas fa-angle-double-left"></i>
</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink Clicked="@HandlePaginationItemClick" Page="@prevBlock.ToString()">
<span aria-hidden="true"><i class="fas fa-angle-left"></i></span>
</PaginationLink>
</PaginationItem>
@for (int i = @startPage; i <= endPage; ++i)
{
var pageNum = i;
<PaginationItem Active="@(currPage.Equals(pageNum))">
<PaginationLink Clicked="@HandlePaginationItemClick" Page="@pageNum.ToString()">
@pageNum
</PaginationLink>
</PaginationItem>
<PaginationItem Active="@(currPage.Equals(pageNum))">
<PaginationLink Clicked="@HandlePaginationItemClick" Page="@pageNum.ToString()">
@pageNum
</PaginationLink>
</PaginationItem>
}
<PaginationItem>
<PaginationLink Clicked="@HandlePaginationItemClick" Page="@nextBlock.ToString()">
<i class="fas fa-angle-right"></i>
</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink Clicked="@HandlePaginationItemClick" Page="@LastPage.ToString()">
<i class="fas fa-angle-double-right"></i>
</PaginationLink>
</PaginationItem>
</Pagination>
}
</div>
<div class="col-3">
@if (!showLoading)
{
<span>@totalCount records</span>
<PaginationItem>
<PaginationLink Clicked="@HandlePaginationItemClick" Page="@nextBlock.ToString()">
<i class="fas fa-angle-right"></i>
</PaginationLink>
</PaginationItem>
<PaginationItem>
<PaginationLink Clicked="@HandlePaginationItemClick" Page="@LastPage.ToString()">
<i class="fas fa-angle-double-right"></i>
</PaginationLink>
</PaginationItem>
</Pagination>
}
</div>
</div>
@@ -48,26 +42,36 @@
<div class="col-12 small">
@if (showLoading)
{
<Progress>
<ProgressBar Value="@percLoading" Striped="true" Animated="true" />
</Progress>
<Progress>
<ProgressBar Value="@percLoading" Striped="true" Animated="true" />
</Progress>
}
</div>
</div>
</div>
<div class="col-6 col-lg-2 text-right">
@if (totalCount > 0)
{
<div class="input-group input-group-sm">
row/pag:&nbsp;
<select @bind="@PageSize" class="form-control form-control-sm">
<option value="5">5</option>
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
<div class="col-12 col-lg-3 small">
<div class="d-flex">
<div class="p-2 flex-fill">
@if (!showLoading)
{
<span>@totalCount records</span>
}
</div>
<div class="p-2 flex-fill text-right">
@if (totalCount > 0)
{
<div class="input-group input-group-sm">
row/pag:&nbsp;
<select @bind="@PageSize" class="form-control form-control-sm">
<option value="5">5</option>
<option value="10">10</option>
<option value="25">25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</div>
}
</div>
</div>
}
</div>
</div>
+2 -5
View File
@@ -8,7 +8,7 @@ using GWMS.UI.Data;
namespace GWMS.UI.Components
{
public partial class DataPager
public partial class DataPager : ComponentBase
{
#region Protected Fields
@@ -58,7 +58,7 @@ namespace GWMS.UI.Components
}
}
// calcola un set 1..numPOages centrato sulla pagina corrente...
// calcola un set 1 .. numPages centrato sulla pagina corrente...
private int startPage
{
get
@@ -69,9 +69,6 @@ namespace GWMS.UI.Components
}
}
[Inject]
private Services.BlazorTimer Timer { get; set; }
#endregion Private Properties
#region Protected Properties
+96
View File
@@ -0,0 +1,96 @@
@using GWMS.UI.Components
@using GWMS.Data.DatabaseModels
@using System.Security.Claims
@using Microsoft.AspNetCore.Components.Authorization
@using GWMS.UI.Data
@using GWMS.Data.DTO
@using Microsoft.Extensions.Configuration
<div class="my-0 small">
<div class="row text-center small">
@if (_currList == null)
{
<div class="col-12">
<i class="fas fa-circle-notch fa-spin"></i>
</div>
}
else if (_currList.Count == 0)
{
<div class="col-12">
<div class="text-secondary text-center p-1">-</div>
</div>
}
else
{
foreach (var item in _currList)
{
<div class="col-12">
<button class="btn btn-block btn-outline-dark" @onclick="() => Edit(item)">
<div class="d-flex justify-content-between">
<div class="px-1">
<i class="fas fa-gas-pump" aria-hidden="true"></i> @item.Plant.PlantDesc
</div>
<div class="px-1">
<span class="badge badge-pill badge-primary"><b>@item.Note</b></span>
</div>
</div>
<div class="d-flex text-center">
<div class="px-1">
<i class="fas fa-industry" aria-hidden="true"></i> @item.Supplier.SupplierDesc
</div>
</div>
<div class="d-flex text-center">
<div class="px-1">
<i class="fas fa-truck-moving" aria-hidden="true"></i> @item.Transporter.TransporterDesc
</div>
</div>
</button>
</div>
}
}
</div>
</div>
@code {
protected List<WeekPlanModel> _currList { get; set; } = new List<WeekPlanModel>();
[Parameter]
public List<WeekPlanModel> currList
{
get
{
return _currList = null;
}
set
{
_currList = value;
}
}
protected void Edit(WeekPlanModel selRecord)
{
selRecordChanged.InvokeAsync(selRecord.WeekPlanId);
}
[Parameter]
public EventCallback<int> selRecordChanged { get; set; }
private WeekPlanModel _currRecord = null;
private WeekPlanModel currRecord
{
get
{
return _currRecord;
}
set
{
bool doReport = (_currRecord == null) || !_currRecord.Equals(value);
if (doReport)
{
_currRecord = value;
}
}
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
<div class="row py-5 my-5">
<div class="row p-5 m-5">
<div class="col-12 text-center mt-5 py-5 alert alert-primary">
<h3>loading data</h3>
<i class="fas fa-spinner fa-spin fa-5x"></i>
+12
View File
@@ -0,0 +1,12 @@
<AuthorizeView>
<Authorized>
<a href="Identity/Account/Manage">Hello, @context.User.Identity.Name !!!</a>
<form method="post" action="Identity/Account/LogOut">
<button type="submit" class="nav-link btn btn-link">Log out</button>
</form>
</Authorized>
<NotAuthorized>
<a href="Identity/Account/Register">Register</a>
<a href="Identity/Account/Login">Log in</a>
</NotAuthorized>
</AuthorizeView>
+91
View File
@@ -0,0 +1,91 @@
@using GWMS.Data
@using GWMS.UI.Data
@using GWMS.UI.Components
@inject GWMSDataService DataService
@inject MessageService AppMService
@inject IJSRuntime JSRuntime
@if (!DbAllOk)
{
<div class="row">
<div class="col-3 text-right">
<h3>DB Init</h3>
</div>
@if (!DbUserOk)
{
<div class="col-3">
<Button id="btnReset" class="btn btn-danger btn-block" Clicked="initDb">
<i class="fas fa-database"></i> Init Main DB
</Button>
</div>
}
else if (!DbIdentity)
{
<div class="col-3">
<Button id="btnReset" class="btn btn-warning btn-block" Clicked="initIdent">
<i class="fas fa-user-shield"></i> Init Ident DB
</Button>
</div>
}
</div>
}
@code {
[Parameter]
public EventCallback<int> evRefresh { get; set; }
[Parameter]
public EventCallback<int> evProcessing { get; set; }
protected async Task initDb()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler effettuare inizializzazione/migrazione DB?"))
return;
reportProcess();
await DbAdmin.migrateDbMain();
await ReloadData();
reportChange();
}
protected async Task initIdent()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler effettuare inizializzazione/migrazione servizi Identity?"))
return;
reportProcess();
await DbAdmin.migrateDbIdentity();
await ReloadData();
reportChange();
}
protected bool DbUserOk { get; set; } = false;
protected bool DbIdentity { get; set; } = false;
protected bool DbAllOk { get; set; } = false;
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
protected async Task ReloadData()
{
var resultUser = await Health.Checks.DbUserApp(DbConfig.DATABASE_NAME);
var resultIden = await Health.Checks.DbIdentity(DbConfig.DATABASE_NAME);
DbUserOk = (resultUser.Status == HealthStatus.Healthy);
DbIdentity = (resultIden.Status == HealthStatus.Healthy);
DbAllOk = (DbUserOk && DbIdentity);
}
private void reportChange()
{
evRefresh.InvokeAsync(1);
}
private void reportProcess()
{
evProcessing.InvokeAsync(1);
}
}
+161
View File
@@ -0,0 +1,161 @@
@using GWMS.UI.Components
@using GWMS.Data.DatabaseModels
@using System.Security.Claims
@using Microsoft.AspNetCore.Components.Authorization
@using GWMS.UI.Data
@using Microsoft.Extensions.Configuration
@inject MessageService AppMService
@inject GWMSDataService DataService
@inject IConfiguration Configuration
<div class="card">
<div class="card-header bg-info text-light">
<b>Modifica</b>
</div>
<div class="card-body small p-1">
<EditForm Model="@_currItem">
<DataAnnotationsValidator />
<div class="row">
<div class="col-12 col-lg-2">
<img src="@getImgUrl(_currItem.OrderCode)" class="img-fluid" width="85" />
</div>
<div class="col-12 col-lg-8 align-items-center">
<div class="row">
<div class="col-8">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" style="width: 3em;">
<span class="fas fa-industry" aria-hidden="true"></span>
</span>
</div>
<InputSelect @bind-Value="@_currItem.SupplierId" class="form-control" title="Fornitore">
@foreach (var item in suppList)
{
<option value="@item.SupplierId">@item.SupplierCode | @item.SupplierDesc</option>
}
</InputSelect>
</div>
</div>
<div class="col-4">
@*<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-calendar-alt" aria-hidden="true"></span>
</span>
</div>
<InputDate id="DtEta" @bind-Value="_currItem.DtETA" class="form-control" title="ETA (previsione consegna)" />
</div>*@
</div>
<div class="col-12 mt-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" style="width: 3em;">
<span class="fas fa-comment-alt" aria-hidden="true"></span>
</span>
</div>
<InputText id="OrderDesc" @bind-Value="_currItem.OrderDesc" class="form-control" title="Note Ordine (opzionali)" />
<div class="input-group-append">
<span class="input-group-text">
Note
</span>
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-2">
<div class="mb-2">
<button type="button" class="btn btn-outline-success btn-block" value="Save" @onclick="saveUpdate">Save <i class="far fa-save"></i></button>
</div>
<div>
<button type="button" class="btn btn-outline-warning btn-block" value="Cancel" @onclick="cancelUpdate">Cancel <i class="fas fa-ban"></i></button>
</div>
</div>
</div>
</EditForm>
</div>
</div>
@code {
private List<SupplierModel> suppList;
protected OrderModel _currItem = new OrderModel();
protected int _supplierId { get; set; } = 0;
[Parameter]
public OrderModel currItem
{
get
{
return _currItem = null;
}
set
{
_currItem = value;
}
}
[Parameter]
public EventCallback<int> DataReset { get; set; }
[Parameter]
public EventCallback<int> DataUpdated { get; set; }
[Parameter]
public int SupplierId
{
get
{
return _supplierId;
}
set
{
_supplierId = value;
// condiziono visualizzazione...
var pUpd = Task.Run(async () => await ReloadAllData());
pUpd.Wait();
}
}
private async Task saveUpdate()
{
if (_currItem != null)
{
DataService.OrderUpdate(_currItem);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("Order null!");
}
}
private async Task cancelUpdate()
{
await DataReset.InvokeAsync(0);
}
protected override async Task OnInitializedAsync()
{
await ReloadAllData();
}
protected async Task ReloadAllData()
{
suppList = await DataService.SuppliersGetAll();
}
/// <summary>
/// Restituisce URL immagine QRCode
/// </summary>
/// <param name="QrValue">Parametro da renderizzare con QRCode</param>
/// <returns></returns>
protected string getImgUrl(object QrValue)
{
string baseUrl = $"{Configuration["ZCodeUrl"]}/HOME/QR_site/JSON?val=";
string payload = "{'baseUrl':'{0}','parameters':['" + $"{QrValue}" + "']}";
string answ = $"{baseUrl}{payload}";
return answ;
}
}
@@ -0,0 +1,161 @@
@using GWMS.UI.Components
@using GWMS.Data.DatabaseModels
@using System.Security.Claims
@using Microsoft.AspNetCore.Components.Authorization
@using GWMS.UI.Data
@using Microsoft.Extensions.Configuration
@inject MessageService AppMService
@inject GWMSDataService DataService
@inject IConfiguration Configuration
<div class="card">
<div class="card-header bg-info text-light">
<b>Modifica</b>
</div>
<div class="card-body small p-1">
<EditForm Model="@_currItem">
<DataAnnotationsValidator />
<div class="row">
<div class="col-12 col-lg-2">
<img src="@getImgUrl(_currItem.OrderCode)" class="img-fluid" width="85" />
</div>
<div class="col-12 col-lg-8 align-items-center">
<div class="row">
<div class="col-8">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" style="width: 3em;">
<span class="fas fa-truck-moving" aria-hidden="true"></span>
</span>
</div>
<InputSelect @bind-Value="@_currItem.TransporterId" title="Trasportatore" class="form-control">
@foreach (var item in transpList)
{
<option value="@item.TransporterId">@item.TransporterCode | @item.TransporterDesc</option>
}
</InputSelect>
</div>
</div>
<div class="col-4">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-calendar-alt" aria-hidden="true"></span>
</span>
</div>
<InputDate id="DtEta" @bind-Value="_currItem.DtETA" class="form-control" title="ETA (previsione consegna)" />
</div>
</div>
<div class="col-12 mt-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" style="width: 3em;">
<span class="fas fa-comment-alt" aria-hidden="true"></span>
</span>
</div>
<InputText id="OrderDesc" @bind-Value="_currItem.OrderDesc" class="form-control" title="Note Ordine (opzionali)" />
<div class="input-group-append">
<span class="input-group-text">
Note
</span>
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-2">
<div class="mb-2">
<button type="button" class="btn btn-outline-success btn-block" value="Save" @onclick="saveUpdate">Save <i class="far fa-save"></i></button>
</div>
<div>
<button type="button" class="btn btn-outline-warning btn-block" value="Cancel" @onclick="cancelUpdate">Cancel <i class="fas fa-ban"></i></button>
</div>
</div>
</div>
</EditForm>
</div>
</div>
@code {
private List<TransporterModel> transpList;
protected OrderModel _currItem = new OrderModel();
protected int _supplierId { get; set; } = 0;
[Parameter]
public OrderModel currItem
{
get
{
return _currItem = null;
}
set
{
_currItem = value;
}
}
[Parameter]
public EventCallback<int> DataReset { get; set; }
[Parameter]
public EventCallback<int> DataUpdated { get; set; }
[Parameter]
public int SupplierId
{
get
{
return _supplierId;
}
set
{
_supplierId = value;
// condiziono visualizzazione...
var pUpd = Task.Run(async () => await ReloadAllData());
pUpd.Wait();
}
}
private async Task saveUpdate()
{
if (_currItem != null)
{
DataService.OrderUpdate(_currItem);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("Order null!");
}
}
private async Task cancelUpdate()
{
await DataReset.InvokeAsync(0);
}
protected override async Task OnInitializedAsync()
{
await ReloadAllData();
}
protected async Task ReloadAllData()
{
transpList = await DataService.TransportersGetAll();
}
/// <summary>
/// Restituisce URL immagine QRCode
/// </summary>
/// <param name="QrValue">Parametro da renderizzare con QRCode</param>
/// <returns></returns>
protected string getImgUrl(object QrValue)
{
string baseUrl = $"{Configuration["ZCodeUrl"]}/HOME/QR_site/JSON?val=";
string payload = "{'baseUrl':'{0}','parameters':['" + $"{QrValue}" + "']}";
string answ = $"{baseUrl}{payload}";
return answ;
}
}
+146
View File
@@ -0,0 +1,146 @@
@using GWMS.UI.Components
@using GWMS.Data.DatabaseModels
@using System.Security.Claims
@using Microsoft.AspNetCore.Components.Authorization
@using GWMS.UI.Data
@using Microsoft.Extensions.Configuration
@inject MessageService AppMService
@inject GWMSDataService DataService
@inject IConfiguration Configuration
<div class="card">
<div class="card-header bg-info text-light">
<b>Modifica</b>
</div>
<div class="card-body small p-1">
<EditForm Model="@_currItem">
<DataAnnotationsValidator />
<div class="row">
<div class="col-12 col-lg-2">
<img src="@getImgUrl(_currItem.OrderCode)" class="img-fluid" />
</div>
<div class="col-12 col-lg-8 align-items-center">
<div class="row small">
<div class="col-12">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text" style="width: 3em;">
<span class="fas fa-calendar-alt" aria-hidden="true"></span>
</span>
</div>
<InputDate id="DtEta" @bind-Value="_currItem.DtETA" class="form-control" title="ETA (previsione consegna)" />
</div>
</div>
<div class="col-12">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text" style="width: 3em;">
<span class="fas fa-comment-alt" aria-hidden="true"></span>
</span>
</div>
<InputText id="OrderDesc" @bind-Value="_currItem.OrderDesc" class="form-control" title="Note Ordine (opzionali)" />
<div class="input-group-append">
<span class="input-group-text">
Note
</span>
</div>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-2">
<div>
<button type="button" class="btn btn-sm btn-outline-success btn-block" value="Save" @onclick="saveUpdate">Save <i class="far fa-save"></i></button>
</div>
<div>
<button type="button" class="btn btn-sm btn-outline-warning btn-block" value="Cancel" @onclick="cancelUpdate">Cancel <i class="fas fa-ban"></i></button>
</div>
</div>
</div>
</EditForm>
</div>
</div>
@code {
private List<TransporterModel> transpList;
protected OrderModel _currItem = new OrderModel();
protected int _supplierId { get; set; } = 0;
[Parameter]
public OrderModel currItem
{
get
{
return _currItem = null;
}
set
{
_currItem = value;
}
}
[Parameter]
public EventCallback<int> DataReset { get; set; }
[Parameter]
public EventCallback<int> DataUpdated { get; set; }
[Parameter]
public int SupplierId
{
get
{
return _supplierId;
}
set
{
_supplierId = value;
// condiziono visualizzazione...
var pUpd = Task.Run(async () => await ReloadAllData());
pUpd.Wait();
}
}
private async Task saveUpdate()
{
if (_currItem != null)
{
DataService.OrderUpdate(_currItem);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("Order null!");
}
}
private async Task cancelUpdate()
{
await DataReset.InvokeAsync(0);
}
protected override async Task OnInitializedAsync()
{
await ReloadAllData();
}
protected async Task ReloadAllData()
{
transpList = await DataService.TransportersGetAll();
}
/// <summary>
/// Restituisce URL immagine QRCode
/// </summary>
/// <param name="QrValue">Parametro da renderizzare con QRCode</param>
/// <returns></returns>
protected string getImgUrl(object QrValue)
{
string baseUrl = $"{Configuration["ZCodeUrl"]}/HOME/QR_site/JSON?val=";
string payload = "{'baseUrl':'{0}','parameters':['" + $"{QrValue}" + "']}";
string answ = $"{baseUrl}{payload}";
return answ;
}
}
+90
View File
@@ -0,0 +1,90 @@
@using Blazorise
@using GWMS.UI.Components
<div class="card">
<div class="card-header table-primary h1 py-1">
@if (currItem != null)
{
<div class="row py-0">
<div class="col-6">
<b>@currItem.PlantCode</b>
</div>
<div class="col-6 text-right">
@currItem.PlantDesc
</div>
</div>
}
</div>
<div class="card-body p-1">
<div class="row">
<div class="col-5 pr-0">
<div class="row">
<div class="col-12">
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center p-0">
<img src="./img/Plant/@(currItem.PlantCode).jpg" class="img-fluid" />
</li>
<li class="list-group-item active d-flex justify-content-between align-items-center py-1">PB Alta</li>
<li class="list-group-item d-flex justify-content-between align-items-center small">
<span><i class="fas fa-compress-arrows-alt"></i> Stoccaggio</span> <span><b>@currItem.PressAct["BH"].ToString("N1")</b>bar</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center small">
<span><i class="fas fa-compress-arrows-alt"></i> Alimentazione</span> <span><b>@currItem.PressAct["BH"].ToString("N1")</b>bar</span>
</li>
<li class="list-group-item active d-flex justify-content-between align-items-center py-1">PB Bassa</li>
<li class="list-group-item d-flex justify-content-between align-items-center small">
<span><i class="fas fa-compress-arrows-alt"></i> Stoccaggio</span> <span><b>@currItem.PressAct["BL"].ToString("N1")</b>bar</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center small">
<span><i class="fas fa-compress-arrows-alt"></i> Alimentazione</span> <span><b>@currItem.PressAct["BL"].ToString("N1")</b>bar</span>
</li>
</ul>
</div>
</div>
</div>
<div class="col-7">
<div class="row">
<div class="col-12">
<ul class="list-group">
<li class="list-group-item active d-flex justify-content-between align-items-center">SERBATOIO Principale</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<div class="row">
<div class="col-12 px-0">
<LineChart @ref="LevelVal" TItem="double" OptionsObject="lineChartOptions" />
</div>
<div class="col-6 small">
@currItem.LevelAct.ToString("N0")
</div>
<div class="col-6 text-right small">
@currItem.LevelMax.ToString("N0")
</div>
<div class="col-12">
<Progress>
<ProgressBar Value="@currItem.LevelRatio" Striped="false" Animated="false" />
</Progress>
</div>
</div>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<span><i class="fas fa-database"></i> Livello</span> <span style="font-size:1.2em;"><b>@currItem.LevelRatio</b>%</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
<span><i class="fas fa-compress-arrows-alt"></i> Pressione</span> <span style="font-size:1.2em;"><b>@currItem.PressAct["Main"].ToString("N1")</b> <span class="small">bar</span></span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="card-footer alert alert-primary mb-0 p-1">
<div class="d-flex justify-content-between">
<div class="py-1 px-2 h2 mb-0">
Ordini aperti: <b>@currItem.OrderTS.Count</b>
</div>
<div class="py-1 px-2">
<button class="btn btn-block btn-primary" title="Mostra Ordini" @onclick="() => ShowOrders(currItem.PlantId)">Mostra Ordini <i class="fas fa-file-invoice"></i></button>
</div>
</div>
</div>
</div>
+180
View File
@@ -0,0 +1,180 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using GWMS.UI.Data;
using GWMS.Data.DTO;
using Microsoft.AspNetCore.Components;
using Blazorise.Charts;
using System.Threading;
namespace GWMS.UI.Components
{
public partial class PlantDetail
{
#region Protected Fields
protected PlantDTO _currItem = new PlantDTO();
protected LineChart<double> LevelVal = new LineChart<double>();
protected object lineChartOptions = new
{
Scales = new
{
XAxes = new object[]
{
new {
Display = true,
//type = "time"
}
},
YAxes = new object[]
{
new {
Display = true,
ticks= new {
suggestedMin = 0,
suggestedMax = 10000
}
}
}
},
Tooltips = new
{
Mode = "nearest",
Intersect = false
},
Hover = new
{
Mode = "nearest",
Intersect = false
},
Animation = false,
AspectRatio = 2
};
#endregion Protected Fields
#region Private Properties
[Inject]
private NavigationManager NavManager { get; set; }
private int SelPlantId
{
get
{
int answ = 0;
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.PlantId;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.PlantId.Equals(value))
{
MessageService.Order_Filter.PlantId = value;
}
}
}
#endregion Private Properties
#region Protected Properties
[Inject]
protected GWMSDataService DataService { get; set; }
[Inject]
protected MessageService MessageService { get; set; }
#endregion Protected Properties
#region Public Properties
[Parameter]
public PlantDTO currItem
{
get
{
return _currItem;
}
set
{
_currItem = value;
if (value != null)
{
var dataReload = Task.Run(async () =>
{
// aggiunta delay o non riesce a disegnare
Thread.Sleep(50);
await HandleRedraw();
});
}
}
}
#endregion Public Properties
#region Private Methods
private LineChartDataset<double> GetLineChartDataset()
{
var answ = new LineChartDataset<double>
{
//Label = "Livello",
Data = _currItem.LevelTS.Select(x => x.ValDouble).ToList(),
BorderColor = getLineColors(1f),
Fill = true,
PointRadius = 3,
BorderWidth = 2,
LineTension = 0,
BorderDash = new List<int> { }
};
return answ;
}
private List<string> GetLineChartLabels()
{
var answ = _currItem.LevelTS.Select(x => x.DtEvent.ToString("dd.MM HH")).ToList();
return answ;
}
#endregion Private Methods
#region Protected Methods
/// <summary>
/// Genera colori sfondo 33% rosso / arancione / giallo
/// </summary>
/// <param name="numRecords"></param>
/// <returns></returns>
protected List<string> getLineColors(float alpha)
{
List<string> answ = new List<string>();
answ.Add(ChartColor.FromRgba(54, 82, 254, alpha));
return answ;
}
protected async Task HandleRedraw()
{
if (LevelVal != null)
{
await LevelVal.Clear();
await LevelVal.AddLabelsDatasetsAndUpdate(GetLineChartLabels(), GetLineChartDataset());
}
}
protected void ShowOrders(int currPlantId)
{
SelPlantId = currPlantId;
// rimando...
NavManager.NavigateTo($"Orders");
}
#endregion Protected Methods
}
}
+101
View File
@@ -0,0 +1,101 @@
@using GWMS.Data
@using GWMS.UI.Data
@using System.ComponentModel.DataAnnotations
@if (!DbAllOk)
{
<div class="card">
<div class="card-header bg-warning text-light">
<h1>Diagnostica <i class="fas fa-exclamation-triangle"></i></h1>
</div>
<div class="card-body my-5">
<div class="row h3">
@if (!(DbUserAdmAuth))
{
<div class="col-3 text-right">
Admin Passcode
</div>
<div class="col-9">
<EditForm Model="@model">
<DataAnnotationsValidator />
@*<ValidationSummary />*@
<InputText type="password" placeholder="Password" @bind-Value="@model.Password" />
</EditForm>
</div>
}
else if (!(DbUserTableOk && DbIdentity))
{
<div class="col-12">
<MigrationManager evRefresh="()=> Done()" evProcessing="()=> Processing()" />
</div>
}
else if (!DbLogOk)
{
<div class="col-12">
<SetupSim evRefresh="()=> Done()" evProcessing="()=> Processing()" />
</div>
}
@if (processRunning)
{
<div class="col-12 text-center">
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:75%"></div>
</div>
</div>
}
</div>
</div>
</div>
}
@code {
protected bool DbUserAdmAuth
{
get
{
return model.Password == "f@mmiEntrare!";
}
}
protected bool DbUserTableOk { get; set; } = false;
protected bool DbLogOk { get; set; } = false;
protected bool DbAllOk { get; set; } = false;
protected bool DbIdentity { get; set; } = false;
protected bool processRunning { get; set; } = false;
class Login
{
[Required]
public string Password { get; set; }
}
private Login model = new Login();
protected override async Task OnInitializedAsync()
{
processRunning = false;
await ReloadData();
}
protected async Task Processing()
{
processRunning = true;
await ReloadData();
}
protected async Task Done()
{
processRunning = false;
await ReloadData();
}
protected async Task ReloadData()
{
var resultUser = await Health.Checks.DbUserApp(DbConfig.DATABASE_NAME);
var resultLog = await Health.Checks.DbPlantLogTable(DbConfig.DATABASE_NAME);
var resultIden = await Health.Checks.DbIdentity(DbConfig.DATABASE_NAME);
DbUserTableOk = (resultUser.Status == HealthStatus.Healthy);
DbLogOk = (resultLog.Status == HealthStatus.Healthy);
DbIdentity = (resultIden.Status == HealthStatus.Healthy);
DbAllOk = (DbUserTableOk && DbLogOk && DbIdentity);
}
}
+77
View File
@@ -0,0 +1,77 @@
@using GWMS.UI.Data
@using GWMS.UI.Components
@inject GWMSDataService DataService
@inject MessageService AppMService
@inject IJSRuntime JSRuntime
<div class="row">
<div class="col-3 text-right">
<h3>Simulazione</h3>
</div>
<div class="col-9">
<div class="d-flex justify-content-between">
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">giorni</span>
</div>
<input @bind-value="@numDays" @bind-value:event="oninput" type="number" class="form-control" title="Giorni" />
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">step</span>
</div>
<input @bind-value="@stepMin" @bind-value:event="oninput" type="number" class="form-control" title="Step sim (minuti)" />
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">cons orario max</span>
</div>
<input @bind-value="@maxHourRate" @bind-value:event="oninput" type="number" class="form-control" title="Consumo massimo orario" />
</div>
</div>
<div class="p-2">
<Button id="btnReset" class="btn btn-danger btn-block" Clicked="resetDB">
<span class="oi oi-reload"></span> Regen DB Data
</Button>
</div>
</div>
</div>
</div>
@code {
[Parameter]
public EventCallback<int> evRefresh { get; set; }
[Parameter]
public EventCallback<int> evProcessing { get; set; }
protected int numDays { get; set; } = 7;
protected int stepMin { get; set; } = 30;
protected int maxHourRate { get; set; } = 800;
protected async Task resetDB()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler risimulare il set di dati di Log?"))
return;
reportProcess();
await DataService.RegenDB(numDays, stepMin, maxHourRate);
reportChange();
}
private void reportChange()
{
evRefresh.InvokeAsync(1);
}
private void reportProcess()
{
evProcessing.InvokeAsync(1);
}
}
+223
View File
@@ -0,0 +1,223 @@
@using GWMS.UI.Components
@using GWMS.Data.DatabaseModels
@using System.Security.Claims
@using Microsoft.AspNetCore.Components.Authorization
@using GWMS.UI.Data
@using GWMS.Data.DTO
@using Microsoft.Extensions.Configuration
@inject MessageService AppMService
@inject GWMSDataService DataService
@inject IConfiguration Configuration
<div class="card">
<div class="card-header bg-info text-light">
<b>Modifica</b>
</div>
<div class="card-body small p-1">
<EditForm Model="@_currItem">
<DataAnnotationsValidator />
<div class="row">
<div class="col-9 col-lg-10">
<div class="row mb-2">
<div class="col-3">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-puzzle-piece"></i></span>
</div>
<InputText @bind-Value="_currItem.UserName" class="form-control" title="User Name" />
</div>
</div>
<div class="col-3">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-user"></i></span>
</div>
<InputText @bind-Value="_currItem.Lastname" class="form-control" title="Cognome" />
</div>
</div>
<div class="col-3">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text"><i class="far fa-user"></i></span>
</div>
<InputText @bind-Value="_currItem.Firstname" class="form-control" title="Nome" />
</div>
</div>
<div class="col-2">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="fas fa-user-shield"></i>
</span>
</div>
<select @bind="_currItem.Livello" class="form-control">
@foreach (var itemVal in Enum.GetValues(typeof(GWMS.Data.UserLevel)))
{
<option>@itemVal</option>
}
</select>
</div>
</div>
<div class="col-1">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="switchAtt" title="attivo" @bind="_currItem.IsActive">
<label class="custom-control-label" for="switchAtt">Att</label>
</div>
</div>
</div>
<div class="row">
<div class="col-3">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fas fa-at"></i></span>
</div>
<InputText @bind-Value="_currItem.Email" class="form-control" title="Email" />
</div>
</div>
<div class="col-3">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-gas-pump" aria-hidden="true"></span>
</span>
</div>
<select @bind="_currItem.MaskPlantId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (PlantsList != null)
{
foreach (var item in PlantsList)
{
<option value="@item.PlantId">@item.PlantCode | @item.PlantDesc</option>
}
}
</select>
</div>
</div>
<div class="col-3">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-industry" aria-hidden="true"></span>
</span>
</div>
<select @bind="_currItem.MaskSupplierId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (SuppliersList != null)
{
foreach (var item in SuppliersList)
{
<option value="@item.SupplierId">@item.SupplierCode | @item.SupplierDesc</option>
}
}
</select>
</div>
</div>
<div class="col-3">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-truck-moving" aria-hidden="true"></span>
</span>
</div>
<select @bind="_currItem.MaskTranspId" class="form-control form-control-sm" title="Trasportatore">
<option value="0">--- Tutti ---</option>
@if (TransportersList != null)
{
foreach (var item in TransportersList)
{
<option value="@item.TransporterId">@item.TransporterCode | @item.TransporterDesc</option>
}
}
</select>
</div>
</div>
</div>
</div>
<div class="col-3 col-lg-2">
<div class="mb-2">
<button type="button" class="btn btn-sm btn-outline-success btn-block" value="Save" @onclick="saveUpdate">Save <i class="far fa-save"></i></button>
</div>
<div>
<button type="button" class="btn btn-sm btn-outline-warning btn-block" value="Cancel" @onclick="cancelUpdate">Cancel <i class="fas fa-ban"></i></button>
</div>
</div>
</div>
</EditForm>
</div>
</div>
@code {
private List<PlantDTO> PlantsList;
private List<SupplierModel> SuppliersList;
private List<TransporterModel> TransportersList;
protected UserModel _currItem = new UserModel();
protected int _supplierId { get; set; } = 0;
[Parameter]
public UserModel currItem
{
get
{
return _currItem = null;
}
set
{
_currItem = value;
}
}
[Parameter]
public EventCallback<int> DataReset { get; set; }
[Parameter]
public EventCallback<int> DataUpdated { get; set; }
[Parameter]
public int SupplierId
{
get
{
return _supplierId;
}
set
{
_supplierId = value;
// condiziono visualizzazione...
var pUpd = Task.Run(async () => await ReloadAllData());
pUpd.Wait();
}
}
private async Task saveUpdate()
{
if (_currItem != null)
{
DataService.UserUpdate(_currItem);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("User null!");
}
}
private async Task cancelUpdate()
{
await DataReset.InvokeAsync(0);
}
protected override async Task OnInitializedAsync()
{
await ReloadAllData();
}
protected async Task ReloadAllData()
{
PlantsList = await DataService.PlantsGetAll();
SuppliersList = await DataService.SuppliersGetAll();
TransportersList = await DataService.TransportersGetAll();
}
}
+240
View File
@@ -0,0 +1,240 @@
@using GWMS.UI.Components
@using GWMS.Data.DatabaseModels
@using System.Security.Claims
@using Microsoft.AspNetCore.Components.Authorization
@using GWMS.UI.Data
@using GWMS.Data.DTO
@using Microsoft.Extensions.Configuration
@inject MessageService AppMService
@inject GWMSDataService DataService
@inject IConfiguration Configuration
@inject IJSRuntime JSRuntime
<div class="card">
<div class="card-header bg-info text-light">
<b>Modifica</b>
</div>
<div class="card-body small p-1">
<EditForm Model="@_currItem">
<DataAnnotationsValidator />
<div class="row">
<div class="col-10 col-lg-11">
<div class="row">
<div class="col-4">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="fas fa-gas-pump" aria-hidden="true"></i>
</span>
</div>
<select @bind="_currItem.PlantId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (PlantsList != null)
{
foreach (var item in PlantsList)
{
<option value="@item.PlantId">@item.PlantCode | @item.PlantDesc</option>
}
}
</select>
</div>
</div>
<div class="col-4">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="fas fa-industry" aria-hidden="true"></i>
</span>
</div>
<select @bind="_currItem.SupplierId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (SuppliersList != null)
{
foreach (var item in SuppliersList)
{
<option value="@item.SupplierId">@item.SupplierCode | @item.SupplierDesc</option>
}
}
</select>
</div>
</div>
<div class="col-4">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="fas fa-truck-moving" aria-hidden="true"></i>
</span>
</div>
<select @bind="_currItem.TransporterId" class="form-control form-control-sm" title="Trasportatore">
<option value="0">--- Tutti ---</option>
@if (TransportersList != null)
{
foreach (var item in TransportersList)
{
<option value="@item.TransporterId">@item.TransporterCode | @item.TransporterDesc</option>
}
}
</select>
</div>
</div>
</div>
<div class="row mt-2">
<div class="col-2">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="fas fa-calendar-day"></i>
</span>
</div>
<select @bind="_currItem.DayNum" class="form-control" title="Giorno">
@foreach (var itemVal in Enum.GetValues(typeof(DayOfWeek)))
{
<option>@itemVal</option>
}
</select>
</div>
</div>
<div class="col-2">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="far fa-clock"></i>
</span>
</div>
<select @bind="_currItem.DeliveryHour" class="form-control" title="Ora">
@for (int iHour = 0; iHour < 24; iHour++)
{
<option>@iHour</option>
}
</select>
</div>
</div>
<div class="col-4">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="far fa-sticky-note"></i>
</span>
</div>
<InputText @bind-Value="_currItem.Note" class="form-control" title="Qty" />
</div>
</div>
<div class="col-2">
@if (showSave)
{
<button type="button" class="btn btn-sm btn-outline-success btn-block" value="Save" @onclick="saveUpdate">Save <i class="far fa-save"></i></button>
}
</div>
<div class="col-2">
<button type="button" class="btn btn-sm btn-outline-warning btn-block" value="Cancel" @onclick="cancelUpdate">Cancel <i class="fas fa-ban"></i></button>
</div>
</div>
</div>
<div class="col-2 col-lg-1">
<button type="button" class="btn btn-sm btn-danger btn-block" value="Delete" @onclick="deleteRecord">Delete <i class="fas fa-trash"></i></button>
</div>
</div>
</EditForm>
</div>
</div>
@code {
private List<PlantDTO> PlantsList;
private List<SupplierModel> SuppliersList;
private List<TransporterModel> TransportersList;
protected WeekPlanModel _currItem = new WeekPlanModel();
protected int _supplierId { get; set; } = 0;
[Parameter]
public WeekPlanModel currItem
{
get
{
return _currItem = null;
}
set
{
_currItem = value;
}
}
protected bool showSave
{
get
{
bool answ = (_currItem.PlantId > 0 && _currItem.SupplierId > 0 && _currItem.TransporterId > 0);
return answ;
}
}
[Parameter]
public EventCallback<int> DataReset { get; set; }
[Parameter]
public EventCallback<int> DataUpdated { get; set; }
[Parameter]
public int SupplierId
{
get
{
return _supplierId;
}
set
{
_supplierId = value;
// condiziono visualizzazione...
var pUpd = Task.Run(async () => await ReloadAllData());
pUpd.Wait();
}
}
private async Task saveUpdate()
{
if (_currItem != null)
{
DataService.WeekPlanUpdate(_currItem);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("User null!");
}
}
private async Task deleteRecord()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler eliminare la consegna selezionata??"))
return;
if (_currItem != null)
{
DataService.WeekPlanDelete(_currItem);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("User null!");
}
}
private async Task cancelUpdate()
{
await DataReset.InvokeAsync(0);
}
protected override async Task OnInitializedAsync()
{
await ReloadAllData();
}
protected async Task ReloadAllData()
{
PlantsList = await DataService.PlantsGetAll();
SuppliersList = await DataService.SuppliersGetAll();
TransportersList = await DataService.TransportersGetAll();
}
}
@@ -0,0 +1,75 @@
using GWMS.Data.DTO;
using GWMS.UI.Data;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace GWMS.UI.Controllers
{
[Route("api/PlantData")]
[ApiController]
public class PlantDataController : ControllerBase
{
#region Public Constructors
public PlantDataController(GWMSDataService DataService)
{
_DataService = DataService;
}
#endregion Public Constructors
#region Protected Properties
protected GWMSDataService _DataService { get; set; }
#endregion Protected Properties
#region Public Methods
// DELETE api/PlantData/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
// GET: api/PlantData
[HttpGet]
public async Task<List<PlantDTO>> Get()
{
// serializzo i dati di PlantDTO dell'impianto richiesto
List<PlantDTO> ListRecords = await _DataService.PlantsGetAll();
return ListRecords;
}
// GET api/PlantData/5
[HttpGet("{id}")]
public async Task<PlantDTO> Get(int id)
{
// serializzo i dati di PlantDTO dell'impianto richiesto
var ListRecords = await _DataService.PlantsGetAll();
//seleziono plant...
var SelRecords = ListRecords.Where(X => X.PlantId == id).FirstOrDefault();
return SelRecords;
}
// POST api/PlantData
[HttpPost]
public void Post([FromBody] string value)
{
}
// PUT api/PlantData/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
#endregion Public Methods
}
}
+99
View File
@@ -0,0 +1,99 @@
using GWMS.Data.DatabaseModels;
using GWMS.UI.Data;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace GWMS.UI.Controllers
{
[Route("api/PlantLog")]
[ApiController]
public class PlantLogController : ControllerBase
{
#region Public Constructors
public PlantLogController(GWMSDataService DataService)
{
_DataService = DataService;
}
#endregion Public Constructors
#region Protected Properties
protected GWMSDataService _DataService { get; set; }
#endregion Protected Properties
#region Public Methods
// DELETE api/PlantLog/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
// GET: api/PlantLog
[HttpGet]
public async Task<List<PlantLogModel>> Get()
{
// arrotondo ai 5 minuti
DateTime adesso = DateTime.Now;
int dayHour = adesso.Hour;
int dayMin = (adesso.Minute / 5) * 5;
DateTime limite = DateTime.Today.AddHours(dayHour).AddMinutes(dayMin);
// serializzo i dati di PlantDTO dell'impianto richiesto
var ListRecords = await _DataService.PlantLogGetFilt(0, limite, 100);
return ListRecords;
}
// GET api/PlantLog/5
[HttpGet("{id}")]
public async Task<List<PlantLogModel>> Get(int id)
{
// arrotondo ai 5 minuti
DateTime adesso = DateTime.Now;
int dayHour = adesso.Hour;
int dayMin = (adesso.Minute / 5) * 5;
DateTime limite = DateTime.Today.AddHours(dayHour).AddMinutes(dayMin);
// serializzo i dati di PlantDTO dell'impianto richiesto
var ListRecords = await _DataService.PlantLogGetFilt(id, limite, 100);
return ListRecords;
}
// POST api/PlantLog
[HttpPost]
public ActionResult Post([FromBody] List<PlantLogModel> newItems)
{
bool fatto = false;
// verifico ci sia valore
if (newItems != null)
{
fatto = _DataService.PlantLogInsert(newItems);
}
if (fatto)
{
return Ok();
}
else
{
return BadRequest();
}
}
// PUT api/PlantLog/5
[HttpPut("{id}")]
public void Put(int id, [FromBody] string value)
{
}
#endregion Public Methods
}
}
+17
View File
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GWMS.UI.Data
{
public class ChartTS
{
#region Public Properties
public DateTime TLabel { get; set; } = DateTime.Now;
public double Value { get; set; } = 0;
#endregion Public Properties
}
}
+378
View File
@@ -0,0 +1,378 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Configuration;
using System.Text;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using GWMS.Data;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Memory;
using Newtonsoft.Json;
using System.Diagnostics;
using NLog;
using GWMS.Data.DTO;
using GWMS.Data.DatabaseModels;
namespace GWMS.UI.Data
{
public class GWMSDataService
{
#region Private Fields
private static IConfiguration _configuration;
private static ILogger<GWMSDataService> _logger;
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private readonly IDistributedCache distributedCache;
private readonly IMemoryCache memoryCache;
/// <summary>
/// Durata assoluta massima della cache IN SECONDI
/// </summary>
private int chAbsExp = 60 * 5;
/// <summary>
/// Durata della cache IN SECONDI in modalità inattiva (non acceduta) prima di venire rimossa
/// NON estende oltre il tempo massimo di validità della cache (chAbsExp)
/// </summary>
private int chSliExp = 60 * 1;
#endregion Private Fields
#region Protected Fields
protected static string connStringBBM = "";
#endregion Protected Fields
#region Public Fields
public static GWMS.Data.Controllers.GWMSController dbController;
#endregion Public Fields
#region Public Constructors
public GWMSDataService(IConfiguration configuration, ILogger<GWMSDataService> logger, IMemoryCache memoryCache, IDistributedCache distributedCache)
{
_logger = logger;
_configuration = configuration;
// conf cache
this.memoryCache = memoryCache;
this.distributedCache = distributedCache;
// conf DB
string connStr = _configuration.GetConnectionString("GWMS.Data");
if (string.IsNullOrEmpty(connStr))
{
_logger.LogError("ConnString empty!");
}
else
{
dbController = new GWMS.Data.Controllers.GWMSController(configuration);
StringBuilder sb = new StringBuilder();
sb.AppendLine($"DbController OK");
_logger.LogInformation(sb.ToString());
}
}
#endregion Public Constructors
#region Private Methods
private DistributedCacheEntryOptions cacheOpt(bool fastCache)
{
var numSecAbsExp = fastCache ? chAbsExp : chAbsExp * 10;
var numSecSliExp = fastCache ? chSliExp : chSliExp * 10;
return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp));
}
#endregion Private Methods
#region Protected Methods
protected string getCacheKey(string TableName, SelectOrderData CurrFilter)
{
string answ = $"{TableName}:P_{CurrFilter.PlantId:00}:S_{CurrFilter.SupplierId:00}:T_{CurrFilter.TransporterId:00}:D_{CurrFilter.DateStart:yyyyMMddHHmm}_{CurrFilter.DateEnd:yyyyMMddHHmm}";
return answ;
}
#endregion Protected Methods
#region Public Methods
public async Task<List<GWMS.Data.DatabaseModels.ConfigModel>> ConfigGetAll()
{
//return Task.FromResult(dbController.ActionsGetAll());
List<GWMS.Data.DatabaseModels.ConfigModel> dbResult = new List<GWMS.Data.DatabaseModels.ConfigModel>();
string cacheKey = "DATA:CONFIG";
string rawData;
var redisDataList = await distributedCache.GetAsync(cacheKey);
if (redisDataList != null)
{
rawData = Encoding.UTF8.GetString(redisDataList);
dbResult = JsonConvert.DeserializeObject<List<GWMS.Data.DatabaseModels.ConfigModel>>(rawData);
}
else
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbController.GetConfig();
rawData = JsonConvert.SerializeObject(dbResult);
redisDataList = Encoding.UTF8.GetBytes(rawData);
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(false));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuata lettura da DB + caching per ConfigGetAll: {ts.TotalMilliseconds} ms");
}
return await Task.FromResult(dbResult);
}
public async Task<bool> HasPlantLog()
{
return await Task.FromResult(dbController.HasPlantLog());
}
public async Task<List<GWMS.Data.DatabaseModels.ItemModel>> ItemsGetAll()
{
//return Task.FromResult(dbController.ActionsGetAll());
List<GWMS.Data.DatabaseModels.ItemModel> dbResult = new List<GWMS.Data.DatabaseModels.ItemModel>();
string cacheKey = "DATA:ITEMS";
string rawData;
var redisDataList = await distributedCache.GetAsync(cacheKey);
if (redisDataList != null)
{
rawData = Encoding.UTF8.GetString(redisDataList);
dbResult = JsonConvert.DeserializeObject<List<GWMS.Data.DatabaseModels.ItemModel>>(rawData);
}
else
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbController.GetItems();
rawData = JsonConvert.SerializeObject(dbResult);
redisDataList = Encoding.UTF8.GetBytes(rawData);
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(false));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuata lettura da DB + caching per ItemsGetAll: {ts.TotalMilliseconds} ms");
}
return await Task.FromResult(dbResult);
}
public async Task<List<OrderModel>> OrdersGetFilt(SelectOrderData CurrFilter)
{
List<OrderModel> dbResult = new List<OrderModel>();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbController.GetOrdersFilt(CurrFilter.PlantId, CurrFilter.SupplierId, CurrFilter.TransporterId, CurrFilter.DateStart, CurrFilter.DateEnd);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuata lettura da DB per OrdersGetFilt: {ts.TotalMilliseconds} ms");
return await Task.FromResult(dbResult);
}
public void OrderUpdate(OrderModel currItem)
{
try
{
dbController.OrderUpdate(currItem);
}
catch
{
}
}
public async Task<List<PlantLogModel>> PlantLogGetFilt(int PlantId, DateTime DtMaxDate, int numRec)
{
List<PlantLogModel> dbResult = new List<PlantLogModel>();
string cacheKey = $"DATA:PLANTS:LOGS:{PlantId}:{DtMaxDate:yyyyMMddHHmm}:{numRec}";
string rawData;
var redisDataList = await distributedCache.GetAsync(cacheKey);
if (redisDataList != null)
{
rawData = Encoding.UTF8.GetString(redisDataList);
dbResult = JsonConvert.DeserializeObject<List<PlantLogModel>>(rawData);
}
else
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbController.GetPlantLog(PlantId, DtMaxDate, numRec);
rawData = JsonConvert.SerializeObject(dbResult);
redisDataList = Encoding.UTF8.GetBytes(rawData);
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuata lettura da DB + caching per PlantLogGetFilt: {ts.TotalMilliseconds} ms");
}
return await Task.FromResult(dbResult);
}
public bool PlantLogInsert(List<PlantLogModel> newItems)
{
return dbController.PlantLogInsertNew(newItems);
}
public async Task<List<PlantDTO>> PlantsGetAll()
{
List<PlantDTO> dbResult = new List<PlantDTO>();
string cacheKey = "DATA:PLANTS:ListDTO";
string rawData;
var redisDataList = await distributedCache.GetAsync(cacheKey);
if (redisDataList != null)
{
rawData = Encoding.UTF8.GetString(redisDataList);
dbResult = JsonConvert.DeserializeObject<List<PlantDTO>>(rawData);
}
else
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbController.GetPlantsDTO();
rawData = JsonConvert.SerializeObject(dbResult);
redisDataList = Encoding.UTF8.GetBytes(rawData);
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuata lettura da DB + caching per PlantsGetAll: {ts.TotalMilliseconds} ms");
}
return await Task.FromResult(dbResult);
}
public async Task<bool> RegenDB(int numDays, int stepMin = 30, int maxHourRate = 800)
{
return await Task.FromResult(dbController.RegenDB(1, numDays, stepMin, maxHourRate));
}
public void rollBackEdit(object item)
{
dbController.rollBackEntity(item);
}
public async Task<List<SupplierModel>> SuppliersGetAll()
{
List<SupplierModel> dbResult = new List<SupplierModel>();
string cacheKey = "DATA:SUPPL:List";
string rawData;
var redisDataList = await distributedCache.GetAsync(cacheKey);
if (redisDataList != null)
{
rawData = Encoding.UTF8.GetString(redisDataList);
dbResult = JsonConvert.DeserializeObject<List<SupplierModel>>(rawData);
}
else
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbController.GetSuppliers();
rawData = JsonConvert.SerializeObject(dbResult);
redisDataList = Encoding.UTF8.GetBytes(rawData);
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuata lettura da DB + caching per PlantsGetAll: {ts.TotalMilliseconds} ms");
}
return await Task.FromResult(dbResult);
}
public async Task<List<TransporterModel>> TransportersGetAll()
{
List<TransporterModel> dbResult = new List<TransporterModel>();
string cacheKey = $"DATA:TRANSP:List";
string rawData;
var redisDataList = await distributedCache.GetAsync(cacheKey);
if (redisDataList != null)
{
rawData = Encoding.UTF8.GetString(redisDataList);
dbResult = JsonConvert.DeserializeObject<List<TransporterModel>>(rawData);
}
else
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbController.GetTransporters();
rawData = JsonConvert.SerializeObject(dbResult);
redisDataList = Encoding.UTF8.GetBytes(rawData);
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true));
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuata lettura da DB + caching per PlantsGetAll: {ts.TotalMilliseconds} ms");
}
return await Task.FromResult(dbResult);
}
public async Task<List<UserModel>> UsersGetFilt(UserLevel UsrLvl, int PlantId, int SupplierId, int TransporterId)
{
List<UserModel> dbResult = new List<UserModel>();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbController.GetUsersFilt(UsrLvl, PlantId, SupplierId, TransporterId);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuata lettura da DB per UsersGetFilt: {ts.TotalMilliseconds} ms");
return await Task.FromResult(dbResult);
}
public void UserUpdate(UserModel currItem)
{
try
{
dbController.UserUpdate(currItem);
}
catch
{
}
}
public async void WeekPlanDelete(WeekPlanModel currItem)
{
try
{
//dbController.ResetController();
dbController.WeekPlanDelete(currItem);
string cacheKey = $"DATA:WEEKPLAN:List";
var redisDataList = Encoding.UTF8.GetBytes("");
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true));
}
catch
{
}
}
public async Task<List<WeekPlanModel>> WeekPlanGet()
{
List<WeekPlanModel> dbResult = new List<WeekPlanModel>();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbController.GetWeekPlan();
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Info($"Effettuata lettura da DB + caching per WeekPlanGet: {ts.TotalMilliseconds} ms");
return await Task.FromResult(dbResult);
}
public async void WeekPlanUpdate(WeekPlanModel currItem)
{
try
{
//dbController.ResetController();
dbController.WeekPlanUpdate(currItem);
string cacheKey = $"DATA:WEEKPLAN:List";
var redisDataList = Encoding.UTF8.GetBytes("");
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true));
}
catch
{
}
}
#endregion Public Methods
}
}
+1
View File
@@ -55,6 +55,7 @@ namespace GWMS.UI.Data
public SelectData KRE_Filter { get; set; } = SelectData.Init(5, 7);
public SelectData ODL_Filter { get; set; } = SelectData.Init(5, 7);
public SelectData OEE_Filter { get; set; } = SelectData.Init(5, 7);
public SelectOrderData Order_Filter { get; set; } = SelectOrderData.Init(5, 7);
public string PageIcon
{
-12
View File
@@ -9,12 +9,8 @@ namespace GWMS.UI.Data
{
#region Public Properties
public string CodArticolo { get; set; } = "*";
public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1);
public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7);
public string IdxMacchina { get; set; } = "*";
public int IdxOdl { get; set; } = -999;
public string KeyRichiesta { get; set; } = "*";
#endregion Public Properties
@@ -44,18 +40,10 @@ namespace GWMS.UI.Data
if (!(obj is SelectData item))
return false;
if (CodArticolo != item.CodArticolo)
return false;
if (DateEnd != item.DateEnd)
return false;
if (DateStart != item.DateStart)
return false;
if (IdxMacchina != item.IdxMacchina)
return false;
if (IdxOdl != item.IdxOdl)
return false;
if (KeyRichiesta != item.KeyRichiesta)
return false;
return true;
}
+54
View File
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GWMS.UI.Data
{
public class SelectOrderData : SelectData
{
#region Public Properties
public int PlantId { get; set; } = 0;
public int SupplierId { get; set; } = 0;
public int TransporterId { get; set; } = 0;
#endregion Public Properties
#region Public Methods
/// <summary>
/// Inizializzazione con periodo e arrotondamento
/// </summary>
/// <param name="minRound"></param>
/// <param name="numDayPrev"></param>
/// <returns></returns>
public static new SelectOrderData Init(int minRound, int numDayPrev)
{
var selD = SelectData.Init(minRound, numDayPrev);
return new SelectOrderData() { DateStart = selD.DateStart, DateEnd = selD.DateEnd };
}
public override bool Equals(object obj)
{
if (!(obj is SelectOrderData item))
return false;
if (PlantId != item.PlantId)
return false;
if (SupplierId != item.SupplierId)
return false;
if (TransporterId != item.TransporterId)
return false;
return ((SelectData)this).Equals((SelectData)obj);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
}
+36 -5
View File
@@ -4,27 +4,58 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS02.pubxml" />
<_WebToolingArtifacts Remove="Properties\PublishProfiles\IISProfile.pubxml" />
<_WebToolingArtifacts Remove="Properties\PublishProfiles\W2019-IIS-DEV.pubxml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GWMS.Data\GWMS.Data.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Blazorise" Version="0.9.3.6" />
<PackageReference Include="Blazorise.Bootstrap" Version="0.9.3.6" />
<PackageReference Include="Blazorise.Charts" Version="0.9.3.6" />
<PackageReference Include="Blazorise.Components" Version="0.9.3.6" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="0.9.3.6" />
<PackageReference Include="AspNetCore.HealthChecks.MySql" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Redis" Version="5.0.2" />
<PackageReference Include="AspNetCore.HealthChecks.System" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="5.0.1" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="5.0.1" />
<PackageReference Include="Blazorise" Version="0.9.3.7" />
<PackageReference Include="Blazorise.Bootstrap" Version="0.9.3.7" />
<PackageReference Include="Blazorise.Charts" Version="0.9.3.7" />
<PackageReference Include="Blazorise.Components" Version="0.9.3.7" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="0.9.3.7" />
<PackageReference Include="ElmahCore" Version="2.0.6" />
<PackageReference Include="ElmahCore.Common" Version="2.0.6" />
<PackageReference Include="ElmahCore.Sql" Version="2.0.6" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.7" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="5.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="5.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.12.0" />
<PackageReference Include="Quartz" Version="3.3.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="Services\" />
</ItemGroup>
<ItemGroup>
<Compile Update="Pages\Transporters - Copy - Copy.razor.cs">
<DependentUpon>Transporters - Copy.razor.cs</DependentUpon>
</Compile>
<Compile Update="Pages\Transporters - Copy.razor.cs">
<DependentUpon>Transporters.razor.cs</DependentUpon>
</Compile>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\post-build.ps1 -ProjectDir $(ProjectDir) -ProjectPath $(ProjectPath)" />
</Target>
+159
View File
@@ -0,0 +1,159 @@
using GWMS.Data;
using GWMS.Data.DatabaseModels;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using NLog;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Net.NetworkInformation;
using System.Threading.Tasks;
namespace GWMS.UI.Health
{
public class Checks
{
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Public Methods
public static async Task<HealthCheckResult> DbIdentity(string dbName)
{
using (var appDb = new UserIdentityDbContext())
{
string description = "Try check Table IdentityUsers";
List<TableCount> recordList = new List<TableCount>();
var healthCheckData = new Dictionary<string, object>();
try
{
string sqlQuery = $"SELECT 'AspNetUsers' AS TableName, COUNT(*) AS Count FROM information_schema.tables WHERE table_schema = '{dbName}' AND table_name = 'AspNetUsers' LIMIT 1;";
var table = await Task.FromResult(appDb.DbSetCounts.FromSqlRaw(sqlQuery).ToList());
// provo a controllare se ho tab utenti
if (table != null && table.Count > 0)
{
// controllo valore
if (table[0].Count > 0)
{
description = $"Check IdentityUsers table, found!";
return HealthCheckResult.Healthy(description, healthCheckData);
}
}
}
catch (Exception exc)
{
Log.Error(exc, "Errore in esecuzione DbIdentity");
}
return HealthCheckResult.Degraded(description + $" {dbName}", null, healthCheckData);
}
}
public static async Task<HealthCheckResult> DbPlantLogTable(string dbName)
{
using (var appDb = new GWMSContext())
{
string description = "Try check Table PlantLog";
List<GWMS.Data.DatabaseModels.PlantLogModel> recordList = new List<GWMS.Data.DatabaseModels.PlantLogModel>();
var healthCheckData = new Dictionary<string, object>();
try
{
// provo a controllare se ho tab utenti
recordList = await Task.FromResult(appDb.DbSetPlantLog.ToList()).ConfigureAwait(false);
if (recordList.Count > 0)
{
description = $"Check PlantLog table, found {recordList.Count} records";
return HealthCheckResult.Healthy(description, healthCheckData);
}
}
catch (Exception exc)
{
Log.Error(exc, "Errore in esecuzione DbPlantLogTable");
}
return HealthCheckResult.Degraded(description + $" {dbName}", null, healthCheckData);
}
}
public static async Task<HealthCheckResult> DbUserApp(string dbName)
{
using (var appDb = new GWMSContext())
{
string description = "Try check Table AppUser";
List<GWMS.Data.DatabaseModels.UserModel> userList = new List<GWMS.Data.DatabaseModels.UserModel>();
var healthCheckData = new Dictionary<string, object>();
try
{
// provo a controllare se ho tab utenti
userList = await Task.FromResult(appDb.DbSetUser.ToList());
//userList = await Task.FromResult(appDb.DbSetUser.ToList()).ConfigureAwait(false);
if (userList.Count > 0)
{
description = $"Check AppUser table, found {userList.Count} records";
return HealthCheckResult.Healthy(description, healthCheckData);
}
}
catch (Exception exc)
{
Log.Error(exc, "Errore in esecuzione DbUserApp");
}
return HealthCheckResult.Degraded(description + $" {dbName}", null, healthCheckData);
}
}
public static async Task<HealthCheckResult> DbUserRoot(string dbName)
{
using (var adminDb = new AdminContext())
{
string description = "Try check MySql User table";
List<GWMS.Data.DatabaseModels.UserPriv> userList = new List<GWMS.Data.DatabaseModels.UserPriv>();
var healthCheckData = new Dictionary<string, object>();
try
{
// provo a controllare se ho tab utenti
userList = await Task.FromResult(adminDb.UserList.ToList()).ConfigureAwait(false);
if (userList.Count > 0)
{
description = $"Check MySql User table, found {userList.Count} records";
return HealthCheckResult.Healthy(description, healthCheckData);
}
}
catch (Exception exc)
{
Log.Error(exc, "Errore in esecuzione DbUserRoot");
}
return HealthCheckResult.Unhealthy(description + $" {dbName}", null, healthCheckData);
}
}
public static async Task<HealthCheckResult> PingCheck(string hostName)
{
using (var thePing = new Ping())
{
var pingResult = await thePing.SendPingAsync(hostName);
var description = $"Ping to {hostName}";
var healthCheckData = new Dictionary<string, object>();
healthCheckData.Add("RoundTripMS", pingResult.RoundtripTime);
healthCheckData.Add("ActualIPAddress", pingResult.Address.ToString());
if (pingResult.Status == IPStatus.Success)
{
description += $" - {pingResult.RoundtripTime}ms";
return HealthCheckResult.Healthy(description, healthCheckData);
}
return HealthCheckResult.Unhealthy(description + $" {hostName}", null, healthCheckData);
}
}
#endregion Public Methods
}
}
+46
View File
@@ -0,0 +1,46 @@
@page "/GasStation"
@using Blazorise.Components
@using GWMS.UI.Components
<div class="card">
<div class="card-header table-primary mb-0">
<div class="row">
<div class="col-12">
<div class="row">
<div class="col-9 col-lg-8 h3">
Registrazione
</div>
<div class="col-3 col-lg-2">
<button class="btn btn-sm btn-block btn-secondary" @onclick="() => ToggleBCode()"><i class="fas fa-qrcode"></i> <i class="fas fa-chevron-down"></i></button>
</div>
</div>
</div>
<div class="col-12 text-right">
</div>
</div>
</div>
<div class="card-body p-1">
<div class="row small">
<div class="col-12">
<b>Acquisizione barcode</b>
<div class="form-group">
<input class="form-control" />
</div>
</div>
</div>
<p class="small">
Work IN progress, links:
<ul>
<li>https://github.com/sabitertan/BlazorBarcodeScanner</li>
<li>https://github.com/tallichet/ZXingBlazor</li>
<li>https://github.com/LorsSilvermort/BlazorBarcodeReader</li>
<li>https://www.bing.com/search?q=blazor+server+qrcode+scanner&qs=n&form=QBRE&sp=-1&pq=blazor+server+qrcode+scanner&sc=0-28&sk=&cvid=D827470C199B47BDB39F277EFC72A266</li>
</ul>
</p>
</div>
<div class="card-footer p-1">
</div>
</div>
+307
View File
@@ -0,0 +1,307 @@
using GWMS.Data.DatabaseModels;
using GWMS.Data.DTO;
using GWMS.UI.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GWMS.UI.Pages
{
public partial class GasStation : ComponentBase, IDisposable
{
#region Private Fields
private OrderModel currRecord = null;
private List<OrderModel> ListRecords;
private List<PlantDTO> PlantsList;
private List<OrderModel> SearchRecords;
private List<TransporterModel> TransportersList;
#endregion Private Fields
#region Private Properties
private int _currPage { get; set; } = 1;
private int _numRecord { get; set; } = 10;
private int currPage
{
get => _currPage;
set
{
if (_currPage != value)
{
_currPage = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool isLoading { get; set; } = false;
private int numRecord
{
get => _numRecord;
set
{
if (_numRecord != value)
{
_numRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelPlantId
{
get
{
int answ = 0;
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.PlantId;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.PlantId.Equals(value))
{
MessageService.Order_Filter.PlantId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelTranspId
{
get
{
int answ = 0;
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.TransporterId;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.TransporterId.Equals(value))
{
MessageService.Order_Filter.TransporterId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool ShowCharts { get; set; } = false;
#endregion Private Properties
#region Protected Properties
[Inject]
protected GWMSDataService DataService { get; set; }
protected DateTime DateEnd
{
get
{
DateTime answ = DateTime.Today.AddDays(1);
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.DateEnd;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.DateEnd.Equals(value))
{
MessageService.Order_Filter.DateEnd = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
protected DateTime DateStart
{
get
{
DateTime answ = DateTime.Today.AddDays(-1);
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.DateStart;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.DateStart.Equals(value))
{
MessageService.Order_Filter.DateStart = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[Inject]
protected MessageService MessageService { get; set; }
[Inject]
protected NavigationManager NavManager { get; set; }
protected bool showBcodeScan { get; set; } = false;
protected int totalCount
{
get
{
int answ = 0;
if (SearchRecords != null)
{
answ = SearchRecords.Count;
}
return answ;
}
}
#endregion Protected Properties
#region Private Methods
private void OnDateEndChanged(DateTime? date)
{
DateEnd = (DateTime)date;
}
private void OnDateStartChanged(DateTime? date)
{
DateStart = (DateTime)date;
}
private async Task ReloadData()
{
isLoading = true;
SearchRecords = await DataService.OrdersGetFilt(MessageService.Order_Filter);
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
isLoading = false;
}
#endregion Private Methods
#region Protected Methods
protected void Edit(OrderModel selRecord)
{
currRecord = selRecord;
}
protected void ForceReload(int newNum)
{
numRecord = newNum;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
}
protected override async Task OnInitializedAsync()
{
MessageService.ShowSearch = false;
MessageService.PageName = "Fornitore";
MessageService.PageIcon = "fas fa-industry pr-2";
MessageService.EA_SearchUpdated += OnSeachUpdated;
await ReloadAllData();
}
protected async Task ReloadAllData()
{
PlantsList = await DataService.PlantsGetAll();
TransportersList = await DataService.TransportersGetAll();
await ReloadData();
}
protected void ResetData()
{
DataService.rollBackEdit(currRecord);
currRecord = null;
}
protected async Task ResetFilter(SelectOrderData newFilter)
{
currRecord = null;
SearchRecords = null;
ListRecords = null;
MessageService.Order_Filter = SelectOrderData.Init(5, 7);
await ReloadAllData();
}
protected void Select(OrderModel selRecord)
{
// applico filtro da selezione
currRecord = selRecord;
}
protected void ToggleBCode()
{
showBcodeScan = !showBcodeScan;
}
protected async Task UpdateData()
{
currRecord = null;
await ReloadData();
}
#endregion Protected Methods
#region Public Methods
public string checkSelect(int OrderId)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.OrderId == OrderId) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
public void Dispose()
{
MessageService.EA_SearchUpdated -= OnSeachUpdated;
}
public async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
Task task = UpdateData();
StateHasChanged();
});
}
#endregion Public Methods
}
}
+51 -3
View File
@@ -1,7 +1,55 @@
@page "/"
<h1>Hello, world!</h1>
@using GWMS.Data
@using GWMS.UI.Data
@using GWMS.UI.Components
Welcome to your new app.
@inject GWMSDataService DataService
@inject MessageService AppMService
<SurveyPrompt Title="How is Blazor working for you?" />
<div class="jumbotron">
<div class="row">
<div class="col-12 col-lg-4">
<h1>GWMS</h1>
<div>
GAS WareHouse Management System
</div>
</div>
<div class="col-12 col-lg-8 text-right">
<div class="text-light display-4">
<span class="fas fa-home" aria-hidden="true"></span> | <span class="fas fa-gas-pump" aria-hidden="true"></span> | <span class="fas fa-file-invoice" aria-hidden="true"></span> | <span class="fas fa-industry" aria-hidden="true"></span> | <span class="fas fa-truck-moving" aria-hidden="true"></span> | <span class="fas fa-wrench" aria-hidden="true"></span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-12 my-5">
<SetupDiagnostics></SetupDiagnostics>
</div>
<div class="col-12 text-center">
<img class="img-fluid mb-3" src="./img/LogoPizzaferri.jpg" />
<h3>
Sistema di gestione e pianificazione logistica impianti distribuzione metano
</h3>
</div>
<div class="col-12 text-center mt-5">
<div class="col-4"></div>
<div class="col-4"></div>
<div class="col-4 badge badge-pill badge-dark">
<h3>
<a class="text-light" href="https://www.egalware.com/" target="_blank">powered by&nbsp;EgalWare <img width="32" class="img-fluid" src="img/LogoBlu.svg" /></a>
</h3>
</div>
</div>
</div>
@code
{
protected override void OnInitialized()
{
AppMService.ShowSearch = false;
AppMService.PageName = "Home";
AppMService.PageIcon = "fas fa-home pr-2";
}
}
+133
View File
@@ -0,0 +1,133 @@
@page "/Orders"
@using Blazorise.Components
@using GWMS.UI.Components
<div class="card">
<div class="card-header table-primary h3">
<div class="row">
<div class="col-3 h3">
Elenco Ordini
</div>
<div class="col-9 text-right">
<div class="d-flex justify-content-between">
<div class="p-2">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">inizio:</span>
<DateEdit class="form-control form-control-sm" TValue="DateTime?" Date="@DateStart" DateChanged="@OnDateStartChanged" />
</div>
</div>
</div>
<div class="p-2">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">fine:</span>
<DateEdit class="form-control form-control-sm" TValue="DateTime?" Date="@DateEnd" DateChanged="@OnDateEndChanged" />
</div>
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-gas-pump" aria-hidden="true"></span>
</span>
</div>
<select @bind="@SelPlantId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (PlantsList != null)
{
foreach (var item in PlantsList)
{
<option value="@item.PlantId">@item.PlantCode | @item.PlantDesc</option>
}
}
</select>
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-industry" aria-hidden="true"></span>
</span>
</div>
<select @bind="@SelSupplierId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (SuppliersList != null)
{
foreach (var item in SuppliersList)
{
<option value="@item.SupplierId">@item.SupplierCode | @item.SupplierDesc</option>
}
}
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-body p-1">
@if (currRecord != null)
{
<OrderAdminEditor currItem="@currRecord" DataReset="ResetData" DataUpdated="UpdateData" SupplierId="@currRecord.SupplierId"></OrderAdminEditor>
}
@if (ListRecords == null)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
}
else
{
<div class="row">
<div class="col-12">
<table class="table table-sm table-striped">
<thead>
<tr>
<th></th>
<th>Impianto</th>
<th>Data Ordine</th>
<th>Ordine</th>
<th class="text-right">Fornitore</th>
<th class="text-right">Qta</th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecords)
{
<tr class="@checkSelect(@record.OrderId)">
<td class="text-nowrap"><button class="btn btn-sm btn-info" @onclick="() => Edit(record)"><span class="oi oi-pencil"></span></button></td>
<td>
<div>@record.Plant.PlantCode</div>
<div class="small">@record.Plant.PlantDesc</div>
</td>
<td>
<div>@record.DtOrder.ToString("yyyy.MM.dd")</div>
<div class="small">@record.DtOrder.ToString("ddd HH:mm.ss")</div>
</td>
<td>@record.OrderCode | @record.OrderDesc</td>
<td class="text-right">
<div class="row">
<div class="col">[@record.Supplier.SupplierCode]</div>
<div class="col text-right">@record.Supplier.SupplierDesc</div>
</div>
<div class="small">@record.Transporter.TransporterCode | @record.Transporter.TransporterDesc</div>
</td>
<td class="text-right">@record.OrderQty.ToString("N0")</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
</div>
<div class="card-footer p-1">
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
</div>
</div>
+300
View File
@@ -0,0 +1,300 @@
using GWMS.Data.DatabaseModels;
using GWMS.Data.DTO;
using GWMS.UI.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GWMS.UI.Pages
{
public partial class Orders : ComponentBase, IDisposable
{
#region Private Fields
private OrderModel currRecord = null;
private List<OrderModel> ListRecords;
private List<PlantDTO> PlantsList;
private List<OrderModel> SearchRecords;
private List<SupplierModel> SuppliersList;
#endregion Private Fields
#region Private Properties
private int _currPage { get; set; } = 1;
private int _numRecord { get; set; } = 10;
private int currPage
{
get => _currPage;
set
{
if (_currPage != value)
{
_currPage = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool isLoading { get; set; } = false;
private int numRecord
{
get => _numRecord;
set
{
if (_numRecord != value)
{
_numRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelPlantId
{
get
{
int answ = 0;
if (AppMService.Order_Filter != null)
{
answ = AppMService.Order_Filter.PlantId;
}
return answ;
}
set
{
if (!AppMService.Order_Filter.PlantId.Equals(value))
{
AppMService.Order_Filter.PlantId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelSupplierId
{
get
{
int answ = 0;
if (AppMService.Order_Filter != null)
{
answ = AppMService.Order_Filter.SupplierId;
}
return answ;
}
set
{
if (!AppMService.Order_Filter.SupplierId.Equals(value))
{
AppMService.Order_Filter.SupplierId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool ShowCharts { get; set; } = false;
#endregion Private Properties
#region Protected Properties
[Inject]
protected MessageService AppMService { get; set; }
[Inject]
protected GWMSDataService DataService { get; set; }
protected DateTime DateEnd
{
get
{
DateTime answ = DateTime.Today.AddDays(1);
if (AppMService.Order_Filter != null)
{
answ = AppMService.Order_Filter.DateEnd;
}
return answ;
}
set
{
if (!AppMService.Order_Filter.DateEnd.Equals(value))
{
AppMService.Order_Filter.DateEnd = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
protected DateTime DateStart
{
get
{
DateTime answ = DateTime.Today.AddDays(-1);
if (AppMService.Order_Filter != null)
{
answ = AppMService.Order_Filter.DateStart;
}
return answ;
}
set
{
if (!AppMService.Order_Filter.DateStart.Equals(value))
{
AppMService.Order_Filter.DateStart = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[Inject]
protected NavigationManager NavManager { get; set; }
protected int totalCount
{
get
{
int answ = 0;
if (SearchRecords != null)
{
answ = SearchRecords.Count;
}
return answ;
}
}
#endregion Protected Properties
#region Private Methods
private void OnDateEndChanged(DateTime? date)
{
DateEnd = (DateTime)date;
}
private void OnDateStartChanged(DateTime? date)
{
DateStart = (DateTime)date;
}
private async Task ReloadData()
{
isLoading = true;
SearchRecords = await DataService.OrdersGetFilt(AppMService.Order_Filter);
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
isLoading = false;
}
#endregion Private Methods
#region Protected Methods
protected void Edit(OrderModel selRecord)
{
currRecord = selRecord;
}
protected void ForceReload(int newNum)
{
numRecord = newNum;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
}
protected override async Task OnInitializedAsync()
{
AppMService.ShowSearch = false;
AppMService.PageName = "Ordini";
AppMService.PageIcon = "fas fa-file-invoice pr-2";
AppMService.EA_SearchUpdated += OnSeachUpdated;
await ReloadAllData();
}
protected async Task ReloadAllData()
{
PlantsList = await DataService.PlantsGetAll();
SuppliersList = await DataService.SuppliersGetAll();
await ReloadData();
}
protected void ResetData()
{
DataService.rollBackEdit(currRecord);
currRecord = null;
}
protected async Task ResetFilter(SelectOrderData newFilter)
{
currRecord = null;
SearchRecords = null;
ListRecords = null;
AppMService.Order_Filter = SelectOrderData.Init(5, 7);
await ReloadAllData();
}
protected void Select(OrderModel selRecord)
{
// applico filtro da selezione
currRecord = selRecord;
}
protected async Task UpdateData()
{
currRecord = null;
await ReloadData();
}
#endregion Protected Methods
#region Public Methods
public string checkSelect(int OrderId)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.OrderId == OrderId) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
public void Dispose()
{
AppMService.EA_SearchUpdated -= OnSeachUpdated;
}
public async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
Task task = UpdateData();
StateHasChanged();
});
}
#endregion Public Methods
}
}
+87
View File
@@ -0,0 +1,87 @@
@page "/Parameters"
@using GWMS.UI.Data
@using GWMS.UI.Components
@inject GWMSDataService DataService
@inject MessageService AppMService
@inject IJSRuntime JSRuntime
<div class="card">
<div class="card-header table-primary h3">
<h2>Setup Parametri</h2>
</div>
<div class="card-body">
<div class="row">
<div class="col-12">
@if (processRunning)
{
<LoadingData></LoadingData>
}
</div>
<div class="col-12">
@*<div class="d-flex justify-content-between">
<div class="p-2">
<h4>Simulazione</h4>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">giorni</span>
</div>
<input @bind-value="@numDays" @bind-value:event="oninput" type="number" class="form-control" title="Giorni" />
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">step</span>
</div>
<input @bind-value="@stepMin" @bind-value:event="oninput" type="number" class="form-control" title="Step sim (minuti)" />
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">cons orario max</span>
</div>
<input @bind-value="@maxHourRate" @bind-value:event="oninput" type="number" class="form-control" title="Consumo massimo orario" />
</div>
</div>
<div class="p-2">
<Button id="btnReset" class="btn btn-danger btn-block" Clicked="resetDB">
<span class="oi oi-reload"></span> Regen DB Data
</Button>
</div>
</div>*@
<SetupSim />
</div>
</div>
</div>
</div>
@code {
protected int numDays { get; set; } = 7;
protected int stepMin { get; set; } = 30;
protected int maxHourRate { get; set; } = 800;
protected bool processRunning { get; set; } = false;
protected async Task resetDB()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler risimulare l'intero set di dati?"))
return;
processRunning = true;
DataService.RegenDB(numDays, stepMin, maxHourRate);
processRunning = false;
}
protected override async Task OnInitializedAsync()
{
AppMService.ShowSearch = false;
AppMService.PageName = "Setup Parametri";
AppMService.PageIcon = "fas fa-wrench pr-2";
}
}
+7
View File
@@ -0,0 +1,7 @@
@page "/PlantAnalisys"
<h3>PlantAnalisys</h3>
@code {
}
+32
View File
@@ -0,0 +1,32 @@
@page "/PlantStatus"
@using GWMS.UI.Components
<div class="row">
@if (ListRecords == null)
{
<div class="col-12">
<LoadingData></LoadingData>
</div>
}
else if (totalCount == 0)
{
<div class="col-12">
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
</div>
}
else
{
<div class="col-12">
<div class="row">
@foreach (var record in ListRecords)
{
<div class="col-12 col-md-6 py-2">
<PlantDetail currItem="@record"></PlantDetail>
</div>
}
</div>
</div>
}
</div>
+113
View File
@@ -0,0 +1,113 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using GWMS.UI.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using GWMS.Data.DTO;
namespace GWMS.UI.Pages
{
public partial class PlantStatus : ComponentBase, IDisposable
{
#region Private Fields
private PlantDTO currRecord = null;
private List<PlantDTO> ListRecords;
#endregion Private Fields
#region Private Properties
private bool isLoading { get; set; } = false;
private bool ShowCharts { get; set; } = false;
#endregion Private Properties
#region Protected Properties
[Inject]
protected GWMSDataService DataService { get; set; }
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[Inject]
protected MessageService MessageService { get; set; }
[Inject]
protected NavigationManager NavManager { get; set; }
protected int totalCount
{
get
{
int answ = 0;
if (ListRecords != null)
{
answ = ListRecords.Count;
}
return answ;
}
}
#endregion Protected Properties
#region Private Methods
private async Task reloadData()
{
isLoading = true;
ListRecords = await DataService.PlantsGetAll();
isLoading = false;
}
#endregion Private Methods
#region Protected Methods
protected override async Task OnInitializedAsync()
{
MessageService.ShowSearch = false;
MessageService.PageName = "Impianti";
MessageService.PageIcon = "fas fa-gas-pump pr-2";
MessageService.EA_SearchUpdated += OnSeachUpdated;
await reloadData();
}
protected void Select(PlantDTO selRecord)
{
// applico filtro da selezione
currRecord = selRecord;
}
protected async Task UpdateData()
{
currRecord = null;
await reloadData();
}
#endregion Protected Methods
#region Public Methods
public void Dispose()
{
MessageService.EA_SearchUpdated -= OnSeachUpdated;
}
public async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
Task task = UpdateData();
StateHasChanged();
});
}
#endregion Public Methods
}
}
+34
View File
@@ -0,0 +1,34 @@
@page "/Scheduler"
@using GWMS.UI.Data
@using GWMS.UI.Components
@inject GWMSDataService DataService
@inject MessageService AppMService
@inject IJSRuntime JSRuntime
<div class="card">
<div class="card-header table-primary">
<div class="row">
<div class="col-9">
<h3>Job Schedulati</h3>
</div>
<div class="col-3">
<button class="btn btn-block btn-primary">Add Job <i class="far fa-calendar-plus"></i></button>
</div>
</div>
</div>
<div class="card-body">
Riportare elenco jobs schedulati e log esecuzione
</div>
</div>
@code {
protected override async Task OnInitializedAsync()
{
AppMService.ShowSearch = false;
AppMService.PageName = "Job Scheduler";
AppMService.PageIcon = "fas fa-calendar-alt pr-2";
}
}
+132
View File
@@ -0,0 +1,132 @@
@page "/Suppliers"
@using Blazorise.Components
@using GWMS.UI.Components
<div class="card">
<div class="card-header table-primary h3">
<div class="row">
<div class="col-3 h3">
Ordini Fornitore
</div>
<div class="col-9 text-right">
<div class="d-flex justify-content-between">
<div class="p-2">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">inizio:</span>
<DateEdit class="form-control form-control-sm" TValue="DateTime?" Date="@DateStart" DateChanged="@OnDateStartChanged" />
</div>
</div>
</div>
<div class="p-2">
<div class="input-group input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">fine:</span>
<DateEdit class="form-control form-control-sm" TValue="DateTime?" Date="@DateEnd" DateChanged="@OnDateEndChanged" />
</div>
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-gas-pump" aria-hidden="true"></span>
</span>
</div>
<select @bind="@SelPlantId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (PlantsList != null)
{
foreach (var item in PlantsList)
{
<option value="@item.PlantId">@item.PlantCode | @item.PlantDesc</option>
}
}
</select>
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-industry" aria-hidden="true"></span>
</span>
</div>
<select @bind="@SelSupplierId" class="form-control form-control-sm" title="Fornitore">
@if (SuppliersList != null)
{
foreach (var item in SuppliersList)
{
<option value="@item.SupplierId">@item.SupplierCode | @item.SupplierDesc</option>
}
}
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-body p-1">
@if (currRecord != null)
{
<OrderSupplierEditor currItem="@currRecord" DataReset="ResetData" DataUpdated="UpdateData" SupplierId="@currRecord.SupplierId"></OrderSupplierEditor>
}
@if (ListRecords == null)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
}
else
{
<div class="row">
<div class="col-12">
<table class="table table-sm table-striped">
<thead>
<tr>
<th></th>
<th>Impianto</th>
<th>Data Ordine</th>
<th>Ordine</th>
<th class="text-right">Fornitore</th>
<th class="text-right">Qta</th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecords)
{
<tr class="@checkSelect(@record.OrderId)">
<td class="text-nowrap"><button class="btn btn-sm btn-info" @onclick="() => Edit(record)"><span class="oi oi-pencil"></span></button></td>
<td>
<div>@record.Plant.PlantCode</div>
<div class="small">@record.Plant.PlantDesc</div>
</td>
<td>
<div>@record.DtOrder.ToString("yyyy.MM.dd")</div>
<div class="small">@record.DtOrder.ToString("ddd HH:mm.ss")</div>
</td>
<td>@record.OrderCode | @record.OrderDesc</td>
<td class="text-right">
<div class="row">
<div class="col">[@record.Supplier.SupplierCode]</div>
<div class="col text-right">@record.Supplier.SupplierDesc</div>
</div>
<div class="small">@record.Transporter.TransporterCode | @record.Transporter.TransporterDesc</div>
</td>
<td class="text-right">@record.OrderQty.ToString("N0")</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
</div>
<div class="card-footer p-1">
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
</div>
</div>
+300
View File
@@ -0,0 +1,300 @@
using GWMS.Data.DatabaseModels;
using GWMS.Data.DTO;
using GWMS.UI.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GWMS.UI.Pages
{
public partial class Suppliers : ComponentBase, IDisposable
{
#region Private Fields
private OrderModel currRecord = null;
private List<OrderModel> ListRecords;
private List<PlantDTO> PlantsList;
private List<OrderModel> SearchRecords;
private List<SupplierModel> SuppliersList;
#endregion Private Fields
#region Private Properties
private int _currPage { get; set; } = 1;
private int _numRecord { get; set; } = 10;
private int currPage
{
get => _currPage;
set
{
if (_currPage != value)
{
_currPage = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool isLoading { get; set; } = false;
private int numRecord
{
get => _numRecord;
set
{
if (_numRecord != value)
{
_numRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelPlantId
{
get
{
int answ = 0;
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.PlantId;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.PlantId.Equals(value))
{
MessageService.Order_Filter.PlantId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelSupplierId
{
get
{
int answ = 0;
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.SupplierId;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.SupplierId.Equals(value))
{
MessageService.Order_Filter.SupplierId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool ShowCharts { get; set; } = false;
#endregion Private Properties
#region Protected Properties
[Inject]
protected GWMSDataService DataService { get; set; }
protected DateTime DateEnd
{
get
{
DateTime answ = DateTime.Today.AddDays(1);
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.DateEnd;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.DateEnd.Equals(value))
{
MessageService.Order_Filter.DateEnd = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
protected DateTime DateStart
{
get
{
DateTime answ = DateTime.Today.AddDays(-1);
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.DateStart;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.DateStart.Equals(value))
{
MessageService.Order_Filter.DateStart = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[Inject]
protected MessageService MessageService { get; set; }
[Inject]
protected NavigationManager NavManager { get; set; }
protected int totalCount
{
get
{
int answ = 0;
if (SearchRecords != null)
{
answ = SearchRecords.Count;
}
return answ;
}
}
#endregion Protected Properties
#region Private Methods
private void OnDateEndChanged(DateTime? date)
{
DateEnd = (DateTime)date;
}
private void OnDateStartChanged(DateTime? date)
{
DateStart = (DateTime)date;
}
private async Task ReloadData()
{
isLoading = true;
SearchRecords = await DataService.OrdersGetFilt(MessageService.Order_Filter);
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
isLoading = false;
}
#endregion Private Methods
#region Protected Methods
protected void Edit(OrderModel selRecord)
{
currRecord = selRecord;
}
protected void ForceReload(int newNum)
{
numRecord = newNum;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
}
protected override async Task OnInitializedAsync()
{
MessageService.ShowSearch = false;
MessageService.PageName = "Fornitore";
MessageService.PageIcon = "fas fa-industry pr-2";
MessageService.EA_SearchUpdated += OnSeachUpdated;
await ReloadAllData();
}
protected async Task ReloadAllData()
{
PlantsList = await DataService.PlantsGetAll();
SuppliersList = await DataService.SuppliersGetAll();
await ReloadData();
}
protected void ResetData()
{
DataService.rollBackEdit(currRecord);
currRecord = null;
}
protected async Task ResetFilter(SelectOrderData newFilter)
{
currRecord = null;
SearchRecords = null;
ListRecords = null;
MessageService.Order_Filter = SelectOrderData.Init(5, 7);
await ReloadAllData();
}
protected void Select(OrderModel selRecord)
{
// applico filtro da selezione
currRecord = selRecord;
}
protected async Task UpdateData()
{
currRecord = null;
await ReloadData();
}
#endregion Protected Methods
#region Public Methods
public string checkSelect(int OrderId)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.OrderId == OrderId) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
public void Dispose()
{
MessageService.EA_SearchUpdated -= OnSeachUpdated;
}
public async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
Task task = UpdateData();
StateHasChanged();
});
}
#endregion Public Methods
}
}
+136
View File
@@ -0,0 +1,136 @@
@page "/Transporters"
@using Blazorise.Components
@using GWMS.UI.Components
<div class="card">
<div class="card-header table-primary mb-0">
<div class="row">
<div class="col-12">
<div class="row">
<div class="col-6 col-lg-8 h3">
In Consegna
</div>
<div class="col-3 col-lg-2">
<button class="btn btn-sm btn-block btn-secondary" @onclick="() => ToggleFiltPeriod()"><i class="far fa-calendar-alt"></i> <i class="fas fa-chevron-down"></i></button>
</div>
<div class="col-3 col-lg-2">
<button class="btn btn-sm btn-block btn-secondary" @onclick="() => ToggleFiltDest()"><i class="fas fa-gas-pump"></i> <i class="fas fa-chevron-down"></i></button>
</div>
</div>
</div>
<div class="col-12 text-right">
@if (showFiltTime)
{
<div class="row small">
<div class="col-6">
<div class="input-group input-group-sm">
<DateEdit class="form-control form-control-sm" TValue="DateTime?" Date="@DateStart" DateChanged="@OnDateStartChanged" />
</div>
</div>
<div class="col-6">
<div class="input-group input-group-sm">
<DateEdit class="form-control form-control-sm" TValue="DateTime?" Date="@DateEnd" DateChanged="@OnDateEndChanged" />
</div>
</div>
</div>
}
@if (showFiltDest)
{
<div class="row">
<div class="col">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-gas-pump" aria-hidden="true"></span>
</span>
</div>
<select @bind="@SelPlantId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (PlantsList != null)
{
foreach (var item in PlantsList)
{
<option value="@item.PlantId">@item.PlantCode | @item.PlantDesc</option>
}
}
</select>
</div>
</div>
@*<div class="col">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-truck-moving" aria-hidden="true"></span>
</span>
</div>
<select @bind="@SelTranspId" class="form-control form-control-sm" title="Trasportatore">
@if (TransportersList != null)
{
foreach (var item in TransportersList)
{
<option value="@item.TransporterId">@item.TransporterCode | @item.TransporterDesc</option>
}
}
</select>
</div>
</div>*@
</div>
}
</div>
</div>
</div>
<div class="card-body p-1">
@if (currRecord != null)
{
<OrderTranspEditor currItem="@currRecord" DataReset="ResetData" DataUpdated="UpdateData" SupplierId="@currRecord.SupplierId"></OrderTranspEditor>
}
@if (ListRecords == null)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
}
else
{
<div class="row">
<div class="col-12">
<table class="table table-sm table-striped">
<thead>
<tr>
<th></th>
<th>Impianto</th>
<th class="text-right">Qta</th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecords)
{
<tr class="@checkSelect(@record.OrderId)">
<td class="text-nowrap"><button class="btn btn-sm btn-info" @onclick="() => Edit(record)"><span class="oi oi-magnifying-glass"></span></button></td>
<td>
<div><b>@record.Plant.PlantCode</b> | @record.Plant.PlantDesc</div>
<div class="small"><span class="fas fa-comment-alt" aria-hidden="true"></span> @record.OrderDesc</div>
</td>
<td class="text-right">
<div>
<b>@record.OrderQty.ToString("N0")</b>
</div>
<div>@record.DtETA.ToString("yyyy.MM.dd")</div>
<div class="small">@record.DtETA.ToString("ddd HH:mm.ss")</div>
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
</div>
<div class="card-footer p-1">
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
</div>
</div>
+314
View File
@@ -0,0 +1,314 @@
using GWMS.Data.DatabaseModels;
using GWMS.Data.DTO;
using GWMS.UI.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GWMS.UI.Pages
{
public partial class Transporters : ComponentBase, IDisposable
{
#region Private Fields
private OrderModel currRecord = null;
private List<OrderModel> ListRecords;
private List<PlantDTO> PlantsList;
private List<OrderModel> SearchRecords;
private List<TransporterModel> TransportersList;
#endregion Private Fields
#region Private Properties
private int _currPage { get; set; } = 1;
private int _numRecord { get; set; } = 10;
private int currPage
{
get => _currPage;
set
{
if (_currPage != value)
{
_currPage = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool isLoading { get; set; } = false;
private int numRecord
{
get => _numRecord;
set
{
if (_numRecord != value)
{
_numRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelPlantId
{
get
{
int answ = 0;
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.PlantId;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.PlantId.Equals(value))
{
MessageService.Order_Filter.PlantId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelTranspId
{
get
{
int answ = 0;
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.TransporterId;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.TransporterId.Equals(value))
{
MessageService.Order_Filter.TransporterId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool ShowCharts { get; set; } = false;
#endregion Private Properties
#region Protected Properties
[Inject]
protected GWMSDataService DataService { get; set; }
protected DateTime DateEnd
{
get
{
DateTime answ = DateTime.Today.AddDays(1);
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.DateEnd;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.DateEnd.Equals(value))
{
MessageService.Order_Filter.DateEnd = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
protected DateTime DateStart
{
get
{
DateTime answ = DateTime.Today.AddDays(-1);
if (MessageService.Order_Filter != null)
{
answ = MessageService.Order_Filter.DateStart;
}
return answ;
}
set
{
if (!MessageService.Order_Filter.DateStart.Equals(value))
{
MessageService.Order_Filter.DateStart = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[Inject]
protected MessageService MessageService { get; set; }
[Inject]
protected NavigationManager NavManager { get; set; }
protected bool showFiltDest { get; set; } = false;
protected bool showFiltTime { get; set; } = false;
protected int totalCount
{
get
{
int answ = 0;
if (SearchRecords != null)
{
answ = SearchRecords.Count;
}
return answ;
}
}
#endregion Protected Properties
#region Private Methods
private void OnDateEndChanged(DateTime? date)
{
DateEnd = (DateTime)date;
}
private void OnDateStartChanged(DateTime? date)
{
DateStart = (DateTime)date;
}
private async Task ReloadData()
{
isLoading = true;
SearchRecords = await DataService.OrdersGetFilt(MessageService.Order_Filter);
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
isLoading = false;
}
#endregion Private Methods
#region Protected Methods
protected void Edit(OrderModel selRecord)
{
currRecord = selRecord;
}
protected void ForceReload(int newNum)
{
numRecord = newNum;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
}
protected override async Task OnInitializedAsync()
{
MessageService.ShowSearch = false;
MessageService.PageName = "Fornitore";
MessageService.PageIcon = "fas fa-industry pr-2";
MessageService.EA_SearchUpdated += OnSeachUpdated;
await ReloadAllData();
}
protected async Task ReloadAllData()
{
PlantsList = await DataService.PlantsGetAll();
TransportersList = await DataService.TransportersGetAll();
await ReloadData();
}
protected void ResetData()
{
DataService.rollBackEdit(currRecord);
currRecord = null;
}
protected async Task ResetFilter(SelectOrderData newFilter)
{
currRecord = null;
SearchRecords = null;
ListRecords = null;
MessageService.Order_Filter = SelectOrderData.Init(5, 7);
await ReloadAllData();
}
protected void Select(OrderModel selRecord)
{
// applico filtro da selezione
currRecord = selRecord;
}
protected void ToggleFiltDest()
{
showFiltDest = !showFiltDest;
}
protected void ToggleFiltPeriod()
{
showFiltTime = !showFiltTime;
}
protected async Task UpdateData()
{
currRecord = null;
await ReloadData();
}
#endregion Protected Methods
#region Public Methods
public string checkSelect(int OrderId)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.OrderId == OrderId) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
public void Dispose()
{
MessageService.EA_SearchUpdated -= OnSeachUpdated;
}
public async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
Task task = UpdateData();
StateHasChanged();
});
}
#endregion Public Methods
}
}
+147
View File
@@ -0,0 +1,147 @@
@page "/UserManager"
@using Blazorise.Components
@using GWMS.UI.Components
<div class="card">
<div class="card-header table-primary h3">
<div class="row">
<div class="col-3 h3">
Elenco Utenti
</div>
<div class="col-9 text-right">
<div class="d-flex justify-content-between">
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<i class="fas fa-user-shield"></i>
</span>
</div>
<select @bind="@SelLevel" class="form-control form-control-sm">
@foreach (var itemVal in Enum.GetValues(typeof(GWMS.Data.UserLevel)))
{
<option>@itemVal</option>
}
</select>
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-gas-pump" aria-hidden="true"></span>
</span>
</div>
<select @bind="@SelPlantId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (PlantsList != null)
{
foreach (var item in PlantsList)
{
<option value="@item.PlantId">@item.PlantCode | @item.PlantDesc</option>
}
}
</select>
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-industry" aria-hidden="true"></span>
</span>
</div>
<select @bind="@SelSupplierId" class="form-control form-control-sm">
<option value="0">--- Tutti ---</option>
@if (SuppliersList != null)
{
foreach (var item in SuppliersList)
{
<option value="@item.SupplierId">@item.SupplierCode | @item.SupplierDesc</option>
}
}
</select>
</div>
</div>
<div class="p-2">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">
<span class="fas fa-truck-moving" aria-hidden="true"></span>
</span>
</div>
<select @bind="@SelTransporterId" class="form-control form-control-sm" title="Trasportatore">
<option value="0">--- Tutti ---</option>
@if (TransportersList != null)
{
foreach (var item in TransportersList)
{
<option value="@item.TransporterId">@item.TransporterCode | @item.TransporterDesc</option>
}
}
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card-body p-1">
@if (currRecord != null)
{
<UserEditor currItem="@currRecord" DataReset="ResetData" DataUpdated="UpdateData"></UserEditor>
}
@if (ListRecords == null)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
}
else
{
<div class="row">
<div class="col-12">
<table class="table table-sm table-striped">
<thead>
<tr>
<th></th>
<th>UserName</th>
<th>Cognome</th>
<th>Nome</th>
<th>Email</th>
<th>Att</th>
<th class="text-right">Livello</th>
<th class="text-right">Mask Impianto</th>
<th class="text-right">Mask Fornitore</th>
<th class="text-right">Mask Trasportatore</th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecords)
{
<tr class="@checkSelect(@record.UserId)">
<td class="text-nowrap"><button class="btn btn-sm btn-info" @onclick="() => Edit(record)"><span class="oi oi-pencil"></span></button></td>
<td>@record.UserName</td>
<td>@record.Lastname</td>
<td>@record.Firstname</td>
<td>@record.Email</td>
<td><input type="checkbox" checked="@record.IsActive"></td>
<td class="text-right">@record.Livello</td>
<td class="text-right">@record.MaskPlantId</td>
<td class="text-right">@record.MaskSupplierId</td>
<td class="text-right">@record.MaskTranspId</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
</div>
<div class="card-footer p-1">
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
</div>
</div>
+253
View File
@@ -0,0 +1,253 @@
using GWMS.Data;
using GWMS.Data.DatabaseModels;
using GWMS.Data.DTO;
using GWMS.UI.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GWMS.UI.Pages
{
public partial class UserManager : ComponentBase, IDisposable
{
#region Private Fields
private UserModel currRecord = null;
private List<UserModel> ListRecords;
private List<PlantDTO> PlantsList;
private List<UserModel> SearchRecords;
private List<SupplierModel> SuppliersList;
private List<TransporterModel> TransportersList;
#endregion Private Fields
#region Private Properties
private int _currPage { get; set; } = 1;
private int _numRecord { get; set; } = 10;
private UserLevel _selLevel { get; set; } = UserLevel.ND;
private int _selPlantId { get; set; } = 0;
private int _selSuppId { get; set; } = 0;
private int _selTraspId { get; set; } = 0;
private int currPage
{
get => _currPage;
set
{
if (_currPage != value)
{
_currPage = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool isLoading { get; set; } = false;
private int numRecord
{
get => _numRecord;
set
{
if (_numRecord != value)
{
_numRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private UserLevel SelLevel
{
get => _selLevel;
set
{
if (_selLevel != value)
{
_selLevel = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelPlantId
{
get => _selPlantId;
set
{
if (_selPlantId != value)
{
_selPlantId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelSupplierId
{
get => _selSuppId;
set
{
if (_selSuppId != value)
{
_selSuppId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelTransporterId
{
get => _selTraspId;
set
{
if (_selTraspId != value)
{
_selTraspId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
#endregion Private Properties
#region Protected Properties
[Inject]
protected MessageService AppMService { get; set; }
[Inject]
protected GWMSDataService DataService { get; set; }
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[Inject]
protected NavigationManager NavManager { get; set; }
protected int totalCount
{
get
{
int answ = 0;
if (SearchRecords != null)
{
answ = SearchRecords.Count;
}
return answ;
}
}
#endregion Protected Properties
#region Private Methods
private async Task ReloadData()
{
isLoading = true;
SearchRecords = await DataService.UsersGetFilt(SelLevel, SelPlantId, SelSupplierId, SelTransporterId);
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
isLoading = false;
}
#endregion Private Methods
#region Protected Methods
protected void Edit(UserModel selRecord)
{
currRecord = selRecord;
}
protected void ForceReload(int newNum)
{
numRecord = newNum;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
}
protected override async Task OnInitializedAsync()
{
AppMService.ShowSearch = true;
AppMService.PageName = "Utenti";
AppMService.PageIcon = "fas fa-users pr-2";
AppMService.EA_SearchUpdated += OnSeachUpdated;
await ReloadAllData();
}
protected async Task ReloadAllData()
{
PlantsList = await DataService.PlantsGetAll();
SuppliersList = await DataService.SuppliersGetAll();
TransportersList = await DataService.TransportersGetAll();
await ReloadData();
}
protected void ResetData()
{
DataService.rollBackEdit(currRecord);
currRecord = null;
}
protected void Select(UserModel selRecord)
{
// applico filtro da selezione
currRecord = selRecord;
}
protected async Task UpdateData()
{
currRecord = null;
await ReloadData();
}
#endregion Protected Methods
#region Public Methods
public string checkSelect(int UserId)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.UserId == UserId) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
public void Dispose()
{
AppMService.EA_SearchUpdated -= OnSeachUpdated;
}
public async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
Task task = UpdateData();
StateHasChanged();
});
}
#endregion Public Methods
}
}
+76
View File
@@ -0,0 +1,76 @@
@page "/WeekPlan"
@using GWMS.UI.Components
<div class="card">
<div class="card-header table-primary">
<div class="row">
<div class="col-9">
<h3>Week Plan</h3>
</div>
<div class="col-3">
<button class="btn btn-block btn-success" @onclick="CreateNew">Aggiunta Consegna <i class="far fa-calendar-plus"></i></button>
</div>
</div>
</div>
<div class="card-body">
@if (currRecord != null)
{
<WeekPlanEditor currItem="@currRecord" DataReset="ResetData" DataUpdated="UpdateData"></WeekPlanEditor>
}
@if (ListRecords == null)
{
<LoadingData></LoadingData>
}
else
{
<div class="row">
<div class="col-12 text-center">
Legenda
</div>
<div class="col-12 text-center">
<table class="table table-sm table-striped">
<thead>
<tr>
<th></th>
<th>LUN</th>
<th>MAR</th>
<th>MER</th>
<th>GIO</th>
<th>VEN</th>
<th>SAB</th>
<th>DOM</th>
</tr>
</thead>
<tbody>
@for (int i = startHour; i <= endHour; i++)
{
<tr class="small">
<td style="width: 5.5%;">@i</td>
<td style="width: 13.5%;"><ItemPlanDetail selRecordChanged="EditRecord" currList="@SlotList(DayOfWeek.Monday, i)"></ItemPlanDetail></td>
<td style="width: 13.5%;"><ItemPlanDetail selRecordChanged="EditRecord" currList="@SlotList(@DayOfWeek.Tuesday, i)"></ItemPlanDetail></td>
<td style="width: 13.5%;"><ItemPlanDetail selRecordChanged="EditRecord" currList="@SlotList(@DayOfWeek.Wednesday, i)"></ItemPlanDetail></td>
<td style="width: 13.5%;"><ItemPlanDetail selRecordChanged="EditRecord" currList="@SlotList(@DayOfWeek.Thursday, i)"></ItemPlanDetail></td>
<td style="width: 13.5%;"><ItemPlanDetail selRecordChanged="EditRecord" currList="@SlotList(@DayOfWeek.Friday, i)"></ItemPlanDetail></td>
<td style="width: 13.5%;"><ItemPlanDetail selRecordChanged="EditRecord" currList="@SlotList(@DayOfWeek.Saturday, i)"></ItemPlanDetail></td>
<td style="width: 13.5%;"><ItemPlanDetail selRecordChanged="EditRecord" currList="@SlotList(@DayOfWeek.Sunday, i)"></ItemPlanDetail></td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
</div>
<div class="card-footer">
<div class="row">
<div class="col-3">
Selezione range orario:&nbsp;
<input @bind="startHour" style="width: 2em;" />
<i class="fas fa-angle-double-right"></i>
<input @bind="endHour" style="width: 2em;" />
</div>
</div>
</div>
</div>
+291
View File
@@ -0,0 +1,291 @@
using GWMS.Data;
using GWMS.Data.DatabaseModels;
using GWMS.Data.DTO;
using GWMS.UI.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GWMS.UI.Pages
{
public partial class WeekPlan : ComponentBase
{
#region Private Fields
private int _endHour = 22;
private int _startHour = 8;
private WeekPlanModel currRecord = null;
private List<WeekPlanModel> ListRecords;
private List<PlantDTO> PlantsList;
private List<SupplierModel> SuppliersList;
private List<TransporterModel> TransportersList;
#endregion Private Fields
#region Private Properties
private int _currPage { get; set; } = 1;
private int _numRecord { get; set; } = 10;
private UserLevel _selLevel { get; set; } = UserLevel.ND;
private int _selPlantId { get; set; } = 0;
private int _selSuppId { get; set; } = 0;
private int _selTraspId { get; set; } = 0;
private int currPage
{
get => _currPage;
set
{
if (_currPage != value)
{
_currPage = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int endHour
{
get => _endHour;
set
{
if (_endHour != value)
{
_endHour = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool isLoading { get; set; } = false;
private int numRecord
{
get => _numRecord;
set
{
if (_numRecord != value)
{
_numRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private UserLevel SelLevel
{
get => _selLevel;
set
{
if (_selLevel != value)
{
_selLevel = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelPlantId
{
get => _selPlantId;
set
{
if (_selPlantId != value)
{
_selPlantId = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int SelSupplierId
{
get => _selSuppId;
set
{
if (_selSuppId != value)
{
_selSuppId = value;
checkHourRange();
}
}
}
private int SelTransporterId
{
get => _selTraspId;
set
{
if (_selTraspId != value)
{
_selTraspId = value;
checkHourRange();
}
}
}
private int startHour
{
get => _startHour;
set
{
if (_startHour != value)
{
_startHour = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
#endregion Private Properties
#region Protected Properties
[Inject]
protected MessageService AppMService { get; set; }
[Inject]
protected GWMSDataService DataService { get; set; }
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[Inject]
protected NavigationManager NavManager { get; set; }
protected int totalCount
{
get
{
int answ = 0;
if (ListRecords != null)
{
answ = ListRecords.Count;
}
return answ;
}
}
#endregion Protected Properties
#region Private Methods
private void checkHourRange()
{
int minHour = 7;
int maxHour = 21;
var minRecord = ListRecords.OrderBy(x => x.DeliveryHour).FirstOrDefault();
if (minRecord != null)
{
minHour = ListRecords.OrderBy(x => x.DeliveryHour).FirstOrDefault().DeliveryHour;
_startHour = _startHour < minHour ? _startHour : minHour;
}
var maxRecord = ListRecords.OrderByDescending(x => x.DeliveryHour).FirstOrDefault();
if (maxRecord != null)
{
maxHour = ListRecords.OrderByDescending(x => x.DeliveryHour).FirstOrDefault().DeliveryHour;
_endHour = _endHour > maxHour ? _endHour : maxHour;
}
}
private async Task ReloadData()
{
isLoading = true;
ListRecords = await DataService.WeekPlanGet();
// calcolo min/max...
checkHourRange();
isLoading = false;
}
#endregion Private Methods
#region Protected Methods
protected void CreateNew()
{
// creo nuovo record
WeekPlanModel newRecord = new WeekPlanModel()
{
DayNum = DayOfWeek.Sunday,
DeliveryHour = 14,
Note = "18K"
};
currRecord = newRecord;
}
protected void Edit(WeekPlanModel selRecord)
{
currRecord = selRecord;
}
protected void EditRecord(int WeekPlanId)
{
currRecord = null;
var findRecord = ListRecords
.Where(x => x.WeekPlanId == WeekPlanId)
.FirstOrDefault();
currRecord = findRecord;
}
protected override async Task OnInitializedAsync()
{
AppMService.ShowSearch = false;
AppMService.PageName = "Planner Consegne";
AppMService.PageIcon = "fas fa-calendar pr-2";
await ReloadAllData();
}
protected async Task ReloadAllData()
{
PlantsList = await DataService.PlantsGetAll();
SuppliersList = await DataService.SuppliersGetAll();
TransportersList = await DataService.TransportersGetAll();
await ReloadData();
}
protected async Task ResetData()
{
DataService.rollBackEdit(currRecord);
currRecord = null;
await ReloadData();
}
protected void Select(WeekPlanModel selRecord)
{
// applico filtro da selezione
currRecord = selRecord;
}
protected List<WeekPlanModel> SlotList(DayOfWeek Giorno, int Ora)
{
List<WeekPlanModel> result = new();
if (ListRecords != null && ListRecords.Count > 0)
{
result = ListRecords
.Where(x => x.DayNum == Giorno && x.DeliveryHour == Ora)
.ToList();
}
return result;
}
protected async Task UpdateData()
{
currRecord = null;
await ReloadData();
}
#endregion Protected Methods
}
}
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>5f0dbab0-122f-4a81-be73-161bbefeef59</ProjectGuid>
<SelfContained>false</SelfContained>
<MSDeployServiceURL>https://IIS01:8172/MsDeploy.axd</MSDeployServiceURL>
<DeployIisAppPath>Default Web Site/GWMS</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>jenkins</UserName>
<_SavePWD>True</_SavePWD>
</PropertyGroup>
</Project>
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>5f0dbab0-122f-4a81-be73-161bbefeef59</ProjectGuid>
<SelfContained>false</SelfContained>
<MSDeployServiceURL>https://IIS02:8172/MsDeploy.axd</MSDeployServiceURL>
<DeployIisAppPath>Default Web Site/GWMS</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>jenkins</UserName>
<_SavePWD>True</_SavePWD>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>Package</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>5f0dbab0-122f-4a81-be73-161bbefeef59</ProjectGuid>
<DesktopBuildPackageLocation>bin\publish\GWMS.UI.zip</DesktopBuildPackageLocation>
<PackageAsSingleFile>true</PackageAsSingleFile>
<DeployIisAppPath>Default Web Site/GWMS</DeployIisAppPath>
<TargetFramework>net5.0</TargetFramework>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>5f0dbab0-122f-4a81-be73-161bbefeef59</ProjectGuid>
<SelfContained>false</SelfContained>
<MSDeployServiceURL>https://w2019-iis-dev:8172/MsDeploy.axd</MSDeployServiceURL>
<DeployIisAppPath>Default Web Site/GWMS</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>jenkins</UserName>
<_SavePWD>True</_SavePWD>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>
+25 -25
View File
@@ -1,28 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:26659",
"sslPort": 44339
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:26659",
"sslPort": 44339
}
},
"GWMS.UI": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"GWMS.UI": {
"commandName": "Project",
"dotnetRunMessages": "true",
"launchBrowser": true,
"applicationUrl": "https://localhost:5003;http://localhost:5002",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
}
}
+42
View File
@@ -0,0 +1,42 @@
using Microsoft.Extensions.Hosting;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace GWMS.UI
{
public class QuartzHostedService : IHostedService
{
#region Private Fields
private readonly IScheduler _scheduler;
#endregion Private Fields
#region Public Constructors
public QuartzHostedService(IScheduler scheduler)
{
_scheduler = scheduler;
}
#endregion Public Constructors
#region Public Methods
public async Task StartAsync(CancellationToken cancellationToken)
{
await _scheduler?.Start(cancellationToken);
}
public async Task StopAsync(CancellationToken cancellationToken)
{
await _scheduler?.Shutdown(cancellationToken);
}
#endregion Public Methods
}
}
+1 -1
View File
@@ -15,7 +15,7 @@
<div class="top-row">
<CmpTop></CmpTop>
</div>
<div class="content px-4 mb-5">
<div class="content px-2 mb-5">
@Body
</div>
<div class="fixed-bottom bottom-row">

Some files were not shown because too many files have changed in this diff Show More