Exemple #1
0
        //public static void InitHR()
        //{
        //    try
        //    {
        //        IList<CompanyData> listCData = new List<CompanyData>();
        //        IList<DepartmentData> ListDData = new List<DepartmentData>();
        //        IList<PostData> ListPData = new List<PostData>();

        //        List<OrganizationWS.T_HR_COMPANY> comList = (List<OrganizationWS.T_HR_COMPANY>)App.Current.Resources["SYS_CompanyInfo"];
        //        List<OrganizationWS.T_HR_DEPARTMENT> deptList = (List<OrganizationWS.T_HR_DEPARTMENT>)App.Current.Resources["SYS_DepartmentInfo"];
        //        List<OrganizationWS.T_HR_POST> postList = (List<OrganizationWS.T_HR_POST>)App.Current.Resources["SYS_PostInfo"];


        //        comList.ForEach(comHR =>
        //        {
        //            ObservableCollection<VirtualDepartment> listDepartment = new ObservableCollection<VirtualDepartment>();

        //            VirtualCompany vc = new VirtualCompany();
        //            vc.ID = comHR.COMPANYID;
        //            vc.Name = comHR.CNAME;
        //            vc.DepartmentCollection = listDepartment;


        //            CompanyData cData = CreateItem<CompanyData>(vc);
        //            List<DepartmentData> listDepartmentData = new List<DepartmentData>();

        //            List<OrganizationWS.T_HR_DEPARTMENT> deptListPart = deptList.FindAll(item =>
        //            {
        //                if (item.T_HR_COMPANY == null)
        //                {
        //                    return false;
        //                }
        //                return item.T_HR_COMPANY.COMPANYID == comHR.COMPANYID;

        //            });

        //            deptListPart.ForEach(deptHR =>
        //            {
        //                ObservableCollection<VirtualPost> listPost = new ObservableCollection<VirtualPost>();

        //                VirtualDepartment vd = new VirtualDepartment();
        //                vd.ID = deptHR.DEPARTMENTID;
        //                vd.Name = deptHR.T_HR_DEPARTMENTDICTIONARY.DEPARTMENTNAME;
        //                vd.VirtualCompany = vc;
        //                vd.PostCollection = listPost;
        //                listDepartment.Add(vd);


        //                DepartmentData dData = CreateItem<DepartmentData>(vd);
        //                List<PostData> listPostData = new List<PostData>();

        //                List<OrganizationWS.T_HR_POST> postListPart = postList.FindAll(item =>
        //                {
        //                    if (item.T_HR_DEPARTMENT == null)
        //                    {
        //                        return false;
        //                    }
        //                    return item.T_HR_DEPARTMENT.DEPARTMENTID == deptHR.DEPARTMENTID;
        //                });

        //                postListPart.ForEach(postHR =>
        //                {
        //                    VirtualPost vp = new VirtualPost();
        //                    vp.ID = postHR.POSTID;
        //                    vp.Name = postHR.T_HR_POSTDICTIONARY.POSTNAME;
        //                    vp.VirtualCompany = vc;
        //                    vp.VirtualDepartment = vd;
        //                    listPost.Add(vp);


        //                    PostData pData = CreateItem<PostData>(vp);
        //                    pData.Company = cData;
        //                    pData.Department = dData;
        //                    listPostData.Add(pData);
        //                    ListPData.Add(pData);

        //                });

        //                dData.Company = cData;
        //                dData.PostCollection = listPostData;
        //                listDepartmentData.Add(dData);
        //                ListDData.Add(dData);
        //            });

        //            cData.DepartmentCollection = listDepartmentData;
        //            listCData.Add(cData);
        //            CompanyList.Add(vc);
        //        });

        //        ReferencedData<CompanyData>.RefData = listCData;
        //        ReferencedData<DepartmentData>.RefData = ListDData;
        //        ReferencedData<PostData>.RefData = ListPData;
        //    }
        //    catch (Exception ex)
        //    {
        //        System.Diagnostics.Debug.WriteLine(ex);
        //        throw new Exception("调用HR服务异常", ex);
        //    }
        //}

        #endregion

        /// <summary>
        /// 新的,从平台组织架构缓存中加载。
        /// </summary>
        public static void InitHR()
        {
            try
            {
                IList <CompanyData>    listCData = new List <CompanyData>();
                IList <DepartmentData> ListDData = new List <DepartmentData>();
                IList <PostData>       ListPData = new List <PostData>();


                List <OrganizationWS.T_HR_COMPANY> comList
                    = App.Current.Resources["SYS_CompanyInfo"] as List <OrganizationWS.T_HR_COMPANY> ?? new List <OrganizationWS.T_HR_COMPANY>();
                List <OrganizationWS.T_HR_DEPARTMENT> deptList
                    = App.Current.Resources["SYS_DepartmentInfo"] as List <OrganizationWS.T_HR_DEPARTMENT> ?? new List <OrganizationWS.T_HR_DEPARTMENT>();
                List <OrganizationWS.T_HR_POST> postList
                    = App.Current.Resources["SYS_PostInfo"] as List <OrganizationWS.T_HR_POST> ?? new List <OrganizationWS.T_HR_POST>();


                comList.ForEach(comHR =>
                {
                    ObservableCollection <VirtualDepartment> listDepartment = new ObservableCollection <VirtualDepartment>();

                    VirtualCompany vc       = new VirtualCompany();
                    vc.ID                   = comHR.COMPANYID;
                    vc.Name                 = comHR.CNAME;
                    vc.DepartmentCollection = listDepartment;


                    CompanyData cData = CreateItem <CompanyData>(vc);
                    List <DepartmentData> listDepartmentData = new List <DepartmentData>();

                    List <OrganizationWS.T_HR_DEPARTMENT> deptListPart = deptList.FindAll(item =>
                    {
                        if (item.T_HR_COMPANY == null)
                        {
                            return(false);
                        }
                        return(item.T_HR_COMPANY.COMPANYID == comHR.COMPANYID);
                    });

                    deptListPart.ForEach(deptHR =>
                    {
                        ObservableCollection <VirtualPost> listPost = new ObservableCollection <VirtualPost>();

                        VirtualDepartment vd = new VirtualDepartment();
                        vd.ID             = deptHR.DEPARTMENTID;
                        vd.Name           = deptHR.T_HR_DEPARTMENTDICTIONARY.DEPARTMENTNAME;
                        vd.VirtualCompany = vc;
                        vd.PostCollection = listPost;
                        listDepartment.Add(vd);


                        DepartmentData dData         = CreateItem <DepartmentData>(vd);
                        List <PostData> listPostData = new List <PostData>();

                        List <OrganizationWS.T_HR_POST> postListPart = postList.FindAll(item =>
                        {
                            if (item.T_HR_DEPARTMENT == null)
                            {
                                return(false);
                            }
                            return(item.T_HR_DEPARTMENT.DEPARTMENTID == deptHR.DEPARTMENTID);
                        });

                        postListPart.ForEach(postHR =>
                        {
                            VirtualPost vp       = new VirtualPost();
                            vp.ID                = postHR.POSTID;
                            vp.Name              = postHR.T_HR_POSTDICTIONARY.POSTNAME;
                            vp.VirtualCompany    = vc;
                            vp.VirtualDepartment = vd;
                            listPost.Add(vp);


                            PostData pData   = CreateItem <PostData>(vp);
                            pData.Company    = cData;
                            pData.Department = dData;
                            listPostData.Add(pData);
                            ListPData.Add(pData);
                        });

                        dData.Company        = cData;
                        dData.PostCollection = listPostData;
                        listDepartmentData.Add(dData);
                        ListDData.Add(dData);
                    });

                    cData.DepartmentCollection = listDepartmentData;
                    listCData.Add(cData);
                    CompanyList.Add(vc);
                });

                ReferencedData <CompanyData> .RefData    = listCData;
                ReferencedData <DepartmentData> .RefData = ListDData;
                ReferencedData <PostData> .RefData       = ListPData;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
                throw new Exception("调用HR服务异常", ex);
            }
        }
