Beispiel #1
0
        public ActionResult EditSchema_Post(string settingGroupData)
        {
            try
            {
                SettingGroup SettingGroup = JsonConvert.DeserializeObject <SettingGroup>(settingGroupData);

                List <WebUserMessage> ErrorList = SettingGroup.Validate();

                //if passed validation
                if (ErrorList == null || ErrorList.Count == 0)
                {
                    //remove data entry property key if data entry does not require just to be safe
                    foreach (var Sett in SettingGroup.SettingsList)
                    {
                        if (!DataEntryTypeProperty.DataTypesRequireProperties.Contains(Sett.EntryType))
                        {
                            Sett.DataEntryStaticPropertyKey = string.Empty;
                        }
                    }

                    if (SettingGroupDAO.Save(SettingGroup))
                    {
                        AddWebUserMessageToSession(Request, String.Format("Successfully saved/updated setting group \"{0}\"", SettingGroup.GroupKey), SUCCESS_MESSAGE_TYPE);
                    }
                    else
                    {
                        AddWebUserMessageToSession(Request, String.Format("Unable to saved/update setting group \"{0}\" at this time", SettingGroup.GroupKey), FAILED_MESSAGE_TYPE);
                    }
                }
                //failed validation
                else
                {
                    AddWebUserMessageToSession(Request, ErrorList);

                    return(RedirectToAction("EditSchema", "Settings", new { settingGroupData = settingGroupData }));
                }

                return(RedirectToAction("Index", "Dashboard"));
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.SettingsController.EditSchema_Post() " + e.Message);
            }

            AddWebUserMessageToSession(Request, String.Format("Unable to save/update setting schemas at this time."), FAILED_MESSAGE_TYPE);

            return(RedirectToAction("Index", "Dashboard"));
        }
Beispiel #2
0
        public void ProcessFile()
        {
            XmlDocument XmlDoc = new XmlDocument();

            XmlDoc.Load(FilePath);

            foreach (var Node in XmlDoc.DocumentElement.GetElementsByTagName("SettingGroup"))
            {
                XmlElement Element = (XmlElement)Node;

                SettingGroup SetGroup = new SettingGroup();

                SetGroup.GroupKey         = Element.GetElementsByTagName("GroupKey")[0].InnerText;
                SetGroup.UserFriendlyName = Element.GetElementsByTagName("UserFriendlyName")[0].InnerText;
                SetGroup.Description      = Element.GetElementsByTagName("Description")[0].InnerText;
                SetGroup.ParentCategory   = (ParentCategoryType)Enum.Parse(typeof(ParentCategoryType), Element.GetElementsByTagName("ParentCategory")[0].InnerText);

                foreach (var ChildNode in Element.GetElementsByTagName("Setting"))
                {
                    XmlElement ChildElement = (XmlElement)ChildNode;

                    Setting Sett = new Setting();

                    Sett.Key = ChildElement.GetElementsByTagName("Key")[0].InnerText;
                    Sett.UserFriendlyName           = ChildElement.GetElementsByTagName("UserFriendlyName")[0].InnerText;
                    Sett.Description                = ChildElement.GetElementsByTagName("Description")[0].InnerText;
                    Sett.Value                      = ChildElement.GetElementsByTagName("Value")[0].InnerText;
                    Sett.EntryType                  = (DataEntryType)Enum.Parse(typeof(DataEntryType), ChildElement.GetElementsByTagName("EntryType")[0].InnerText);
                    Sett.DataEntryStaticPropertyKey = ChildElement.GetElementsByTagName("DataEntryStaticPropertyKey")[0].InnerText;

                    foreach (var ChildChildNode in ChildElement.GetElementsByTagName("SettingAttribute"))
                    {
                        XmlElement ChildChildElement = (XmlElement)ChildChildNode;

                        SettingAttribute SetAttr = new SettingAttribute();

                        SetAttr.Key   = ChildChildElement.GetElementsByTagName("Key")[0].InnerText;
                        SetAttr.Value = ChildChildElement.GetElementsByTagName("Value")[0].InnerText;

                        Sett.SettingAttributeList.Add(SetAttr);
                    }

                    SetGroup.SettingsList.Add(Sett);
                }

                SettingGroupDAO.Save(SetGroup);
            }
        }
Beispiel #3
0
        public ActionResult EditValues_Post(string id)
        {
            try
            {
                SettingGroup SettingGroup = SettingGroupDAO.LoadSettingGroupById(id);

                foreach (var Sett in SettingGroup.SettingsList)
                {
                    if (!string.IsNullOrWhiteSpace(Request["setting_" + Sett.Key]))
                    {
                        Sett.Value = Request["setting_" + Sett.Key];
                    }
                    else
                    {
                        Sett.Value = string.Empty;
                    }
                }

                if (SettingGroupDAO.Save(SettingGroup))
                {
                    AddWebUserMessageToSession(Request, String.Format("Successfully saved/updated setting group \"{0}\"", SettingGroup.GroupKey), SUCCESS_MESSAGE_TYPE);
                }
                else
                {
                    AddWebUserMessageToSession(Request, String.Format("Unable to saved/update setting group \"{0}\" at this time", SettingGroup.GroupKey), FAILED_MESSAGE_TYPE);
                }

                return(RedirectToAction("Index", "Dashboard"));
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.SettingsController.EditValues_Post() " + e.Message);
            }

            AddWebUserMessageToSession(Request, String.Format("Unable to save/update setting values at this time."), FAILED_MESSAGE_TYPE);

            return(RedirectToAction("Index", "Dashboard"));
        }