示例#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));
            }
        }
示例#2
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
            }));
        }
示例#3
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"));
        }