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

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10. using System.ComponentModel;
  11. namespace OThinker.H3.Portal
  12. {
  13.     public enum ViewModal
  14.     {
  15.         /// <summary>
  16.         /// 通过时间来区分
  17.         /// </summary>
  18.         SortByTime,
  19.         /// <summary>
  20.         /// 通过流程的名称来区分
  21.         /// </summary>
  22.         CategorizedByWorkflow,
  23.         CategorizedByPackage
  24.     }
  25.     /// <summary>
  26.     /// Summary description for CatalogWorkItemView
  27.     /// </summary>
  28.     [DefaultProperty("Text"),
  29.       ToolboxData("<{0}:CatalogWorkItemView runat=server></{0}:CatalogWorkItemView>")]
  30.     public class CatalogWorkItemView : WebControl
  31.     {
  32.         public CatalogWorkItemView()
  33.         {
  34.             
  35.         }
  36.         // 从数据库中查找到的表
  37.         private System.Data.DataTable _WorkItemTable;
  38.         public System.Data.DataTable WorkItemTable
  39.         {
  40.             get
  41.             {
  42.                 return this._WorkItemTable;
  43.             }
  44.             set
  45.             {
  46.                 this._WorkItemTable = value;
  47.             }
  48.         }
  49.         private ViewModal _ViewModal = ViewModal.SortByTime;
  50.         [Category("H3"), Browsable(true)]
  51.         public ViewModal ViewModal
  52.         {
  53.             get
  54.             {
  55.                 return this._ViewModal;
  56.             }
  57.             set
  58.             {
  59.                 this._ViewModal = value;
  60.             }
  61.         }
  62.         protected override void Render(HtmlTextWriter writer)
  63.         {
  64.             // 这里按照工作项所属的工作流来进行分类(CategoryName, (System.Data.DataTable WorkItemTable))
  65.             System.Collections.SortedList CatalogTable = new System.Collections.SortedList();
  66.             if (this.DesignMode)
  67.             {
  68.                 // 处于设计状态,构造显示表
  69.                 this.WorkItemTable = new DataTable();
  70.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_ActivityName);
  71.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_InstanceId);
  72.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_InstanceName);
  73.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_ConsultedWorkItemID);
  74.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_FinishTime);
  75.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_Priority);
  76.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_State);
  77.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_LongUsedTime);
  78.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_LongWaitTime);
  79.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_ObjectID);
  80.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_Originator);
  81.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_Participant);
  82.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_ReceiveTime);
  83.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_StartTime);
  84.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_TokenId);
  85.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_Urgency);
  86.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_SheetType);
  87.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_SheetAddress);
  88.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_WorkflowPackage);
  89.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_WorkflowName);
  90.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_WorkflowVersion);
  91.                 this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_DisplayName);
  92.                 this.WorkItemTable.Rows.Add(new object[] { "Activity", 1, "InstanceName", 1, System.DateTime.Now, 0, 0, 0, 0, 0, "Originator", "Participant", System.DateTime.Now, System.DateTime.Now, 0, "Urgency", (int)OThinker.H3.WorkflowTemplate.SheetType.CustomSheet, "Url", "Package1", "Workflow1", 0, "WorkItem1" });
  93.                 this.WorkItemTable.Rows.Add(new object[] { "Activity", 1, "InstanceName", 1, System.DateTime.Now, 0, 0, 0, 0, 0, "Originator", "Participant", System.DateTime.Now, System.DateTime.Now, 0, "Urgency", (int)OThinker.H3.WorkflowTemplate.SheetType.CustomSheet, "Url", "Package1", "Workflow1", 0, "WorkItem2" });
  94.                 this.WorkItemTable.Rows.Add(new object[] { "Activity", 1, "InstanceName", 1, System.DateTime.Now, 0, 0, 0, 0, 0, "Originator", "Participant", System.DateTime.Now, System.DateTime.Now, 0, "Urgency", (int)OThinker.H3.WorkflowTemplate.SheetType.CustomSheet, "Url", "Package2", "Workflow3", 0, "WorkItem3" });
  95.             }
  96.             // 进行分类
  97.             switch (this.ViewModal)
  98.             {
  99.                 case ViewModal.CategorizedByPackage:
  100.                     foreach (System.Data.DataRow row in this.WorkItemTable.Rows)
  101.                     {
  102.                         // 获得工作流名称
  103.                         string packageName = (string)row[H3.WorkItem.WorkItem.PropertyName_WorkflowPackage];
  104.                         // 找到对应的工作项列表
  105.                         DataTable itemTable;
  106.                         if ((itemTable = (DataTable)CatalogTable[packageName]) == null)
  107.                         {
  108.                             itemTable = new DataTable();
  109.                             foreach (DataColumn column in this.WorkItemTable.Columns)
  110.                             {
  111.                                 itemTable.Columns.Add(column.ColumnName);
  112.                             }
  113.                             CatalogTable.Add(packageName, itemTable);
  114.                         }
  115.                         // 将对应的行添加到该表中
  116.                         itemTable.Rows.Add(row.ItemArray);
  117.                     }
  118.                     break;
  119.                 case ViewModal.CategorizedByWorkflow:
  120.                     foreach (System.Data.DataRow row in this.WorkItemTable.Rows)
  121.                     {
  122.                         // 获得工作流名称
  123.                         string packageName = (string)row[H3.WorkItem.WorkItem.PropertyName_WorkflowPackage];
  124.                         string name = (string)row[H3.WorkItem.WorkItem.PropertyName_WorkflowName];
  125.                         string workflowName = H3.WorkflowTemplate.WorkflowTemplate.GetWorkflowFullName(packageName, name);
  126.                         // 找到对应的工作项列表
  127.                         DataTable itemTable;
  128.                         if ((itemTable = (DataTable)CatalogTable[workflowName]) == null)
  129.                         {
  130.                             itemTable = new DataTable();
  131.                             foreach (DataColumn column in this.WorkItemTable.Columns)
  132.                             {
  133.                                 itemTable.Columns.Add(column.ColumnName);
  134.                             }
  135.                             CatalogTable.Add(workflowName, itemTable);
  136.                         }
  137.                         // 将对应的行添加到该表中
  138.                         itemTable.Rows.Add(row.ItemArray);
  139.                     }
  140.                     break;
  141.                 case ViewModal.SortByTime:
  142.                     foreach (System.Data.DataRow row in this.WorkItemTable.Rows)
  143.                     {
  144.                         // 找到对应的工作项列表
  145.                         DataTable itemTable;
  146.                         if ((itemTable = (DataTable)CatalogTable["按时间来排列"]) == null)
  147.                         {
  148.                             itemTable = new DataTable();
  149.                             foreach (DataColumn column in this.WorkItemTable.Columns)
  150.                             {
  151.                                 itemTable.Columns.Add(column.ColumnName);
  152.                             }
  153.                             CatalogTable.Add("按时间来排列", itemTable);
  154.                         }
  155.                         // 将对应的行添加到该表中
  156.                         itemTable.Rows.Add(row.ItemArray);
  157.                     }
  158.                     break;
  159.             }
  160.             if (this.WorkItemTable == null || this.WorkItemTable.Rows.Count == 0)
  161.             {
  162.                 writer.Write("没有找到记录");
  163.             }
  164.             else
  165.             {
  166.                 writer.Write("<TABLE WIDTH="100%" cellpadding="0" cellspacing="0">");
  167.                 int count=0;
  168.                 foreach (string categoryName in CatalogTable.Keys)
  169.                 {
  170.                     DataTable table = (DataTable)CatalogTable[categoryName];
  171.                     
  172.                     writer.Write("<TR WIDTH="100%">");
  173.                     writer.Write("<TD WIDTH="100%">");
  174.                     AbstractWorkItemGrid grid = new AbstractWorkItemGrid();
  175.                     grid.Attributes.Add("width", "100%");
  176.                     string divName = "DIV_CategoryWorkItemView_" + count;
  177.                     // 如果不采用按时间来区分,则不需要分页
  178.                     if (this.ViewModal != ViewModal.SortByTime)
  179.                     {
  180.                         grid.AllowPaging = false;
  181.                         
  182.                         // 隐藏显示按钮
  183.                         string hideButtonName = divName + "_HideButton";
  184.                         string displayButtonName = divName + "_DisplayButton";
  185.                         writer.Write("<a id="" + hideButtonName + "" onClick="javascript:" + divName + ".style.display='none';" + hideButtonName + ".style.display='none';" + displayButtonName + ".style.display='block';" style="cursor: hand" >-" + categoryName + "</a>");
  186.                         writer.Write("<a id="" + displayButtonName + "" style="display: none;" onClick="javascript:" + divName + ".style.display='block';" + hideButtonName + ".style.display='block';" + displayButtonName + ".style.display='none';" style="cursor: hand" >+" + categoryName + "</a>");
  187.                     }
  188.                     grid.BindDataGrid(table);
  189.                     writer.Write("<DIV ID="" + divName + "">");
  190.                     grid.RenderControl(writer);
  191.                     writer.Write("</DIV>");
  192.                     writer.Write("</TD>");
  193.                     writer.Write("</TR>");
  194.                     count++;
  195.                 }
  196.                 writer.Write("</TABLE>");
  197.             }
  198.         }
  199.     }
  200. }