Пример #1
0
        public static void Save(string jsonInput)
        {
            var dict = Convertor.FromJsonToDict2(jsonInput);
            var inst = new OrgItem();

            if (dict.ContainsKey("ID") && null != dict["ID"])
            {
                inst.ID = dict["ID"].ToString();
            }
            inst = EntityManager.GetInstance().Get <OrgItem>(inst);
            foreach (var kv in dict)
            {
                var property = inst.GetType().GetProperty(kv.Key);
                if (property.CanWrite)
                {
                    if (typeof(DateTime) == property.PropertyType)
                    {
                        property.SetValue(inst, DateTime.Parse(kv.Value.ToString()));
                    }
                    else if (null != kv.Value && typeof(string) == kv.Value.GetType())
                    {
                        property.SetValue(inst, kv.Value.ToString().Trim());
                    }
                    else
                    {
                        property.SetValue(inst, kv.Value);
                    }
                }
            }
            inst.Save();
        }
Пример #2
0
        public OrgItem GetOrg(string id)
        {
            var inst = new OrgItem();

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

            inst.ID = id;
            inst.Remove();
            return(0);
        }
Пример #4
0
        public object Aggregate(string itemType, string match, string group)
        {
            var item = new BaseItem();

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

            return(res);
        }
Пример #5
0
 /// <summary>
 /// 保存一个目录
 /// </summary>
 /// <param name="name"></param>
 /// <param name="parentId"></param>
 /// <param name="id"></param>
 /// <returns></returns>
 public int SaveOrg(string jsonInput)
 {
     OrgItem.Save(jsonInput);
     return(0);
 }