Ejemplo n.º 1
0
        public static ITextValueItem FindReferencedData <T>(object value) where T : ITextValueItem
        {
            T t = ReferencedData <T> .Find(value);

            return(t as ITextValueItem);
        }
Ejemplo n.º 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();
            }
        }