public ActionResult SaveLocation(ComponentLocation location) { if (!ModelState.IsValid && location.Id != 0) { var viewModel = new LocationFormViewModel { Location = location, }; return(View("LocationForm", viewModel)); } var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); //Choose between add and update if (location.Id == 0) { xmlDB.Locations.Add(location); } else { var locationInDB = xmlDB.Locations.Single(c => c.Id == location.Id); locationInDB.Name = location.Name; locationInDB.Prefix = location.Prefix; } xmlDB.Save(); return(RedirectToAction("Index", "HWConf")); }
public IO UpdateIO(int id, IO IO) { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var IOInDb = xmlDB.IOs.SingleOrDefault(c => c.Id == id); if (IOInDb == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } IOInDb.Comment = IO.Comment; IOInDb.ComponentId = IO.ComponentId; IOInDb.ConnectionType = IO.ConnectionType; IOInDb.Location = IO.Location; IOInDb.MatchStatus = IO.MatchStatus; IOInDb.Name = IO.Name; IOInDb.ParentName = IO.ParentName; IOInDb.IOAddress = IO.IOAddress; xmlDB.Save(); return(IO); }
public ActionResult SaveModule(Module module) { if (!ModelState.IsValid && module.Id != 0) { var viewModel = new ModuleFormViewModel { Module = module, }; return(View("ModuleForm", viewModel)); } var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); // Create new or update if (module.Id == 0) { //new module.Address = xmlDB.Modules.Count(); xmlDB.Modules.Add(module); } else { //Update var moduleInDB = xmlDB.Modules.Single(c => c.Id == module.Id); moduleInDB.Name = module.Name; moduleInDB.IOModulesType = module.IOModulesType; } xmlDB.Save(); return(RedirectToAction("Index", "HWConf")); }
public ActionResult SavePLC(PLC PLC) { if (!ModelState.IsValid && PLC.Id != 0) { var viewModel = new PLCFormViewModel { PLC = PLC, }; return(View("PLCForm", viewModel)); } var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); xmlDB.PLC = PLC; xmlDB.Save(); //------------------------------------------------------------------------ //Add embedded IO modules if (PLC.ProductType == Enums.ControllerType.L16ER || PLC.ProductType == Enums.ControllerType.L18ER && (xmlDB.Modules.Where(c => ((c.IOModulesType == Enums.IOModulesType.EmbDIx16) || (c.IOModulesType == Enums.IOModulesType.EmbDOx16))).Count() == 0)) { var embDI = new Module { Name = "PLC_Emb_DI", IOModulesType = Enums.IOModulesType.EmbDIx16, Address = 1 }; var embDO = new Module { Name = "PLC_Emb_DO", IOModulesType = Enums.IOModulesType.EmbDOx16, Address = 1 }; xmlDB.Modules.Add(embDI); xmlDB.Modules.Add(embDO); xmlDB.Save(); } return(RedirectToAction("Index", "HWConf")); }
public IHttpActionResult CreateLocation(ComponentLocation location) { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); if (!ModelState.IsValid) { return(BadRequest()); } xmlDB.Locations.Add(location); xmlDB.Save(); return(Created(new Uri(Request.RequestUri + "/" + location.Id), location)); }
public IHttpActionResult CreateIO(IO IO) { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); if (!ModelState.IsValid) { return(BadRequest()); } xmlDB.IOs.Add(IO); xmlDB.Save(); return(Created(new Uri(Request.RequestUri + "/" + IO.Id), IO)); }
public void DeleteIO(int id) { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); var IOInDb = xmlDB.IOs.SingleOrDefault(c => c.Id == id); if (IOInDb == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } xmlDB.IOs.Remove(IOInDb); xmlDB.Save(); return; }
public ActionResult Approve(int stdId, int IOId) { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); var ioInDb = xmlDB.IOs.First(c => c.Id == IOId); var componentInDb = xmlDB.Components.First(c => c.Id == ioInDb.ComponentId); componentInDb.StandardId = stdId; ioInDb.MatchStatus = Enums.MatchStatus.Match; componentInDb.MatchStatus = Enums.MatchStatus.Match; xmlDB.Save(); return(RedirectToAction("Index", "IOList")); }
//==================================================================================================================== //ADD LOCATIONS private void DetectLocations() { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); foreach (IO io in xmlDB.IOs.ToList()) { //Add location if not duplicate if (xmlDB.Locations.SingleOrDefault(c => c.Name == io.Location) == null) //Add location if it doesnt exist and if it is not empty or null { xmlDB.Locations.Add(new ComponentLocation { Name = io.Location }); xmlDB.Save(); } } return; }
public IHttpActionResult UpdateComponent(int id, Component component) { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var componentInDb = xmlDB.Components.SingleOrDefault(c => c.Id == id); if (componentInDb == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } componentInDb.MatchStatus = Enums.MatchStatus.Match; componentInDb.Name = component.Name; componentInDb.Comment = component.Comment; componentInDb.Location = component.Location; componentInDb.StandardId = component.StandardId; componentInDb.ConnectionType = componentInDb.ConnectionType; componentInDb.Dependancy = component.Dependancy; var io = xmlDB.IOs.FirstOrDefault(c => c.Id == componentInDb.IOId); if (io != null) { io.MatchStatus = Enums.MatchStatus.Match; io.ComponentId = componentInDb.Id; } xmlDB.Save(); return(Ok()); }
public ComponentLocation UpdateLocation(int id, ComponentLocation location) { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var locationInDb = xmlDB.Locations.SingleOrDefault(c => c.Id == id); if (locationInDb == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } locationInDb.Prefix = location.Prefix; locationInDb.Name = location.Name; xmlDB.Save(); return(location); }
public Module UpdateModule(int id, Module module) { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var moduleInDb = xmlDB.Modules.SingleOrDefault(c => c.Id == id); if (moduleInDb == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } moduleInDb.Name = module.Name; moduleInDb.IOModulesType = module.IOModulesType; xmlDB.Save(); return(module); }
public ActionResult Index(HttpPostedFileBase file) { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); var ioList = new List <IO>(); // Verify that the user selected a file if (file != null && file.ContentLength > 0) { // extract only the filename //var fileName = Path.GetFileName(file.FileName); // store the file inside ~/App_Data/uploads folder //var path = Path.Combine(Server.MapPath("C:/Users/Ivan/Desktop/OP generator PLC koda/uploads"), fileName); //file.SaveAs(path); //Parsing file var ms = new MemoryStream(); file.InputStream.CopyTo(ms); byte[] array = ms.GetBuffer(); string fileAsString = Encoding.UTF8.GetString(array); //Split by lines String[] CSVrows = fileAsString.Split(new[] { Environment.NewLine }, StringSplitOptions.None).Skip(1).ToArray(); //Each line split by ';' -- parse values to database foreach (string str in CSVrows) { if (str.Length < 10) { continue; } var IOmembers = str.Split(';'); var io = new IO(); io.Location = IOmembers[0]; switch (IOmembers[1]) { case ("AI"): io.ConnectionType = Enums.ConnectionType.AI; break; case ("AO"): io.ConnectionType = Enums.ConnectionType.AO; break; case ("DI"): io.ConnectionType = Enums.ConnectionType.DI; break; case ("DO"): io.ConnectionType = Enums.ConnectionType.DO; break; case ("DIO"): io.ConnectionType = Enums.ConnectionType.DIO; break; default: throw new Exception("Error reading PLC IO type"); } io.IOAddress = new IOAddress(IOmembers[2]); io.Name = IOmembers[3]; io.ParentName = IOmembers[4]; io.Comment = IOmembers[5]; //Add io ioList.Add(io); } } foreach (var io in ioList) { xmlDB.IOs.Add(io); } xmlDB.Save(); //Add locations to database DetectLocations(); CreateComponents(); return(RedirectToAction("Index")); }
//========================================================================================================== //Match IO to Standard private void CreateComponents() { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); foreach (var io in xmlDB.IOs.ToList()) { if (!String.IsNullOrWhiteSpace(io.ParentName)) { //IO is part of parent component io.MatchStatus = Enums.MatchStatus.Check; //If parent component doesnt exist create it if (!xmlDB.Components.Any(c => c.Name == io.ParentName)) { var component = new Component(); component.Name = io.ParentName; component.Comment = io.Comment; component.Location = io.Location; component.Dependancy = Enums.Dependancy.Parent; component.MatchStatus = Enums.MatchStatus.No_Match; if (io.IOAddress.Type == Enums.IOType.IO) { component.ConnectionType = Enums.ConnectionType.DIO; } else { component.ConnectionType = Enums.ConnectionType.ETH; } xmlDB.Components.Add(component); } else { //if it exist check connection type - if any child IO is IP(ETH) type -> switch components connection type if (io.IOAddress.Type == Enums.IOType.IP) { var componentDB = xmlDB.Components.Single(c => c.Name == io.ParentName); componentDB.ConnectionType = Enums.ConnectionType.ETH; } } } else { switch (io.ConnectionType) { case Enums.ConnectionType.AI: // Create single component var componentAI = new Component(); componentAI.IOId = io.Id; componentAI.Name = io.Name; componentAI.Comment = io.Comment; componentAI.Location = io.Location; componentAI.Dependancy = Enums.Dependancy.Single; componentAI.ConnectionType = io.ConnectionType; //Matching var possibleStdAIAOI = xmlDB.Standards.Where(c => c.ConnectionType == io.ConnectionType).ToList(); switch (possibleStdAIAOI.Count()) { case (0): componentAI.StandardId = null; componentAI.MatchStatus = Enums.MatchStatus.No_Match; io.MatchStatus = Enums.MatchStatus.No_Match; break; case (1): componentAI.StandardId = possibleStdAIAOI.ElementAt(0).Id; componentAI.MatchStatus = Enums.MatchStatus.Match; io.MatchStatus = Enums.MatchStatus.Match; break; // Case more than one default: // take first one - standards should be sorted from most used to least used componentAI.StandardId = possibleStdAIAOI.ElementAt(0).Id; componentAI.MatchStatus = Enums.MatchStatus.Check; io.MatchStatus = Enums.MatchStatus.Check; break; } xmlDB.Components.Add(componentAI); break; //===================================================================================== case Enums.ConnectionType.AO: //Always part of parent component throw new Exception("Analog output must be part of parent component"); //===================================================================================== case Enums.ConnectionType.DI: // Create single component var componentDI = new Component(); componentDI.IOId = io.Id; componentDI.Name = io.Name; componentDI.Comment = io.Comment; componentDI.Location = io.Location; componentDI.Dependancy = Enums.Dependancy.Single; componentDI.ConnectionType = io.ConnectionType; //Matching var possibleStdDIAOI = xmlDB.Standards.Where(c => c.ConnectionType == io.ConnectionType).ToList(); switch (possibleStdDIAOI.Count()) { case (0): componentDI.StandardId = null; componentDI.MatchStatus = Enums.MatchStatus.No_Match; io.MatchStatus = Enums.MatchStatus.No_Match; break; case (1): componentDI.StandardId = possibleStdDIAOI.ElementAt(0).Id; componentDI.MatchStatus = Enums.MatchStatus.Match; io.MatchStatus = Enums.MatchStatus.Match; break; // Case more than one default: // take first one - standards should be sorted from most used to least used componentDI.StandardId = possibleStdDIAOI.ElementAt(0).Id; componentDI.MatchStatus = Enums.MatchStatus.Check; io.MatchStatus = Enums.MatchStatus.Check; break; } xmlDB.Components.Add(componentDI); break; //===================================================================================== case Enums.ConnectionType.DO: // Create single component var componentDO = new Component(); componentDO.IOId = io.Id; componentDO.Name = io.Name; componentDO.Comment = io.Comment; componentDO.Location = io.Location; componentDO.Dependancy = Enums.Dependancy.Single; componentDO.ConnectionType = io.ConnectionType; //Matching var possibleStdDOAOI = xmlDB.Standards.Where(c => c.ConnectionType == io.ConnectionType).ToList(); switch (possibleStdDOAOI.Count()) { case (0): componentDO.StandardId = null; componentDO.MatchStatus = Enums.MatchStatus.No_Match; io.MatchStatus = Enums.MatchStatus.No_Match; break; case (1): componentDO.StandardId = possibleStdDOAOI.ElementAt(0).Id; componentDO.MatchStatus = Enums.MatchStatus.Match; io.MatchStatus = Enums.MatchStatus.Match; break; // Case more than one default: // take first one - standards should be sorted from most used to least used componentDO.StandardId = possibleStdDOAOI.ElementAt(0).Id; componentDO.MatchStatus = Enums.MatchStatus.Check; io.MatchStatus = Enums.MatchStatus.Check; break; } xmlDB.Components.Add(componentDO); break; //===================================================================================== case Enums.ConnectionType.ETH: //ETH and DIO reserved for parent components throw new Exception("ETH and DIO connection types reserved for parent components"); case Enums.ConnectionType.DIO: //ETH and DIO reserved for parent components throw new Exception("ETH and DIO connection types reserved for parent components"); default: throw new Exception("Matching: Unknown connection type"); } } } xmlDB.Save(); //Fill up io.ComponentId foreach (var io in xmlDB.IOs) { var component = xmlDB.Components.FirstOrDefault(c => c.IOId == io.Id); //If component exist link with IO if (component != null) { io.ComponentId = component.Id; } else { //For child components io.ComponentId = xmlDB.Components.First(c => c.Name == io.ParentName).Id; } } xmlDB.Save(); }
public ActionResult Save(IO io) { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); //Load page name String pageName; if (String.IsNullOrEmpty(userName)) { pageName = ""; } else { pageName = _context.Users.First(c => c.Name == userName).ActProject; } if (!ModelState.IsValid) { var viewModel = new EditIOIOListViewModel { IO = io, IOLocations = xmlDB.Locations.ToList(), Parents = xmlDB.Components.Where(c => c.Dependancy == Enums.Dependancy.Parent), PageName = pageName }; return(View("IOForm", viewModel)); } //Component created by user -> set to match io.MatchStatus = Enums.MatchStatus.Match; if (String.IsNullOrWhiteSpace(io.ParentName) || String.IsNullOrEmpty(io.ParentName)) { // UPDATE/ADD Single IOs Component var componentInDb = xmlDB.Components.SingleOrDefault(c => c.IOId == io.Id); if (componentInDb == null) { // Create single component var component = new Component(); component.IOId = io.Id; component.Name = io.Name; component.Comment = io.Comment; component.Location = io.Location; component.Dependancy = Enums.Dependancy.Single; component.MatchStatus = Enums.MatchStatus.No_Match; xmlDB.Components.Add(component); } else { //Update single component componentInDb.Comment = io.Comment; componentInDb.Location = io.Location; componentInDb.Name = io.Name; } } else { // Update/Add parent component var componentInDb = xmlDB.Components.SingleOrDefault(c => c.Name == io.ParentName); if (componentInDb == null) { // Create parent component var component = new Component(); component.IOId = io.Id; component.Name = io.Name; component.Comment = io.Comment; component.Location = io.Location; component.Dependancy = Enums.Dependancy.Parent; component.MatchStatus = Enums.MatchStatus.No_Match; xmlDB.Components.Add(component); } } xmlDB.Save(); //UPDATE/ADD IO var IOInDb = xmlDB.IOs.SingleOrDefault(c => c.Id == io.Id); if (IOInDb == null) { xmlDB.IOs.Add(io); } else { IOInDb.Name = io.Name; IOInDb.Comment = io.Comment; IOInDb.Location = io.Location; IOInDb.IOAddress = io.IOAddress; IOInDb.ComponentId = io.ComponentId; IOInDb.ConnectionType = io.ConnectionType; IOInDb.MatchStatus = io.MatchStatus; } xmlDB.Save(); //UPDATE IDs var ioIDUpdate = xmlDB.IOs.First(c => c.Name == io.Name); var ComponentIDUpdate = new Component(); // Search for component when it is single/parent if (String.IsNullOrEmpty(io.ParentName)) { ComponentIDUpdate = xmlDB.Components.First(c => c.Name == io.Name); //Update single components IO ID ComponentIDUpdate.IOId = ioIDUpdate.Id; } else { ComponentIDUpdate = xmlDB.Components.First(c => c.Name == io.ParentName); //Parent component has on IO ID because they are multiple } ioIDUpdate.ComponentId = ComponentIDUpdate.Id; xmlDB.Save(); return(RedirectToAction("Index", "IOList")); }
public ActionResult Save(Component component) { var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); //Load page name String pageName; if (String.IsNullOrEmpty(userName)) { pageName = ""; } else { pageName = _context.Users.First(c => c.Name == userName).ActProject; } // Input validation TODO //If standard is changed if (component.StandardId != null && component.StandardId != 0) { component.ConnectionType = xmlDB.Standards.First(c => c.Id == component.StandardId).ConnectionType; component.MatchStatus = Enums.MatchStatus.Match; } //Add/Update component if (component.Id == 0) { xmlDB.Components.Add(component); } else { var componentInDb = xmlDB.Components.SingleOrDefault(c => c.Id == component.Id); if (componentInDb == null) { xmlDB.Components.Add(component); } else { componentInDb.Name = component.Name; componentInDb.Comment = component.Comment; componentInDb.Location = component.Location; componentInDb.Dependancy = component.Dependancy; componentInDb.IOId = component.IOId; componentInDb.StandardId = component.StandardId; componentInDb.MatchStatus = component.MatchStatus; componentInDb.ConnectionType = component.ConnectionType; if (componentInDb.Setup != null) { //Update parameter values (setup) for (int i = 0; i < componentInDb.Setup.Parameters.Count; i++) { if (component.Setup.Parameters[i] != null) { //Choose from which AuxValue take value if (componentInDb.Setup.Parameters[i].Type == ParType.Parameter) { //Case Parameter if (componentInDb.Setup.Parameters[i].DataType == DataType.BOOL) { //Case Parameter - BOOL componentInDb.Setup.Parameters[i].Value = component.Setup.Parameters[i].AuxValueBOOL ? "1" : "0"; } if (componentInDb.Setup.Parameters[i].DataType == DataType.REAL) {//Case Parameter - Real if (component.Setup.Parameters[i].AuxValueFLOAT == null) { componentInDb.Setup.Parameters[i].Value = componentInDb.Setup.Parameters[i].DefaultValue; } else { componentInDb.Setup.Parameters[i].Value = component.Setup.Parameters[i].AuxValueFLOAT.ToString(); } } } else {//case IO if (component.Setup.Parameters[i].AuxValueINT == null) { componentInDb.Setup.Parameters[i].Value = componentInDb.Setup.Parameters[i].DefaultValue; } else { componentInDb.Setup.Parameters[i].Value = component.Setup.Parameters[i].AuxValueINT.ToString(); } } } } } } } //Set all components childs to Match foreach (var io in xmlDB.IOs.Where(c => c.ComponentId == component.Id)) { io.MatchStatus = Enums.MatchStatus.Match; } xmlDB.Save(); return(RedirectToAction("Index", "IOList")); }
public ActionResult LoadDefaultStandards() { // Loading default standards var standards = new List <Standard>(); DirectoryInfo d = new DirectoryInfo(@"C:\Users\Ivan\Desktop\OP generator PLC koda\StandardAOI"); //Assuming Test is your Folder FileInfo[] Files = d.GetFiles("*.L5X"); //Getting L5X files foreach (var file in Files) { switch (file.Name) { case ("AlarmDi.L5X"): standards.Add(new Standard { AOIName = file.Name.Substring(0, file.Name.Length - 4), ConnectionType = Enums.ConnectionType.DI, Group = "DIAlarm" }); break; case ("Analog.L5X"): standards.Add(new Standard { AOIName = file.Name.Substring(0, file.Name.Length - 4), //Generated together with AlarmAI ConnectionType = Enums.ConnectionType.AI, Group = "AIAlarm" }); break; case ("Average.L5X"): standards.Add(new Standard { AOIName = file.Name.Substring(0, file.Name.Length - 4), //Generated together with AlarmAI ConnectionType = Enums.ConnectionType.No_Connection_Type, Group = "Aux" }); break; case ("CLOCK.L5X"): standards.Add(new Standard { AOIName = file.Name.Substring(0, file.Name.Length - 4), //Generated always ConnectionType = Enums.ConnectionType.No_Connection_Type, Group = "Always" }); break; case ("CNT.L5X"): standards.Add(new Standard { AOIName = file.Name.Substring(0, file.Name.Length - 4), //Generated always ConnectionType = Enums.ConnectionType.DI, Group = "Counter" }); break; case ("DanfossFC_FV2_0.L5X"): standards.Add(new Standard { AOIName = file.Name.Substring(0, file.Name.Length - 4), //Generated with FRQ Dir and Rev ConnectionType = Enums.ConnectionType.No_Connection_Type, Group = "Aux" }); break; case ("DriftPause.L5X"): standards.Add(new Standard { AOIName = file.Name.Substring(0, file.Name.Length - 4), //Generated on request with Motor ConnectionType = Enums.ConnectionType.No_Connection_Type, Group = "Aux" }); break; case ("MotorDir.L5X"): standards.Add(new Standard { AOIName = file.Name.Substring(0, file.Name.Length - 4), //Generated as parent ConnectionType = Enums.ConnectionType.DIO, Group = "Motor" }); standards.Add(new Standard { AOIName = file.Name.Substring(0, file.Name.Length - 4), //Generated as parent ConnectionType = Enums.ConnectionType.ETH, Group = "Motor" }); break; /* * case ("MotorRev.L5X"): * standards.Add(new Standard * { * AOIName = file.Name.Substring(0, file.Name.Length - 4), * //Generated as parent * ConnectionType = Enums.ConnectionType.DIO, * Group = "Motor" * }); * standards.Add(new Standard * { * AOIName = file.Name.Substring(0, file.Name.Length - 4), * //Generated as parent * ConnectionType = Enums.ConnectionType.ETH, * Group = "Motor" * }); * break; */ case ("ValveControl.L5X"): standards.Add(new Standard { AOIName = file.Name.Substring(0, file.Name.Length - 4), //Generated as parent ConnectionType = Enums.ConnectionType.DIO, Group = "Valve" }); break; case ("SCP.L5X"): standards.Add(new Standard { AOIName = file.Name.Substring(0, file.Name.Length - 4), //Generated as parent ConnectionType = Enums.ConnectionType.No_Connection_Type, Group = "Aux" }); break; default: break; } } var userName = User.Identity.GetUserName(); var xmlDB = new XMLDatabase(userName, _context.Users.First(c => c.Name == userName).ActProject); foreach (var standard in standards) { //Add to file xmlDB.Standards.Add(standard); } /*//Add DO * xmlDB.Standards.Add(new Standard { * AOIName = "Std_DO_NoAOI", * ConnectionType = Enums.ConnectionType.DO, * Group = "Aux" * });*/ xmlDB.Save(); // CREATE DEFAULT CONFIG FILES //Create config file AlarmDi xmlDB.AddConfigFile("AlarmDi", GenerateAlarmDiConfig()); //Create config file Analog xmlDB.AddConfigFile("Analog", GenerateAnalogConfig()); //Create config file CLOCK xmlDB.AddConfigFile("CLOCK", GenerateCLOCKConfig()); //Create config file CNT xmlDB.AddConfigFile("CNT", GenerateCNTConfig()); //Create config file DanfossFC_FV2_0 xmlDB.AddConfigFile("DanfossFC_FV2_0", GenerateDanfossFC_FV2_0Config()); //Create config file MotorDir xmlDB.AddConfigFile("MotorDir", GenerateMotorDirConfig()); //Create config file ValveControl xmlDB.AddConfigFile("ValveControl", GenerateValveControlConfig()); return(RedirectToAction("Index", "Standards")); }