Пример #1
0
        /// <summary>
        /// 确定明细信息
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public async Task <ActionResult> Detail(string itemCode)
        {
            using (DataAcquisitionItemServiceClient client = new DataAcquisitionItemServiceClient())
            {
                MethodReturnResult <DataAcquisitionItem> result = await client.GetAsync(itemCode);

                if (result.Code == 0)
                {
                    DataAcquisitionItemViewModel viewModel = new DataAcquisitionItemViewModel()
                    {
                        ItemCode      = result.Data.Key,           //项目代码
                        ItemName      = result.Data.ItemName,      //项目名称
                        Description   = result.Data.Description,   //描述
                        RouteStepName = result.Data.RouteStepName, //工序名称
                        Creator       = result.Data.Creator,       //创建人
                        CreateTime    = result.Data.CreateTime,    //创建日期
                        Editor        = result.Data.Editor,        //编辑人
                        EditTime      = result.Data.EditTime       //编辑日期
                    };

                    return(PartialView("_InfoPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }

            return(PartialView("_InfoPartial"));
        }
Пример #2
0
        public async Task <ActionResult> SaveModify(DataAcquisitionItemViewModel model)
        {
            using (DataAcquisitionItemServiceClient client = new DataAcquisitionItemServiceClient())
            {
                MethodReturnResult <DataAcquisitionItem> result = await client.GetAsync(model.ItemCode);

                if (result.Code == 0)
                {
                    result.Data.Key           = model.ItemCode;         //项目代码
                    result.Data.ItemName      = model.ItemName;         //项目名称
                    result.Data.Description   = model.Description;      //项目描述
                    result.Data.RouteStepName = model.RouteStepName;    //工序名称
                    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(StringResource.DataAcquisitionItem_SaveModify_Success
                                                    , model.ItemCode);
                    }

                    return(Json(rst));
                }

                return(Json(result));
            }
        }
Пример #3
0
        /// <summary>
        /// 根据采集项目初始化采集字段窗体
        /// </summary>
        /// <param name="itemCode">采集项目代码</param>
        /// <returns></returns>
        public async Task <ActionResult> Index(string itemCode)
        {
            //取得采集项目对象
            using (DataAcquisitionItemServiceClient client = new DataAcquisitionItemServiceClient())
            {
                MethodReturnResult <DataAcquisitionItem> result = await client.GetAsync(itemCode ?? string.Empty);

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

                ViewBag.DataAcquisitionItem = result.Data;
            }

            //提取采集字段数据
            using (DataAcquisitionFieldServiceClient client = new DataAcquisitionFieldServiceClient())
            {
                await Task.Run(() =>
                {
                    //string where = string.Format("Key.ItemCode = '{0}'", itemCode);

                    PagingConfig cfg = new PagingConfig()
                    {
                        Where   = string.Format("Key.ItemCode = '{0}'", itemCode),
                        OrderBy = "Key.ItemCode,SerialNumber"
                    };

                    //提取数据
                    MethodReturnResult <IList <DataAcquisitionField> > result = client.Get(ref cfg);

                    if (result.Code > 0 || result.Data == null)
                    {
                        //错误信息处理
                    }
                    else
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }

            return(View(new DataAcquisitionFieldQueryViewModel()
            {
                ItemCode = itemCode
            }));
        }