Ejemplo n.º 1
0
        public async Task <ActionResult> Query(RuleQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (RuleServiceClient client = new RuleServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.Code))
                            {
                                where.AppendFormat(" {0} Key LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Code);
                            }

                            if (!string.IsNullOrEmpty(model.Name))
                            {
                                where.AppendFormat(" {0} Name LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Name);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <Rule> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Ejemplo n.º 2
0
        //
        // GET: /ZPVM/Rule/
        public async Task <ActionResult> Index()
        {
            using (RuleServiceClient client = new RuleServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <Rule> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new RuleQueryViewModel()));
        }
Ejemplo n.º 3
0
        public ActionResult GetRuleCode(string q)
        {
            IList <Rule> lstDetail = new List <Rule>();

            using (RuleServiceClient client = new RuleServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format(@"Key LIKE '{0}%'
                                            AND IsUsed=1"
                                             , q),
                    OrderBy = "Key"
                };

                MethodReturnResult <IList <Rule> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null)
                {
                    lstDetail = result.Data;
                }
            }

            var lnq = from item in lstDetail
                      select item.Key;

            return(Json(from item in lstDetail
                        select new
            {
                @label = item.Key + "-" + item.Name,
                @value = item.Key,
                @Name = item.Name,
                @MaxPower = item.MaxPower,
                @MinPower = item.MinPower,
                @FixCycle = item.FixCycle,
                @CalibrationCycle = item.CalibrationCycle,
                @CalibrationType = item.CalibrationType,
                @PowerDegree = item.PowerDegree,
                @FullPackageQty = item.FullPackageQty
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            if (ModelState.IsValid)
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;
                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }
                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                using (RuleServiceClient client = new RuleServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <Rule> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }