Ejemplo n.º 1
0
        private IList getChildOUInfos(string node, string type, string ouType)
        {
            if (logger.IsDebugEnabled)
            {
                logger.Debug("getChildOUInfos:node=" + node);
                logger.Debug("getChildOUInfos:type=" + type);
                logger.Debug("getChildOUInfos:ouType=" + ouType);
            }
            IList ouInfoLists;

            if (type.Equals("all"))
            {
                ouInfoLists = this.ouInfoService.FindChilds(node, ouType);// ou下的所有子ou
            }
            else
            {
                OUInfo ouInfo = this.ouInfoService.Load(node);
                if (logger.IsDebugEnabled)
                {
                    logger.Debug("getChildOUInfos:ouInfo.Unid=" + node);
                    logger.Debug("getChildOUInfos:ouInfo.Name=" + ouInfo.Name);
                    logger.Debug("getChildOUInfos:ouInfo.Type=" + ouInfo.Type);
                }
                if (ouInfo.Type.Equals(OUInfo.OT_UNIT))
                {
                    ouInfoLists = this.ouInfoService.FindDepartmentByUnit(node, true);// 单位下的所有部门
                }
                else
                {
                    ouInfoLists = this.ouInfoService.FindChilds(node, OUInfo.OT_DEPARTMENT);// 部门下的所有子部门
                }
            }
            return(ouInfoLists);
        }
