InstanceToken.aspx.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:12k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- namespace OThinker.H3.Portal
- {
- /// <summary>
- /// Summary description for QueryCaseToken.
- /// </summary>
- public partial class InstanceToken : PortalPage
- {
- private string InstanceId
- {
- get
- {
- return this.Request.QueryString[Param_InstanceId];
- }
- }
- private System.Data.DataTable TokenTable;
- private System.Data.DataTable WorkItemTable;
- private System.Data.DataTable ChildInstanceTable;
- /// <summary>
- /// 获得该状态的工作项的状态描述
- /// </summary>
- /// <param name="TokenID"></param>
- /// <returns></returns>
- private DataRow[] GetWorkItems(long TokenID)
- {
- ArrayList list = new ArrayList();
- foreach (System.Data.DataRow row in this.WorkItemTable.Rows)
- {
- if ((long)row[WorkItem.WorkItem.PropertyName_TokenId] == TokenID)
- {
- list.Add(row);
- }
- }
- return OThinker.Data.ArrayConvertor<DataRow>.ToArray(list);
- }
- private DataRow[] GetChildInstances(long TokenID)
- {
- ArrayList list = new ArrayList();
- if (this.ChildInstanceTable != null && this.ChildInstanceTable.Rows != null && this.ChildInstanceTable.Rows.Count != 0)
- {
- foreach (DataRow row in this.ChildInstanceTable.Rows)
- {
- if ((long)row[Instance.InstanceContext.PropertyName_ParentActivityTokenId] == TokenID)
- {
- list.Add(row);
- }
- }
- }
- return OThinker.Data.ArrayConvertor<DataRow>.ToArray(list);
- }
- protected void Page_Load(object sender, System.EventArgs e)
- {
- if (!this.IsPostBack)
- {
- // 查询记录
- this.TokenTable = Query.QueryToken(this.InstanceId);
- this.WorkItemTable = Query.QueryWorkItem(
- null,
- null,
- WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion,
- null,
- new string[] { this.InstanceId },
- null,
- System.DateTime.MinValue,
- System.DateTime.MaxValue,
- OThinker.H3.WorkItem.WorkItemState.Unspecified,
- OThinker.H3.Instance.PriorityType.Unspecified,
- null,
- null,
- OThinker.Data.BoolMatchValue.Unspecified,
- OThinker.Data.BoolMatchValue.Unspecified);
- this.ChildInstanceTable = Query.QueryInstance(
- null,
- null,
- null,
- this.InstanceId,
- OThinker.H3.Instance.InstanceState.Unspecified,
- null,
- null,
- WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion,
- System.DateTime.MinValue,
- System.DateTime.MaxValue,
- null,
- OThinker.H3.Instance.PriorityType.Unspecified,
- OThinker.Data.BoolMatchValue.Unspecified,
- OThinker.Data.BoolMatchValue.Unspecified);
- }
- this.TokenGrid.DataSource = this.TokenTable;
- this.TokenGrid.DataBind();
- }
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: This call is required by the ASP.NET Web Form Designer.
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.TokenGrid.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.TokenGrid_ItemDataBound);
- }
- #endregion
- private void TokenGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
- {
- if (e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Footer)
- {
- // 设置序列号
- e.Item.Cells[0].Text = (e.Item.ItemIndex + 1).ToString();
- // Token ID
- long tokenId = (long)this.TokenTable.Rows[e.Item.ItemIndex][Instance.Token.PropertyName_TokenId];
- // 获得工作项状态描述
- System.Text.StringBuilder workItemHtml = new System.Text.StringBuilder();
- DataRow[] workItems = this.GetWorkItems(tokenId);
- if (workItems != null && workItems.Length != 0)
- {
- workItemHtml.Append("<TABLE WIDTH=100%>");
- foreach (System.Data.DataRow row in workItems)
- {
- workItemHtml.Append("<TR>");
- workItemHtml.Append("<TD width=30% valign=top>");
- string participant = (string)row[WorkItem.WorkItem.PropertyName_Participant];
- string participantName = OThinker.H3.Server.Engine.Organization.GetName(participant);
- workItemHtml.Append(
- "<a href="" + PageName_EditUser + "?" + Param_ID + "=" + participant + "&" + Param_Mode + "=" + EditUserType.View + "" target=_blank>" +
- participantName + "</a>");
- workItemHtml.Append("</TD>");
- workItemHtml.Append("<TD valign=top>");
- object rawComment = row[WorkItem.WorkItem.PropertyName_Comment];
- string comment = (rawComment == null || rawComment == System.DBNull.Value) ? null : rawComment.ToString();
- workItemHtml.Append(comment);
- workItemHtml.Append("</TD>");
- workItemHtml.Append("<TD ALIGN='RIGHT' valign=top>");
- int intState = (int)row[WorkItem.WorkItem.PropertyName_State];
- string strState = null;
- if (intState == (int)WorkItem.WorkItemState.Finished)
- {
- if ((int)row[WorkItem.WorkItem.PropertyName_Approval] == (int)OThinker.Data.BoolMatchValue.True)
- {
- strState = "同意";
- }
- else if ((int)row[WorkItem.WorkItem.PropertyName_Approval] == (int)OThinker.Data.BoolMatchValue.False)
- {
- strState = "否决";
- }
- }
- if (strState == null)
- {
- WorkItem.WorkItemState state = (OThinker.H3.WorkItem.WorkItemState)intState;
- strState = WorkItem.WorkItemStateConvertor.ToString(state);
- }
- workItemHtml.Append(strState);
- workItemHtml.Append("</TD>");
- workItemHtml.Append("</TR>");
- }
- workItemHtml.Append("</TABLE>");
- }
- // 获得子流程状态描述
- System.Text.StringBuilder childHtml = new System.Text.StringBuilder();
- DataRow[] childInstances = this.GetChildInstances(tokenId);
- if (childInstances != null && childInstances.Length != 0)
- {
- childHtml.Append("<TABLE WIDTH=100%>");
- foreach (DataRow childInstance in childInstances)
- {
- childHtml.Append("<TR>");
- childHtml.Append("<TD>");
- string childOriginator = (string)childInstance[Instance.InstanceContext.PropertyName_Originator];
- string childOrginatorName = OThinker.H3.Server.Engine.Organization.GetName(childOriginator);
- childHtml.Append(
- "<a href="" + PageName_EditUser + "?" + Param_ID + "=" + childOriginator + "&" + Param_Mode + "=" + EditUserType.View + "" target=_blank>" +
- childOrginatorName + "</a>");
- childHtml.Append("</TD>");
- childHtml.Append("<TD VALIGN='RIGHT'>");
- string childInstanceId = (string)childInstance[Instance.InstanceContext.PropertyName_InstanceId];
- // 显示日志的链接
- childHtml.Append("<A HREF='" + PageName_InstanceToken + "?" + Param_InstanceId + "=" + childInstanceId + "'>日志</A>");
- childHtml.Append(" ");
- childHtml.Append("<A HREF='" + PageName_InstanceStateChart + "?" + Param_InstanceId + "=" + childInstanceId + "'>流程图</A>");
- childHtml.Append(" ");
- Instance.InstanceState childState = (Instance.InstanceState)childInstance[Instance.InstanceContext.PropertyName_State];
- childHtml.Append(Instance.InstanceStateConvertor.ToString(childState));
- childHtml.Append("</TD>");
- childHtml.Append("</TR>");
- }
- childHtml.Append("</TABLE>");
- }
- string workItem = workItemHtml.ToString();
- string child = childHtml.ToString();
- string br = (workItem == null || workItem == "" || child == null || child == "") ? null : "<BR>";
- e.Item.Cells[3].Text = workItem + br + child;
- // 操作描述
- e.Item.Cells[4].Text = e.Item.Cells[4].Text == null ? e.Item.Cells[4].Text : e.Item.Cells[4].Text.Replace(Instance.Token.DescriptionInterval, "<BR>");
- // 是否同意
- System.Web.UI.WebControls.CheckBox approval = new CheckBox();
- approval.Checked = e.Item.Cells[5].Text == "1";
- approval.Enabled = false;
- e.Item.Cells[5].Controls.Add(approval);
- // 是否允许取回
- System.Web.UI.WebControls.CheckBox retrievable = new CheckBox();
- retrievable.Checked = e.Item.Cells[6].Text == "1";
- retrievable.Enabled = false;
- e.Item.Cells[6].Controls.Add(retrievable);
- // 是否作废
- CheckBox dropped = new CheckBox();
- dropped.Checked = e.Item.Cells[7].Text == "1";
- dropped.Enabled = false;
- e.Item.Cells[7].Controls.Add(dropped);
- // 成本
- double cost = double.Parse(e.Item.Cells[9].Text);
- e.Item.Cells[9].Text = System.Math.Round(cost, 2).ToString();
- double costRate = double.Parse(e.Item.Cells[10].Text);
- e.Item.Cells[10].Text = System.Math.Round(costRate * 100, 2).ToString() + "%";
- // 耗时
- string usedTimeText = e.Item.Cells[11].Text;
- System.TimeSpan usedTime = new System.TimeSpan(long.Parse(usedTimeText));
- e.Item.Cells[11].Text = usedTime.Days + " " + usedTime.Hours + ":" + usedTime.Minutes + ":" + usedTime.Seconds;
- }
- }
- }
- }