Esempio n. 1
0
 public ActionResult PagedData(string id, string model, string fullJson, string key)
 {
     try
     {
         QueryDescriptor descriptor = FullJsonValue.GetObject <QueryDescriptor>(fullJson);
         DbContext       db         = GetNetDatabase();
         if (!string.IsNullOrEmpty(id))
         {
             descriptor.Condition = GetIdFilter(id);
         }
         object data = null;
         if (string.Compare(model, "net_order", true) == 0)
         {
             data = GetPageDataByQuery <net_order>(db, descriptor);
         }
         else if (string.Compare(model, "net_user", true) == 0)
         {
             data = GetPageDataByQuery <net_user>(db, descriptor);
         }
         return(Json(data));
     }
     catch (Exception ex)
     {
         return(Json(new
         {
             statusCode = "3",
             data = ex.Message
         }));
     }
 }
Esempio n. 2
0
        public object Save(string model, string method, string fullJson, string parm)
        {
            Type entityType = DataAccessHelper.GetEntityType(model, "Form");
            var  postdata   = FullJsonValue.GetObject(entityType, fullJson);

            if (postdata == null)
            {
                throw new Exception("提交数据处理失败");
            }
            if ((model.ToLower() == "core_user" || model.ToLower() == "core_role") && IsWebLocked())
            {
                throw new UserException("没有操作权限");
            }
            IService service = ServiceHelper.GetService(model);

            if (parm != null)
            {
                service.ServiceParm = parm;
            }
            bool   flag          = method == "create";
            object obj           = null;
            object propertyValue = DataHelper.GetPropertyValue(postdata.GetType(), postdata, "data");

            obj = ((!flag) ? service.Update(propertyValue) : service.Create(propertyValue));
            return(obj);
        }
Esempio n. 3
0
        public object PagedData(string id, string model, string fullJson, Dictionary <string, object> treeCondition, string key)
        {
            QueryDescriptor descriptor = FullJsonValue.GetObject <QueryDescriptor>(fullJson);
            IService        service    = ServiceHelper.GetService(model);

            if (treeCondition != null && treeCondition.Keys.Count > 0)
            {
                FilterGroup treeCondition2 = service.GetTreeCondition(treeCondition);
                if (treeCondition2 != null)
                {
                    descriptor.Condition.groups.Add(treeCondition2);
                }
            }
            ChangeFilterGroup(model, key, descriptor.Condition);
            object pageData = service.GetPageData(descriptor);
            var    presult  = pageData as PagedData;

            if (presult != null)
            {
                return(new PageQueryResult <Dictionary <string, object> >()
                {
                    PageIndex = (int)descriptor.PageIndex,
                    PageSize = (int)descriptor.PageSize,
                    Total = (int)presult.Total,
                    Rows = presult.Records
                });
            }

            return(null);
        }
Esempio n. 4
0
        public object DetailData(string model, string id, string filter)
        {
            FilterGroup filterGroup = FullJsonValue.GetObject <FilterGroup>(filter);
            IService    service     = ServiceHelper.GetService(model);
            Dictionary <string, object> detailData = service.GetDetailData(id, filterGroup);

            return(detailData);
        }
Esempio n. 5
0
        public object ListData(string model, string filter, string key)
        {
            FilterGroup filterGroup = FullJsonValue.GetObject <FilterGroup>(filter);
            IService    service     = ServiceHelper.GetService(model);

            ChangeFilterGroup(model, key, filterGroup);
            List <Dictionary <string, object> > listData = service.GetListData(filterGroup);

            return(listData);
        }