public virtual async Task ModifyContractAsync(ContractContentInfoRequest buildingBaseInfoRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (buildingBaseInfoRequest == null)
            {
                throw new ArgumentNullException(nameof(buildingBaseInfoRequest));
            }

            if (buildingBaseInfoRequest.AnnexInfo != null && buildingBaseInfoRequest.AnnexInfo.Count > 0)
            {
                await Store.UpdateListAsync(_mapper.Map <List <AnnexInfo> >(buildingBaseInfoRequest.AnnexInfo), cancellationToken);
            }

            if (buildingBaseInfoRequest.ComplementInfo != null && buildingBaseInfoRequest.ComplementInfo.Count > 0)
            {
                await Store.UpdateListAsync(_mapper.Map <List <ComplementInfo> >(buildingBaseInfoRequest.ComplementInfo), cancellationToken);
            }

            await Store.UpdateAsync(_mapper.Map <ContractInfo>(buildingBaseInfoRequest), cancellationToken);
        }
        public async Task <ResponseMessage <string> > ModifySimpleContract(UserInfo User, [FromBody] ContractContentInfoRequest request)
        {
            Logger.Trace($"用户{User?.UserName ?? ""}({User?.Id ?? ""})保存合同基础信息(PutBuildingBaseInfo):\r\n请求参数为:\r\n" + (request != null ? JsonHelper.ToJson(request) : ""));

            var response = new ResponseMessage <string>();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                return(response);
            }

            try
            {
                //写发送成功后的表
                var guid = Guid.NewGuid().ToString();

                //审核提交
                GatewayInterface.Dto.ExamineSubmitRequest exarequest = new GatewayInterface.Dto.ExamineSubmitRequest();
                exarequest.ContentId      = request.BaseInfo.ID;
                exarequest.ContentType    = "ContractCommit";
                exarequest.ContentName    = "Modify";
                exarequest.SubmitDefineId = guid;
                exarequest.Source         = "";
                exarequest.CallbackUrl    = "";
                exarequest.Action         = "TEST" /*"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);
                }

                Logger.Trace($"{exarequest.ContentId}发生审核成功");
                request.BaseInfo.Num = string.IsNullOrEmpty(request.BaseInfo.Num) ? await _contractInfoManager.GetContractNum(request.BaseInfo.ID, HttpContext.RequestAborted) : request.BaseInfo.Num;

                await _contractInfoManager.ModifyContractBeforCheckAsync(User, request, guid, "TEST", HttpContext.RequestAborted);


                response.Extension = guid;
                response.Message   = "modify simple ok";
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Error($"用户{User?.UserName ?? ""}({User?.Id ?? ""})合同动态提交审核(UpdateRecordSubmit)报错:\r\n{e.ToString()},\r\n请求参数为:\r\n" + (request != null ? JsonHelper.ToJson(request) : ""));
            }

            return(response);
        }
        public async Task <ResponseMessage <ContractInfoResponse> > AddSimpleContract(UserInfo User, [FromBody] ContractContentInfoRequest request)
        {
            Logger.Trace($"用户{User?.UserName ?? ""}({User?.Id ?? ""})保存合同基础信息(PutBuildingBaseInfo):\r\n请求参数为:\r\n" + (request != null ? JsonHelper.ToJson(request) : ""));

            var response = new ResponseMessage <ContractInfoResponse>();

            if (!ModelState.IsValid)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                return(response);
            }

            try
            {
                //写发送成功后的表
                if (!string.IsNullOrEmpty(User.OrganizationId))
                {
                    var resp = await _restClient.Get <ResponseMessage <string> >($"http://localhost:5000/api/Organization/{User.OrganizationId}", null);

                    request.BaseInfo.CreateDepartment = resp.Extension;
                }

                string strModifyGuid = "";
                if (request.Modifyinfo != null && request.Modifyinfo.Count > 0)
                {
                    strModifyGuid = request.Modifyinfo.ElementAt(0).ID;
                }
                else
                {
                    strModifyGuid      = Guid.NewGuid().ToString();
                    request.Modifyinfo = new List <ContractModifyResponse>();
                    request.Modifyinfo.Add(new ContractModifyResponse {
                        ID = strModifyGuid
                    });
                }


                GatewayInterface.Dto.ExamineSubmitRequest exarequest = new GatewayInterface.Dto.ExamineSubmitRequest();
                exarequest.ContentId      = request.BaseInfo.ID;
                exarequest.ContentType    = "ContractCommit";
                exarequest.ContentName    = "AddContract";
                exarequest.SubmitDefineId = strModifyGuid;
                exarequest.Source         = "";
                exarequest.CallbackUrl    = "";
                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);
                }
                request.BaseInfo.Num = await _contractInfoManager.GetContractNum(request.BaseInfo.ID, HttpContext.RequestAborted);

                response.Extension = await _contractInfoManager.AddContractAsync(User, strModifyGuid, request, "TEST", HttpContext.RequestAborted);

                response.Message = "add simple ok";
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Error($"用户{User?.UserName ?? ""}({User?.Id ?? ""})合同动态提交审核(UpdateRecordSubmit)报错:\r\n{e.ToString()},\r\n请求参数为:\r\n" + (request != null ? JsonHelper.ToJson(request) : ""));
            }

            return(response);
        }
        public virtual async Task <ContractInfoResponse> AddContractAsync(UserInfo userinfo, string modifyGuid, ContractContentInfoRequest buildingBaseInfoRequest, string checkaction, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (buildingBaseInfoRequest == null)
            {
                throw new ArgumentNullException(nameof(buildingBaseInfoRequest));
            }

            if (buildingBaseInfoRequest.AnnexInfo != null && buildingBaseInfoRequest.AnnexInfo.Count > 0)
            {
                await Store.CreateAsync(_mapper.Map <SimpleUser>(userinfo), _mapper.Map <List <AnnexInfo> >(buildingBaseInfoRequest.AnnexInfo), cancellationToken);
            }

            if (buildingBaseInfoRequest.ComplementInfo != null && buildingBaseInfoRequest.ComplementInfo.Count > 0)
            {
                await Store.CreateAsync(_mapper.Map <SimpleUser>(userinfo), _mapper.Map <List <ComplementInfo> >(buildingBaseInfoRequest.ComplementInfo), cancellationToken);
            }

            var baseinfo = await Store.CreateAsync(_mapper.Map <SimpleUser>(userinfo), _mapper.Map <ContractInfo>(buildingBaseInfoRequest),
                                                   modifyGuid /*(buildingBaseInfoRequest.Modifyinfo!=null&&buildingBaseInfoRequest.Modifyinfo.Count>0)?buildingBaseInfoRequest.Modifyinfo.ElementAt(0).ID:null*/, JsonHelper.ToJson(buildingBaseInfoRequest), null, checkaction, cancellationToken);

            return(_mapper.Map <ContractInfoResponse>(baseinfo));
        }
        public virtual async Task <string> ModifyContractBeforCheckAsync(UserInfo userinfo, ContractContentInfoRequest buildingBaseInfoRequest, string strmodify, string checkaction, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (buildingBaseInfoRequest == null)
            {
                throw new ArgumentNullException(nameof(buildingBaseInfoRequest));
            }

            await Store.CreateModifyAsync(_mapper.Map <SimpleUser>(userinfo),
                                          buildingBaseInfoRequest.BaseInfo.ID,
                                          strmodify, ModifyContract, checkaction, ExamineStatusEnum.Auditing, true,
                                          JsonHelper.ToJson(buildingBaseInfoRequest), null);//2是修改

            return(strmodify);
        }