/// <summary> /// Read a configuration from the XML Configuration File /// based on the given id /// </summary> /// <param name="id">id of the configuration</param> private void ReadConfiguration(string id) { var configFile = XDocument.Load(xmlFilePth); var config = from data in configFile.Descendants("Configuration") .Where(item => ((string)item.Attribute("confId")).CompareTo(id) == 0) .Descendants("MyData") select new { XmlId = data.Element("Id")?.Value, XmlAction = data.Element("Action")?.Value, XmlServer = data.Element("Server")?.Value, XmlSource = data.Element("Source")?.Value, XmlDestination = data.Element("Destination")?.Value, XmlSourceFolderPath = data.Element("SourceFolderPath")?.Value, XmlDescription = data.Element("Description")?.Value, XmlSite = data.Element("Site")?.Value }; ListEntries.Clear(); foreach (var item in config) { var dataConfig = new MyData() { Action = item.XmlAction, Description = item.XmlDescription, Destination = item.XmlDestination, Server = item.XmlServer, Site = item.XmlSite, Source = item.XmlSource, SourceFolderPath = item.XmlSourceFolderPath, Id = Convert.ToInt32(item.XmlId) }; ListEntries.Add(dataConfig); } }
public ActionResult InsertEntry(UnitModel newEntry) { ActionResult res = new ActionResult(); if (!CheckMaxModelcount(newEntry)) { res.Success = false; res.Message = "Die Einheit ist voll, es können keine neuen Modelle mehr hinzugefügt werden (außer reine Upgrades...)"; return(res); } if (!CheckMinimumRequirement(newEntry)) { res.Success = false; res.Message = "Es sind noch nicht genügend Modelle enthalten, um dieses Upgrade auszuwählen."; return(res); } if (!CheckMForN(newEntry)) { res.Success = false; res.Message = "Es sind noch nicht genügend Modelle enthalten, um dieses Upgrade (_n_ für je _x_ Modelle) auszuwählen."; return(res); } if (ListEntries.Any(x => x.Id == newEntry.Id)) { UnitModel exitstingEntry = (UnitModel)ListEntries.Where(x => x.Id == newEntry.Id).Distinct(); exitstingEntry = newEntry; } else { ListEntries.Add(newEntry); } res.Success = true; return(res); }