コード例 #1
0
ファイル: ConfigManage.cs プロジェクト: decadestory/Configer
        public int AddConfig(CenterConfiger cfg, string parentKey)
        {
            using (var db = new Db())
            {
                if (!string.IsNullOrEmpty(parentKey))
                {
                    var conf = GetConfig(parentKey);
                    cfg.ParentId = conf.Id;
                }

                var exist = db.Top <CenterConfiger>(t => t.Key == cfg.Key);
                if (exist == null)
                {
                    return(db.Insert(cfg));
                }

                exist.Name        = cfg.Name;
                exist.ParentId    = cfg.ParentId;
                exist.Value       = cfg.Value;
                exist.Version     = cfg.Version;
                exist.Description = cfg.Description;
                exist.EditTime    = DateTime.Now;
                return(db.Update(exist));
            }
        }
コード例 #2
0
ファイル: Configer.cs プロジェクト: decadestory/Configer
        public static bool Set(string key, string value, string parentKey = "", string name = "", string desc = "", int version = 1)
        {
            var cc = new CenterConfiger()
            {
                Key         = key,
                Value       = value,
                Version     = version,
                Name        = name,
                Description = desc,
                AddTime     = DateTime.Now,
                EditTime    = DateTime.Now,
                Enable      = true
            };

            return(confm.AddConfig(cc, parentKey) > 0);
        }