Ejemplo n.º 2
0
        public string[] FindDataScope(User userInfo, string privilege)
        {
            if (String.IsNullOrEmpty(privilege) || privilege.Equals(Constants.DP_LOCAL, StringComparison.OrdinalIgnoreCase))
            {
                return new string[] { userInfo.UnitUnid }
            }
            ;
            if (privilege.Equals(Constants.DP_ALL, StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            IList ous = this.ouInfoService.FindUnitByParentUnid(userInfo.UnitUnid, true);

            if (null == ous || ous.Count == 0)
            {
                return new string[] { userInfo.UnitUnid }
            }
            ;
            else
            {
                string[] ouUnids = new string[ous.Count];

                for (int i = 0; i < ous.Count; i++)
                {
                    OUInfo ouInfo = (OUInfo)ous[i];
                    ouUnids[i] = ouInfo.Unid;
                }
                return(ouUnids);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据公司ID获取对应部门, 给Select2控件显示的下拉列表(值为Name|ID)
        /// </summary>
        /// <param name="parentId"></param>
        /// <returns></returns>
        public ActionResult GetDeptDictJson2(string parentId)
        {
            List <CListItem> itemList = new List <CListItem>();

            if (!string.IsNullOrEmpty(parentId) && parentId != "null")
            {
                OUInfo groupInfo = BLLFactory <OU> .Instance.FindByID(parentId);

                if (groupInfo != null)
                {
                    var groupValue = string.Format("{0}|{1}", groupInfo.Name, groupInfo.ID);
                    itemList.Add(new CListItem(groupInfo.Name, groupValue));

                    List <OUInfo> list = BLLFactory <OU> .Instance.GetAllOUsByParent(groupInfo.ID);

                    list = CollectionHelper <OUInfo> .Fill(groupInfo.ID, 0, list, "PID", "ID", "Name");

                    foreach (OUInfo info in list)
                    {
                        var value = string.Format("{0}|{1}", info.Name, info.ID);//值为Name|ID
                        itemList.Add(new CListItem(info.Name, value));
                    }
                }
            }

            return(ToJsonContent(itemList));
        }
Ejemplo n.º 4
0
 public ADOUAddDlg()
 {
     InitializeComponent();
     ouInfo        = new OUInfo();
     btnOK.Enabled = false;
     this.Text     = "New Object - Organizational Unit";
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取用户的公司结构(分级需要)给Select2控件显示的下拉列表
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        public ActionResult GetMyCompanyDictJson(int userId)
        {
            List <CListItem> itemList = new List <CListItem>();

            UserInfo userInfo = BLLFactory <User> .Instance.FindByID(userId);

            if (userInfo != null)
            {
                List <OUNodeInfo> list = new List <OUNodeInfo>();
                if (BLLFactory <User> .Instance.UserInRole(userInfo.Name, RoleInfo.SuperAdminName))
                {
                    list = BLLFactory <OU> .Instance.GetGroupCompanyTree();
                }
                else
                {
                    OUInfo myCompanyInfo = BLLFactory <OU> .Instance.FindByID(userInfo.Company_ID);

                    if (myCompanyInfo != null)
                    {
                        list.Add(new OUNodeInfo(myCompanyInfo));
                    }
                }

                foreach (OUNodeInfo info in list)
                {
                    itemList.Add(new CListItem(info.ID.ToString(), info.Name));
                    foreach (OUNodeInfo subInfo in info.Children)
                    {
                        itemList.Add(new CListItem(subInfo.ID.ToString(), "    " + subInfo.Name));
                    }
                }
            }

            return(ToJsonContent(itemList));
        }
Ejemplo n.º 6
0
        private OUInfo SetOUInfo(OUInfo info)
        {
            info.Name       = this.txtName.Text;
            info.Note       = this.txtNote.Text;
            info.Address    = this.txtAddress.Text;
            info.InnerPhone = this.txtInnerPhone.Text;
            info.OuterPhone = this.txtOuterPhone.Text;
            info.HandNo     = this.txtHandNo.Text;
            info.Seq        = this.txtSeq.Text;
            info.Category   = this.txtCategory.Text;
            info.Editor     = Portal.gc.UserInfo.FullName;
            info.Editor_ID  = Portal.gc.UserInfo.ID.ToString();
            info.EditTime   = DateTimeHelper.GetServerDateTime2();
            info.PID        = this.cmbUpperOU.Value.ToString().ToInt32();

            OUInfo pInfo = BLLFactory <OU> .Instance.FindByID(info.PID);

            if (pInfo != null)
            {
                //pInfo.Category == "集团" ||
                if (pInfo.Category == "公司")
                {
                    info.Company_ID  = pInfo.ID.ToString();
                    info.CompanyName = pInfo.Name;
                }
                else if (pInfo.Category == "部门" || pInfo.Category == "工作组")
                {
                    info.Company_ID  = pInfo.Company_ID;
                    info.CompanyName = pInfo.CompanyName;
                }
            }
            info.CurrentLoginUserId = Portal.gc.UserInfo.ID;
            return(info);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 编辑或者保存状态下取值函数
        /// </summary>
        /// <param name="info"></param>
        private void SetInfo(CouponInfo info)
        {
            info.ID = txtID.Text.Trim();
            if (string.IsNullOrEmpty(ID))
            {
                info.Creator    = Portal.gc.UserInfo.LoginName;
                info.Creator_ID = Portal.gc.UserInfo.ID.ToString();
                info.CreateTime = DateTime.Now;
            }
            info.CouponCategory_ID = (txtCategory.SelectedItem as CListItem).Value;
            CouponCategoryInfo couponCategoryInfo = BLLFactory <CouponCategory> .Instance.FindByID(info.CouponCategory_ID);

            if (couponCategoryInfo != null)
            {
                info.CouponCategory_Name = couponCategoryInfo.Name;
                info.Company_ID          = couponCategoryInfo.BelongCompanys;
                OUInfo ouInfo = BLLFactory <OU> .Instance.FindByID(info.Company_ID);

                info.Company_Name = ouInfo.Name;
            }

            info.MobilePhone = txtMobilePhone.Text;
            info.LoginName   = txtLoginName.Text;
            info.StartTime   = txtStartTime.DateTime;
            info.EndTime     = txtEndTime.DateTime;
            info.DELETED     = txtEnabled.SelectedIndex;
        }
Ejemplo n.º 8
0
        public IList FindByOU(string ouUnid, bool includeUnit, string groupType)
        {
            OUInfo ouInfo = this.ouInfoService.Load(ouUnid);

            if (null == ouInfo)
            {
                return(new ArrayList());
            }

            string[] ouUnids;
            if (ouInfo.Type.Equals(OUInfo.OT_DEPARTMENT, StringComparison.OrdinalIgnoreCase))
            {
                if (includeUnit)
                {
                    if (ouInfo.ParentOUUnid != ouInfo.UnitUnid)
                    {
                        ouUnids = new string[] { ouUnid, ouInfo.ParentOUUnid, ouInfo.UnitUnid };
                    }
                    else
                    {
                        ouUnids = new string[] { ouUnid, ouInfo.UnitUnid };
                    }
                }
                else
                {
                    ouUnids = new string[] { ouUnid };
                }
            }
            else
            {
                ouUnids = new string[] { ouUnid };
            }
            return(this.groupDao.FindByOU(ouUnids, groupType));
        }
Ejemplo n.º 9
0
        private void menu_Add_Click(object sender, EventArgs e)
        {
            if (!HasFunction("Role/add"))
            {
                MessageDxUtil.ShowError(Const.NoAuthMsg);
                return;
            }

            //跳转到第一个页面
            this.xtraTabControl1.SelectedTabPageIndex = 0;

            ClearInput();
            currentID          = "";
            groupControl2.Text = Const.Add + "角色详细信息";

            // 20171127 wjm 修复添加后立刻添加成员错误
            btnEditOU.Enabled     = false;
            btnRemoveOU.Enabled   = false;
            btnEditUser.Enabled   = false;
            btnRemoveUser.Enabled = false;

            TreeNode node = this.treeView1.SelectedNode;

            if (node != null && node.Tag != null)
            {
                OUInfo ouInfo = node.Tag as OUInfo;//转换为机构对象
                if (ouInfo != null)
                {
                    this.txtCompany.Value = ouInfo.ID.ToString();
                }
            }
            this.txtName.Focus();
        }
Ejemplo n.º 10
0
 public ADOUAddDlg()
 {
     InitializeComponent();
     ouInfo = new OUInfo();
     btnOK.Enabled = false;
     this.Text = "New Object - Organizational Unit";
 }
Ejemplo n.º 11
0
        public int AddOU(string identity, OUInfo ouInfo)
        {
            this.VerifyUser(identity);
            OU ou = new OU();

            return(ou.Insert2(ouInfo));
        }
Ejemplo n.º 12
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node != null)
            {
                Int32  Id   = Convert.ToInt32(e.Node.Name);
                OUInfo info = BLLFactory <OU> .Instance.FindById(Id);

                if (info != null)
                {
                    groupControl2.Text = Const.Edit + "组织机构详细信息";
                    currentID          = Id;

                    this.txtName.Text       = info.Name;
                    this.txtRemark.Text     = info.Remark;
                    this.txtAddress.Text    = info.Address;
                    this.txtSeq.Text        = info.Seq;
                    this.txtOuCode.Text     = info.OuCode;
                    this.txtOuterPhone.Text = info.OutPhone;
                    this.txtInnerPhone.Text = info.InnerPhone;
                    this.txtCategory.Text   = info.OuType.ToString();
                    this.txtCreator.Text    = info.CreatorId.ToString();
                    this.txtCreateTime.Text = info.CreatorTime.ToString();

                    //由于选择的节点不同,因此根据用户选择的最顶级机构ID进行初始化,才能列出指定机构下的层次关系
                    TreeNode topTreeNode = GetNodeTopParent(e.Node);
                    if (topTreeNode != null && topTreeNode.Tag != null)
                    {
                        string topOuId = topTreeNode.Tag.ToString();
                        this.cmbUpperOU.ParentOuId = topOuId.ToInt32();
                        this.cmbUpperOU.Init();
                    }
                    OUInfo info2 = BLLFactory <OU> .Instance.FindById(info.Pid);

                    if (info2 != null)
                    {
                        this.cmbUpperOU.Value = info.Pid.ToString();
                    }
                    else
                    {
                        this.cmbUpperOU.Value = "-1";
                    }

                    //如果是公司管理员,不能编辑公司的信息

                    /*if (Portal.gc.UserInfo.CompanyId == currentID &&
                     *  Portal.gc.UserInRole(RoleInfo.CompanyAdminName))
                     * {
                     *  this.btnSave.Enabled = false;
                     * }
                     * else
                     * {
                     *  this.btnSave.Enabled = true;
                     * }*/

                    int intID = Convert.ToInt32(Id);
                    RefreshUsers(intID);
                    RefreshRoles(intID);
                }
            }
        }
Ejemplo n.º 13
0
        private OUInfo SetOUInfo(OUInfo info)
        {
            info.Name           = this.txtName.Text;
            info.Remark         = this.txtRemark.Text;
            info.Address        = this.txtAddress.Text;
            info.InnerPhone     = this.txtInnerPhone.Text;
            info.OutPhone       = this.txtOuterPhone.Text;
            info.OuCode         = this.txtOuCode.Text;
            info.Seq            = this.txtSeq.Text;
            info.OuType         = Convert.ToInt16(this.txtCategory.Text);
            info.EditorId       = Portal.gc.UserInfo.Id;
            info.LastUpdateTime = DateTimeHelper.GetServerDateTime2();
            info.Pid            = this.cmbUpperOU.Value.ToString().ToInt32();

            OUInfo pInfo = BLLFactory <OU> .Instance.FindById(info.Pid);

            if (pInfo != null)
            {
                //pInfo.Category == "集团" ||
                if (pInfo.OuType == 0)
                {
                    info.CompanyId = pInfo.Id;
                }
                else if (pInfo.OuType == 1 || pInfo.OuType == 2)
                {
                    info.CompanyId = pInfo.CompanyId;
                }
            }
            info.CurrentLoginUserId = Portal.gc.UserInfo.Id;
            return(info);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 获取用户的公司结构(分级需要)(bootstrap的JSTree)
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        public ActionResult GetMyCompanyJsTreeJson(int userId)
        {
            List <JsTreeData> treeList = new List <JsTreeData>();

            UserInfo userInfo = BLLFactory <User> .Instance.FindByID(userId);

            if (userInfo != null)
            {
                List <OUNodeInfo> list = new List <OUNodeInfo>();
                if (BLLFactory <User> .Instance.UserInRole(userInfo.Name, RoleInfo.SuperAdminName))
                {
                    list = BLLFactory <OU> .Instance.GetGroupCompanyTree();
                }
                else
                {
                    OUInfo myCompanyInfo = BLLFactory <OU> .Instance.FindByID(userInfo.Company_ID);

                    if (myCompanyInfo != null)
                    {
                        list.Add(new OUNodeInfo(myCompanyInfo));
                    }
                }

                if (list.Count > 0)
                {
                    OUNodeInfo info = list[0];//无论是集团还是公司,节点只有一个
                    JsTreeData node = new JsTreeData(info.ID, info.Name, GetBootstrapIcon(info.Category));
                    GetJsTreeDataWithOUNode(info.Children, node);
                    treeList.Add(node);
                }
            }

            return(ToJsonContent(treeList));
        }
Ejemplo n.º 15
0
        private void AddRole(OUInfo ouInfo, EasyTreeData treeNode)
        {
            List <RoleInfo> roleList = BLLFactory <Role> .Instance.GetRolesByCompany(ouInfo.ID.ToString());

            foreach (RoleInfo roleInfo in roleList)
            {
                EasyTreeData roleNode = new EasyTreeData("role" + roleInfo.ID, roleInfo.Name, "icon-group-key");
                treeNode.children.Add(roleNode);
            }
        }
Ejemplo n.º 16
0
        private void AddJsRole(OUInfo ouInfo, JsTreeData treeNode)
        {
            List <RoleInfo> roleList = BLLFactory <Role> .Instance.GetRolesByCompany(ouInfo.ID.ToString());

            foreach (RoleInfo roleInfo in roleList)
            {
                JsTreeData roleNode = new JsTreeData("role" + roleInfo.ID, roleInfo.Name, "fa fa-user icon-state-info icon-lg");
                treeNode.children.Add(roleNode);
            }
        }
Ejemplo n.º 17
0
        public OUInfo GetOU(string identity, int ouID)
        {
            OUInfo info = null;

            if (this.IdentityIsValid(identity))
            {
                OU ou = new OU();
                info = (OUInfo)ou.FindByID(ouID.ToString());
            }
            return(info);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 新增和编辑同时需要修改的内容
        /// </summary>
        /// <param name="info"></param>
        private void SetCommonInfo(RoleInfo info)
        {
            info.Editor    = CurrentUser.FullName;
            info.Editor_ID = CurrentUser.ID.ToString();
            info.EditTime  = DateTime.Now;

            OUInfo companyInfo = BLLFactory <OU> .Instance.FindByID(info.Company_ID);

            if (companyInfo != null)
            {
                info.CompanyName = companyInfo.Name;
            }
        }
Ejemplo n.º 19
0
        public override void Save(Group group)
        {
            if (!this.groupDao.IsUnique(group))
            {
                throw new ResourceException("GROUP.EXCEPTION.HAD_EXIST", new string[] { group.Name, group.Code });
            }

            // 保存与角色之间的关联关系
            IList  roleUnids     = group.RoleUnidLists;
            IList  relationShips = new ArrayList();
            string relation      = Group.RELATIONSHIP_CODE + "." + Role.RELATIONSHIP_CODE;

            if (null != roleUnids && roleUnids.Count > 0)
            {
                foreach (string role in roleUnids)
                {
                    RelationShip relationShip = new RelationShip(group.Unid, Group.RELATIONSHIP_CODE, role, Role.RELATIONSHIP_CODE,
                                                                 relation);
                    relationShips.Add(relationShip);
                }
            }
            this.relationShipService.UpdateRelationByParent(group.Unid, relation, relationShips);

            // 保存与人员之间的关联关系
            IList UserInfoUnids = group.UserInfoUnidLists;

            relationShips = new ArrayList();
            relation      = Group.RELATIONSHIP_CODE + "." + User.RELATIONSHIP_CODE;
            if (null != UserInfoUnids && UserInfoUnids.Count > 0)
            {
                foreach (string userUnid in UserInfoUnids)
                {
                    RelationShip relationShip = new RelationShip(group.Unid, Group.RELATIONSHIP_CODE, userUnid, User.RELATIONSHIP_CODE,
                                                                 relation);
                    relationShips.Add(relationShip);
                }
            }
            this.relationShipService.UpdateRelationByParent(group.Unid, relation, relationShips);

            // 同步上级单位的信息
            OUInfo ouInfo = this.ouInfoService.Load(group.OUUnid);

            if (null != ouInfo)
            {
                group.OUName     = ouInfo.Name;
                group.OUCode     = ouInfo.Code;
                group.OUFullName = ouInfo.FullName;
                group.OUFullCode = ouInfo.FullCode;
            }
            this.groupDao.Save(group);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 初始化部门信息
        /// </summary>
        public void Init()
        {
            //InitUpperOU
            DataTable dt = DataTableHelper.CreateTable("ImageIndex|int,ID,PID,Name,HandNo,Category,Address,Note");
            DataRow   dr = null;

            if (!string.IsNullOrEmpty(ParentOuID))
            {
                List <OUInfo> list = BLLFactory <OU> .Instance.GetAllOUsByParent(ParentOuID.ToInt32());

                OUInfo parentInfo = BLLFactory <OU> .Instance.FindByID(ParentOuID);

                if (parentInfo != null)
                {
                    list.Insert(0, parentInfo);
                }

                foreach (OUInfo info in list)
                {
                    dr = dt.NewRow();
                    dr["ImageIndex"] = Portal.gc.GetImageIndex(info.Category);
                    dr["ID"]         = info.ID.ToString();
                    dr["PID"]        = info.PID.ToString();
                    dr["Name"]       = info.Name;
                    dr["HandNo"]     = info.HandNo;
                    dr["Category"]   = info.Category;
                    dr["Address"]    = info.Address;
                    dr["Note"]       = info.Note;

                    dt.Rows.Add(dr);
                }
            }
            //增加一行空的
            dr         = dt.NewRow();
            dr["ID"]   = "0"; //使用0代替-1,避免出现节点的嵌套显示,因为-1已经作为了一般节点的顶级标识
            dr["PID"]  = "-1";
            dr["Name"] = "无";
            dt.Rows.InsertAt(dr, 0);

            //设置图形序号
            this.treeListLookUpEdit1TreeList.SelectImageList = this.imageList2;
            this.treeListLookUpEdit1TreeList.StateImageList  = this.imageList2;

            this.txtDept.Properties.TreeList.KeyFieldName    = "ID";
            this.txtDept.Properties.TreeList.ParentFieldName = "PID";
            this.txtDept.Properties.DataSource    = dt;
            this.txtDept.Properties.ValueMember   = "ID";
            this.txtDept.Properties.DisplayMember = "Name";
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 初始化数据
        /// </summary>
        public void Init()
        {
            DataTable     dt   = DataTableHelper.CreateTable("ImageIndex|int,ID,PID,Name");
            List <OUInfo> list = new List <OUInfo>();

            if (Portal.gc.UserInRole(RoleInfo.SuperAdminName))
            {
                list = BLLFactory <OU> .Instance.GetGroupCompany();
            }
            else
            {
                try
                {
                    OUInfo myCompanyInfo = BLLFactory <OU> .Instance.FindByID(Portal.gc.UserInfo.Company_ID);

                    if (myCompanyInfo != null)
                    {
                        list.Add(myCompanyInfo);
                    }
                }
                catch (Exception ex)
                {
                    MessageDxUtil.ShowWarning(ex.Message);
                }
            }

            DataRow dr = null;

            foreach (OUInfo info in list)
            {
                dr = dt.NewRow();
                dr["ImageIndex"] = Portal.gc.GetImageIndex(info.Category);
                dr["ID"]         = info.ID.ToString();
                dr["PID"]        = info.PID.ToString();
                dr["Name"]       = info.Name;
                dt.Rows.Add(dr);
            }

            //设置图形序号

            this.treeListLookUpEdit1TreeList.SelectImageList = this.imageList2;
            this.treeListLookUpEdit1TreeList.StateImageList  = this.imageList2;

            this.txtCompany.Properties.TreeList.KeyFieldName    = "ID";
            this.txtCompany.Properties.TreeList.ParentFieldName = "PID";
            this.txtCompany.Properties.DataSource    = dt;
            this.txtCompany.Properties.ValueMember   = "ID";
            this.txtCompany.Properties.DisplayMember = "Name";
        }
Ejemplo n.º 22
0
        private void AddRole(OUInfo ouInfo, TreeNode treeNode)
        {
            List <RoleInfo> roleList = BLLFactory <Role> .Instance.GetRolesByCompanyId(ouInfo.Id);

            foreach (RoleInfo roleInfo in roleList)
            {
                TreeNode roleNode = new TreeNode();
                roleNode.Text               = roleInfo.Name;
                roleNode.Tag                = roleInfo.Id;
                roleNode.ImageIndex         = 5;
                roleNode.SelectedImageIndex = 5;

                treeNode.Nodes.Add(roleNode);
            }
        }
Ejemplo n.º 23
0
        public void RemoveOU(int ouID, int roleID)
        {
            this.getRoleID();
            if (roleID != intRoleID)
            {
                goto Label_00E1;
            }
            User user = new User();
            List <SimpleUserInfo> simpleUsersByRole = user.GetSimpleUsersByRole(intRoleID);

            if (simpleUsersByRole.Count >= 1)
            {
                goto Label_00E1;
            }
            simpleUsersByRole.Clear();
            List <UserInfo> usersByOU = user.GetUsersByOU(ouID);

            if (usersByOU.Count <= 0)
            {
                goto Label_00E1;
            }
            usersByOU.Clear();
            bool          flag      = false;
            List <OUInfo> oUsByRole = new OU().GetOUsByRole(intRoleID);

            using (List <OUInfo> .Enumerator enumerator = oUsByRole.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    OUInfo current = enumerator.Current;
                    if ((current.ID != ouID) && (user.GetSimpleUsersByOU(current.ID).Count > 0))
                    {
                        goto Label_00B8;
                    }
                }
                goto Label_00CB;
Label_00B8:
                flag = true;
            }
Label_00CB:
            oUsByRole.Clear();
            if (!flag)
            {
                throw new MyException("管理员角色至少需要包含一个用户!");
            }
Label_00E1:
            this.irole_0.RemoveOU(ouID, roleID);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 初始化部门信息
        /// </summary>
        public void Init()
        {
            DataTable dt = DataTableHelper.CreateTable("ImageIndex|int,Id,Pid,Name,OuCode,OuType,Address,Remark");
            DataRow   dr = null;

            if (ParentOuId > -1)
            {
                List <OUInfo> list = BLLFactory <OU> .Instance.GetAllOUsByParent(ParentOuId);

                OUInfo parentInfo = BLLFactory <OU> .Instance.FindById(ParentOuId);

                if (parentInfo != null)
                {
                    list.Insert(0, parentInfo);
                }

                foreach (OUInfo info in list)
                {
                    dr = dt.NewRow();
                    dr["ImageIndex"] = info.OuType;
                    dr["Id"]         = info.Id;
                    dr["Pid"]        = info.Pid;
                    dr["Name"]       = info.Name;
                    dr["OuCode"]     = info.OuCode;
                    dr["OuType"]     = info.OuType;
                    dr["Address"]    = info.Address;
                    dr["Remark"]     = info.Remark;

                    dt.Rows.Add(dr);
                }
            }
            //增加一行空的
            dr         = dt.NewRow();
            dr["Id"]   = "0"; //使用0代替-1,避免出现节点的嵌套显示,因为-1已经作为了一般节点的顶级标识
            dr["Pid"]  = "-1";
            dr["Name"] = "无";
            dt.Rows.InsertAt(dr, 0);

            //设置图形序号
            this.treeListLookUpEdit1TreeList.SelectImageList = this.imageList2;
            this.treeListLookUpEdit1TreeList.StateImageList  = this.imageList2;

            this.txtDept.Properties.TreeList.KeyFieldName    = "Id";
            this.txtDept.Properties.TreeList.ParentFieldName = "Pid";
            this.txtDept.Properties.DataSource    = dt;
            this.txtDept.Properties.ValueMember   = "Id";
            this.txtDept.Properties.DisplayMember = "Name";
        }
Ejemplo n.º 25
0
        private TreeNode AddOUNode(OUInfo ouInfo, TreeNode parentNode = null)
        {
            TreeNode ouNode = new TreeNode();

            ouNode.Text               = ouInfo.Name;
            ouNode.Tag                = string.Format("Company_ID='{0}' ", ouInfo.ID);
            ouNode.ImageIndex         = Portal.gc.GetImageIndex(ouInfo.Category);
            ouNode.SelectedImageIndex = Portal.gc.GetImageIndex(ouInfo.Category);

            if (parentNode != null)
            {
                parentNode.Nodes.Add(ouNode);
            }

            return(ouNode);
        }
Ejemplo n.º 26
0
        private TreeNode AddOUNode(OUInfo ouInfo, TreeNode parentNode = null)
        {
            TreeNode ouNode = new TreeNode();

            ouNode.Text               = ouInfo.Name;
            ouNode.Tag                = string.Format("CompanyId='{0}' ", ouInfo.Id);
            ouNode.ImageIndex         = ouInfo.OuType;
            ouNode.SelectedImageIndex = ouInfo.OuType;

            if (parentNode != null)
            {
                parentNode.Nodes.Add(ouNode);
            }

            return(ouNode);
        }
Ejemplo n.º 27
0
        private static JavaScriptArray createOUInfosJsonArray(IList ouInfoLists, bool isLink, bool singleClickExpand)
        {
            JavaScriptArray jsonArray = new JavaScriptArray();

            if (ouInfoLists != null)
            {
                JavaScriptObject json;
                for (int i = 0; i < ouInfoLists.Count; i++)
                {
                    OUInfo ouInfo = (OUInfo)ouInfoLists[i];
                    json = new JavaScriptObject();
                    json.Add("text", ouInfo.Name);
                    json.Add("id", ouInfo.Unid);
                    json.Add("dbID", ouInfo.ID);

                    json.Add("cls", "folder");
                    if (OUInfo.OT_UNIT.Equals(ouInfo.Type, StringComparison.OrdinalIgnoreCase))
                    {
                        json.Add("iconCls", "egd-treeNode-unit");
                    }
                    else if (OUInfo.OT_DEPARTMENT.Equals(ouInfo.Type, StringComparison.OrdinalIgnoreCase))
                    {
                        json.Add("iconCls", "egd-treeNode-department");
                    }

                    json.Add("FullName", ouInfo.FullName);
                    json.Add("Code", ouInfo.Code);
                    json.Add("FullCode", ouInfo.FullCode);
                    //json.Add("isLeaf", ouInfo.);
                    json.Add("Type", ouInfo.Type);

                    json.Add("UnitUnid", ouInfo.UnitUnid);
                    json.Add("UnitName", ouInfo.UnitName);
                    json.Add("UnitFullName", ouInfo.UnitFullName);
                    json.Add("UnitFullCode", ouInfo.UnitFullCode);

                    json.Add("singleClickExpand", singleClickExpand);
                    if (isLink)
                    {
                        json.Add("href", "javascript:onTreeNode_Click('" + ouInfo.Unid + "')");// 不推荐使用
                    }
                    jsonArray.Add(json);
                }
            }
            return(jsonArray);
        }
Ejemplo n.º 28
0
        public override void Save(User user)
        {
            // 判断是否唯一
            if (!this.userDao.IsUnique(user))
            {
                throw new ResourceException("USERINFO.EXCEPTION.HAD_EXIST", new string[] { user.Name, user.LoginID });
            }

            // 保存与岗位之间的关联关系
            IList  groupUnids    = user.GroupUnidLists;
            IList  relationShips = new ArrayList();
            string relation      = Group.RELATIONSHIP_CODE + "." + User.RELATIONSHIP_CODE;

            if (null != groupUnids && groupUnids.Count > 0)
            {
                foreach (string group in groupUnids)
                {
                    RelationShip relationShip = new RelationShip(group, Group.RELATIONSHIP_CODE, user.Unid, User.RELATIONSHIP_CODE,
                                                                 relation);
                    relationShips.Add(relationShip);
                }
            }
            this.relationShipService.UpdateRelationByChild(user.Unid, relation, relationShips);

            // 同步OU的信息
            OUInfo ouInfo = this.ouInfoService.Load(user.OUUnid);

            if (null != ouInfo)
            {
                user.OUName     = ouInfo.Name;
                user.OUCode     = ouInfo.Code;
                user.OUFullName = ouInfo.FullName;
                if (ouInfo.Type.Equals(OUInfo.OT_DEPARTMENT, StringComparison.OrdinalIgnoreCase))
                {
                    user.UnitUnid = ouInfo.UnitUnid;
                    user.UnitName = ouInfo.UnitName;
                }
                else
                {
                    user.UnitUnid = ouInfo.Unid;
                    user.UnitName = ouInfo.Name;
                }
            }
            this.userDao.Save(user);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 根据当前用户身份,获取对应的顶级机构管理节点。
        /// 如果是超级管理员,返回集团节点;如果是公司管理员,返回其公司节点
        /// </summary>
        /// <returns></returns>
        public List <OUInfo> GetMyTopGroup()
        {
            List <OUInfo> list      = new List <OUInfo>();
            OUInfo        groupInfo = null;

            if (UserInRole(RoleInfo.SuperAdminName))
            {
                //超级管理员取集团节点
                list.AddRange(BLLFactory <OU> .Instance.GetTopGroup());
            }
            else
            {
                groupInfo = BLLFactory <OU> .Instance.FindByID(UserInfo.Company_ID);//公司管理员取公司节点

                list.Add(groupInfo);
            }
            return(list);
        }
Ejemplo n.º 30
0
        public IList FindByOU(string ouUnid)
        {
            OUInfo ouInfo = this.ouInfoService.Load(ouUnid);

            if (null == ouInfo)
            {
                return(new ArrayList());
            }
            if (ouInfo.Type.Equals(OUInfo.OT_DEPARTMENT, StringComparison.OrdinalIgnoreCase))
            {
                ouInfo = this.ouInfoService.Load(ouInfo.UnitUnid);
                if (null == ouInfo)
                {
                    return(new ArrayList());
                }
            }
            return(FindByLevel(ouInfo.Level, false));
        }
Ejemplo n.º 31
0
        public IList FindByOU(string ouUnid, bool includeUnit, string groupType, bool includeChildOUGroup)
        {
            OUInfo ouInfo = this.ouInfoService.Load(ouUnid);

            if (null == ouInfo)
            {
                return(new ArrayList());
            }
            IList childOUs = this.ouInfoService.FindChilds(ouUnid, OUInfo.OT_DEPARTMENT, includeChildOUGroup);

            IList ouUnids = new ArrayList();

            if (ouInfo.Type.Equals(OUInfo.OT_DEPARTMENT, StringComparison.OrdinalIgnoreCase))
            {
                if (includeUnit)
                {
                    if (ouInfo.ParentOUUnid != ouInfo.UnitUnid)
                    {
                        ouUnids.Add(ouUnid);
                        ouUnids.Add(ouInfo.ParentOUUnid);
                        ouUnids.Add(ouInfo.UnitUnid);
                    }
                    else
                    {
                        ouUnids.Add(ouUnid);
                        ouUnids.Add(ouInfo.UnitUnid);
                    }
                }
                else
                {
                    ouUnids.Add(ouUnid);
                }
            }
            else
            {
                ouUnids.Add(ouUnid);
            }
            foreach (OUInfo ou in childOUs)
            {
                ouUnids.Add(ou.Unid);
            }
            return(this.groupDao.FindByOU(ListUtils.ListToStringArray(ouUnids), groupType));
        }