Beispiel #1
0
        /// <summary>
        /// 加载菜单数据
        /// </summary>
        private void LoadData()
        {
            //ServiceClient.GetSysRoleByTypeAsync(this.txtSearchSystemType.Text.Trim());
            string filter    = "";                                                                                    //查询过滤条件
            int    pageCount = 0;
            ObservableCollection <object> paras = new System.Collections.ObjectModel.ObservableCollection <object>(); //参数值
            ComboBox         cbxSystemType      = Utility.FindChildControl <ComboBox>(expander, "cbxSystemType");
            TextBox          RoleName           = Utility.FindChildControl <TextBox>(expander, "TxtRoleName");
            T_SYS_DICTIONARY dict        = cbxSystemType.SelectedItem as T_SYS_DICTIONARY;
            string           StrRoleName = "";

            StrRoleName = RoleName.Text;


            if (!string.IsNullOrEmpty(StrRoleName))
            {
                if (!string.IsNullOrEmpty(filter))
                {
                    filter += " and ";
                }

                //filter += " @" + paras.Count().ToString() + ".Contains(ROLENAME)";//类型名称
                //filter += "ROLENAME  ^@" + paras.Count().ToString();//类型名称
                filter += " @" + paras.Count().ToString() + ".Contains(ROLENAME)";
                paras.Add(StrRoleName);
            }
            //if (!string.IsNullOrEmpty(txtEmpCode.Text.Trim()))
            //{
            //    //filter += "EMPLOYEECODE==@" + paras.Count().ToString();
            //    filter += " @" + paras.Count().ToString() + ".Contains(EMPLOYEECODE)";
            //    paras.Add(txtEmpCode.Text.Trim());
            //}


            string systype = "";

            if (dict != null)
            {
                systype = dict.DICTIONARYVALUE == null ? "" : dict.DICTIONARYVALUE.GetValueOrDefault().ToString();
            }
            if (!string.IsNullOrEmpty(systype))
            {
                if (!string.IsNullOrEmpty(filter))
                {
                    filter += " and ";
                }
                filter += "SYSTEMTYPE ==@" + paras.Count().ToString();//类型名称
                paras.Add(systype);
            }
            string       sValue       = "";
            TreeViewItem selectedItem = treeOrganization.SelectedItem as TreeViewItem;

            if (selectedItem != null)
            {
                string IsTag = selectedItem.Tag.ToString();
                switch (IsTag)
                {
                case "Company":
                    SMT.Saas.Tools.OrganizationWS.T_HR_COMPANY company = selectedItem.DataContext as SMT.Saas.Tools.OrganizationWS.T_HR_COMPANY;
                    //sType = "Company";
                    sValue = company.COMPANYID;
                    if (!string.IsNullOrEmpty(filter))
                    {
                        filter += " and ";
                    }
                    filter += "OWNERCOMPANYID ==@" + paras.Count().ToString();    //类型名称
                    paras.Add(sValue);
                    break;

                case "Department":
                    SMT.Saas.Tools.OrganizationWS.T_HR_DEPARTMENT department = selectedItem.DataContext as SMT.Saas.Tools.OrganizationWS.T_HR_DEPARTMENT;
                    //sType = "Department";
                    sValue = department.DEPARTMENTID;
                    if (!string.IsNullOrEmpty(filter))
                    {
                        filter += " and ";
                    }
                    filter += "OWNERDEPARTMENTID ==@" + paras.Count().ToString();    //类型名称
                    paras.Add(sValue);
                    break;
                }
            }
            if (string.IsNullOrEmpty(filter))
            {
                //默认为自己公司的角色
                filter += "OWNERCOMPANYID ==@" + paras.Count().ToString();//类型名称
                paras.Add(Common.CurrentLoginUserInfo.UserPosts[0].CompanyID);
            }

            loadbar.Start();
            SMT.Saas.Tools.PermissionWS.LoginUserInfo loginUserInfo = new SMT.Saas.Tools.PermissionWS.LoginUserInfo();
            loginUserInfo.companyID = Common.CurrentLoginUserInfo.UserPosts[0].CompanyID;
            loginUserInfo.userID    = Common.CurrentLoginUserInfo.EmployeeID;
            //只能查看自己所在公司的角色
            //CompanyIDList.Clear();
            //CompanyIDList.Add(Common.CurrentLoginUserInfo.UserPosts);
            //if (Common.CurrentLoginUserInfo.UserPosts.Count() > 0)
            //{
            //    foreach (var str in Common.CurrentLoginUserInfo.UserPosts)
            //    {
            //        CompanyIDList.Add(str.CompanyID);
            //    }
            //}
            var    userPost          = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts;
            string ownerDepartmentid = string.Empty;

            foreach (var post in userPost)
            {
                ownerDepartmentid = ownerDepartmentid + post.DepartmentID + ",";
            }
            DepartMentIDList.Add(ownerDepartmentid);
            //ServiceClient.GetSysRoleInfosPagingByCompanyIDsAsync(dataPager.PageIndex, dataPager.PageSize, "CREATEDATE",
            //    filter, paras, pageCount, loginUserInfo,DepartMentIDList);
            ServiceClient.GetRoleViewAsync(dataPager.PageIndex, dataPager.PageSize, "CREATEDATE",
                                           filter, paras, pageCount, loginUserInfo, DepartMentIDList);
            DepartMentIDList.Clear();
        }