private String RenderActivityContent(WorkflowService api, WFBaseProcessInstance pi, string id, WFManualWorkItem[] mwks, WFAutomaticWorkItem[] awks) { string header = // "<DIV style=\"DISPLAY:none;OVERFLOW: auto\">\n" "<TABLE id='popupTable' align=center border=1 bordercolor=lightgrey>\n" + "<TR><td>\n" + "<TABLE style=\"background-color: #ffffcc;font-family: 宋体,Verdana,sans-serif;font-size: 12;Z-INDEX:106\" cellSpacing=\"0\" cellPadding=\"2\" border=\"0\">\n"; string footer = "</TABLE>\n" + "</TD></TR>\n" + "</TABLE>\n"; string content = ""; WFBaseActivityInstance ai = api.GetActivityInst(id); //Retreive process definition and Activity definition string xmlString = api.GetProcDefXml(pi.DefID); WFProcessDefinition processDef = new WFProcessDefinition(); ProcDefXmlParser xmlParser = new ProcDefXmlParser(processDef); xmlParser.Parse(xmlString); IWFActivityDefinition ad = processDef.FindActivityByName(ai.Name); WFManualActivityDefinition activityDef = null; if (ad != null && ad.GetType() == typeof(WFManualActivityDefinition)) { activityDef = (WFManualActivityDefinition)ad; } bool isSub = false; //zhouli ArrayList arrSub = new ArrayList(); ArrayList arrSubName = new ArrayList(); if (ai.Session > 0) { string status = ConvUtil.GetDisplayStatus(pi.Status, ai.Session, ai.TokenPos.Value, ai.Pending, ai.InStack); //zhouli string sql = string.Format(@"SELECT Proc_Inst_ID,Proc_Inst_Name FROM WF_PROC_INSTS WHERE SUPER_PROC_INST_ID='{0}'", pi.ProcInstID); DataTable dtSub = SQLHelper.GetDataTable2(sql); if (dtSub.Rows.Count > 0) { foreach (DataRow dr in dtSub.Rows) { arrSub.Add(dr["Proc_Inst_ID"].ToString()); arrSubName.Add(dr["Proc_Inst_Name"].ToString()); } } status = GetCNStatus(status); content += ConstructRow(status, ""); content += ConstructRow(null, null); if (mwks == null || mwks.Length == 0) { content += ConstructRow("开始日期:", DTFormat(ai.StartedDate)); if (ai.CompletedDate.Ticks > 0) { content += ConstructRow("完成日期:", DTFormat(ai.CompletedDate)); } if (awks != null) { Hashtable names = GetSubProcInstName(api, awks); string url = null; string procInstName = null; foreach (WFAutomaticWorkItem wk in awks) { procInstName = (string)names[wk.WorkItemID]; url = string.Format("<a href=# onclick=\"parent.showSubProcess('{0}')\">Sub Process '{1}'</a>", wk.WorkItemID, procInstName); content += ConstructRow(string.Format("#{0}", wk.Session), url); } } } //Show Mannual activity information else { ArrayList participantList = new ArrayList(); ArrayList participantStatus = new ArrayList(); //Create a list of participant involved in this activity for (int index = mwks.Length - 1; index >= 0; index--) { if (mwks[index].Status == WFManualWorkItem.ASSIGNED || mwks[index].Status == WFManualWorkItem.OVERDUE || mwks[index].Status == WFManualWorkItem.COMPLETED) { if (!String.IsNullOrEmpty(mwks[index].UserID)) { participantList.Add(mwks[index].UserID); participantStatus.Add(mwks[index].Status); } } } //Show type of activity and participant info if it AgileWork of type process adaptation if (activityDef != null && activityDef.CustomProperties.Contains("Ascentn.AgileWork.Premier.ProcessAdaptation")) { //Get type of the AgileWork string activityType = api.GetCustomAttr(pi.WorkObjectID, id + "_ApprovalType") as string; //Show type of the activity content += ConstructRow(null, null); content += ConstructRow("Activity Type:", activityType); //Add those participant who have not been assgined yet(in case of sequential type) to participantList if (activityType == "Sequential") { string activityProperties = api.GetCustomAttr(pi.WorkObjectID, id + "_ActivityProperties") as string; if (!String.IsNullOrEmpty(activityProperties)) { string[] approverInfoList = activityProperties.Split(';'); //If number of Approver is more than one, only first approver is get assigned //So add the rest approver(who have not been assigned)to the Participant List if (approverInfoList.Length > 1) { for (int i = 1; i < approverInfoList.Length; i++) { string[] userInfoList = approverInfoList[i].Split('|'); string user = userInfoList[0]; if (!String.IsNullOrEmpty(user)) { participantList.Add(user); participantStatus.Add("In Queue"); } } } } } } #region 显示人物列表 //Show participant list for the activity if (participantList.Count > 0) { content += ConstructRow("参与该任务的用户", null); for (int i = 0; i < participantList.Count; i++) { if (participantList[i].ToString().ToLower() != @"dev003\dummy")//zhouli { content += ConstructRow(participantList[i] + ":", participantStatus[i]); } } } foreach (WFManualWorkItem wk in mwks) { if (content.Length > 0) { content += ConstructRow(null, null); } if (wk.UserID.ToLower() == @"dev003\dummy") //zhouli { for (int sub = 0; sub < arrSub.Count; sub++) { //content += ConstructRow("子流程", arrSub[sub].ToString()); string url = string.Format("<a href=# onclick=\"parent.showSubProcess('{0}')\">{1}</a>", arrSub[sub].ToString(), arrSubName[sub].ToString()); content += ConstructRow("子流程", url); } } else { content += ConstructRow("会话:", wk.Session); content += ConstructRow("任务:", wk.Name); content += ConstructRow("任务处理人:", GetUserName(wk.UserID)); //zhouli content += ConstructRow("任务接收日期:", DTFormat(wk.AssignedDate)); //content += ConstructRow("过期日期:", DTFormat(wk.DueDate)); if (wk.CompletedDate.Ticks > 0) { content += ConstructRow("完成日期:", DTFormat(wk.CompletedDate)); } content += ConstructRow("状态:", wk.Status); } } #endregion } //Add custom attributes changes during this activity into content content += AddCustomAttribToContent(pi.ProcInstID, ai.StartedDate.ToString("M/d/yyyy H:mm:ss:fff tt"), ai.CompletedDate.ToString("M/d/yyyy H:mm:ss:fff tt")); //Show Process Adaptation Link only when AgileWork is of type Ascentn.AgileWork.Premier.ProcessAdaptation and not completed or cancled if (status != WFBaseActivityInstance.PASSED && status != WFBaseActivityInstance.CANCELLED && activityDef != null && activityDef.CustomProperties.Contains("Ascentn.AgileWork.Premier.ProcessAdaptation")) { // Get Process Adaptation Url from web.config string processAdaptationUrl = (String)ConfigurationManager.AppSettings["ProcessAdaptationUrl"]; string queryString = "?ProcessTemplate=" + pi.DefName + "&ProcessInstance=" + pi.ProcInstID + "&ActiveInstance=" + id; string processAdptationLink = string.Format("<a href=# onclick=\"parent.showProcessAdaptation('{0}')\">Open Process Adaptation</a>", processAdaptationUrl + queryString); //Add process adaptation link to the content content += ConstructRow(null, null); content += ConstructRow(processAdptationLink, null); } } else { content += ConstructRow("信息:", "此步骤还未流转到!"); } return(header + content + footer); }
private String RenderActivityContent(WorkflowService api, WFBaseProcessInstance pi, string id, WFManualWorkItem[] mwks, WFAutomaticWorkItem[] awks) { string header = // "<DIV style=\"DISPLAY:none;OVERFLOW: auto\">\n" "<TABLE id='popupTable' align=center border=1 bordercolor=lightgrey>\n" + "<TR><td>\n" + "<TABLE style=\"background-color: #ffffcc;font-family: 宋体,Verdana,sans-serif;font-size: 12;Z-INDEX:106\" cellSpacing=\"0\" cellPadding=\"2\" border=\"0\">\n"; string footer = "</TABLE>\n" + "</TD></TR>\n" + "</TABLE>\n"; string content = ""; WFBaseActivityInstance ai = api.GetActivityInst(id); //Retreive process definition and Activity definition string xmlString = api.GetProcDefXml(pi.DefID); WFProcessDefinition processDef = new WFProcessDefinition(); ProcDefXmlParser xmlParser = new ProcDefXmlParser(processDef); xmlParser.Parse(xmlString); IWFActivityDefinition ad = processDef.FindActivityByName(ai.Name); WFManualActivityDefinition activityDef = null; if (ad != null && ad.GetType() == typeof(WFManualActivityDefinition)) { activityDef = (WFManualActivityDefinition)ad; } bool isSub = false; //zhouli ArrayList arrSub = new ArrayList(); ArrayList arrSubName = new ArrayList(); if (ai.Session > 0) { string status = ConvUtil.GetDisplayStatus(pi.Status, ai.Session, ai.TokenPos.Value, ai.Pending, ai.InStack); //zhouli string sql = string.Format(@"SELECT Proc_Inst_ID,Proc_Inst_Name FROM WF_PROC_INSTS WHERE SUPER_PROC_INST_ID='{0}'", pi.ProcInstID); DataTable dtSub = SQLHelper.GetDataTable2(sql); if (dtSub.Rows.Count > 0) { foreach (DataRow dr in dtSub.Rows) { arrSub.Add(dr["Proc_Inst_ID"].ToString()); arrSubName.Add(dr["Proc_Inst_Name"].ToString()); } } status = GetCNStatus(status); content += ConstructRow(status, ""); content += ConstructRow(null, null); if (mwks == null || mwks.Length == 0) { content += ConstructRow("开始日期:", DTFormat(ai.StartedDate)); if (ai.CompletedDate.Ticks > 0) { content += ConstructRow("完成日期:", DTFormat(ai.CompletedDate)); } if (awks != null) { Hashtable names = GetSubProcInstName(api, awks); string url = null; string procInstName = null; foreach (WFAutomaticWorkItem wk in awks) { procInstName = (string)names[wk.WorkItemID]; url = string.Format("<a href=# onclick=\"parent.showSubProcess('{0}')\">Sub Process '{1}'</a>", wk.WorkItemID, procInstName); content += ConstructRow(string.Format("#{0}", wk.Session), url); } } } //Show Mannual activity information else { ArrayList participantList = new ArrayList(); ArrayList participantStatus = new ArrayList(); //Create a list of participant involved in this activity for (int index = mwks.Length - 1; index >= 0; index--) { if (mwks[index].Status == WFManualWorkItem.ASSIGNED || mwks[index].Status == WFManualWorkItem.OVERDUE || mwks[index].Status == WFManualWorkItem.COMPLETED) { if (!String.IsNullOrEmpty(mwks[index].UserID)) { participantList.Add(mwks[index].UserID); participantStatus.Add(mwks[index].Status); } } } //Show type of activity and participant info if it AgileWork of type process adaptation if (activityDef != null && activityDef.CustomProperties.Contains("Ascentn.AgileWork.Premier.ProcessAdaptation")) { //Get type of the AgileWork string activityType = api.GetCustomAttr(pi.WorkObjectID, id + "_ApprovalType") as string; //Show type of the activity content += ConstructRow(null, null); content += ConstructRow("Activity Type:", activityType); //Add those participant who have not been assgined yet(in case of sequential type) to participantList if (activityType == "Sequential") { string activityProperties = api.GetCustomAttr(pi.WorkObjectID, id + "_ActivityProperties") as string; if (!String.IsNullOrEmpty(activityProperties)) { string[] approverInfoList = activityProperties.Split(';'); //If number of Approver is more than one, only first approver is get assigned //So add the rest approver(who have not been assigned)to the Participant List if (approverInfoList.Length > 1) { for (int i = 1; i < approverInfoList.Length; i++) { string[] userInfoList = approverInfoList[i].Split('|'); string user = userInfoList[0]; if (!String.IsNullOrEmpty(user)) { participantList.Add(user); participantStatus.Add("In Queue"); } } } } } } #region 显示人物列表 //Show participant list for the activity if (participantList.Count > 0) { content += ConstructRow("参与该任务的用户", null); for (int i = 0; i < participantList.Count; i++) { if (participantList[i].ToString().ToLower() != @"dev003\dummy")//zhouli content += ConstructRow(participantList[i] + ":", participantStatus[i]); } } foreach (WFManualWorkItem wk in mwks) { if (content.Length > 0) content += ConstructRow(null, null); if (wk.UserID.ToLower() == @"dev003\dummy") //zhouli { for (int sub = 0; sub < arrSub.Count; sub++) { //content += ConstructRow("子流程", arrSub[sub].ToString()); string url = string.Format("<a href=# onclick=\"parent.showSubProcess('{0}')\">{1}</a>", arrSub[sub].ToString(), arrSubName[sub].ToString()); content += ConstructRow("子流程", url); } } else { content += ConstructRow("会话:", wk.Session); content += ConstructRow("任务:", wk.Name); content += ConstructRow("任务处理人:", GetUserName(wk.UserID)); //zhouli content += ConstructRow("任务接收日期:", DTFormat(wk.AssignedDate)); //content += ConstructRow("过期日期:", DTFormat(wk.DueDate)); if (wk.CompletedDate.Ticks > 0) { content += ConstructRow("完成日期:", DTFormat(wk.CompletedDate)); } content += ConstructRow("状态:", wk.Status); } } #endregion } //Add custom attributes changes during this activity into content content += AddCustomAttribToContent(pi.ProcInstID, ai.StartedDate.ToString("M/d/yyyy H:mm:ss:fff tt"), ai.CompletedDate.ToString("M/d/yyyy H:mm:ss:fff tt")); //Show Process Adaptation Link only when AgileWork is of type Ascentn.AgileWork.Premier.ProcessAdaptation and not completed or cancled if (status != WFBaseActivityInstance.PASSED && status != WFBaseActivityInstance.CANCELLED && activityDef != null && activityDef.CustomProperties.Contains("Ascentn.AgileWork.Premier.ProcessAdaptation")) { // Get Process Adaptation Url from web.config string processAdaptationUrl = (String)ConfigurationManager.AppSettings["ProcessAdaptationUrl"]; string queryString = "?ProcessTemplate=" + pi.DefName + "&ProcessInstance=" + pi.ProcInstID + "&ActiveInstance=" + id; string processAdptationLink = string.Format("<a href=# onclick=\"parent.showProcessAdaptation('{0}')\">Open Process Adaptation</a>", processAdaptationUrl + queryString); //Add process adaptation link to the content content += ConstructRow(null, null); content += ConstructRow(processAdptationLink, null); } } else { content += ConstructRow("信息:", "此步骤还未流转到!"); } return header + content + footer; }