WorkflowGrid.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:6k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.ComponentModel;
- using System.Collections.Generic;
- using OThinker.H3.WorkflowTemplate;
- namespace OThinker.H3.Portal
- {
- /// <summary>
- /// Summary description for WorkflowGrid.
- /// </summary>
- [DefaultProperty("Text"),
- ToolboxData("<{0}:WorkflowGrid runat=server></{0}:WorkflowGrid>")]
- public class WorkflowGrid : System.Web.UI.WebControls.WebControl
- {
- public WorkflowGrid()
- {
- }
- private UserValidator UserValidator;
- public void Initialize(UserValidator UserValidator)
- {
- this.UserValidator = UserValidator;
- }
- private Dictionary<string, Dictionary<string, int>> CreatePackageTable()
- {
- // 创建
- Dictionary<string, Dictionary<string, int>> packageTable = new Dictionary<string, Dictionary<string, int>>();
- // 查找所有符合条件的工作流表
- if (this.DesignMode)
- {
- // 设计模式
- foreach (string package in new string[] { "工作流包1", "工作流包2", "工作流包3" })
- {
- // 创建(Workflow)
- Dictionary<string, int> nameTable = new Dictionary<string, int>();
- packageTable.Add(package, nameTable);
- foreach (string name in new string[] { "工作流1", "工作流2", "工作流3" })
- {
- nameTable.Add(name, 1);
- }
- }
- }
- else
- {
- // 查询流程模板
- System.Collections.Generic.List<string> unitList = new System.Collections.Generic.List<string>(this.UserValidator.RecursiveMemberOfs);
- if(!unitList.Contains(this.UserValidator.UserID))
- {
- unitList.Add(this.UserValidator.UserID);
- }
- System.Data.DataTable table = OThinker.H3.Portal.Query.QueryWorkflow(unitList.ToArray());
- // 构建包
- foreach(System.Data.DataRow row in table.Rows)
- {
- string package = (string)row[OThinker.H3.WorkflowTemplate.WorkflowTemplate.PropertyName_WorkflowPackageName];
- Dictionary<string, int> nameTable = new Dictionary<string, int>();
- if(packageTable.ContainsKey(package))
- {
- nameTable = packageTable[package];
- }
- else
- {
- nameTable = new Dictionary<string, int>();
- packageTable.Add(package, nameTable);
- }
- string name = (string)row[OThinker.H3.WorkflowTemplate.WorkflowTemplate.PropertyName_WorkflowName];
- if(!nameTable.ContainsKey(name))
- {
- int version = (int)row[OThinker.H3.WorkflowTemplate.WorkflowTemplate.PropertyName_WorkflowVersion];
- nameTable.Add(name, version);
- }
- }
- }
- return packageTable;
- }
- // (PackageName, (WorkflowName, WorkflowVersion))
- private Dictionary<string, Dictionary<string, int>> _PackageTable;
- public Dictionary<string, Dictionary<string, int>> PackageTable
- {
- get
- {
- if (this._PackageTable == null)
- {
- this._PackageTable = this.CreatePackageTable();
- }
- return this._PackageTable;
- }
- }
- protected override void Render(HtmlTextWriter writer)
- {
- // 显示
- if (this.PackageTable.Count == 0)
- {
- writer.Write("没有找到记录");
- }
- else
- {
- writer.Write("<TABLE WIDTH="100%" cellpadding="0" cellspacing="0">");
- int count = 0;
- foreach (string package in this.PackageTable.Keys)
- {
- writer.Write("<TR WIDTH="100%">");
- writer.Write("<TD WIDTH="100%">");
- string divName = "DIV_CategoryWorkflowView_" + count;
- // 隐藏显示按钮
- 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" ><strong>-" + package + "</strong></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" ><strong>+" + package + "</strong></a>");
- writer.Write("<DIV ID="" + divName + "" >");
- Dictionary<string, int> nameTable = this.PackageTable[package];
- foreach(string name in nameTable.Keys)
- {
- int version = nameTable[name];
- WorkflowGridItem item = new WorkflowGridItem(package, name, version);
- item.Attributes.Add("width", "100%");
- item.RenderControl(writer);
- }
- writer.Write("</DIV>");
- writer.Write("</TD>");
- writer.Write("</TR>");
- count++;
- }
- writer.Write("</TABLE>");
- }
- }
- }
- }