Exemplo n.º 1
0
        /// <summary>
        /// GET: /Display/Alarm/GetLatestOperation
        /// </summary>
        /// <returns></returns>
        public ActionResult GetLatestOperation()
        {
            GetLastOperationData data = new GetLastOperationData();

            try
            {
                using (var service = ServiceFactory.GetCallbackServiceWrapper <IOperationService>(new OperationServiceCallback()))
                {
                    IList <int> ids = service.Instance.GetOperationIds(WebsiteConfiguration.Instance.MaxAge, WebsiteConfiguration.Instance.NonAcknowledgedOnly, 1);
                    if (ids.Count == 1)
                    {
                        Operation item = service.Instance.GetOperationById(ids[0]);
                        data.success = true;
                        data.op      = item;
                    }
                    else if (ids.Count == 0)
                    {
                        data.success = true;
                        data.op      = null;
                    }
                }
            }
            catch (Exception ex)
            {
                // It's ok when an exception is thrown here. We catch it, log it, and the View considers it as an error (success is false).
                Logger.Instance.LogException(this, ex);
            }

            JsonResult result = new JsonResult();

            result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            result.Data = data;
            return(result);
        }
        /// <summary>
        /// GET: /Display/Alarm/GetLatestOperation
        /// </summary>
        /// <returns></returns>
        public ActionResult GetLatestOperation()
        {
            GetLastOperationData data = new GetLastOperationData();

            try
            {
                using (var service = ServiceFactory.GetCallbackServiceWrapper <IOperationService>(new OperationServiceCallback()))
                {
                    IList <int> ids = service.Instance.GetOperationIds(WebsiteConfiguration.Instance.MaxAge, WebsiteConfiguration.Instance.NonAcknowledgedOnly, 1);
                    if (ids.Any())
                    {
                        Operation item = service.Instance.GetOperationById(ids.Single());
                        data.op = item;
                    }

                    data.success = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.LogException(this, ex);
            }

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        /// <summary>
        /// GET: /Display/Alarm/GetLatestOperation
        /// </summary>
        /// <returns></returns>
        public ActionResult GetLatestOperation()
        {
            GetLastOperationData data = new GetLastOperationData();
            try
            {
                using (var service = ServiceFactory.GetCallbackServiceWrapper<IOperationService>(new OperationServiceCallback()))
                {
                    IList<int> ids = service.Instance.GetOperationIds(WebsiteConfiguration.Instance.MaxAge, WebsiteConfiguration.Instance.NonAcknowledgedOnly, 1);
                    if (ids.Count == 1)
                    {
                        Operation item = service.Instance.GetOperationById(ids[0]);
                        data.success = true;
                        data.op = item;
                    }
                    else if (ids.Count == 0)
                    {
                        data.success = true;
                        data.op = null;
                    }
                }
            }
            catch (Exception ex)
            {
                // It's ok when an exception is thrown here. We catch it, log it, and the View considers it as an error (success is false).
                Logger.Instance.LogException(this, ex);
            }

            JsonResult result = new JsonResult();
            result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            result.Data = data;
            return result;
        }
        /// <summary>
        /// GET: /Display/Alarm/ResetLatestOperation
        /// </summary>
        /// <returns></returns>
        public ActionResult ResetLatestOperation()
        {
            JsonResult latestOperation = GetLatestOperation() as JsonResult;

            if (latestOperation != null)
            {
                GetLastOperationData data = latestOperation.Data as GetLastOperationData;
                if (data != null && (data.success && data.op != null))
                {
                    return(ResetOperation(data.op.Id));
                }
            }

            var result = new ResetOperationData {
                message = "An undefined error occured.", success = false
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        /// <summary>
        /// GET: /Display/Alarm/ResetLatestOperation
        /// </summary>
        /// <returns></returns>
        public ActionResult ResetLatestOperation()
        {
            JsonResult result = GetLatestOperation() as JsonResult;

            if (result != null)
            {
                GetLastOperationData data = result.Data as GetLastOperationData;
                if (data != null && (data.success && data.op != null))
                {
                    return(ResetOperation(data.op.Id));
                }
            }
            JsonResult jsonResult = new JsonResult();

            jsonResult.Data = new ResetOperationData {
                message = "An undefined error occured.", success = false
            };
            jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(jsonResult);
        }