Example #1
0
        public async Task <ResponseMessage <HumanInfoResponse> > SaveHumanInfo(UserInfo user, [FromBody] HumanInfoRequest humanInfoRequest)
        {
            Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})保存员工人事信息,如果已存在则更新(SaveHumanInfo),请求体为:\r\n" + (humanInfoRequest != null ? JsonHelper.ToJson(humanInfoRequest) : ""));

            ResponseMessage <HumanInfoResponse> response = new ResponseMessage <HumanInfoResponse>();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})保存员工人事信息,如果已存在则更新(SaveHumanInfo)模型验证失败:{response.Message}请求体为:\r\n" + (humanInfoRequest != null ? JsonHelper.ToJson(humanInfoRequest) : ""));
                return(response);
            }
            try
            {
                return(await _humanInfoManager.SaveHumanInfo(user, humanInfoRequest, HttpContext.RequestAborted));
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.Message;
                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})根据报告Id获取成交报告信息(GetReport)失败:{response.Message}请求体为:\r\n" + (humanInfoRequest != null ? JsonHelper.ToJson(humanInfoRequest) : ""));
            }
            return(response);
        }
Example #2
0
        public async Task <ResponseMessage <HumanInfoResponse> > SaveHumanInfo(UserInfo user, HumanInfoRequest humanInfoRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            ResponseMessage <HumanInfoResponse> response = new ResponseMessage <HumanInfoResponse>();

            if (user == null || humanInfoRequest == null)
            {
                throw new ArgumentNullException(nameof(UserInfo) + nameof(HumanInfoRequest));
            }
            //判断是否新增,则走审核流程
            if (!string.IsNullOrEmpty(humanInfoRequest.Id))
            {
                var result = await GetHumanInfoAsync(user, humanInfoRequest.Id);

                if (result?.Extension != null && (result.Extension?.ExamineStatus != ExamineStatusEnum.UnSubmit || result.Extension?.ExamineStatus != ExamineStatusEnum.Reject) && !result.Extension.IsDeleted)
                {
                    var gatwayurl = ApplicationContext.Current.AppGatewayUrl.EndsWith("/") ? ApplicationContext.Current.AppGatewayUrl.TrimEnd('/') : ApplicationContext.Current.AppGatewayUrl;
                    GatewayInterface.Dto.ExamineSubmitRequest examineSubmitRequest = new GatewayInterface.Dto.ExamineSubmitRequest();
                    examineSubmitRequest.ContentId       = !string.IsNullOrEmpty(humanInfoRequest.Id) ? humanInfoRequest.Id : "";
                    examineSubmitRequest.ContentType     = "HumanInfo";
                    examineSubmitRequest.ContentName     = humanInfoRequest.Name;
                    examineSubmitRequest.Content         = "新增员工人事信息";
                    examineSubmitRequest.Source          = user.FilialeName;
                    examineSubmitRequest.CallbackUrl     = gatwayurl + "/api/humaninfo/humaninfocallback";
                    examineSubmitRequest.StepCallbackUrl = gatwayurl + "/api/humaninfo/shoponsitestepcallback";
                    examineSubmitRequest.Action          = "HumanInfo";
                    examineSubmitRequest.TaskName        = $"新增员工人事信息:{humanInfoRequest.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 <HumanInfoResponse>(await Store.SaveAsync(user, _mapper.Map <HumanInfo>(humanInfoRequest), cancellationToken));
            return(response);
        }
Example #3
0
        public async Task <ResponseMessage <List <HumanInfoResponse1> > > CreateHumanInfo(UserInfo User, [FromBody] HumanInfoRequest humanInfoRequest)
        {
            var Response = new ResponseMessage <List <HumanInfoResponse1> >();

            try
            {
                string modifyid = Guid.NewGuid().ToString();

                GatewayInterface.Dto.ExamineSubmitRequest exarequest = new GatewayInterface.Dto.ExamineSubmitRequest();
                //exarequest.ContentId = condition.humaninfo.ID;
                exarequest.ContentType = "HumanCommit";
                //exarequest.ContentName = $"addhuman {condition.humaninfo.Name}";
                exarequest.SubmitDefineId = modifyid;
                exarequest.Source         = "";
                //exarequest.CallbackUrl = ApplicationContext.Current.UpdateExamineCallbackUrl;
                exarequest.Action   = "TEST" /*exarequest.ContentType*/;
                exarequest.TaskName = $"{User.UserName}提交入职请求{exarequest.ContentName}的动态{exarequest.ContentType}";;
                GatewayInterface.Dto.UserInfo userinfo = new GatewayInterface.Dto.UserInfo()
                {
                    Id               = User.Id,
                    KeyWord          = User.KeyWord,
                    OrganizationId   = User.OrganizationId,
                    OrganizationName = User.OrganizationName,
                    UserName         = User.UserName
                };

                var examineInterface = ApplicationContext.Current.Provider.GetRequiredService <IExamineInterface>();
                var reponse          = await examineInterface.Submit(userinfo, exarequest);

                if (reponse.Code != ResponseCodeDefines.SuccessCode)
                {
                    Response.Code    = ResponseCodeDefines.ServiceError;
                    Response.Message = "向审核中心发起审核请求失败:" + reponse.Message;
                    return(Response);
                }

                //if (condition.fileinfo != null)
                //{
                //    NameValueCollection nameValueCollection = new NameValueCollection();
                //    var nwf = CreateNwf(User, "humaninfo", condition.fileinfo);

                //    nameValueCollection.Add("appToken", "app:nwf");
                //    Logger.Info("nwf协议");
                //    string response2 = await _restClient.Post(ApplicationContext.Current.NWFUrl, nwf, "POST", nameValueCollection);
                //    Logger.Info("返回:\r\n{0}", response2);

                //    await _humanManage.CreateFileScopeAsync(User.Id, condition.humaninfo.ID, condition.fileinfo, HttpContext.RequestAborted);
                //}

                //await _humanManage.AddHuman(User, condition.humaninfo, modifyid, "TEST", HttpContext.RequestAborted);
                Response.Message = $"addhumaninfo sucess";
            }
            catch (Exception e)
            {
                Response.Code    = ResponseCodeDefines.ServiceError;
                Response.Message = "服务器错误:" + e.ToString();
                Logger.Error("error");
            }
            return(Response);
        }