//
        // GET: /FMM/EquipmentChangeState/
        public async Task <ActionResult> Index()
        {
            using (EquipmentStateServiceClient client = new EquipmentStateServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        OrderBy  = "Type,Key"
                    };
                    MethodReturnResult <IList <EquipmentState> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.StateList = result.Data;
                    }
                    else
                    {
                        ModelState.AddModelError("", result.Message);
                    }
                });
            }

            using (EquipmentChangeStateServiceClient client = new EquipmentChangeStateServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false
                    };
                    MethodReturnResult <IList <EquipmentChangeState> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.ChangeStateList = result.Data;
                    }
                    else
                    {
                        ModelState.AddModelError("", result.Message);
                    }
                });
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("_ListPartial"));
            }
            else
            {
                return(View());
            }
        }
Exemple #2
0
        public ActionResult GetEquipmentChangeState(string stateName)
        {
            //获取用户拥有权限的设备状态。
            IList <Resource> lstResource = new List <Resource>();

            using (UserAuthenticateServiceClient client = new UserAuthenticateServiceClient())
            {
                MethodReturnResult <IList <Resource> > result = client.GetResourceList(User.Identity.Name, ResourceType.EquipmentState);
                if (result.Code <= 0 && result.Data != null)
                {
                    lstResource = result.Data;
                }
            }
            var lnq = from item in lstResource
                      where item.Data == stateName
                      select item;

            IList <EquipmentChangeState> lst = new List <EquipmentChangeState>();

            if (lnq.Count() > 0)
            {
                //根据设备状态获取设备状态事件。
                using (EquipmentChangeStateServiceClient client = new EquipmentChangeStateServiceClient())
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format(@"FromStateName='{0}'", stateName)
                    };
                    MethodReturnResult <IList <EquipmentChangeState> > result = client.Get(ref cfg);
                    if (result.Code <= 0 && result.Data != null)
                    {
                        lst = result.Data;
                    }
                }
            }


            var lnq1 = from item in lst
                       select new
            {
                Key         = item.Key,
                Text        = item.Key,
                ToStateName = item.ToStateName
            };

            return(Json(lnq1, JsonRequestBehavior.AllowGet));
        }