Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string processDefID = Request.QueryString["ProcessDefID"];
                string srcActivity = Request.QueryString["SrcActivity"];
                string destActivity = Request.QueryString["DestActivity"];
                try
                {
                    WorkflowEngine engine = new WorkflowEngine();
                    ProcessDefine processDefine = engine.GetProcessDefine(processDefID);

                    AgileEAP.Workflow.Definition.Transition transition = processDefine.Transitions.FirstOrDefault(t => t.SrcActivity == srcActivity && t.DestActivity == destActivity);

                    bool isDefault = string.IsNullOrEmpty(transition.Name) && string.IsNullOrEmpty(transition.Expression);
                    txtExpression.Text = transition.Expression;
                    txtName.Text = isDefault ? "默认连接" : transition.Name;
                    chkIsDefault.Checked = isDefault ? true : transition.IsDefault;
                }
                catch (Exception ex)
                {
                    log.Error(string.Format("显示流程{0}迁移srcActivity={1},destActivity={2}信息出错", processDefID, srcActivity, destActivity), ex);
                }
            }
        }
Пример #2
0
        public ActionResult DeleteProcessInst(string processInstID)
        {
            AjaxResult ajaxResult = new AjaxResult() { Result = DoResult.Failed };
            string actionMessage = string.Format("删除流程实例{0}", processInstID);
            try
            {
                IWorkflowEngine engine = new WorkflowEngine();
                engine.DeleteProcessInst(processInstID);
                ajaxResult.Result = DoResult.Success;
                ajaxResult.RetValue = AgileEAP.Workflow.Enums.ProcessInstStatus.Terminated.GetRemark();
                actionMessage += "成功";
            }
            catch (Exception ex)
            {
                actionMessage += "出错";
                log.Error(actionMessage, ex);
            }
            finally
            {
                AddActionLog<ProcessInst>(actionMessage, ajaxResult.Result);
            }

            ajaxResult.PromptMsg = actionMessage;
            return Json(ajaxResult);
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    IWorkflowEngine engine = new WorkflowEngine();
                    WorkItem workItem = engine.Persistence.Repository.GetDomain<WorkItem>(Request.QueryString["workItemID"]);
                    ActivityInst activityInst = engine.Persistence.GetActivityInst(workItem.ActivityInstID);

                    ProcessDefID = workItem.ProcessID;
                    ProcessInstID = workItem.ProcessInstID;
                    Activity activity = engine.Persistence.GetActivity(workItem.ProcessID, activityInst.ActivityDefID);
                    if (activity is ManualActivity)
                    {
                        ManualActivity manualActivity = engine.Persistence.GetActivity(workItem.ProcessID, activityInst.ActivityDefID) as ManualActivity;
                        if (manualActivity.CustomURL.URLType == URLType.DefaultURL)
                        {
                            Url = "/Workflow/eForm" + Request.Url.Query;
                        }
                        else
                        {
                            Url = string.Format("{0}{1}{2}", RootPath, workItem.ActionURL ?? manualActivity.CustomURL.SpecifyURL, Request.Url.Query);
                        }
                    }
                    else
                    {
                        Url = string.Format("{0}{1}{2}", RootPath, workItem.ActionURL, Request.Url.Query);
                    }

                    //IList<WorkItem> workItems = repository.Query<WorkItem>().Where(o => o.ProcessInstID == workItem.ProcessInstID).OrderBy(o => o.ExecuteTime).ToList();
                    //ProcessInst pi = repository.GetDomain<ProcessInst>(workItem.ProcessInstID);
                    //if (pi.CurrentState == (short)ProcessInstStatus.Completed || pi.CurrentState == (short)ProcessInstStatus.Terminated)
                    //{
                    //    workItems.Add(new WorkItem()
                    //    {
                    //        Name = "结束",
                    //        ExecutorName = "工作流引擎",
                    //        Executor = "WorkflowEngine"
                    //    });
                    //}

                    System.Data.DataTable dt = repository.ExecuteDataTable<ActivityInst>(string.Format(@"select a.ID, a.DestActID,a.DestActInstName,b.Executor,b.ExecutorName,b.ExecuteTime,a.TransTime,
            (case  when b.CurrentState is null then 5 else  b.CurrentState end) as CurrentState
            from WF_Transition a left join WF_WorkItem b on a.ProcessInstID=b.ProcessInstID and a.DestActInstID=b.ActivityInstID
            where a.ProcessInstID ='{0}'
            order by a.TransTime", ProcessInstID));

                    gvList.DataSource = dt;
                    gvList.DataBind();
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }

            }
        }
Пример #4
0
        public void GetActiveWorkItemsTest()
        {
            IWorkflowEngine engine = new WorkflowEngine();

            var processInstID = "4c571b40-0732-4d0c-8434-a08400b24258";
            var value = engine.GetActiveWorkItems(processInstID);

            Assert.IsNotNull(value);
        }
Пример #5
0
        public void ErrorActivityInstTest()
        {
            IWorkflowEngine engine = new WorkflowEngine();

            var processInstID = "1e5438f0-9ef6-4bc3-8fe5-a0b000f97ef9";
            engine.ErrorActivityInst(processInstID);

            Assert.IsNotNull(true);
        }
