EditOrganization.aspx.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:9k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- namespace OThinker.H3.Portal
- {
- public partial class EditOrganization : PortalPage
- {
- public const string Target = "OrganizationMain";
- private int VisibleUnitType
- {
- get
- {
- string type = this.Request.QueryString[Param_VisibleUnitType];
- if (type == null || type == "")
- {
- return (int)OThinker.Organization.UnitType.Unspecified;
- }
- else
- {
- return int.Parse(type);
- }
- }
- }
- private bool IsVisible(OThinker.Organization.UnitType UnitType)
- {
- if (this.VisibleUnitType == (int)OThinker.Organization.UnitType.Unspecified)
- {
- return true;
- }
- else
- {
- return (this.VisibleUnitType & (int)UnitType) > 0;
- }
- }
- #region 要展开的节点
- protected string ExpandPath
- {
- get
- {
- return HttpUtility.UrlDecode(this.Request.QueryString[Param_ExpandPath]);
- }
- }
- private System.Collections.Generic.List<string> _ExpandList = null;
- protected System.Collections.Generic.List<string> ExpandList
- {
- get
- {
- if (this._ExpandList == null)
- {
- this._ExpandList = new System.Collections.Generic.List<string>();
- if (this.ExpandPath != null && this.ExpandPath != "")
- {
- string[] units = this.ExpandPath.Split('/');
- this._ExpandList = new System.Collections.Generic.List<string>(units);
- }
- }
- return this._ExpandList;
- }
- }
- #endregion
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!this.IsPostBack)
- {
- //// 验证是否具有管理员权限
- //if (!this.UserValidator.ValidateAdministrator())
- //{
- // this.NotifyMessage(LackOfAuth);
- //}
- TreeNode root = new TreeNode();
- root.Value = OThinker.H3.Server.Engine.Organization.Company.UnitID;
- root.Text = OThinker.H3.Server.Engine.Organization.Company.Name;
- root.NavigateUrl = PageName_EditCompany + "?UnitID=" + OThinker.H3.Server.Engine.Organization.Company.UnitID;
- root.Target = Target;
- root.PopulateOnDemand = true;
- root.SelectAction = TreeNodeSelectAction.Select;
- root.ImageToolTip = root.Value;
- this.SetNodeNavigateUrl(root, OThinker.Organization.UnitType.Company);
- this.UserTree.Nodes.Add(root);
- root.Expand();
- }
- }
- protected void UserTree_TreeNodePopulate(object sender, TreeNodeEventArgs e)
- {
- //if (IsCallback)
- //{
- if (e.Node.ChildNodes.Count == 0)
- {
- LoadChildNode(e.Node);
- }
- //}
- }
- protected void LoadChildNode(TreeNode node)
- {
- string[] children = OThinker.H3.Server.Engine.Organization.GetChildren(node.Value, OThinker.Organization.UnitType.Unspecified, false);
- if (children != null)
- {
- // 按照OrganizationUnit, Group, User的顺序进行排列
- ArrayList unitList = new ArrayList();
- ArrayList keyList = new ArrayList();
- foreach (string child in children)
- {
- OThinker.Organization.Unit unit = OThinker.H3.Server.Engine.Organization.GetUnit(child);
- // 检查是否可见
- if (!this.IsVisible(unit.UnitType))
- {
- continue;
- }
- switch (unit.UnitType)
- {
- case OThinker.Organization.UnitType.Company:
- keyList.Add("a" + unit.Name);
- break;
- case OThinker.Organization.UnitType.OrganizationUnit:
- keyList.Add("b" + unit.Name);
- break;
- case OThinker.Organization.UnitType.Group:
- keyList.Add("c" + unit.Name);
- break;
- case OThinker.Organization.UnitType.User:
- keyList.Add("d" + unit.Name);
- break;
- default:
- throw new NotImplementedException();
- }
- unitList.Add(unit);
- }
- unitList = OThinker.Data.Sorter.Sort(keyList, unitList);
- foreach (OThinker.Organization.Unit unit in unitList)
- {
- if (unit == null)
- {
- continue;
- }
- TreeNode subNode = new TreeNode(unit.Name);
- subNode.Value = unit.UnitID;
- subNode.Target = Target;
- node.ChildNodes.Add(subNode);
- string param = "?" + Param_ID + "=" + unit.UnitID + "&" + Param_ExpandPath + "=" + HttpUtility.UrlEncode(subNode.ValuePath);
- switch (unit.UnitType)
- {
- case OThinker.Organization.UnitType.User:
- subNode.SelectAction = TreeNodeSelectAction.Select;
- subNode.ImageUrl = "images/IB_Man.gif";
- subNode.NavigateUrl = PageName_EditUser + param;
- break;
- case OThinker.Organization.UnitType.OrganizationUnit:
- subNode.SelectAction = TreeNodeSelectAction.SelectExpand;
- subNode.PopulateOnDemand = true;
- subNode.ImageUrl = "images/IB_OU.ico";
- subNode.NavigateUrl = PageName_EditOrganizationUnit + param;
- break;
- case OThinker.Organization.UnitType.Group:
- subNode.SelectAction = TreeNodeSelectAction.SelectExpand;
- subNode.PopulateOnDemand = true;
- subNode.ImageUrl = "images/IB_SelectUser.gif";
- subNode.NavigateUrl = PageName_EditGroup + param;
- break;
- default:
- break;
- }
- this.SetNodeNavigateUrl(subNode, unit.UnitType);
- if (this.ExpandList.Contains(subNode.Value))
- {
- subNode.Expand();
- }
- }
- }
- }
- private void SetNodeNavigateUrl(TreeNode Node, OThinker.Organization.UnitType UnitType)
- {
- // 如果目标类型未指定,则该单元能被选择
- // 如果目标类型和当前类型一致,则该单元能被选择
- // 如果目标类型为组织单元,且该单元类型为Company,则该单元也能被选择
- //string url = null;
- //switch (UnitType)
- //{
- // case OThinker.Organization.UnitType.Company:
- // url = PageName_EditCompany;
- // break;
- // case OThinker.Organization.UnitType.OrganizationUnit:
- // url = PageName_EditOrganizationUnit;
- // break;
- // case OThinker.Organization.UnitType.Group:
- // url = PageName_EditGroup;
- // break;
- // case OThinker.Organization.UnitType.User:
- // url = PageName_EditUser;
- // break;
- // default:
- // throw new NotImplementedException();
- //}
- //url += "?" + Param_ID + "=" + Node.Value;
- //Node.NavigateUrl = url;
- }
- }
- }