Ejemplo n.º 1
0
        /// <summary>
        /// 从本地数据库读取登陆人所能查看到的公司信息,而后加载到缓存中
        /// </summary>
        /// <param name="strUserID"></param>
        public void GetCompanysByLocal(string strUserID)
        {
            if (Application.Current.Resources["SYS_CompanyInfo"] != null && Application.Current.Resources["SYS_DepartmentInfo"] != null && Application.Current.Resources["SYS_PostInfo"] != null)
            {
                return;
            }

            List <SMT.Saas.Tools.OrganizationWS.V_COMPANY> companyinfo = new List <SMT.Saas.Tools.OrganizationWS.V_COMPANY>();

            List <V_CompanyInfo> vLocalCompanys = V_CompanyInfoVM.GetAllV_CompanyInfo(strUserID);

            foreach (var item in vLocalCompanys)
            {
                if (string.IsNullOrWhiteSpace(item.COMPANYID))
                {
                    continue;
                }

                SMT.Saas.Tools.OrganizationWS.V_COMPANY info = item.CloneObject <SMT.Saas.Tools.OrganizationWS.V_COMPANY>(new SMT.Saas.Tools.OrganizationWS.V_COMPANY());

                companyinfo.Add(info);
            }

            allCompanysView = companyinfo;
            LoadCompanyInfo();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存组织架构到本地数据库
        /// </summary>
        /// <param name="strUserID"></param>
        private void SaveOrganizationByLocal(string strUserID)
        {
            List <V_CompanyInfo>    vLocalCompanys    = new List <V_CompanyInfo>();
            List <V_DepartmentInfo> vLocalDepartments = new List <V_DepartmentInfo>();
            List <V_PostInfo>       vLocalPosts       = new List <V_PostInfo>();

            foreach (var item in allCompanysView)
            {
                if (string.IsNullOrWhiteSpace(item.COMPANYID))
                {
                    continue;
                }

                V_CompanyInfo info = item.CloneObject <V_CompanyInfo>(new V_CompanyInfo());
                info.UserModuleID = System.Guid.NewGuid().ToString();
                info.UserID       = strUserID;
                vLocalCompanys.Add(info);

                if (allDepartmentsView != null)
                {
                    if (allDepartmentsView.Count() > 0)
                    {
                        foreach (var p in allDepartmentsView)
                        {
                            V_DepartmentInfo departmentInfo = item.CloneObject <V_DepartmentInfo>(new V_DepartmentInfo());
                            departmentInfo.UserModuleID = info.UserModuleID;
                            departmentInfo.UserID       = strUserID;

                            vLocalDepartments.Add(departmentInfo);
                        }
                    }
                }

                if (allPostsView != null)
                {
                    if (allPostsView.Count() > 0)
                    {
                        foreach (var d in allPostsView)
                        {
                            V_PostInfo postInfo = item.CloneObject <V_PostInfo>(new V_PostInfo());
                            postInfo.UserModuleID = info.UserModuleID;
                            postInfo.UserID       = strUserID;

                            vLocalPosts.Add(postInfo);
                        }
                    }
                }
            }

            V_CompanyInfoVM.SaveV_CompanyInfo(strUserID, vLocalCompanys);
            V_DepartmentInfoVM.SaveV_DepartmentInfo(strUserID, vLocalDepartments);
            V_PostInfoVM.SaveV_PostInfo(strUserID, vLocalPosts);
        }