Пример #6
0
        public void FormJsonTest()
        {
            IWorkflowEngine engine = new WorkflowEngine();

            var processDefID = "06528f7e-5a95-49ce-8e04-7fe4890569a0";
            ProcessDefine processDefine = engine.GetProcessDefine(processDefID);

            string json = AgileEAP.Core.JsonConvert.SerializeObject(processDefine, new Newtonsoft.Json.Converters.StringEnumConverter { CamelCaseText = false });
            ProcessDefine processDefine2 = AgileEAP.Core.JsonConvert.DeserializeObject<ProcessDefine>(json, new ActivityConvert());

            Assert.IsNotNull(true);
        }
Пример #7
0
        public string Save(string json)
        {
            AjaxResult ajaxResult = new AjaxResult();

            string errorMsg = string.Empty;
            DoResult actionResult = DoResult.Failed;
            string actionMessage = string.Empty;
            string processDefID = Request.QueryString["ProcessDefID"];
            string srcActivity = Request.QueryString["SrcActivity"];
            string destActivity = Request.QueryString["DestActivity"];
            try
            {
                WorkflowEngine engine = new WorkflowEngine();
                ProcessDefine processDefine = engine.GetProcessDefine(processDefID);
                ProcessDef processDef = repository.GetDomain<ProcessDef>(processDefID);

                AgileEAP.Workflow.Definition.Transition transition = processDefine.Transitions.FirstOrDefault(t => t.SrcActivity == srcActivity && t.DestActivity == destActivity);
                IDictionary<string, object> values = JsonConvert.DeserializeObject<IDictionary<string, object>>(json);

                transition.IsDefault = values.GetSafeValue<bool>("IsDefault", false);
                transition.Name = values.GetSafeValue<string>("Name", transition.Name);
                transition.Expression = values.GetSafeValue<string>("Expression", transition.Expression);
                processDef.Content = processDefine.ToXml();

                repository.SaveOrUpdate(processDef);

                actionResult = DoResult.Success;
                //获取提示信息
                actionMessage = RemarkAttribute.GetEnumRemark(actionResult);

                //记录操作日志
                AddActionLog(processDef, actionResult, string.Format("保存流程{0}迁移srcActivity={1},destActivity={2}信息", processDefID, srcActivity, destActivity));

                ajaxResult.Result = actionResult;
                ajaxResult.RetValue = srcActivity + ":" + destActivity;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                ajaxResult.Result = DoResult.Failed;
                AddActionLog<ProcessDef>(string.Format("保存流程{0}迁移srcActivity={1},destActivity={2}信息", processDefID, srcActivity, destActivity), ajaxResult.Result);
                log.Error(string.Format("显示流程{0}迁移srcActivity={1},destActivity={2}信息出错", processDefID, srcActivity, destActivity), ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
Пример #8
0
        public string StartProcessInst(string processDefID)
        {
            AjaxResult ajaxResult = new AjaxResult();
            string errorMsg = string.Empty;
            DoResult actionResult = DoResult.Failed;
            string actionMessage = string.Empty;

            try
            {
                WorkflowEngine engine = new WorkflowEngine(); // TODO: Initialize to an appropriate value
                string processInstID = engine.CreateAProcess(processDefID);// string.Empty; // TODO: Initialize to an appropriate value
                engine.StartAProcess(processInstID, null);

                ProcessInst pi = repository.GetDomain<ProcessInst>(processInstID);
                IDictionary<string, object> parameters = new Dictionary<string, object>();
                parameters.Add("ProcessInstID", processInstID);

                WorkItem wi = repository.FindOne<WorkItem>(parameters);

                actionResult = DoResult.Success;
                //获取提示信息
                actionMessage = RemarkAttribute.GetEnumRemark(actionResult);

                //记录操作日志
                AddActionLog(pi, actionResult, actionMessage);

                ajaxResult.Result = actionResult;
                ajaxResult.RetValue = pi.ID + '$' + wi.ID;
                ajaxResult.PromptMsg = actionMessage;
            }
            catch (Exception ex)
            {
                actionMessage = RemarkAttribute.GetEnumRemark(actionResult);
                log.Error(actionMessage, ex);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
Пример #9
0
        public string Delete(string processInstID)
        {
            AjaxResult ajaxResult = new AjaxResult();
            string actionMessage = string.Format("删除流程实例{0}", processInstID);
            try
            {
                IWorkflowEngine engine = new WorkflowEngine();
                engine.DeleteProcessInst(processInstID);
                ajaxResult.Result = DoResult.Success;
                ajaxResult.RetValue = AgileEAP.Workflow.Enums.ProcessInstStatus.Running.GetRemark();
                ajaxResult.PromptMsg = actionMessage + "成功";
            }
            catch (Exception ex)
            {
                log.Error(actionMessage + "出错", ex);
            }
            finally
            {
                AddActionLog<ProcessInst>(actionMessage, ajaxResult.Result);
            }

            return JsonConvert.SerializeObject(ajaxResult);
        }
Пример #10
0
        /// <summary>
        /// 显示列表信息
        /// </summary>
        /// <param name="gvList">GridView对象</param>
        /// <param name="pageInfo">分页信息</param>
        public void ShowList(PagedGridView gvList, PageInfo pageInfo)
        {
            WorkflowEngine wfEngine = new WorkflowEngine();
            IList<Activity> result = wfEngine.GetProcessDefine(ProcessDefID).Activities.OrderBy(a => a.ActivityType).ToList();

            gvList.ItemCount = result.Count;
            gvList.DataSource = result;
            gvList.DataBind();
        }