Beispiel #1
0
        public async Task <ResponseMessage> HumanRegular(UserInfo user, HumanInfoRegularRequest humanRegularRequest)
        {
            ResponseMessage response = new ResponseMessage();



            return(response);
        }
        public async Task <ResponseMessage <HumanInfoRegularResponse> > UpdateAsync(UserInfo user, string id, HumanInfoRegularRequest humanInfoRegularRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            ResponseMessage <HumanInfoRegularResponse> response = new ResponseMessage <HumanInfoRegularResponse>();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            if (humanInfoRegularRequest == null)
            {
                throw new ArgumentNullException(nameof(humanInfoRegularRequest));
            }
            var humaninfo = await _humanInfoStore.GetAsync(a => a.Where(b => b.Id == humanInfoRegularRequest.HumanId && !b.IsDeleted), cancellationToken);

            if (humaninfo == null)
            {
                response.Code    = ResponseCodeDefines.NotFound;
                response.Message = "操作的人事信息未找到";
                return(response);
            }
            var org = await _permissionExpansionManager.GetOrganizationOfPermission(user.Id, "HumanRegular");

            if (org == null || org.Count == 0 || !org.Contains(humaninfo.DepartmentId))
            {
                response.Code    = ResponseCodeDefines.NotAllow;
                response.Message = "没有权限";
                return(response);
            }
            var humanInfoRegular = _mapper.Map <HumanInfoRegular>(humanInfoRegularRequest);

            humanInfoRegular.Id = id;
            response.Extension  = _mapper.Map <HumanInfoRegularResponse>(await Store.UpdateAsync(user, humanInfoRegular, cancellationToken));
            return(response);
        }
        public async Task <ResponseMessage <HumanInfoRegularResponse> > CreateAsync(UserInfo user, HumanInfoRegularRequest humanInfoRegularRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            ResponseMessage <HumanInfoRegularResponse> response = new ResponseMessage <HumanInfoRegularResponse>();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            if (humanInfoRegularRequest == null)
            {
                throw new ArgumentNullException(nameof(humanInfoRegularRequest));
            }
            var humaninfo = await _humanInfoStore.GetAsync(a => a.Where(b => b.Id == humanInfoRegularRequest.HumanId && !b.IsDeleted), cancellationToken);

            if (humaninfo == null)
            {
                response.Code    = ResponseCodeDefines.NotFound;
                response.Message = "操作的人事信息未找到";
                return(response);
            }
            var org = await _permissionExpansionManager.GetOrganizationOfPermission(user.Id, "HumanRegular");

            if (org == null || org.Count == 0 || !org.Contains(humaninfo.DepartmentId))
            {
                response.Code    = ResponseCodeDefines.NotAllow;
                response.Message = "没有权限";
                return(response);
            }
            if (string.IsNullOrEmpty(humanInfoRegularRequest.Id))
            {
                humanInfoRegularRequest.Id = Guid.NewGuid().ToString();
            }
            var gatwayurl = ApplicationContext.Current.AppGatewayUrl.EndsWith("/") ? ApplicationContext.Current.AppGatewayUrl.TrimEnd('/') : ApplicationContext.Current.AppGatewayUrl;

            GatewayInterface.Dto.ExamineSubmitRequest examineSubmitRequest = new GatewayInterface.Dto.ExamineSubmitRequest();
            examineSubmitRequest.ContentId       = humanInfoRegularRequest.Id;
            examineSubmitRequest.ContentType     = "HumanRegular";
            examineSubmitRequest.ContentName     = humaninfo.Name;
            examineSubmitRequest.Content         = "新增员工人事转正信息";
            examineSubmitRequest.Source          = user.FilialeName;
            examineSubmitRequest.SubmitDefineId  = humanInfoRegularRequest.Id;
            examineSubmitRequest.CallbackUrl     = gatwayurl + "/api/humanregular/humanregularcallback";
            examineSubmitRequest.StepCallbackUrl = gatwayurl + "/api/humanregular/humanregularstepcallback";
            examineSubmitRequest.Action          = "HumanRegular";
            examineSubmitRequest.TaskName        = $"新增员工人事转正信息:{humaninfo.Name}";
            examineSubmitRequest.Desc            = $"新增员工人事转正信息";

            GatewayInterface.Dto.UserInfo userInfo = new GatewayInterface.Dto.UserInfo()
            {
                Id               = user.Id,
                KeyWord          = user.KeyWord,
                OrganizationId   = user.OrganizationId,
                OrganizationName = user.OrganizationName,
                UserName         = user.UserName
            };
            examineSubmitRequest.UserInfo = userInfo;

            string tokenUrl         = $"{ApplicationContext.Current.AuthUrl}/connect/token";
            string examineCenterUrl = $"{ApplicationContext.Current.ExamineCenterUrl}";

            Logger.Info($"新增员工人事转正信息提交审核,\r\ntokenUrl:{tokenUrl ?? ""},\r\nexamineCenterUrl:{examineCenterUrl ?? ""},\r\nexamineSubmitRequest:" + (examineSubmitRequest != null ? JsonHelper.ToJson(examineSubmitRequest) : ""));
            var tokenManager = new TokenManager(tokenUrl, ApplicationContext.Current.ClientID, ApplicationContext.Current.ClientSecret);
            var response2    = await tokenManager.Execute(async (token) =>
            {
                return(await _restClient.PostWithToken <ResponseMessage>(examineCenterUrl, examineSubmitRequest, token));
            });

            if (response2.Code != ResponseCodeDefines.SuccessCode)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = "向审核中心发起审核请求失败:" + response2.Message;
                Logger.Info($"新增员工人事转正信息提交审核失败:" + response2.Message);
                return(response);
            }

            response.Extension = _mapper.Map <HumanInfoRegularResponse>(await Store.CreateAsync(user, _mapper.Map <HumanInfoRegular>(humanInfoRegularRequest), cancellationToken));
            return(response);
        }
Beispiel #4
0
        public async Task <ResponseMessage <HumanInfoRegularResponse> > CreateHumanInfoRegular(UserInfo user, [FromBody] HumanInfoRegularRequest humanInfoRegularRequest)
        {
            Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增人事转正信息(CreateHumanInfoRegular),请求体为:\r\n" + (humanInfoRegularRequest != null ? JsonHelper.ToJson(humanInfoRegularRequest) : ""));
            ResponseMessage <HumanInfoRegularResponse> response = new ResponseMessage <HumanInfoRegularResponse>();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增人事转正信息(CreateHumanInfoRegular)模型验证失败:{response.Message}请求体为:\r\n" + (humanInfoRegularRequest != null ? JsonHelper.ToJson(humanInfoRegularRequest) : ""));
                return(response);
            }
            try
            {
                return(await _humanInfoRegularManager.CreateAsync(user, humanInfoRegularRequest, HttpContext.RequestAborted));
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.Message;
                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增人事转正信息(CreateHumanInfoRegular)失败:{response.Message}请求体为:\r\n" + (humanInfoRegularRequest != null ? JsonHelper.ToJson(humanInfoRegularRequest) : ""));
            }
            return(response);
        }