// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(); services.AddAuthentication(IISDefaults.AuthenticationScheme); services.AddControllersWithViews(); services.AddSingleton <IADUser>(p => (IADUser)WCFProxyFactory.GetWCFProxy(typeof(IADUser), Configuration)); services.AddSingleton <IRegion>(p => (IRegion)WCFProxyFactory.GetWCFProxy(typeof(IRegion), Configuration)); services.AddTransient <IPDFSaver>(p => (IPDFSaver)WCFProxyFactory.GetWCFProxy(typeof(IPDFSaver), Configuration)); //services.AddTransient<IService1CWCF>(p => (IService1CWCF)WCFProxyFactory.GetWCFProxy(typeof(IService1CWCF), Configuration)); //services.AddTransient<IService1СSoapWCF>(p => (IService1СSoapWCF)WCFProxyFactory.GetWCFProxy(typeof(IService1СSoapWCF), Configuration)); services.AddTransient <IService1C, EFService1C>(); services.AddTransient <IService1СSoap, Service1СSoap>(); //services.AddTransient<IServiceNBCHWCF>(p => (IServiceNBCHWCF)WCFProxyFactory.GetWCFProxy(typeof(IServiceNBCHWCF), Configuration)); services.AddTransient <IServiceNBCH, EFServiceNBCH>(); services.AddTransient <IServiceNBCHsoap, ServiceNBCHsoap>(); //services.AddTransient<IServiceRegistrarWCF>(p => (IServiceRegistrarWCF)WCFProxyFactory.GetWCFProxy(typeof(IServiceRegistrarWCF), Configuration)); services.AddTransient <IServiceRegistrar, EFServiceRegistrar>(); //services.AddTransient<IServicePDNWCF>(p => (IServicePDNWCF)WCFProxyFactory.GetWCFProxy(typeof(IServicePDNWCF), Configuration)); services.AddTransient <IServicePDN, EFServicePDN>(); services.AddTransient <ISecret1C>(p => Secret1C.GetSecret(Configuration)); services.AddTransient <ISecretNBCH[]>(p => SecretNBCH.GetSecretNBCHs(Configuration)); //services.AddTransient<IServicePostsWCF>(p => (IServicePostsWCF)WCFProxyFactory.GetWCFProxy(typeof(IServicePostsWCF), Configuration)); services.AddTransient <IServicePosts, EFServicePosts>(); services.AddTransient <IServiceInspecting, EFServiceInspecting>(); }
public async Task <IActionResult> Index(IndexModel model, string submit, ClientPersonalInfo clientPersonalInfo, string regionWebServiceListName, string[] orgs) { IndexModel.SubmitType submitType = Enum.IsDefined(typeof(IndexModel.SubmitType), submit) ? (IndexModel.SubmitType)Enum.Parse(typeof(IndexModel.SubmitType), submit) : IndexModel.SubmitType.Null; if (!int.TryParse(Request.Cookies["ClientTimeZone"], out int clientTimeZone)) { submitType = IndexModel.SubmitType.Null; model.ErrorMessage = "Ошибка определения часового пояса на клиентской машине"; } model.ClientPersonalInfo = clientPersonalInfo ?? new ClientPersonalInfo(); ViewData["RequestCreditHistoryButtonDisabled"] = "style=\"display: none\""; ViewData["orgs"] = Organization.OrganizationsByLogin(User.Identity.Name, orgs); switch (submitType) { case IndexModel.SubmitType.Null: break; case IndexModel.SubmitType.GetFrom1C: if ((model.Account1CCode ?? default) == default) { break; } ModelState.Clear(); try { model = await NBCHRequest.GetDataFrom1CAsync(_Service1C, model.Account1CCode, _Secret1Cs, regionWebServiceListName, _Configuration); ViewData["RequestCreditHistoryButtonDisabled"] = ""; } catch (Exception exception) { _Logger.LogError( exception, "Ошибка получения данных из 1С. Пользователь: {login}, данные запроса: {model}, регион {region}, ошибка: {exceptionMessage}.", HelperASP.Login(User), model, regionWebServiceListName, exception.Message); model.ErrorMessage = exception.InnerException != default ? model.ErrorMessage += Environment.NewLine + exception.InnerException.Message : exception.Message; } break; case IndexModel.SubmitType.GetCH: Report report = new Report(); model.ClientTimeZone = clientTimeZone; try { report = await NBCHRequest.GetCreditHistoryAsync(_ServiceNBCHsoap, model, SecretNBCH.GetSecretNBCH(_Configuration, model.InquiryReq.ConsentReq.reportUser), _Logger); } catch (EndpointNotFoundException) { report.ErrorMessage = "Не удалось подключиться к службе NBCH (запрос данных из НБКИ)."; _Logger.LogError(report.ErrorMessage); } catch (Exception exception) { report.ErrorMessage = exception.ToString(); _Logger.LogError( exception, "Ошибка получения данных из НБКИ. Пользователь: {login}, данные запроса: {model}, ошибка: {exceptionMessage}.", HelperASP.Login(User), model, exception.Message); } model.AccountReply = report.AccountReply; model.Calc = report.calc; model.ErrorMessage = report.ErrorMessage; break; default: break; } ViewData["ReportDate"] = model?.Calc?.ReportDate ?? default; model.RegionsWebServiceListName = Secret1C.GetRegions(_Secret1Cs, regionWebServiceListName); Response.Cookies.Append(Startup.WebService1CRegion, regionWebServiceListName); return(View(model)); }