UserReport.aspx.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:8k
源码类别:
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 UserReport.
- /// </summary>
- public partial class UserReport : ReportPage
- {
- protected System.Web.UI.WebControls.DropDownList lstTaskName;
- protected void Page_Load(object sender, System.EventArgs e)
- {
- if(!this.IsPostBack)
- {
- // 验证是否具有管理员权限
- if (!this.UserValidator.ValidateViewReport())
- {
- this.NotifyMessage(LackOfAuth);
- }
- // 设置默认的搜索时间
- System.DateTime today = System.DateTime.Now;
- System.DateTime tomorrow = today.Add(new System.TimeSpan(1, 0, 0, 0, 0));
- this.txtFromTime.Text = today.ToShortDateString();
- this.txtToTime.Text = tomorrow.ToShortDateString();
- string[] catalogs = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowPackages();
- // 添加一空元素表示全部
- this.lstWorkflowPackage.Items.Add(NullItemValue);
- foreach(string catalog in catalogs)
- {
- this.lstWorkflowPackage.Items.Add(catalog);
- }
- }
- }
- #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.btnQuery.Click += new System.Web.UI.ImageClickEventHandler(this.btnQuery_Click);
- }
- #endregion
- protected void lstWorkflowPackage_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- string catalog = this.lstWorkflowPackage.SelectedValue;
- this.lstWorkflowName.Items.Clear();
- this.lstWorkflowVersion.Items.Clear();
- this.lstActivityName.Items.Clear();
- if(this.IsSelectedNull(catalog))
- {
- this.lstWorkflowName.Items.Add(NullItemValue);
- this.lstWorkflowVersion.Items.Add(NullItemValue);
- this.lstActivityName.Items.Add(NullItemValue);
- }
- else
- {
- string[] names = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNames(catalog, OThinker.H3.WorkflowTemplate.WorkflowState.Unspecified);
- this.lstWorkflowName.Items.Add(NullItemValue);
- foreach(string name in names)
- {
- this.lstWorkflowName.Items.Add(name);
- }
- }
- }
- protected void lstWorkflowName_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- string catalog = this.lstWorkflowPackage.SelectedValue;
- string name = this.lstWorkflowName.SelectedValue;
- this.lstWorkflowVersion.Items.Clear();
- this.lstActivityName.Items.Clear();
- if(this.IsSelectedNull(name))
- {
- this.lstWorkflowVersion.Items.Add(NullItemValue);
- this.lstActivityName.Items.Add(NullItemValue);
- }
- else
- {
- int[] versions = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowVersions(
- catalog,
- name);
- this.lstWorkflowVersion.Items.Add(NullItemValue);
- if(versions != null)
- {
- foreach(int version in versions)
- {
- this.lstWorkflowVersion.Items.Add(version.ToString());
- }
- }
- }
- }
- protected void lstWorkflowVersion_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- string catalog = this.lstWorkflowPackage.SelectedValue;
- string name = this.lstWorkflowName.SelectedValue;
- int version = OThinker.H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion;
- this.lstActivityName.Items.Clear();
- if(this.IsSelectedNull(this.lstWorkflowVersion.SelectedValue))
- {
- this.lstActivityName.Items.Add(NullItemValue);
- }
- else
- {
- version = int.Parse(this.lstWorkflowVersion.SelectedValue);
- // 获得该流程
- OThinker.H3.WorkflowTemplate.WorkflowTemplate process = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflow(
- catalog,
- name,
- version);
- foreach (OThinker.H3.WorkflowTemplate.ActivityTemplate task in process.Activities)
- {
- this.lstActivityName.Items.Add(task.Name);
- }
- }
- }
- #region 查询
- protected override string ReportTableSessionName
- {
- get
- {
- return OThinker.H3.WorkSheet.Sessions.GetUserReportTable();
- }
- }
- private void btnQuery_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- this.Query();
- }
- protected void lnkQuery_Click(object sender, System.EventArgs e)
- {
- this.Query();
- }
- private void Query()
- {
- #region 查找相关人员
- // 类型
- string catalog = null;
- if(!this.IsSelectedNull(this.lstWorkflowPackage.SelectedValue))
- {
- catalog = this.lstWorkflowPackage.SelectedValue;
- }
- // 名称
- string name = null;
- if(!this.IsSelectedNull(this.lstWorkflowName.SelectedValue))
- {
- name = this.lstWorkflowName.SelectedValue;
- }
- // 版本号
- int version = OThinker.H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion;
- if(!this.IsSelectedNull(this.lstWorkflowVersion.SelectedValue))
- {
- version = int.Parse(this.lstWorkflowVersion.SelectedValue);
- }
- string taskName = null;
- if(!this.IsSelectedNull(this.lstActivityName.SelectedValue))
- {
- taskName = this.lstActivityName.SelectedValue;
- }
- System.DateTime from;
- try
- {
- from = System.DateTime.Parse(this.txtFromTime.Text);
- }
- catch
- {
- from = System.DateTime.MinValue;
- }
- System.DateTime to;
- try
- {
- to = System.DateTime.Parse(this.txtToTime.Text);
- }
- catch
- {
- to = System.DateTime.MaxValue;
- }
- // 查询操作人员
- string[] actors = OThinker.H3.Server.Engine.WorkItemManager.GetWorkflowParticipants(
- catalog,
- name,
- version,
- taskName,
- from,
- to);
- #endregion
- System.Data.DataTable performanceTable = new DataTable();
- performanceTable.Columns.Add("User Name");
- performanceTable.Columns.Add("Times");
- performanceTable.Columns.Add("Shortest Wait Time");
- performanceTable.Columns.Add("Average Wait Time");
- performanceTable.Columns.Add("Longest Wait Time");
- performanceTable.Columns.Add("Shortest Used Time");
- performanceTable.Columns.Add("Average Used Time");
- performanceTable.Columns.Add("Longest Used Time");
- if(actors != null)
- {
- foreach(string actor in actors)
- {
- OThinker.H3.WorkItem.UserPerformance performance = OThinker.H3.Server.Engine.WorkItemManager.GetUserPerformance(
- catalog,
- name,
- version,
- taskName,
- actor,
- from,
- to);
- string userName = OThinker.H3.Server.Engine.Organization.GetFullName(actor);
- if(performance == null)
- {
- performanceTable.Rows.Add(
- new object[]{
- userName,
- 0,
- null,
- null,
- null,
- null,
- null,
- null});
- }
- else
- {
- performanceTable.Rows.Add(
- new object[]{
- userName,
- performance.ExecutedTimes,
- OThinker.Data.Convertor.Format(new System.TimeSpan(performance.ShortestWaitTime)),
- OThinker.Data.Convertor.Format(new System.TimeSpan(performance.AverageWaitTime)),
- OThinker.Data.Convertor.Format(new System.TimeSpan(performance.LongestWaitTime)),
- OThinker.Data.Convertor.Format(new System.TimeSpan(performance.ShortestUsedTime)),
- OThinker.Data.Convertor.Format(new System.TimeSpan(performance.AverageUsedTime)),
- OThinker.Data.Convertor.Format(new System.TimeSpan(performance.LongestUsedTime))});
- }
- }
- this.ReportTable = performanceTable;
- // 保存结果
- this.UserPerformanceGrid.DataSource = this.ReportTable;
- this.UserPerformanceGrid.DataBind();
- }
- }
- #endregion
- #region 导出报表
- private void btnExport_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- this.Export();
- }
- protected void lnkExport_Click(object sender, System.EventArgs e)
- {
- this.Export();
- }
- #endregion
- }
- }