Esempio n. 1
0
        public static void Save(string jsonInput)
        {
            var dict = Convertor.FromJsonToDict2(jsonInput);
            var inst = new YunDocItem();

            if (dict.ContainsKey("ID") && null != dict["ID"])
            {
                inst.ID = dict["ID"].ToString();
            }
            inst = EntityManager.GetInstance().Get <YunDocItem>(inst);
            foreach (var kv in dict)
            {
                var property = inst.GetType().GetProperty(kv.Key);
                if (property.CanWrite)
                {
                    property.SetValue(inst, kv.Value);
                }
            }
            inst.Name  = "[" + SESSION.Current.UserName + "]" + inst.Name;  ///调试用
            inst.Title = "[" + SESSION.Current.UserName + "]" + inst.Title; ///调试用
            inst.Save();

            #region 创建共享文档
            if (null != inst.UserAllowedArray)
            {
                var redirectID = inst.ID;
                foreach (string id in inst.UserAllowedArray)
                {
                    var staff = StaffItem.Load(id);
                    inst.ID          = null;
                    inst.Name        = "[共享给" + staff.Name + "]" + inst.Name;
                    inst.Title       = "[共享给" + staff.Name + "]" + inst.Title;
                    inst._RedirectID = redirectID;
                    inst.OwnerID     = id;
                    inst.Save();
                }
            }
            #endregion
        }
Esempio n. 2
0
 /// <summary>
 /// 保存一个目录
 /// </summary>
 /// <param name="name"></param>
 /// <param name="parentId"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public int SaveEntity(string jsonInput)
 {
     YunDocItem.Save(jsonInput);
     return(0);
 }