/// <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);
            }
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// RenderEditMode renders the Edit mode of the control
 /// </summary>
 /// <param name="writer">A HtmlTextWriter.</param>
 /// <history>
 ///     [cnurse]	05/04/2006	created
 /// </history>
 /// -----------------------------------------------------------------------------
 protected override void RenderEditMode(HtmlTextWriter writer)
 {
     if (ListEntries == null || !ListEntries.Any())
     {
         //No List so use a Text Box
         string propValue = Convert.ToString(Value);
         ControlStyle.AddAttributesToRender(writer);
         writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
         writer.AddAttribute(HtmlTextWriterAttribute.Value, propValue);
         writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID);
         writer.RenderBeginTag(HtmlTextWriterTag.Input);
         writer.RenderEndTag();
     }
     else
     {
         //Render the standard List
         base.RenderEditMode(writer);
     }
 }
 protected override void RenderEditMode(HtmlTextWriter writer)
 {
     if (ListEntries != null && ListEntries.Any())
     {
         foreach (ListEntryInfo item in ListEntries)
         {
             Regions.Items.Add(new ListItem()
             {
                 Text = item.Text, Value = item.EntryID.ToString()
             });
         }
     }
     ControlStyle.AddAttributesToRender(writer);
     writer.AddAttribute("data-name", Name);
     writer.AddAttribute("data-list", "Region");
     writer.AddAttribute("data-category", Category);
     writer.AddAttribute("data-required", Required.ToString().ToLowerInvariant());
     writer.RenderBeginTag(HtmlTextWriterTag.Div);
     RenderChildren(writer);
     writer.RenderEndTag();
 }
Пример #4
0
        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);
        }