protected void Page_Load(object sender, EventArgs e) { id = RequestData.Get <string>("id"); if (!string.IsNullOrEmpty(id)) { ent = AbsenceApply.Find(id); } switch (RequestActionString) { case "delete": ent.DoDelete(); break; case "submit": StartFlow(); break; case "AutoExecuteFlow": AutoExecuteFlow(); break; case "CancelFlow": ent.WorkFlowState = "End"; ent.ApproveResult = "已撤销"; ent.DoUpdate(); IList <WorkflowInstance> wfiEnts = WorkflowInstance.FindAllByProperties("Status", "Processing", "RelateId", ent.Id); if (wfiEnts.Count > 0) { wfiEnts[0].Status = "Completed"; wfiEnts[0].EndTime = System.DateTime.Now; wfiEnts[0].DoUpdate(); sql = "update Task set Status=4 ,Result='已撤销',Description='已撤销',FinishTime='" + System.DateTime.Now + "' where WorkFlowInstanceId='" + wfiEnts[0].ID + "' and Status=0"; DataHelper.ExecSql(sql); } break; default: DoSelect(); break; } }
protected void Page_Load(object sender, EventArgs e) { switch (this.RequestActionString.ToLower()) { case "getusers": GetNextUsers(this.RequestData["TemplateId"].ToString(), this.RequestData["FlowInstanceId"].ToString(), this.RequestData["Name"].ToString(), this.RequestData["CurrentName"].ToString()); break; case "getbackusers": Aim.WorkFlow.Task[] tks = Aim.WorkFlow.Task.FindAllByProperties(Aim.WorkFlow.Task.Prop_WorkflowInstanceID, this.RequestData["FlowInstanceId"].ToString(), Aim.WorkFlow.Task.Prop_ApprovalNodeName, this.RequestData["TaskName"].ToString()); if (tks != null && tks.Length == 1) //打回情况一个人的时候有效,多人的话,还是从之前配置里取 { this.PageState.Add("NextUserIds", tks[0].OwnerId); this.PageState.Add("NextUserNames", tks[0].Owner); } break; default: Aim.WorkFlow.Task fTask = null; if (this.RequestData["FormId"] != null) { Aim.WorkFlow.WorkflowInstance wf = WorkflowInstance.FindAllByProperties(WorkflowInstance.Prop_RelateId, this.RequestData["FormId"].ToString())[0]; fTask = Aim.WorkFlow.Task.FindAllByProperties(Aim.WorkFlow.Task.Prop_WorkflowInstanceID, wf.ID).Where(Ent => Ent.Ext1 != "Branch").ToArray()[0]; } else { fTask = Aim.WorkFlow.Task.Find(this.RequestData["TaskId"].ToString()); } /*if (fTask.Ext1 == "Branch") * { * Response.Redirect("FreeTask.aspx?op=r&Type=Branch&TaskId=" + this.RequestData["TaskId"].ToString()); * }*/ /*if (!fTask.UpdatedTime.HasValue) * { * try * { * DataTable dt = DataHelper.QueryDataTable("select FactDeptName,FactDeptId from View_SysUserGroupFact where UserId='" + this.UserInfo.UserID + "' and FactDeptName is not null "); * if (dt.Rows.Count > 0) * { * fTask.DeptId = dt.Rows[0]["FactDeptId"].ToString(); * fTask.DeptName = dt.Rows[0]["FactDeptName"].ToString(); * } * } * catch { } * fTask.UpdatedTime = DateTime.Now; * fTask.Save(); * }*/ Aim.WorkFlow.WorkflowInstance instance = WorkflowInstance.Find(fTask.WorkflowInstanceID); this.PageState.Add("InstanceId", fTask.WorkflowInstanceID); this.PageState.Add("TemplateId", instance.WorkflowTemplateID); FlowInstanceId = instance.ID; FormUrl = instance.RelateUrl; FlowDefineId = instance.WorkflowTemplateID; Title = fTask.WorkFlowName;//+ "->" + fTask.ApprovalNodeName; XmlSerializer xs = new XmlSerializer(typeof(TaskContext)); if (!string.IsNullOrEmpty(fTask.Context)) { StringReader sr = new StringReader(fTask.Context); TaskContext content = xs.Deserialize(sr) as TaskContext; if (content.SwitchRules.Length > 0) { TaskContextSwitchRuleNextAction[] arrs = content.SwitchRules[0].NextActions; string comboxdataText = "['{0}','{1}'],"; if (arrs.Length > 0) { int first = 0; foreach (TaskContextSwitchRuleNextAction ar in arrs) { //GetNextRoute(currentNode, nsmgr, ar.Name) NextStep += string.Format(comboxdataText, ar.Name, ar.Name); if (first == 0) { GetNextUsers(instance.WorkflowTemplateID, fTask.WorkflowInstanceID, ar.Name, fTask.ApprovalNodeName); } first++; } } else { NextStep += string.Format("['','{0}'],", "结束"); } } else { NextStep += string.Format("['','{0}'],", "结束"); } } else { NextStep += string.Format("['','{0}'],", "结束"); } NextStep = NextStep.TrimEnd(','); Aim.WorkFlow.Task[] tasks = Aim.WorkFlow.Task.FindAll(Expression.Eq("WorkflowInstanceID", fTask.WorkflowInstanceID)).OrderBy(ens => !ens.FinishTime.HasValue ? DateTime.Now : ens.FinishTime).OrderBy(ens => ens.CreatedTime).ToArray(); this.PageState.Add("Tasks", JsonHelper.GetJsonString(tasks)); this.PageState.Add("Task", fTask); break; } }