CatalogWorkItemView.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:11k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Data;
- using System.Configuration;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.ComponentModel;
- namespace OThinker.H3.Portal
- {
- public enum ViewModal
- {
- /// <summary>
- /// 通过时间来区分
- /// </summary>
- SortByTime,
- /// <summary>
- /// 通过流程的名称来区分
- /// </summary>
- CategorizedByWorkflow,
- CategorizedByPackage
- }
- /// <summary>
- /// Summary description for CatalogWorkItemView
- /// </summary>
- [DefaultProperty("Text"),
- ToolboxData("<{0}:CatalogWorkItemView runat=server></{0}:CatalogWorkItemView>")]
- public class CatalogWorkItemView : WebControl
- {
- public CatalogWorkItemView()
- {
- }
- // 从数据库中查找到的表
- private System.Data.DataTable _WorkItemTable;
- public System.Data.DataTable WorkItemTable
- {
- get
- {
- return this._WorkItemTable;
- }
- set
- {
- this._WorkItemTable = value;
- }
- }
- private ViewModal _ViewModal = ViewModal.SortByTime;
- [Category("H3"), Browsable(true)]
- public ViewModal ViewModal
- {
- get
- {
- return this._ViewModal;
- }
- set
- {
- this._ViewModal = value;
- }
- }
- protected override void Render(HtmlTextWriter writer)
- {
- // 这里按照工作项所属的工作流来进行分类(CategoryName, (System.Data.DataTable WorkItemTable))
- System.Collections.SortedList CatalogTable = new System.Collections.SortedList();
- if (this.DesignMode)
- {
- // 处于设计状态,构造显示表
- this.WorkItemTable = new DataTable();
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_ActivityName);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_InstanceId);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_InstanceName);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_ConsultedWorkItemID);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_FinishTime);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_Priority);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_State);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_LongUsedTime);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_LongWaitTime);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_ObjectID);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_Originator);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_Participant);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_ReceiveTime);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_StartTime);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_TokenId);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_Urgency);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_SheetType);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_SheetAddress);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_WorkflowPackage);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_WorkflowName);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_WorkflowVersion);
- this.WorkItemTable.Columns.Add(H3.WorkItem.WorkItem.PropertyName_DisplayName);
- 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" });
- 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" });
- 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" });
- }
- // 进行分类
- switch (this.ViewModal)
- {
- case ViewModal.CategorizedByPackage:
- foreach (System.Data.DataRow row in this.WorkItemTable.Rows)
- {
- // 获得工作流名称
- string packageName = (string)row[H3.WorkItem.WorkItem.PropertyName_WorkflowPackage];
- // 找到对应的工作项列表
- DataTable itemTable;
- if ((itemTable = (DataTable)CatalogTable[packageName]) == null)
- {
- itemTable = new DataTable();
- foreach (DataColumn column in this.WorkItemTable.Columns)
- {
- itemTable.Columns.Add(column.ColumnName);
- }
- CatalogTable.Add(packageName, itemTable);
- }
- // 将对应的行添加到该表中
- itemTable.Rows.Add(row.ItemArray);
- }
- break;
- case ViewModal.CategorizedByWorkflow:
- foreach (System.Data.DataRow row in this.WorkItemTable.Rows)
- {
- // 获得工作流名称
- string packageName = (string)row[H3.WorkItem.WorkItem.PropertyName_WorkflowPackage];
- string name = (string)row[H3.WorkItem.WorkItem.PropertyName_WorkflowName];
- string workflowName = H3.WorkflowTemplate.WorkflowTemplate.GetWorkflowFullName(packageName, name);
- // 找到对应的工作项列表
- DataTable itemTable;
- if ((itemTable = (DataTable)CatalogTable[workflowName]) == null)
- {
- itemTable = new DataTable();
- foreach (DataColumn column in this.WorkItemTable.Columns)
- {
- itemTable.Columns.Add(column.ColumnName);
- }
- CatalogTable.Add(workflowName, itemTable);
- }
- // 将对应的行添加到该表中
- itemTable.Rows.Add(row.ItemArray);
- }
- break;
- case ViewModal.SortByTime:
- foreach (System.Data.DataRow row in this.WorkItemTable.Rows)
- {
- // 找到对应的工作项列表
- DataTable itemTable;
- if ((itemTable = (DataTable)CatalogTable["按时间来排列"]) == null)
- {
- itemTable = new DataTable();
- foreach (DataColumn column in this.WorkItemTable.Columns)
- {
- itemTable.Columns.Add(column.ColumnName);
- }
- CatalogTable.Add("按时间来排列", itemTable);
- }
- // 将对应的行添加到该表中
- itemTable.Rows.Add(row.ItemArray);
- }
- break;
- }
- if (this.WorkItemTable == null || this.WorkItemTable.Rows.Count == 0)
- {
- writer.Write("没有找到记录");
- }
- else
- {
- writer.Write("<TABLE WIDTH="100%" cellpadding="0" cellspacing="0">");
- int count=0;
- foreach (string categoryName in CatalogTable.Keys)
- {
- DataTable table = (DataTable)CatalogTable[categoryName];
- writer.Write("<TR WIDTH="100%">");
- writer.Write("<TD WIDTH="100%">");
- AbstractWorkItemGrid grid = new AbstractWorkItemGrid();
- grid.Attributes.Add("width", "100%");
- string divName = "DIV_CategoryWorkItemView_" + count;
- // 如果不采用按时间来区分,则不需要分页
- if (this.ViewModal != ViewModal.SortByTime)
- {
- grid.AllowPaging = false;
- // 隐藏显示按钮
- string hideButtonName = divName + "_HideButton";
- string displayButtonName = divName + "_DisplayButton";
- writer.Write("<a id="" + hideButtonName + "" onClick="javascript:" + divName + ".style.display='none';" + hideButtonName + ".style.display='none';" + displayButtonName + ".style.display='block';" style="cursor: hand" >-" + categoryName + "</a>");
- 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>");
- }
- grid.BindDataGrid(table);
- writer.Write("<DIV ID="" + divName + "">");
- grid.RenderControl(writer);
- writer.Write("</DIV>");
- writer.Write("</TD>");
- writer.Write("</TR>");
- count++;
- }
- writer.Write("</TABLE>");
- }
- }
- }
- }