Added import-export tool table
Added scada new image field "negate"
This commit is contained in:
@@ -549,5 +549,49 @@ namespace Step.Database.Controllers
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
|
||||
public DTOExportToolTableModel GetExportData()
|
||||
{
|
||||
return new DTOExportToolTableModel
|
||||
{
|
||||
Tools = FindTools(),
|
||||
Families = FindFamilies(),
|
||||
Shanks = FindShanks()
|
||||
};
|
||||
}
|
||||
|
||||
public void ImportData(DTOExportToolTableModel data)
|
||||
{
|
||||
List<DbNcToolModel> tools = FindTools();
|
||||
List<DbNcFamilyModel> families = FindFamilies();
|
||||
List<DbNcShankModel> shanks = FindShanks();
|
||||
|
||||
// loop thought new families
|
||||
foreach (var family in data.Families)
|
||||
{
|
||||
// Check if not exist
|
||||
if (families.FirstOrDefault(x => x.FamilyId == family.FamilyId) == null)
|
||||
dbCtx.Families.Add(family);
|
||||
}
|
||||
|
||||
// loop thought new shanks
|
||||
foreach (var shank in data.Shanks)
|
||||
{
|
||||
// Check if not exist
|
||||
if (shanks.FirstOrDefault(x => x.ShankId == shank.ShankId) == null)
|
||||
dbCtx.Shanks.Add(shank);
|
||||
}
|
||||
|
||||
// loop thought new tools
|
||||
foreach (var tool in data.Tools)
|
||||
{
|
||||
// Check if not exist
|
||||
if (tools.FirstOrDefault(x => x.ToolId == tool.ToolId) == null)
|
||||
dbCtx.Tools.Add(tool);
|
||||
}
|
||||
|
||||
// Save
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user