Esempio n. 1
0
        //
        // GET: /FMM/EquipmentLayout/Detail
        public async Task <ActionResult> Detail(string key)
        {
            using (EquipmentLayoutServiceClient client = new EquipmentLayoutServiceClient())
            {
                MethodReturnResult <EquipmentLayout> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    EquipmentLayoutViewModel viewModel = new EquipmentLayoutViewModel()
                    {
                        Name        = result.Data.Key,
                        Width       = result.Data.Width,
                        Height      = result.Data.Height,
                        Status      = result.Data.Status,
                        CreateTime  = result.Data.CreateTime,
                        Creator     = result.Data.Creator,
                        Description = result.Data.Description,
                        Editor      = result.Data.Editor,
                        EditTime    = result.Data.EditTime
                    };
                    return(PartialView("_InfoPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_InfoPartial"));
        }
Esempio n. 2
0
        public async Task <ActionResult> SaveModify(EquipmentLayoutViewModel model)
        {
            MethodReturnResult rst = new MethodReturnResult();

            if (model.BackgroundImage != null &&
                !model.BackgroundImage.ContentType.Contains("image"))
            {
                rst.Code    = 1000;
                rst.Message = string.Format(StringResource.ValidateImageFileFormat, FMMResources.StringResource.EquipmentLayoutViewModel_BackgroundImage);
                return(Json(rst));
            }
            try
            {
                using (EquipmentLayoutServiceClient client = new EquipmentLayoutServiceClient())
                {
                    MethodReturnResult <EquipmentLayout> result = await client.GetAsync(model.Name);

                    if (result.Code == 0)
                    {
                        result.Data.Height      = model.Height;
                        result.Data.Width       = model.Width;
                        result.Data.Status      = model.Status;
                        result.Data.Description = model.Description;
                        result.Data.Editor      = User.Identity.Name;
                        result.Data.EditTime    = DateTime.Now;
                        if (model.IsDeleteBackgroudImage)
                        {
                            result.Data.BackgroundImage = null;
                        }
                        else if (model.BackgroundImage != null && model.BackgroundImage.ContentLength > 10)
                        {
                            int length = (int)model.BackgroundImage.InputStream.Length;
                            result.Data.BackgroundImage = new byte[length];
                            model.BackgroundImage.InputStream.Read(result.Data.BackgroundImage, 0, length);
                        }
                        rst = await client.ModifyAsync(result.Data);

                        if (rst.Code == 0)
                        {
                            rst.Message = string.Format(FMMResources.StringResource.EquipmentLayout_SaveModify_Success
                                                        , model.Name);
                        }
                        return(Json(rst));
                    }
                    return(Json(result));
                }
            }
            catch (Exception ex)
            {
                rst.Code    = 1000;
                rst.Message = ex.Message;
                rst.Detail  = ex.ToString();
            }
            return(Json(rst));
        }
Esempio n. 3
0
        public async Task <ActionResult> Query(EquipmentLayoutDetailQueryViewModel model)
        {
            using (EquipmentLayoutServiceClient client = new EquipmentLayoutServiceClient())
            {
                MethodReturnResult <EquipmentLayout> result = await client.GetAsync(model.LayoutName ?? string.Empty);

                ViewBag.EquipmentLayout = result.Data;
            }

            using (EquipmentLayoutDetailServiceClient client = new EquipmentLayoutDetailServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format(" Key.LayoutName = '{0}'"
                                                 , model.LayoutName)
                    };
                    MethodReturnResult <IList <EquipmentLayoutDetail> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            using (EquipmentStateServiceClient client = new EquipmentStateServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false
                    };
                    MethodReturnResult <IList <EquipmentState> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.StateList = result.Data;
                    }
                });
            }
            return(PartialView("_ListPartial", new EquipmentLayoutDetailViewModel()
            {
                LayoutName = model.LayoutName
            }));
        }
        //
        // GET: /FMM/EquipmentLayoutDetail/
        public async Task <ActionResult> Index(string layoutName)
        {
            using (EquipmentLayoutServiceClient client = new EquipmentLayoutServiceClient())
            {
                MethodReturnResult <EquipmentLayout> result = await client.GetAsync(layoutName ?? string.Empty);

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

            using (EquipmentLayoutDetailServiceClient client = new EquipmentLayoutDetailServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format(" Key.LayoutName = '{0}'"
                                                 , layoutName)
                    };
                    MethodReturnResult <IList <EquipmentLayoutDetail> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial", new EquipmentLayoutDetailViewModel()
                {
                    LayoutName = layoutName
                }));
            }
            else
            {
                return(View(new EquipmentLayoutDetailQueryViewModel()
                {
                    LayoutName = layoutName
                }));
            }
        }