Пример #1
0
        public JsonResult FixException(string id)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult();

                OThinker.H3.Exceptions.ExceptionLog log = this.Engine.ExceptionManager.GetException(id);

                //查找到异常环节
                OThinker.H3.Instance.InstanceContext context = this.Engine.InstanceManager.GetInstanceContext(log.InstanceId);
                Token ExceptionToken = null;
                foreach (Token t in context.Tokens)
                {
                    if (t.Exceptional)
                    {
                        ExceptionToken = t;
                        break;
                    }
                }

                //修复
                if (log.State != OThinker.H3.Exceptions.ExceptionState.Fixed)
                {
                    this.Engine.ExceptionManager.FixException(id);
                }

                System.Threading.Thread.Sleep(5000);

                //重新激活
                if (ExceptionToken != null)
                {
                    OThinker.H3.Messages.ActivateActivityMessage activateMessage
                        = new OThinker.H3.Messages.ActivateActivityMessage(
                              OThinker.H3.Messages.MessageEmergencyType.Normal,
                              context.InstanceId, ExceptionToken.Activity,
                              ExceptionToken.TokenId,
                              ExceptionToken.Participants,
                              null,
                              false,
                              H3.WorkItem.ActionEventType.Adjust);

                    this.Engine.InstanceManager.SendMessage(activateMessage);
                }
                result.Success = true;
                log = this.Engine.ExceptionManager.GetException(id);
                result.Extend = new
                {
                    IsFixed = true,
                    ExceptionDetail = new ExceptionDetailViewModel()
                    {
                        Fix = "ExceptionLog.Fixed",
                        FixTime = log.FixedTime.ToShortDateString(),
                    }
                };

                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }
Пример #2
0
 public JsonResult GetExceptionLogDetail(string id)
 {
     return(ExecuteFunctionRun(() =>
     {
         ActionResult result = new ActionResult();
         ExceptionDetailViewModel model = new ExceptionDetailViewModel();
         bool isFixed = false;//是否已修复
         OThinker.H3.Exceptions.ExceptionLog log = this.Engine.ExceptionManager.GetException(id);
         if (log != null)
         {
             model.Action = log.Action.ToString();
             model.Block = log.Block.ToString();
             OThinker.H3.Instance.InstanceContext context = this.Engine.InstanceManager.GetInstanceContext(log.InstanceId);
             if (context == null)
             {
                 result.Message = "ExceptionLog.WorkflowNotExist";
                 result.Success = false;
                 return Json(result, JsonRequestBehavior.AllowGet);
             }
             model.InstanceName = string.IsNullOrWhiteSpace(context.InstanceName) ? context.InstanceId : context.InstanceName;
             model.InstanceUrl = this.GetInstanceUrl(log.InstanceId, DateTime.Now.ToString("yyyyMMddHHmmss"));
             model.Message = log.Message.Replace("\r\n", "<BR>");
             if (log.State == OThinker.H3.Exceptions.ExceptionState.Fixed)
             {
                 model.Fix = "ExceptionLog.Fixed";
                 model.FixTime = log.FixedTime.ToString();
                 isFixed = true;
             }
             else
             {
                 model.Fix = "ExceptionLog.UnFixed";
                 model.FixTime = null;
                 isFixed = false;
             }
             model.ObjectID = log.ObjectID;
             model.WorkflowPackage = log.WorkflowCode;
             model.WorkflowVersion = log.WorkflowVersion.ToString();
             model.SourceName = log.SourceName;
             model.ExceptionSource = log.SourceType.ToString();
             model.OccurrenceTime = log.ThrownTime.ToString();
         }
         result.Success = true;
         result.Extend = new
         {
             IsFixed = isFixed,
             ExceptionDetail = model
         };
         return Json(result, JsonRequestBehavior.AllowGet);
     }));
 }