Пример #1
0
        /// <summary>
        /// 彻底删除实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeleteEntity(string id)
        {
            var inst = new YunDocItem();

            inst.ID = id;
            inst.Delete();
            return(0);
        }
Пример #2
0
        public YunDocItem GetEntity(string id)
        {
            var inst = new YunDocItem();

            inst.ID = id;
            inst    = EntityManager.GetInstance().Get <YunDocItem>(inst);
            return(inst);
        }
Пример #3
0
        /// <summary>
        /// 删除一个目录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int RemoveEntity(string id)
        {
            var inst = new YunDocItem();

            inst.ID = id;
            inst.Remove();
            return(0);
        }
Пример #4
0
        /// <summary>
        /// 统计操作
        /// </summary>
        /// <returns></returns>
        public object Count(string json)
        {
            var item  = new YunDocItem();
            var match = "{$match:" + json + "}";
            var group = "{$group:{_id:'YunDocItem总数',Count:{$sum:1}}}";
            var res   = EntityManager.GetInstance().Aggregate(item._DbName, item._CollectionName, match, group);

            return(res);
        }
Пример #5
0
        public object Aggregate(string itemType, string match, string group)
        {
            var item = new BaseItem();

            if ("Entity" == itemType)
            {
                item = new YunDocItem();
            }
            else if ("Category" == itemType)
            {
                item = new CategoryItem();
            }
            var res = EntityManager.GetInstance().Aggregate(item._DbName, item._CollectionName, match, group);

            return(res);
        }
Пример #6
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
        }
Пример #7
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);
 }