Exemple #1
0
        /// <summary>
        /// 创建用户信息,如果不存在,则创建如果存在,则不处理。
        /// 从/api/v2/WebApiPersonInfoes获取信息
        /// </summary>
        /// <returns></returns>
        private async Task <HandleWebApiCotentResult> CreateUserInfoIfNotExistFromHumanResourceManagerSystem()
        {
            HandleWebApiCotentResult result = new HandleWebApiCotentResult();

            // Call Cliennt
            result = await GetPersonInfoJsonStringFromHumanResourceSystem();

            if (result.Successed)
            {
                var newUserInfoModels = TransferWebApiUserInfosToCreateUserViewModelForCreateNewUser(result.ResponseContent);

                if (newUserInfoModels != null && newUserInfoModels.Count > 0)
                {
                    result.TotalContentCount = newUserInfoModels.Count;
                    foreach (var user in newUserInfoModels)
                    {
                        var userResult = await user.CreateUserAsync(_userManager);

                        if (userResult != null)
                        {
                            result.SuccessCount++;
                        }
                    }
                }
            }
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 查询数据库中是否存在该用户,如果存在,则判断是否有登录帐号是否与得到的工号信息相同,如果不相同,则修改登录帐号,相同则不处理。
        /// </summary>
        /// <returns></returns>
        private async Task <HandleWebApiCotentResult> UpdatePersonInfoFromHumanResourceSystem()
        {
            HandleWebApiCotentResult result = new HandleWebApiCotentResult();

            result = await GetPersonInfoJsonStringFromHumanResourceSystem();

            if (result.Successed)
            {
                var newUserInfoModels = TransferWebApiUserInfosToEditUserViewModelForUpdateUser(result.ResponseContent);

                if (newUserInfoModels != null && newUserInfoModels.Count > 0)
                {
                    result.TotalContentCount = newUserInfoModels.Count;
                    foreach (var user in newUserInfoModels)
                    {
                        var userResult = await user.UpdateUserInfo(_userManager);

                        if (userResult != null)
                        {
                            result.SuccessCount++;
                        }
                    }
                }
            }
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// 通过构建Http Client从人力资源系统中获得人员信息的Json字符串
        /// </summary>
        /// <returns>获取成功,返回获取的信息。获取失败,返回错误信息</returns>
        private async Task <HandleWebApiCotentResult> GetPersonInfoJsonStringFromHumanResourceSystem()
        {
            HandleWebApiCotentResult result = new HandleWebApiCotentResult();
            // Call Cliennt
            var client  = new HttpClient();
            var respone = await client.GetAsync(_userInfoFromHumanResourceOption.Value.PersonInfosUriNoAuthorize);

            if (!respone.IsSuccessStatusCode)
            {
                result.Successed    = false;
                result.ErrorMessage = respone.StatusCode.ToString() + respone.RequestMessage.ToString();
            }
            result.Successed       = true;
            result.ResponseContent = await respone.Content.ReadAsStringAsync();

            return(result);
        }
Exemple #4
0
        /// <summary>
        /// 更改人员登录帐号,如果人力资源系统中已标记为删除,则在此处需删除登录帐号
        /// 查找人员信息,如果找到,则判断登录帐号是工号是相同,如果不相同,则需更改登录帐号,如果相同则不处理。
        /// </summary>
        /// <returns>从WebpApi中获得结果</returns>
        private async Task <HandleWebApiCotentResult> UpdateUserAccountFromHumanResourceSystem()
        {
            HandleWebApiCotentResult result = new HandleWebApiCotentResult();

            result = await GetPersonInfoJsonStringFromHumanResourceSystem();

            if (result.Successed)
            {
                //获得人员删除标记为false的人员,更改其登录帐号
                var newUserInfoModels = TransferWebApiUserInfosToChangeUserAccountViewModelForUpdateUserAccount(result.ResponseContent);
                if (newUserInfoModels != null && newUserInfoModels.Count > 0)
                {
                    result.TotalContentCount += newUserInfoModels.Count;
                    foreach (var user in newUserInfoModels)
                    {
                        var userResult = await user.ChangeUserAccountAsync(_userManager);

                        if (userResult != null && userResult.Succeeded)
                        {
                            result.SuccessCount++;
                        }
                    }
                }
                //获得人员删除标记为true的人员,删除其登录帐号
                var deleteUserInfoModels = TransferWebApiUserInfosToDeleteUserViewModelForUpdateUserAccount(result.ResponseContent);
                if (deleteUserInfoModels != null && deleteUserInfoModels.Count > 0)
                {
                    result.TotalContentCount += deleteUserInfoModels.Count;
                    foreach (var user in deleteUserInfoModels)
                    {
                        var userResult = await user.DeleteUserAsync(_userManager);

                        if (userResult != null && userResult.Succeeded)
                        {
                            result.SuccessCount++;
                        }
                    }
                }
            }
            return(result);
        }