Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        private List <string> OnOwnerPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            List <string> propertyNameList = new List <string>();

            entityHelper.EntityCharged -= new EventHandler <EntityChangedArgs>(entityHelper_EntityCharged);
            try
            {
                switch (e.PropertyName)
                {
                case "OWNERID":

                    EmployeerData emplyeerData = this.ReferencedData["Entity.OWNERID"] as EmployeerData;
                    if (emplyeerData != null)
                    {
                        this.SetObjValue(EntityFieldName.OwnerName, emplyeerData.Text);

                        this.SetObjValue(EntityFieldName.OwnerPostID, emplyeerData.Post.Value);
                        this.SetObjValue(EntityFieldName.OwnerPostName, emplyeerData.Post.Text);

                        this.SetObjValue(EntityFieldName.OwnerDepartmentID, emplyeerData.Department.Value);
                        this.SetObjValue(EntityFieldName.OwnerDepartmentName, emplyeerData.Department.Text);

                        this.SetObjValue(EntityFieldName.OwnerCompanyID, emplyeerData.Company.Value);
                        this.SetObjValue(EntityFieldName.OwnerCompanyName, emplyeerData.Company.Text);
                        propertyNameList.Add(EntityFieldName.OwnerID);
                        propertyNameList.Add(EntityFieldName.OwnerName);

                        propertyNameList.Add(EntityFieldName.OwnerPostID);
                        propertyNameList.Add(EntityFieldName.OwnerPostName);

                        propertyNameList.Add(EntityFieldName.OwnerDepartmentID);
                        propertyNameList.Add(EntityFieldName.OwnerDepartmentName);

                        propertyNameList.Add(EntityFieldName.OwnerCompanyID);
                        propertyNameList.Add(EntityFieldName.OwnerCompanyName);
                    }


                    break;

                case "OWNERCOMPANYID":
                    SetTextFromValue <CompanyData>("Entity.OWNERCOMPANYID", "Entity.OWNERCOMPANYNAME");

                    propertyNameList.Add(EntityFieldName.OwnerCompanyID);
                    propertyNameList.Add(EntityFieldName.OwnerCompanyName);

                    break;

                case "OWNERDEPARTMENTID":
                    DepartmentData dData = SetTextFromValue <DepartmentData>("Entity.OWNERDEPARTMENTID", "Entity.OWNERDEPARTMENTNAME");
                    propertyNameList.Add(EntityFieldName.OwnerDepartmentID);
                    propertyNameList.Add(EntityFieldName.OwnerDepartmentName);
                    try
                    {
                        if (dData != null)
                        {
                            this.SetObjValue(EntityFieldName.OwnerCompanyID, dData.Company.Value);
                            this.SetObjValue(EntityFieldName.OwnerCompanyName, dData.Company.Text);

                            propertyNameList.Add(EntityFieldName.OwnerCompanyID);
                            propertyNameList.Add(EntityFieldName.OwnerCompanyName);
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    break;

                case "OWNERPOSTID":
                    PostData pData = SetTextFromValue <PostData>(EntityFieldName.OwnerPostID, "Entity.OWNERPOSTNAME");
                    //this.SetObjValue(EntityFieldName.OwnerCompanyID, pData.Company.Value);
                    //this.SetObjValue(EntityFieldName.OwnerCompanyName, pData.Company.Text);

                    //this.SetObjValue(EntityFieldName.OwnerDepartmentID, pData.Department.Value);
                    //this.SetObjValue(EntityFieldName.OwnerDepartmentName, pData.Department.Text);

                    //propertyNameList.Add(EntityFieldName.OwnerPostID);
                    //propertyNameList.Add(EntityFieldName.OwnerPostName);

                    //propertyNameList.Add(EntityFieldName.OwnerDepartmentID);
                    //propertyNameList.Add(EntityFieldName.OwnerDepartmentName);

                    //propertyNameList.Add(EntityFieldName.OwnerCompanyID);
                    //propertyNameList.Add(EntityFieldName.OwnerCompanyName);

                    break;

                default:
                    propertyNameList.Add(e.PropertyName.ToEntityString());
                    break;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
            entityHelper.EntityCharged += new EventHandler <EntityChangedArgs>(entityHelper_EntityCharged);
            return(propertyNameList);
        }
Exemplo n.º 3
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();
            }
        }