214 lines
20 KiB
C#
214 lines
20 KiB
C#
using MP.MONO.Data.DbModels;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System;
|
|
|
|
namespace MP.MONO.Data
|
|
{
|
|
public static class ModelBuilderExtensions
|
|
{
|
|
/// <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 Machine
|
|
modelBuilder.Entity<MachineModel>().HasData(
|
|
new MachineModel { MachineId = 1, Serial = "SN-0000-0000-0000", Model = "Egalware SIM", Name = "EGW-SIM-Machine", Description = "Default SIM Machine" }
|
|
);
|
|
|
|
// initi valori default x eventi
|
|
modelBuilder.Entity<EventModel>().HasData(
|
|
new EventModel { CodEvent = "", Description = "NA", IsUser = false }
|
|
, new EventModel { CodEvent = "Run", Description = "Running", IsUser = true }
|
|
, new EventModel { CodEvent = "Setup", Description = "Machine Setup", IsUser = true }
|
|
, new EventModel { CodEvent = "ProgEdit", Description = "Program Editing", IsUser = true }
|
|
, new EventModel { CodEvent = "Fill", Description = "Machine Fill", IsUser = true }
|
|
, new EventModel { CodEvent = "SetError", Description = "Error", IsUser = true }
|
|
, new EventModel { CodEvent = "WuCd", Description = "Warm Up / CoolDown Machine", IsUser = false }
|
|
, new EventModel { CodEvent = "ContrPwr", Description = "Controlled PowerOn / ShutDown", IsUser = false }
|
|
, new EventModel { CodEvent = "ProgMiss", Description = "Program Missing", IsUser = true }
|
|
, new EventModel { CodEvent = "HRMiss", Description = "HR Missing", IsUser = true }
|
|
, new EventModel { CodEvent = "Maint", Description = "Maintenance", IsUser = true }
|
|
, new EventModel { CodEvent = "Clean", Description = "Machine CleanUp", IsUser = true }
|
|
, new EventModel { CodEvent = "SetPwrOff", Description = "Power OFF Declaration", IsUser = true }
|
|
, new EventModel { CodEvent = "Init", Description = "Init", IsUser = false }
|
|
, new EventModel { CodEvent = "PowerOff", Description = "Power OFF", IsUser = false }
|
|
, new EventModel { CodEvent = "PowerOn", Description = "Power ON", IsUser = false }
|
|
, new EventModel { CodEvent = "Cycle", Description = "Machining", IsUser = false }
|
|
, new EventModel { CodEvent = "EndCycle", Description = "End machining", IsUser = false }
|
|
, new EventModel { CodEvent = "Error", Description = "Error", IsUser = false }
|
|
, new EventModel { CodEvent = "PzCount", Description = "Item Count(+1)", IsUser = false }
|
|
, new EventModel { CodEvent = "StartPall", Description = "Start pallet", IsUser = false }
|
|
, new EventModel { CodEvent = "EndPall", Description = "End pallet", IsUser = false }
|
|
, new EventModel { CodEvent = "Manual", Description = "Manual", IsUser = false }
|
|
, new EventModel { CodEvent = "LOutFull", Description = "Line Out Full", IsUser = false }
|
|
, new EventModel { CodEvent = "LInEmpty", Description = "Line In Empty", IsUser = false }
|
|
, new EventModel { CodEvent = "CycleTOut", Description = "Timeout Std CycleTime", IsUser = false }
|
|
, new EventModel { CodEvent = "RMatMiss", Description = "Raw Material Missing", IsUser = true }
|
|
, new EventModel { CodEvent = "Emergency", Description = "Emergency", IsUser = false }
|
|
, new EventModel { CodEvent = "ToolRepl", Description = "Tool Replacement", IsUser = true }
|
|
, new EventModel { CodEvent = "CncAlam", Description = "CNC Alarm", IsUser = false }
|
|
, new EventModel { CodEvent = "PlcAlam", Description = "PLC Alarm", IsUser = false }
|
|
, new EventModel { CodEvent = "Warning", Description = "Warning State", IsUser = false }
|
|
, new EventModel { CodEvent = "Message", Description = "Machine Message", IsUser = false }
|
|
, new EventModel { CodEvent = "PzIncr", Description = "Item Count Increment", IsUser = false }
|
|
, new EventModel { CodEvent = "PzSet", Description = "Item Count Set", IsUser = false }
|
|
, new EventModel { CodEvent = "UserComm", Description = "User Comment", IsUser = true }
|
|
);
|
|
|
|
// initi valori default x stati
|
|
modelBuilder.Entity<StatusModel>().HasData(
|
|
new StatusModel { Prior = 0, CodStatus = "", Description = "NA", CssClass = "dark", Group = "NA" }
|
|
|
|
// alta priorità
|
|
, new StatusModel { Prior = 5, CodStatus = "Error", Description = "Error", CssClass = "danger", Group = "StopRed" }
|
|
, new StatusModel { Prior = 5, CodStatus = "Emergency", Description = "Emergency", CssClass = "danger", Group = "StopRed" }
|
|
, new StatusModel { Prior = 4, CodStatus = "Manual", Description = "Manual", CssClass = "warning", Group = "ManYellow" }
|
|
, new StatusModel { Prior = 4, CodStatus = "PzProd", Description = "Item Produced", CssClass = "warning", Group = "MicroYellow" }
|
|
, new StatusModel { Prior = 4, CodStatus = "Unkn", Description = "Unknown Stop", CssClass = "warning", Group = "MicroYellow" }
|
|
|
|
// fermi rossi
|
|
, new StatusModel { Prior = 1, CodStatus = "ProgMissing", Description = "Program Missing", CssClass = "danger", Group = "StopRed" }
|
|
, new StatusModel { Prior = 1, CodStatus = "HRMissing", Description = "HR Missing", CssClass = "danger", Group = "StopRed" }
|
|
, new StatusModel { Prior = 1, CodStatus = "Maint", Description = "Maintenance", CssClass = "warning", Group = "StopRed" }
|
|
, new StatusModel { Prior = 1, CodStatus = "LineOutFull", Description = "Line Out Full", CssClass = "danger", Group = "StopRed" }
|
|
, new StatusModel { Prior = 1, CodStatus = "LineInEmpty", Description = "Line In Empty", CssClass = "danger", Group = "StopRed" }
|
|
, new StatusModel { Prior = 1, CodStatus = "RawMatMiss", Description = "Raw Material Missing", CssClass = "danger", Group = "StopRed" }
|
|
, new StatusModel { Prior = 1, CodStatus = "CncAlam", Description = "CNC Alarm", CssClass = "danger", Group = "StopRed" }
|
|
, new StatusModel { Prior = 1, CodStatus = "PlcAlam", Description = "PLC Alarm", CssClass = "danger", Group = "StopRed" }
|
|
|
|
// fermo blu non gestito/qualificato
|
|
, new StatusModel { Prior = 1, CodStatus = "WUpCDown", Description = "Warm Up / CoolDown Machine", CssClass = "primary", Group = "WaitBlue" }
|
|
, new StatusModel { Prior = 1, CodStatus = "ContrPOnSDown", Description = "Controller PowerOn / ShutDown", CssClass = "primary", Group = "WaitBlue" }
|
|
, new StatusModel { Prior = 1, CodStatus = "Init", Description = "Init", CssClass = "primary", Group = "WaitBlue" }
|
|
, new StatusModel { Prior = 1, CodStatus = "PowerOn", Description = "Power ON", CssClass = "primary", Group = "WaitBlue" }
|
|
, new StatusModel { Prior = 1, CodStatus = "TimeoutCycle", Description = "Timeout Std CycleTime", CssClass = "primary", Group = "WaitBlue" }
|
|
, new StatusModel { Prior = 1, CodStatus = "Waiting", Description = "Waiting State", CssClass = "primary", Group = "WaitBlue" }
|
|
|
|
// fermo giallo manuale
|
|
, new StatusModel { Prior = 1, CodStatus = "ProgEdit", Description = "Program Editing", CssClass = "warning", Group = "ManYellow" }
|
|
, new StatusModel { Prior = 1, CodStatus = "Setup", Description = "Machine Setup", CssClass = "warning", Group = "ManYellow" }
|
|
, new StatusModel { Prior = 1, CodStatus = "Clean", Description = "Machine CleanUp", CssClass = "warning", Group = "ManYellow" }
|
|
, new StatusModel { Prior = 1, CodStatus = "Fill", Description = "Machine Fill", CssClass = "warning", Group = "MicroYellow" }
|
|
, new StatusModel { Prior = 1, CodStatus = "ToolReplace", Description = "Tool Replacement", CssClass = "warning", Group = "MicroYellow" }
|
|
, new StatusModel { Prior = 1, CodStatus = "Warning", Description = "Warning State", CssClass = "warning", Group = "MicroYellow" }
|
|
|
|
// macchina spenta
|
|
, new StatusModel { Prior = 1, CodStatus = "PowerOff", Description = "Power OFF", CssClass = "secondary", Group = "Gray" }
|
|
|
|
// produzione
|
|
, new StatusModel { Prior = 1, CodStatus = "Run", Description = "Running", CssClass = "success", Group = "Green" }
|
|
, new StatusModel { Prior = 1, CodStatus = "Cycle", Description = "Machining", CssClass = "success", Group = "Green" }
|
|
|
|
);
|
|
|
|
// inizializzazione dei valori di default x Tipologia counters
|
|
modelBuilder.Entity<CounterModel>().HasData(
|
|
new CounterModel { CCode = "MacPowerOn", Description = "Machine Power On" },
|
|
new CounterModel { CCode = "CycleProc01", Description = "Process 1 on Cycle state" },
|
|
new CounterModel { CCode = "SpindleTorque01", Description = "Spindle 01 Torque % > 0" },
|
|
new CounterModel { CCode = "SpindleTorque02", Description = "Spindle 02 Torque % > 0" },
|
|
new CounterModel { CCode = "SpindleTorque03", Description = "Spindle 03 Torque % > 0" },
|
|
new CounterModel { CCode = "SpindleTorque04", Description = "Spindle 04 Torque % > 0" },
|
|
new CounterModel { CCode = "LMCheckElapsed", Description = "Time Elapsed from last full Manufacturer Check" }
|
|
);
|
|
|
|
// inizializzazione dei valori di default x Tipologia UserTeam
|
|
modelBuilder.Entity<PMUTModel>().HasData(
|
|
new PMUTModel { PMUTCode = "TrainOp", Description = "Trained Operator" },
|
|
new PMUTModel { PMUTCode = "MaintServ", Description = "Maintenance Service" },
|
|
new PMUTModel { PMUTCode = "DevSupp", Description = "Device Supplier" },
|
|
new PMUTModel { PMUTCode = "MultiaxServ", Description = "Multiax Service" }
|
|
);
|
|
|
|
// inizializzazione dei valori di default x Topic di Prev Maint
|
|
modelBuilder.Entity<PMTaskTopicModel>().HasData(
|
|
new PMTaskTopicModel { PMTCode = "Mechanical", Description = "Mechanical system" },
|
|
new PMTaskTopicModel { PMTCode = "Electro", Description = "Electrical system" },
|
|
new PMTaskTopicModel { PMTCode = "Lubro", Description = "Lubrication system" },
|
|
new PMTaskTopicModel { PMTCode = "Coolant", Description = "Coolant system" },
|
|
new PMTaskTopicModel { PMTCode = "Preumo", Description = "Pneumatic system" },
|
|
new PMTaskTopicModel { PMTCode = "Hydro", Description = "Hydraulic system" },
|
|
new PMTaskTopicModel { PMTCode = "Safety", Description = "Enclosure/Safety system" },
|
|
new PMTaskTopicModel { PMTCode = "Suction", Description = "Suction system" },
|
|
new PMTaskTopicModel { PMTCode = "GeoAdj", Description = "Geometrical system" }
|
|
);
|
|
|
|
// inizializzazione dei valori di default x Machine Group
|
|
modelBuilder.Entity<PMMGroupModel>().HasData(
|
|
new PMMGroupModel { PMMGCode = "Whole", Description = "Whole Machine" },
|
|
new PMMGroupModel { PMMGCode = "Load", Description = "Part loader/unloader" },
|
|
new PMMGroupModel { PMMGCode = "MovBelts", Description = "Part moving belts" },
|
|
new PMMGroupModel { PMMGCode = "MovRoll", Description = "Part moving rollers" },
|
|
new PMMGroupModel { PMMGCode = "Axis", Description = "Machining axis" },
|
|
new PMMGroupModel { PMMGCode = "Spindles", Description = "Tool spindles" },
|
|
new PMMGroupModel { PMMGCode = "ToolChange", Description = "Automatic tool changer" },
|
|
new PMMGroupModel { PMMGCode = "Cabinet", Description = "Electrical cabinet" },
|
|
new PMMGroupModel { PMMGCode = "ChipConv", Description = "Chips conveyor" },
|
|
new PMMGroupModel { PMMGCode = "DustSuct", Description = "Dust suction" },
|
|
new PMMGroupModel { PMMGCode = "OpPanel", Description = "Operator pannel" },
|
|
new PMMGroupModel { PMMGCode = "Access", Description = "Accessories" }
|
|
);
|
|
|
|
#if false
|
|
// 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" }
|
|
);
|
|
#endif
|
|
|
|
#if false
|
|
// inizializzazione dei valori di default x Plant
|
|
modelBuilder.Entity<PlantDetailModel>().HasData(
|
|
new PlantDetailModel { PlantId = 1, PlantCode = "PIZ03", PlantDesc = "Collecchio", LevelMax = 26000, LevelReorder = 15000, OrderQtyStd = 18000 },
|
|
new PlantDetailModel { PlantId = 2, PlantCode = "PIZ04", PlantDesc = "Noceto", LevelMax = 28000, LevelReorder = 15000, OrderQtyStd = 18000 },
|
|
new PlantDetailModel { PlantId = 3, PlantCode = "PIZ05", PlantDesc = "Baganzola", LevelMax = 24000, LevelReorder = 15000, OrderQtyStd = 18000 },
|
|
new PlantDetailModel { PlantId = 4, PlantCode = "PIZ08", PlantDesc = "Pilastrello", LevelMax = 26000, LevelReorder = 15000, OrderQtyStd = 18000 },
|
|
new PlantDetailModel { PlantId = 5, PlantCode = "PIZ09", PlantDesc = "Guardamiglio", LevelMax = 26000, LevelReorder = 15000, OrderQtyStd = 18000 }
|
|
// new PlantDetailModel { PlantId = 1, PlantCode = "PIZ03", PlantDesc = "Collecchio", LevelMax = 26000, 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 = 26000, PressMax = 19, PressBHMax = 270, PressBLMax = 270 }
|
|
);
|
|
#endif
|
|
|
|
|
|
#if false
|
|
// 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" }
|
|
);
|
|
#endif
|
|
|
|
#if false
|
|
// 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 }
|
|
);
|
|
#endif
|
|
}
|
|
}
|
|
}
|