ActivityReport.aspx.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:7k
源码类别:
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 ActivityReport.
- /// </summary>
- public partial class ActivityReport : PortalPage
- {
- protected void Page_Load(object sender, System.EventArgs e)
- {
- if(!this.IsPostBack)
- {
- if (!this.UserValidator.ValidateViewReport())
- {
- this.NotifyMessage(LackOfAuth);
- }
- }
- #region 分析参数
- string catalog = System.Web.HttpUtility.UrlDecode(this.Request.QueryString[Param_WorkflowPackage]);
- if(catalog == null || catalog == "")
- {
- catalog = null;
- }
- string name = System.Web.HttpUtility.UrlDecode(this.Request.QueryString[Param_WorkflowName]);
- if(name == null || name == "")
- {
- name = null;
- }
- string _version = System.Web.HttpUtility.UrlDecode(this.Request.QueryString[Param_WorkflowVersion]);
- int version;
- try
- {
- version = int.Parse(_version);
- }
- catch
- {
- version = OThinker.H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion;
- }
- string _from = System.Web.HttpUtility.UrlDecode(this.Request.QueryString[Param_From]);
- System.DateTime from;
- try
- {
- from = System.DateTime.Parse(_from);
- }
- catch
- {
- from = System.DateTime.MinValue;
- }
- string _to = System.Web.HttpUtility.UrlDecode(this.Request.QueryString[Param_To]);
- System.DateTime to;
- try
- {
- to = System.DateTime.Parse(_to);
- }
- catch
- {
- to = System.DateTime.MaxValue;
- }
- #endregion
- System.Data.DataTable performances = new DataTable();
- performances.Columns.Add("模板全名");
- performances.Columns.Add("活动名称");
- performances.Columns.Add("执行次数");
- performances.Columns.Add("平均完成时间");
- if(catalog == null)
- {
- // 显示所有流程的所有任务的性能
- string[] catalogs = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowPackages();
- if(catalogs != null)
- {
- foreach(string c in catalogs)
- {
- string[] names = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNames(c, OThinker.H3.WorkflowTemplate.WorkflowState.Unspecified);
- if(names != null)
- {
- foreach(string n in names)
- {
- int[] versions = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowVersions(c, n);
- if(versions != null)
- {
- foreach(int v in versions)
- {
- this.GetPerformance(
- performances,
- c,
- n,
- v,
- from,
- to);
- }
- }
- }
- }
- }
- }
- }
- else if(name == null)
- {
- // 显示某个类型下的所有流程的所有任务的性能
- string[] names = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNames(catalog, OThinker.H3.WorkflowTemplate.WorkflowState.Unspecified);
- if(names != null)
- {
- foreach(string n in names)
- {
- int[] versions = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowVersions(catalog, n);
- if(versions != null)
- {
- foreach(int v in versions)
- {
- this.GetPerformance(
- performances,
- catalog,
- n,
- v,
- from,
- to);
- }
- }
- }
- }
- }
- else if (version == OThinker.H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion || version == OThinker.H3.WorkflowTemplate.WorkflowTemplate.AllWorkflowVersion)
- {
- // 某个流程所有版本的所有任务
- int[] versions = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowVersions(catalog, name);
- if(versions != null)
- {
- foreach(int v in versions)
- {
- this.GetPerformance(
- performances,
- catalog,
- name,
- v,
- from,
- to);
- }
- }
- }
- else
- {
- this.GetPerformance(
- performances,
- catalog,
- name,
- version,
- from,
- to);
- }
- this.PerformanceGrid.DataSource = performances;
- this.PerformanceGrid.DataBind();
- }
- // 获得某个流程的某个任务的性能,结果存放在Performances表中
- private void GetPerformance(
- System.Data.DataTable Performances,
- string WorkflowPackage,
- string WorkflowName,
- int WorkflowVersion,
- System.DateTime From,
- System.DateTime To)
- {
- // 获得在这个时间段内的所有流程实例
- // 注意:这里必须获得已完成的任务,如果一个任务未完成可能会导致计算的平均值为负
- string[] instances = OThinker.H3.Server.Engine.InstanceManager.Query(
- null,
- null,
- OThinker.H3.Instance.InstanceContext.UnspecifiedID,
- OThinker.H3.Instance.InstanceState.Complete,
- WorkflowPackage,
- WorkflowName,
- WorkflowVersion,
- From,
- To,
- null);
- // 获得该流程
- OThinker.H3.WorkflowTemplate.WorkflowTemplate process = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflow(
- WorkflowPackage,
- WorkflowName,
- WorkflowVersion);
- // 获得该流程的每个任务的性能
- foreach (OThinker.H3.WorkflowTemplate.ActivityTemplate task in process.Activities)
- {
- OThinker.H3.WorkflowTemplate.ActivityPerformance performance = OThinker.H3.Server.Engine.TokenPool.GetActivityPerformance(
- instances,
- task.Name);
- if(performance == null)
- {
- Performances.Rows.Add(
- new object[]{
- OThinker.H3.WorkflowTemplate.WorkflowTemplate.GetWorkflowFullName(WorkflowPackage, WorkflowName, WorkflowVersion),
- task.Name,
- 0,
- null});
- }
- else
- {
- Performances.Rows.Add(
- new object[]{
- OThinker.H3.WorkflowTemplate.WorkflowTemplate.GetWorkflowFullName(WorkflowPackage, WorkflowName, WorkflowVersion),
- task.Name,
- performance.ExecutedTimes,
- OThinker.Data.Convertor.Format(new System.TimeSpan(performance.AverageUsedTime))});
- }
- }
- }
- #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()
- {
- }
- #endregion
- }
- }