Consult.aspx.cs
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:6k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. namespace OThinker.H3.Portal
  12. {
  13. /// <summary>
  14. /// Summary description for Consult.
  15. /// </summary>
  16.     public partial class Consult : PortalPage
  17. {
  18.         private OThinker.H3.WorkItem.WorkItem WorkItem
  19. {
  20. get
  21. {
  22.                 // 获得被征询的任务ID
  23.                 string itemId = this.Request.QueryString[Param_WorkItemID];
  24.                 string sessionName = OThinker.H3.WorkSheet.Sessions.GetWorkItem(itemId);
  25.                 if (this.Session[sessionName] == null)
  26. {
  27. OThinker.H3.WorkItem.WorkItem job = OThinker.H3.Server.Engine.WorkItemManager.GetWorkItem(itemId);
  28.                     this.Session[sessionName] = job;
  29. }
  30.                 return (OThinker.H3.WorkItem.WorkItem)this.Session[sessionName];
  31. }
  32. }
  33.         private string[] OptionalConsultants
  34.         {
  35.             get
  36.             {
  37.                 string options = this.Request.QueryString[Param_OptionalConsultants];
  38.                 if (options == null || options == "")
  39.                 {
  40.                     return null;
  41.                 }
  42.                 else
  43.                 {
  44.                     return OThinker.Data.ArrayConvertor<string>.StringToArray(options);
  45.                 }
  46.             }
  47.         }
  48. protected void Page_Load(object sender, System.EventArgs e)
  49.         {
  50.             this.UserSelector.SelectMode = OThinker.H3.WorkSheet.UserSelector.SelectionMode.Multi;
  51.             this.UserSelector.SelectUserUrl = PageName_SelectUser;
  52.             this.UserSelector.SelectUserImageUrl = PageName_SelectUserImage;
  53. if(!this.IsPostBack)
  54. {
  55. // 检查该任务是否可以进行征询意见
  56. if(!this.WorkItem.PermittedActions.Consult)
  57. {
  58. this.NotifyMessage("不能进行征询意见操作");
  59. }
  60. // 以前被征询的人
  61. string[] consultants = OThinker.H3.Server.Engine.WorkItemManager.GetAllConsultants(this.WorkItem.WorkItemID);
  62.                 // 可选的被征询的人
  63.                 string[] optionalConsultants = this.OptionalConsultants;
  64.                 System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
  65.                 if (optionalConsultants != null)
  66.                 {
  67.                     foreach (string c in optionalConsultants)
  68.                     {
  69.                         if (c != null && c != "" && !list.Contains(c))
  70.                         {
  71.                             list.Add(c);
  72.                         }
  73.                     }
  74.                 }
  75.                 if (consultants != null)
  76.                 {
  77.                     foreach (string c in consultants)
  78.                     {
  79.                         if (c != null && c != "" && !list.Contains(c))
  80.                         {
  81.                             list.Add(c);
  82.                         }
  83.                     }
  84.                 }
  85.                 this.UserSelector.LoadSelection(OThinker.H3.Server.Engine.Organization, list.ToArray());
  86. }
  87. }
  88. #region Web Form Designer generated code
  89. override protected void OnInit(EventArgs e)
  90. {
  91. //
  92. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  93. //
  94. InitializeComponent();
  95. base.OnInit(e);
  96. }
  97. /// <summary>
  98. /// Required method for Designer support - do not modify
  99. /// the contents of this method with the code editor.
  100. /// </summary>
  101. private void InitializeComponent()
  102. {    
  103. this.btnSubmit.Click += new System.Web.UI.ImageClickEventHandler(this.btnSubmit_Click);
  104. }
  105. #endregion
  106. private void btnSubmit_Click(object sender, System.Web.UI.ImageClickEventArgs e)
  107. {
  108. this.Submit();
  109. }
  110. protected void lnkConfirm_Click(object sender, System.EventArgs e)
  111. {
  112. this.Submit();
  113. }
  114.         public void Submit()
  115.         {
  116.             // 获得选中的用户
  117.             string[] selectedUsers = this.UserSelector.SelectedUsers;
  118.             string[] consultants = OThinker.H3.Server.Engine.Organization.GetMembers(selectedUsers);
  119.             // 获得已经征询过意见的人员
  120.             string[] consultedConsultants = OThinker.H3.Server.Engine.WorkItemManager.GetAllConsultants(this.WorkItem.WorkItemID);
  121.             System.Collections.ArrayList consultantList = new ArrayList();
  122.             if (consultants != null)
  123.             {
  124.                 foreach (string consultant in consultants)
  125.                 {
  126.                     bool exist = false;
  127.                     // 检查是否在已被征询过人里面
  128.                     if (consultedConsultants != null)
  129.                     {
  130.                         foreach (string consulted in consultedConsultants)
  131.                         {
  132.                             if (consultant == consulted)
  133.                             {
  134.                                 exist = true;
  135.                                 break;
  136.                             }
  137.                         }
  138.                     }
  139.                     if (exist)
  140.                     {
  141.                         continue;
  142.                     }
  143.                     else
  144.                     {
  145.                         consultantList.Add(consultant);
  146.                     }
  147.                 }
  148.             }
  149.             string[] newConsultants = OThinker.Data.ArrayConvertor<string>.ToArray(consultantList);
  150.             // 添加征询任务
  151.             if (OThinker.H3.Server.Engine.WorkItemManager.Consult(this.WorkItem.WorkItemID, newConsultants) == OThinker.H3.ErrorCode.SUCCESS)
  152.             {
  153.                 this.NotifyMessage("征询意见成功");
  154.             }
  155.             else
  156.             {
  157.                 this.NotifyMessage("征询意见成功,可能该工作项不存在或者不能征询该工作项的意见");
  158.             }
  159.         }
  160. }
  161. }