예제 #1
0
        public static void Save(string jsonInput)
        {
            var dict = Convertor.FromJsonToDict2(jsonInput);
            var inst = new CategoryItem();

            if (dict.ContainsKey("ID") && null != dict["ID"])
            {
                inst.ID = dict["ID"].ToString();
            }
            inst = EntityManager.GetInstance().Get <CategoryItem>(inst);
            foreach (var kv in dict)
            {
                inst.GetType().GetProperty(kv.Key).SetValue(inst, kv.Value);
            }
            inst.Save();
        }
예제 #2
0
        public int Save(string name, string parentId, string id)
        {
            var session = SESSION.Current;
            var inst    = new CategoryItem();
            var isNew   = false;

            if (StringChecker.IsObjectId(id))
            {
                inst._id = ObjectId.Parse(id);
            }
            else
            {
                inst._id = ObjectId.GenerateNewId();
                //inst.ID = Guid.NewGuid();
                inst.CreateTime  = DateTime.Now.AddDays(new Random().Next(-100, 100));
                inst.CreatorName = session.UserName;
                inst.CreatorID   = session.UserID;
                isNew            = true;
            }


            inst.Name     = name;
            inst.ParentID = parentId;
            //inst.GroupName = "文档库模板";
            inst.UpdateTime = DateTime.Now;
            inst.Status     = CONST.Status.Normal;
            inst.Save();

            ///添加记录
            //if (isNew)
            //{
            //    ModifyLogItem.LogAsNew(inst.id, CONST.DB.DBName_DocService, CONST.DB.CollectionName_CategoryItem);
            //}
            //else
            //{
            //    ModifyLogItem.LogAsModify(inst.id, CONST.DB.DBName_DocService, CONST.DB.CollectionName_CategoryItem);
            //}

            return(0);
        }
예제 #3
0
 /// <summary>
 /// 保存一个目录
 /// </summary>
 /// <param name="name"></param>
 /// <param name="parentId"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public int SaveCategory(string jsonInput)
 {
     CategoryItem.Save(jsonInput);
     return(0);
 }