Beispiel #1
0
        public async Task <ActionResult> SaveModify(RuleViewModel model)
        {
            using (RuleServiceClient client = new RuleServiceClient())
            {
                MethodReturnResult <Rule> result = await client.GetAsync(model.Code);

                if (result.Code == 0)
                {
                    result.Data.FullPackageQty   = model.FullPackageQty.Value;
                    result.Data.Name             = model.Name;
                    result.Data.CalibrationCycle = model.CalibrationCycle;
                    result.Data.CalibrationType  = model.CalibrationType;
                    result.Data.FixCycle         = model.FixCycle;
                    result.Data.MaxPower         = model.MaxPower;
                    result.Data.MinPower         = model.MinPower;
                    result.Data.PowerDegree      = model.PowerDegree;
                    result.Data.PowersetCode     = model.PowersetCode.ToUpper();
                    result.Data.Description      = model.Description;
                    result.Data.IsUsed           = model.IsUsed;
                    result.Data.Editor           = User.Identity.Name;
                    result.Data.EditTime         = DateTime.Now;
                    MethodReturnResult rst = await client.ModifyAsync(result.Data);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(ZPVMResources.StringResource.Rule_SaveModify_Success
                                                    , model.Code);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
Beispiel #2
0
        //
        // POST: /ZPVM/Rule/Save
        public async Task <ActionResult> Save(RuleViewModel model)
        {
            using (RuleServiceClient client = new RuleServiceClient())
            {
                Rule obj = new Rule()
                {
                    Key              = model.Code,
                    Name             = model.Name.ToUpper(),
                    CalibrationCycle = model.CalibrationCycle,
                    CalibrationType  = model.CalibrationType,
                    FixCycle         = model.FixCycle,
                    MaxPower         = model.MaxPower,
                    MinPower         = model.MinPower,
                    PowerDegree      = model.PowerDegree,
                    PowersetCode     = model.PowersetCode.ToUpper(),
                    Description      = model.Description,
                    IsUsed           = model.IsUsed,
                    FullPackageQty   = model.FullPackageQty.Value,
                    Editor           = User.Identity.Name,
                    EditTime         = DateTime.Now,
                    CreateTime       = DateTime.Now,
                    Creator          = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(ZPVMResources.StringResource.Rule_Save_Success
                                                , obj.Key);
                }
                return(Json(rst));
            }
        }
Beispiel #3
0
        public async Task <ActionResult> Delete(string code)
        {
            MethodReturnResult result = new MethodReturnResult();

            using (RuleServiceClient client = new RuleServiceClient())
            {
                result = await client.DeleteAsync(code);

                if (result.Code == 0)
                {
                    result.Message = string.Format(ZPVMResources.StringResource.Rule_Delete_Success
                                                   , code);
                }
                return(Json(result));
            }
        }
Beispiel #4
0
        //
        // GET: /ZPVM/RuleControlObject/
        public async Task <ActionResult> Index(string code)
        {
            if (string.IsNullOrEmpty(code))
            {
                return(RedirectToAction("Index", "Rule"));
            }

            using (RuleServiceClient client = new RuleServiceClient())
            {
                MethodReturnResult <Rule> result = await client.GetAsync(code);

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "Rule"));
                }
                ViewBag.Rule = result.Data;
            }

            using (RuleControlObjectServiceClient client = new RuleControlObjectServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        Where = string.Format(" Key.Code = '{0}'"
                                              , code),
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <RuleControlObject> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new RuleControlObjectQueryViewModel()
            {
                Code = code
            }));
        }
Beispiel #5
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"));
        }
Beispiel #6
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()));
        }
Beispiel #7
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));
        }
Beispiel #8
0
        //
        // GET: /ZPVM/Rule/Modify
        public async Task <ActionResult> Modify(string code)
        {
            RuleViewModel viewModel = new RuleViewModel();

            using (RuleServiceClient client = new RuleServiceClient())
            {
                MethodReturnResult <Rule> result = await client.GetAsync(code);

                if (result.Code == 0)
                {
                    viewModel = new RuleViewModel()
                    {
                        Code             = result.Data.Key,
                        Name             = result.Data.Name,
                        CalibrationType  = result.Data.CalibrationType,
                        PowersetCode     = result.Data.PowersetCode,
                        PowerDegree      = result.Data.PowerDegree,
                        MinPower         = result.Data.MinPower,
                        MaxPower         = result.Data.MaxPower,
                        FixCycle         = result.Data.FixCycle,
                        CalibrationCycle = result.Data.CalibrationCycle,
                        Description      = result.Data.Description,
                        IsUsed           = result.Data.IsUsed,
                        FullPackageQty   = result.Data.FullPackageQty,
                        CreateTime       = result.Data.CreateTime,
                        Creator          = result.Data.Creator,
                        Editor           = result.Data.Editor,
                        EditTime         = result.Data.EditTime
                    };
                    return(PartialView("_ModifyPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_ModifyPartial"));
        }
Beispiel #9
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"));
        }