コード例 #1
0
        public async Task <ResponseMessage> HumanAdjustment(UserInfo user, HumanInfoAdjustmentRequest humanAdjustmentRequest)
        {
            ResponseMessage response = new ResponseMessage();



            return(response);
        }
コード例 #2
0
        public async Task <ResponseMessage <HumanInfoAdjustmentResponse> > CreateAsync(UserInfo user, HumanInfoAdjustmentRequest humanInfoAdjustmentRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            ResponseMessage <HumanInfoAdjustmentResponse> response = new ResponseMessage <HumanInfoAdjustmentResponse>();

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

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

            if (org == null || org.Count == 0 || !org.Contains(humanInfoAdjustmentRequest.DepartmentId) || !org.Contains(humaninfo.DepartmentId))
            {
                response.Code    = ResponseCodeDefines.NotAllow;
                response.Message = "没有权限";
                return(response);
            }

            if (string.IsNullOrEmpty(humanInfoAdjustmentRequest.Id))
            {
                humanInfoAdjustmentRequest.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       = humanInfoAdjustmentRequest.Id;
            examineSubmitRequest.ContentType     = "HumanAdjustment";
            examineSubmitRequest.ContentName     = humaninfo.Name;
            examineSubmitRequest.Content         = "新增员工人事调动信息";
            examineSubmitRequest.Source          = user.FilialeName;
            examineSubmitRequest.SubmitDefineId  = humanInfoAdjustmentRequest.Id;
            examineSubmitRequest.CallbackUrl     = gatwayurl + "/api/humanadjustment/humanadjustmentcallback";
            examineSubmitRequest.StepCallbackUrl = gatwayurl + "/api/humanadjustment/humanadjustmentstepcallback";
            examineSubmitRequest.Action          = "HumanAdjustment";
            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 <HumanInfoAdjustmentResponse>(await Store.CreateAsync(user, _mapper.Map <HumanInfoAdjustment>(humanInfoAdjustmentRequest), cancellationToken));
            return(response);
        }
コード例 #3
0
        public async Task <ResponseMessage <HumanInfoAdjustmentResponse> > UpdateAsync(UserInfo user, string id, HumanInfoAdjustmentRequest humanInfoAdjustmentRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            ResponseMessage <HumanInfoAdjustmentResponse> response = new ResponseMessage <HumanInfoAdjustmentResponse>();

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

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

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

            humanInfoAdjustment.Id = id;
            response.Extension     = _mapper.Map <HumanInfoAdjustmentResponse>(await Store.UpdateAsync(user, humanInfoAdjustment, cancellationToken));
            return(response);
        }
コード例 #4
0
        public async Task <ResponseMessage <HumanInfoAdjustmentResponse> > CreateHumanInfoAdjustment(UserInfo user, [FromBody] HumanInfoAdjustmentRequest humanInfoAdjustmentRequest)
        {
            Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})新增异动调薪信息(CreateHumanInfoAdjustment),请求体为:\r\n" + (humanInfoAdjustmentRequest != null ? JsonHelper.ToJson(humanInfoAdjustmentRequest) : ""));
            ResponseMessage <HumanInfoAdjustmentResponse> response = new ResponseMessage <HumanInfoAdjustmentResponse>();

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