Consult.aspx.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:6k
源码类别:
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 Consult.
- /// </summary>
- public partial class Consult : PortalPage
- {
- private OThinker.H3.WorkItem.WorkItem WorkItem
- {
- get
- {
- // 获得被征询的任务ID
- string itemId = this.Request.QueryString[Param_WorkItemID];
- string sessionName = OThinker.H3.WorkSheet.Sessions.GetWorkItem(itemId);
- if (this.Session[sessionName] == null)
- {
- OThinker.H3.WorkItem.WorkItem job = OThinker.H3.Server.Engine.WorkItemManager.GetWorkItem(itemId);
- this.Session[sessionName] = job;
- }
- return (OThinker.H3.WorkItem.WorkItem)this.Session[sessionName];
- }
- }
- private string[] OptionalConsultants
- {
- get
- {
- string options = this.Request.QueryString[Param_OptionalConsultants];
- if (options == null || options == "")
- {
- return null;
- }
- else
- {
- return OThinker.Data.ArrayConvertor<string>.StringToArray(options);
- }
- }
- }
- protected void Page_Load(object sender, System.EventArgs e)
- {
- this.UserSelector.SelectMode = OThinker.H3.WorkSheet.UserSelector.SelectionMode.Multi;
- this.UserSelector.SelectUserUrl = PageName_SelectUser;
- this.UserSelector.SelectUserImageUrl = PageName_SelectUserImage;
- if(!this.IsPostBack)
- {
- // 检查该任务是否可以进行征询意见
- if(!this.WorkItem.PermittedActions.Consult)
- {
- this.NotifyMessage("不能进行征询意见操作");
- }
- // 以前被征询的人
- string[] consultants = OThinker.H3.Server.Engine.WorkItemManager.GetAllConsultants(this.WorkItem.WorkItemID);
- // 可选的被征询的人
- string[] optionalConsultants = this.OptionalConsultants;
- System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
- if (optionalConsultants != null)
- {
- foreach (string c in optionalConsultants)
- {
- if (c != null && c != "" && !list.Contains(c))
- {
- list.Add(c);
- }
- }
- }
- if (consultants != null)
- {
- foreach (string c in consultants)
- {
- if (c != null && c != "" && !list.Contains(c))
- {
- list.Add(c);
- }
- }
- }
- this.UserSelector.LoadSelection(OThinker.H3.Server.Engine.Organization, list.ToArray());
- }
- }
- #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.btnSubmit.Click += new System.Web.UI.ImageClickEventHandler(this.btnSubmit_Click);
- }
- #endregion
- private void btnSubmit_Click(object sender, System.Web.UI.ImageClickEventArgs e)
- {
- this.Submit();
- }
- protected void lnkConfirm_Click(object sender, System.EventArgs e)
- {
- this.Submit();
- }
- public void Submit()
- {
- // 获得选中的用户
- string[] selectedUsers = this.UserSelector.SelectedUsers;
- string[] consultants = OThinker.H3.Server.Engine.Organization.GetMembers(selectedUsers);
- // 获得已经征询过意见的人员
- string[] consultedConsultants = OThinker.H3.Server.Engine.WorkItemManager.GetAllConsultants(this.WorkItem.WorkItemID);
- System.Collections.ArrayList consultantList = new ArrayList();
- if (consultants != null)
- {
- foreach (string consultant in consultants)
- {
- bool exist = false;
- // 检查是否在已被征询过人里面
- if (consultedConsultants != null)
- {
- foreach (string consulted in consultedConsultants)
- {
- if (consultant == consulted)
- {
- exist = true;
- break;
- }
- }
- }
- if (exist)
- {
- continue;
- }
- else
- {
- consultantList.Add(consultant);
- }
- }
- }
- string[] newConsultants = OThinker.Data.ArrayConvertor<string>.ToArray(consultantList);
- // 添加征询任务
- if (OThinker.H3.Server.Engine.WorkItemManager.Consult(this.WorkItem.WorkItemID, newConsultants) == OThinker.H3.ErrorCode.SUCCESS)
- {
- this.NotifyMessage("征询意见成功");
- }
- else
- {
- this.NotifyMessage("征询意见成功,可能该工作项不存在或者不能征询该工作项的意见");
- }
- }
- }
- }