Example #1
0
        private void LoadData()
        {
            SystemConfigOperation sysConfigOperation = new SystemConfigOperation();
            string strFilePath = AppConfigHelper.GetConfigValue(Constnatmanager.Config.XmlConfigFilePath);
            IList<CombinerModel> combinerList = sysConfigOperation.ReadData(strFilePath).OrderByDescending(t => t.CreateDate).ToList();

            rlist.DataSource = combinerList;
            rlist.DataBind();
        }
 public void ReadDataTest()
 {
     SystemConfigOperation target = new SystemConfigOperation(); // TODO: 初始化为适当的值
     string fileName = "E://CombinerConfig.xml"; // TODO: 初始化为适当的值
     List<CombinerModel> expected = null; // TODO: 初始化为适当的值
     List<CombinerModel> actual;
     actual = target.ReadData(fileName);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("验证此测试方法的正确性。");
 }
 public void SaveDataTest()
 {
     SystemConfigOperation target = new SystemConfigOperation(); // TODO: 初始化为适当的值
     List<CombinerModel> list = null; // TODO: 初始化为适当的值
     list = TestHelper.CreateTestData();
     string fileName = "E://CombinerConfig.xml"; // TODO: 初始化为适当的值
     bool expected = false; // TODO: 初始化为适当的值
     bool actual;
     actual = target.SaveData(list, fileName);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("验证此测试方法的正确性。");
 }
        private void LoadData()
        {
            SystemConfigOperation sysConfigOperation = new SystemConfigOperation();
            string strFilePath = AppConfigHelper.GetConfigValue(Constnatmanager.Config.XmlConfigFilePath);
            IList<CombinerModel> combinerList = sysConfigOperation.ReadData(strFilePath);

            if (string.IsNullOrEmpty(guid))
            {
                combiner = new CombinerModel();
            }
            else
            {
                combiner = combinerList.Where(x => x.GUID == guid).FirstOrDefault();
            }
        }
 public CombinerModel GetConfigItem(string filePath, string name, string version)
 {
     SystemConfigOperation operation = new SystemConfigOperation();
     List<CombinerModel> list = operation.ReadData(filePath);
     return list.Where(l => l.Name == name && l.Version == version).FirstOrDefault<CombinerModel>();
 }
Example #6
0
        public static List<CombinerModel> LoadXMLConfigItems(string configFilePath)
        {
            SystemConfigOperation systemComfigOperation = new SystemConfigOperation();
            string strFilePath = AppConfigHelper.GetConfigValue(configFilePath);

            List<CombinerModel> combinerList = systemComfigOperation.ReadData(strFilePath);
            return combinerList;
        }
        private CombinerModel GetConfigItem(string name, string version)
        {
            string strFilePath = AppConfigHelper.GetConfigValue(Constnatmanager.Config.XmlConfigFilePath);

            if (!string.IsNullOrEmpty(strFilePath))
            {
                SystemConfigOperation operation = new SystemConfigOperation();
                return operation.GetConfigItem(strFilePath, name, version);
            }

            return null;
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = Constnatmanager.CONTENT_TYPE;
            ActionResult action;

            HttpRequest request = context.Request;
            OperatingType cmd = (OperatingType)System.Enum.Parse(typeof(OperatingType), request[Constnatmanager.Request.CMD]);
            List<CombinerModel> combinerList = ConfigHelper.LoadXMLConfigItems(Constnatmanager.Config.XmlConfigFilePath);
            bool result = false;
            string message = Constnatmanager.Message.FAILE;
            string guid = context.Request.Form[Constnatmanager.Request.Form.GUID];
            CombinerModel configItem = ConfigHelper.GetConfigItem(guid, combinerList);

            string name = string.Empty;
            string description = string.Empty;
            string expires = string.Empty;
            string iNames = string.Empty;
            string version = string.Empty;
            ContentType contentType = ContentType.defualt;
            bool isCache = false;
            bool isMinify = false;
            bool isDebug = false;

            if (cmd == OperatingType.Modify || cmd == OperatingType.Add)
            {
                name = context.Request.Form[Constnatmanager.Request.Form.NAME];
                description = context.Request.Form[Constnatmanager.Request.Form.DESCRIPTION];
                expires = context.Request.Form[Constnatmanager.Request.Form.EXPIRES];
                iNames = context.Request.Form[Constnatmanager.Request.Form.ITEMSNAMES];
                contentType = (ContentType)Convert.ToInt32(context.Request.Form[Constnatmanager.Request.Form.CONTENTTYPE]);
                isCache = Convert.ToBoolean(Convert.ToInt32(context.Request.Form[Constnatmanager.Request.Form.ISCACHE]));
                isMinify = Convert.ToBoolean(Convert.ToInt32(context.Request.Form[Constnatmanager.Request.Form.ISMINIFY]));
                version = context.Request.Form[Constnatmanager.Request.Form.VERSION];
                isDebug = Convert.ToBoolean(Convert.ToInt32(context.Request.Form[Constnatmanager.Request.Form.ISDEBUG]));
            }

            try
            {
                switch (cmd)
                {
                    case OperatingType.Modify:

                        if ((combinerList.Where(c => c.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase) && c.Version.Equals(version, StringComparison.CurrentCultureIgnoreCase)).Count() > 0)
                            && !(configItem.Name.Equals(name) && configItem.Version.Equals(version)))
                        {
                            message = Constnatmanager.Message.REPEAT;
                            result = false;
                        }
                        else
                        {
                            result = combinerList.Remove(configItem);
                            ConfigHelper.RemoveCache(configItem);
                            ConfigHelper.AddXMLConfig(name, description, expires, iNames, contentType, isCache, isMinify, combinerList, isDebug, version);
                        }
                        break;
                    case OperatingType.Delete:
                        result = combinerList.Remove(configItem);
                        ConfigHelper.RemoveCache(configItem);
                        break;
                    case OperatingType.Add:
                        if (combinerList.Where(c => c.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase) && c.Version.Equals(version, StringComparison.CurrentCultureIgnoreCase)).Count() > 0)
                        {
                            message = Constnatmanager.Message.REPEAT;
                            result = false;
                        }
                        else
                        {
                            List<CombinerModel> combinerMList = ConfigHelper.AddXMLConfig(name, description, expires, iNames, contentType, isCache, isMinify, combinerList, isDebug, version);
                            if (combinerMList != null)
                            {
                                result = true;
                            }
                        }
                        break;
                    default:
                        break;
                }

                if (result)
                {
                    SystemConfigOperation systemComfigOperation = new SystemConfigOperation();
                    string strFilePath = AppConfigHelper.GetConfigValue(Constnatmanager.Config.XmlConfigFilePath);
                    result = systemComfigOperation.SaveData(combinerList, strFilePath);
                }

                if (result)
                {
                    message = Constnatmanager.Message.SUCCESS;
                }

                action = new ActionResult(result, message);

            }
            catch (Exception ex)
            {
                action = new ActionResult(false, ex.Message);
            }

            context.Response.Write(JsonConvert.SerializeObject(action));
        }