/// <summary> /// Получить данные из 1С и подготовить для вывода на форму асинхронно. /// </summary> /// <param name="service1C">Сервис 1С</param> /// <param name="account1CCode">Номер договора</param> /// <param name="secret1C">Данные для подключения</param> /// <param name="region">Регион</param> /// <param name="configuration">Настройки подключения</param> /// <returns>Модель данных для отображения</returns> public static async Task <IndexModel> GetDataFrom1CAsync(IService1СSoap service1C, string account1CCode, ISecret1C secret1C, string region, IConfiguration configuration) { IndexModel result = new IndexModel(); CreditDocumentNResult account = await service1C.GetCreditDocumentAsync( secret1C.Servers[region], secret1C.Login, secret1C.Password, account1CCode, CancellationToken.None); if (account.CreditDocument == default) { throw new Exception($"{Environment.NewLine}{account.Errors}"); } if (account.CreditDocument.Client == default) { throw new Exception($"{Environment.NewLine}Договор с номером \"{account1CCode}\" в базе 1С не найден"); } CreditDocument creditDocument = account.CreditDocument; result.ClientPersonalInfo.AddressReq = (AddressReq[])creditDocument.Client; result.ClientPersonalInfo.IdReq = (IdReq)creditDocument.Client; result.ClientPersonalInfo.PersonReq = (PersonReq)creditDocument.Client; result.InquiryReq = (InquiryReq)creditDocument; result.Client1CCode = creditDocument.Client.ID1C; result.Account1CCode = creditDocument.Code1C; result.Account1CDate = SOAPNBCH.StringToDateTime(creditDocument.DateOfCredit); return(result); }
/// <summary> /// Изменить дату и время согласия клиента в соответствии с Московским временем. /// </summary> /// <param name="request">Запрос в НБКИ</param> /// <returns></returns> private ProductRequest UpdateDateToMoscowTimeZone(ProductRequest request) { DateTime consentDate = SOAPNBCH.StringToDateTime(request.Prequest.Req.InquiryReq.ConsentReq.consentDate); consentDate = EndOfDay(consentDate); DateTime moscowDate = DateTime.Now.AddHours(SOAPNBCH.MoscowTimeZone - ServerTimeZone); consentDate = consentDate > moscowDate?consentDate.AddDays(-1) : consentDate; request.Prequest.Req.InquiryReq.ConsentReq.consentDate = SOAPNBCH.DateTimeToString(consentDate); return(request); }