Exemple #2
0
        public static void GetLoginUserInfo(ref string strMsg)
        {
            DataCore.CurrentUser = new LoginUserData();
            List <LoginUserData> listLogin = new List <LoginUserData>();

            string userID   = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeID;
            string userName = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.EmployeeName;

            try
            {
                listLogin = SMT.SAAS.Main.CurrentContext.Common.CurrentLoginUserInfo.UserPosts.CreateList(userPost =>
                {
                    LoginUserData eData = new LoginUserData();

                    eData.Value = userID;
                    eData.Text  = userName;

                    eData.Post = ReferencedData <PostData> .Find(userPost.PostID);

                    // 处理缓存不存在登录人的岗位
                    if (eData.Post == null)
                    {
                        PostData newPostData = new PostData();
                        //公司
                        CompanyData newComData = new CompanyData();
                        newComData.Text        = userPost.CompanyName;
                        newComData.Value       = userPost.CompanyID;

                        newPostData.Company = newComData;
                        // 判断和添加 部门
                        DepartmentData newDepData = new DepartmentData();
                        newDepData.Text           = userPost.DepartmentName;
                        newDepData.Value          = userPost.DepartmentID;

                        newPostData.Department = newDepData;

                        // 添加岗位
                        newPostData.Text  = userPost.PostName;
                        newPostData.Value = userPost.PostID;

                        ReferencedData <PostData> .RefData.Add(newPostData);
                        eData.Post = newPostData;
                    }
                    eData.Company    = eData.Post.Company;
                    eData.Department = eData.Post.Department;
                    return(eData);
                });
                listLogin.ForEach(item =>
                {
                    item.PostInfos = listLogin;
                });

                DataCore.CurrentUser = listLogin.FirstOrDefault();

                ReferencedData <LoginUserData> .RefData = listLogin;
            }
            catch (Exception ex)
            {
                strMsg = ex.ToString();
            }
        }