InstanceData.aspx.cs
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:6k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. namespace OThinker.H3.Portal
  12. {
  13. /// <summary>
  14. /// Summary description for CaseData.
  15. /// </summary>
  16.     public partial class InstanceData : PortalPage
  17. {
  18. private System.Data.DataTable ValueTable = new DataTable();
  19. private System.Collections.ArrayList ValueList = new ArrayList();
  20. protected void Page_Load(object sender, System.EventArgs e)
  21. {
  22. string instanceId = this.Request.QueryString[Param_InstanceId];
  23.             if (instanceId != null && instanceId != "" && instanceId != Instance.InstanceContext.NullObjectID)
  24. {
  25.                 string processCatalog = OThinker.H3.Server.Engine.InstanceManager.GetInstanceWorkflowPackage(instanceId);
  26.                 string processName = OThinker.H3.Server.Engine.InstanceManager.GetInstanceWorkflowName(instanceId);
  27.                 int processVersion = OThinker.H3.Server.Engine.InstanceManager.GetInstanceWorkflowVersion(instanceId);
  28. // 获得工作流
  29.                 H3.WorkflowTemplate.WorkflowTemplate workflow = this.GetWorkflow(
  30. processCatalog, 
  31. processName, 
  32. processVersion);
  33.                 Data.InstanceData data = new OThinker.H3.Data.InstanceData(
  34.                     OThinker.H3.Server.Engine.InstanceDataManager,
  35.                     OThinker.H3.Server.Engine.WorkflowManager,
  36.                     OThinker.H3.Server.Engine.InstanceManager,
  37.                     instanceId,
  38.                     Instance.Token.UnspecifiedID,
  39.                     workflow,
  40.                     null,
  41.                     this.UserValidator.UserID,
  42.                     null);
  43.                 
  44. if(workflow.DataItems != null)
  45. {
  46. this.ValueTable.Columns.Clear();
  47. this.ValueTable.Columns.Add("Name");
  48. this.ValueTable.Columns.Add("Type");
  49. this.ValueTable.Columns.Add("Value");
  50. this.ValueTable.Columns.Add("ViewDataTrailText");
  51. this.ValueTable.Columns.Add("ViewDataTrailUrl");
  52. this.ValueList.Clear();
  53. foreach(OThinker.H3.Data.WorkflowDataItem processItem in workflow.DataItems)
  54. {
  55.                         // 显示这条流程数据
  56.                         System.Data.DataRow row = this.ValueTable.NewRow();
  57.                         this.ValueTable.Rows.Add(row);
  58.                         row["Name"] = processItem.ItemName;
  59.                         row["Type"] = processItem.LogicTypeName;
  60.                         if (processItem.Trackable)
  61.                         {
  62.                             row["ViewDataTrailText"] = "查看";
  63.                             row["ViewDataTrailUrl"] =
  64.                                 PageName_InstanceDataTrack + "?" +
  65.                                 Param_InstanceId + "=" + instanceId + "&" +
  66.                                 Param_ItemName + "=" + System.Web.HttpUtility.UrlEncode(processItem.ItemName);
  67.                         }
  68.                         object itemValue = null;
  69.                         if (!OThinker.H3.Data.DataLogicTypeConvertor.IsAttachmentType(processItem.LogicType))
  70.                         {
  71.                             // 非附件类型
  72.                             itemValue = data[processItem.ItemName].Value;
  73.                         }
  74.                         else
  75.                         {
  76.                             // 是附件类型
  77.                             itemValue = 
  78.                                 "<a href="" + 
  79.                                 PageName_ReadAttachment + "?" + 
  80.                                 Param_InstanceId + "=" + instanceId + "&" + 
  81.                                 Param_ItemName + "=" + System.Web.HttpUtility.UrlEncode(processItem.ItemName) + 
  82.                                 "">" + "查看附件" + "</a>";
  83.                         }
  84.                         this.ValueList.Add(itemValue);
  85. }
  86. }
  87. }
  88. this.InstanceDataGrid.DataSource = this.ValueTable;
  89. this.InstanceDataGrid.DataBind();
  90. }
  91. #region Web Form Designer generated code
  92. override protected void OnInit(EventArgs e)
  93. {
  94. //
  95. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  96. //
  97. InitializeComponent();
  98. base.OnInit(e);
  99. }
  100. /// <summary>
  101. /// Required method for Designer support - do not modify
  102. /// the contents of this method with the code editor.
  103. /// </summary>
  104. private void InitializeComponent()
  105. {    
  106. this.InstanceDataGrid.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.InstanceDataGrid_ItemDataBound);
  107. }
  108. #endregion
  109. private void InstanceDataGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
  110. {
  111. if(e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Header && 
  112. e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Footer)
  113. {
  114. System.Web.UI.WebControls.WebControl control = null;
  115. object itemValue = this.ValueList[e.Item.ItemIndex];
  116. if(itemValue == null)
  117. {
  118. control = new Label();
  119. ((Label)control).Text = "null";
  120. }
  121. else if(itemValue.GetType().BaseType == typeof(System.Array))
  122. {
  123. Table table = new Table();
  124. control = table;
  125. for(int count=0; count<((System.Array)itemValue).Length; count++)
  126. {
  127. TableRow arrayTableRow = new TableRow();
  128. table.Rows.Add(arrayTableRow);
  129. this.AddCell(arrayTableRow, count.ToString() + ": ") ;
  130. object arrayElementValue = ((System.Array)itemValue).GetValue(count);
  131. if(arrayElementValue == null)
  132. {
  133. this.AddCell(arrayTableRow, "null");
  134. }
  135. else
  136. {
  137. this.AddCell(arrayTableRow, arrayElementValue.ToString().Replace("n", "<BR>"));
  138. }
  139. }
  140. }
  141. else
  142. {
  143. control = new Label();
  144. ((Label)control).Text = itemValue.ToString().Replace("n", "<BR>");
  145. }
  146. e.Item.Cells[2].Controls.Add(control);
  147. }
  148. }
  149. private void AddCell(TableRow Row, string Content)
  150. {
  151. TableCell cell = new TableCell();
  152. cell.Attributes.Add("valign", "top");
  153. Row.Cells.Add(cell);
  154. Label label = new Label();
  155. cell.Controls.Add(label);
  156. label.Text = Content;
  157. }
  158. }
  159. }