QueryInstanceByFullText.aspx.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:9k
源码类别:
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 QueryCaseByData.
- /// </summary>
- public partial class QueryInstanceByFullText : PortalPage
- {
- protected void Page_Load(object sender, System.EventArgs e)
- {
- if(!this.IsPostBack)
- {
- // 验证是否具有管理员权限
- if (!this.UserValidator.ValidateViewReport())
- {
- this.NotifyMessage(LackOfAuth);
- }
- // 设置默认状态为未完成
- this.lstState.SelectedIndex = 0;
- // 设置默认的搜索时间
- 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();
- }
- }
- #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
- 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()
- {
- string keyword = null;
- if(this.txtKeyword.Text == null || this.txtKeyword.Text == "")
- {
- keyword = null;
- }
- else
- {
- keyword = this.txtKeyword.Text;
- }
- string[] originators = null;
- if (this.txtOriginator.SelectedUser == null || this.txtOriginator.SelectedUser == "")
- {
- originators = null;
- }
- else
- {
- originators = OThinker.H3.Server.Engine.Organization.GetChildren(this.txtOriginator.SelectedUser, OThinker.Organization.UnitType.User, true);
- }
- bool finished = this.lstState.SelectedIndex != 0;
- 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;
- }
- if(
- keyword == null &&
- originators == null &&
- from == System.DateTime.MinValue &&
- to == System.DateTime.MaxValue)
- {
- // 所有的查询条件都没有赋值,不进行查询
- }
- else
- {
- // 查找满足条件的实例
- System.Data.DataTable table = this.Query(
- keyword,
- originators,
- finished,
- from,
- to);
- this.InstanceGridView.BindDataGrid(table);
- }
- }
- public System.Data.DataTable Query(
- string Keyword,
- string[] Originators,
- bool Finished,
- System.DateTime CreatedTime_From,
- System.DateTime CreatedTime_To)
- {
- // 查找
- H3.Instance.InstanceState state;
- if (Finished)
- {
- state = H3.Instance.InstanceState.Complete;
- }
- else
- {
- state = H3.Instance.InstanceState.Unfinished;
- }
- // 符合条件的流程ID集合
- string[] instances;
- // 查找满足条件的实例
- instances = OThinker.H3.Server.Engine.InstanceManager.Query(
- Originators,
- null,
- H3.Instance.InstanceContext.UnspecifiedID,
- state,
- null,
- null,
- H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion,
- CreatedTime_From,
- CreatedTime_To,
- null);
- // 按照内容关键字查找
- int queriedTables = 0;
- System.Collections.ArrayList instanceCollection = new System.Collections.ArrayList();
- // 获得当前系统中的所有工作流
- string[] packages = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowPackages();
- if (packages != null)
- {
- foreach (string package in packages)
- {
- string[] names = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowNames(package, OThinker.H3.WorkflowTemplate.WorkflowState.Active);
- if (names != null)
- {
- foreach (string name in names)
- {
- int[] versions = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflowVersions(package, name);
- if (versions != null)
- {
- foreach (int version in versions)
- {
- WorkflowTemplate.WorkflowTemplate workflow = OThinker.H3.Server.Engine.WorkflowManager.GetWorkflow(
- package,
- name,
- version);
- // 对每一个数据项进行查找
- foreach (Data.WorkflowDataItem item in workflow.DataItems)
- {
- // 检查是否能转换成为需要比较的类型
- object convertedValue = null;
- try
- {
- convertedValue = OThinker.Data.Convertor.Convert(Keyword, item.RealType, true);
- }
- catch
- {
- continue;
- }
- string[] ids = OThinker.H3.Server.Engine.InstanceDataManager.Query(
- workflow,
- item.ItemName,
- OThinker.Data.ComparisonOperatorType.Approximate,
- convertedValue,
- instances);
- if (ids != null)
- {
- foreach (string id in ids)
- {
- if (id != null && !instanceCollection.Contains(id))
- {
- instanceCollection.Add(id);
- }
- }
- }
- // 当前的已经查询的表加1
- queriedTables++;
- }
- }
- }
- }
- }
- }
- }
- // 按照标题关键字查找
- string[] titleInstances = OThinker.H3.Server.Engine.InstanceManager.Query(
- Originators,
- null,
- H3.Instance.InstanceContext.UnspecifiedID,
- state,
- null,
- null,
- H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion,
- CreatedTime_From,
- CreatedTime_To,
- Keyword);
- // 合并两个关键字查找的结果
- if (titleInstances != null)
- {
- foreach (string instanceId in titleInstances)
- {
- if (!instanceCollection.Contains(instanceId))
- {
- instanceCollection.Add(instanceId);
- }
- }
- }
- instances = OThinker.Data.ArrayConvertor<string>.ToArray(instanceCollection);
- // 显示该列表
- return Portal.Query.QueryInstance(
- instances,
- null,
- null,
- H3.Instance.InstanceContext.UnspecifiedID,
- Instance.InstanceState.Unspecified,
- null,
- null,
- H3.WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion,
- System.DateTime.MinValue,
- System.DateTime.MaxValue,
- null,
- OThinker.H3.Instance.PriorityType.Unspecified,
- OThinker.Data.BoolMatchValue.Unspecified,
- OThinker.Data.BoolMatchValue.Unspecified);
- }
- }
- }