Пример #1
0
        public static void SaveSysConfigValueByName(SysConfig[] list, SysConfigNameDefine Name, string Value, SysConfig_Project[] configProjectList = null, int ProjectID = 0)
        {
            var data = list.FirstOrDefault(p => p.Name.Equals(Name.ToString()));

            if (data == null)
            {
                data         = new SysConfig();
                data.Name    = Name.ToString();
                data.AddTime = DateTime.Now;
            }
            if (ProjectID <= 1)
            {
                data.Value = Value;
            }
            data.Save();
            if (ProjectID > 1 && configProjectList != null)
            {
                var configProject = configProjectList.FirstOrDefault(p => p.ConfigID == data.ID && p.ProjectID == ProjectID);
                if (configProject == null)
                {
                    configProject           = new SysConfig_Project();
                    configProject.AddTime   = DateTime.Now;
                    configProject.ProjectID = ProjectID;
                    configProject.ConfigID  = data.ID;
                }
                configProject.ConfigValue = Value;
                configProject.Save();
            }
        }
Пример #2
0
        public static SysConfig SaveSysConfigByType(SysConfig[] list, SysConfigNameDefine Name, string Value, SqlHelper helper, string ConfigType = "", bool CanSaveValue = true)
        {
            var data = list.FirstOrDefault(p => p.Name.Equals(Name.ToString()));

            if (data == null)
            {
                data            = new SysConfig();
                data.AddTime    = DateTime.Now;
                data.ConfigType = ConfigType;
                data.Name       = Name.ToString();
                data.Value      = Value;
            }
            if (CanSaveValue)
            {
                data.Value = Value;
            }
            data.Save(helper);
            return(data);
        }
Пример #3
0
        public static string GetConfigValueByList(SysConfig[] configList, SysConfigNameDefine ConfigName, string AllParentID = "")
        {
            SysConfig[] myConfigList = new SysConfig[] { };
            if (!string.IsNullOrEmpty(AllParentID))
            {
                myConfigList = configList.Where(p => AllParentID.Contains("," + p.ProjectID + ",") || p.ProjectID <= 1).ToArray();
            }
            if (myConfigList.Length == 0)
            {
                myConfigList = configList;
            }
            var config = myConfigList.FirstOrDefault(p => p.Name.Equals(ConfigName.ToString()));

            if (config == null)
            {
                return(string.Empty);
            }
            return(config.Value);
        }
Пример #4
0
        public static string GetSysConfigValueByName(SysConfig[] list, SysConfigNameDefine Name)
        {
            var data = list.FirstOrDefault(p => p.Name.Equals(Name.ToString()));

            return(data == null ? string.Empty : data.Value);
        }