/// <summary>
        /// GET: /Display/Alarm/ResetOperation/Id
        /// </summary>
        /// <returns></returns>
        public ActionResult ResetOperation(int id)
        {
            ResetOperationData result = new ResetOperationData();

            try
            {
                using (var service = ServiceFactory.GetCallbackServiceWrapper <IOperationService>(new OperationServiceCallback()))
                {
                    Operation item = service.Instance.GetOperationById(id);
                    if (item == null)
                    {
                        result.success = false;
                        result.message = "Operation not found!";
                    }
                    else if (item.IsAcknowledged)
                    {
                        result.success = false;
                        result.message = "Operation is already acknowledged!";
                    }
                    else
                    {
                        service.Instance.AcknowledgeOperation(id);
                        result.success = true;
                        result.message = "Operation successfully acknowledged!";
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.LogException(this, ex);
            }

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        /// <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));
        }
Esempio n. 3
0
        /// <summary>
        /// GET: /Display/Alarm/ResetOperation/Id
        /// </summary>
        /// <returns></returns>
        public ActionResult ResetOperation(int id)
        {
            ResetOperationData returnValue = new ResetOperationData();

            try
            {
                using (var service = ServiceFactory.GetCallbackServiceWrapper <IOperationService>(new OperationServiceCallback()))
                {
                    Operation item = service.Instance.GetOperationById(id);
                    if (item == null)
                    {
                        returnValue.success = false;
                        returnValue.message = "Operation not found!";
                    }
                    else if (item.IsAcknowledged)
                    {
                        returnValue.success = false;
                        returnValue.message = "Operation is already acknowledged!";
                    }
                    else
                    {
                        service.Instance.AcknowledgeOperation(id);
                        returnValue.success = true;
                        returnValue.message = "Operation successfully acknowledged!";
                    }
                }
            }
            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 jsonResult = new JsonResult();

            jsonResult.Data = returnValue;
            jsonResult.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            return(jsonResult);
        }