public PassengersService(ISessionBagService sessionBag, IUserSessionService userSessionService, IBookingManager client, IBookingService bookingService, IOptions <AppSettings> appSettings) : base(appSettings) { _sessionBag = sessionBag ?? throw new ArgumentNullException(nameof(sessionBag)); _bookingService = bookingService ?? throw new ArgumentNullException(nameof(bookingService)); _client = client ?? throw new ArgumentNullException(nameof(client)); }
public AgentService(ISessionBagService sessionBag, IAgentManager client, IPersonManager personClient, IUserSessionService userSessionService, IOptions <AppSettings> appSettings) : base(appSettings) { _sessionBag = sessionBag ?? throw new ArgumentNullException(nameof(sessionBag)); _userSessionService = userSessionService ?? throw new ArgumentNullException(nameof(userSessionService)); _client = client ?? throw new ArgumentNullException(nameof(client)); _personClient = personClient ?? throw new ArgumentNullException(nameof(personClient)); }
public FeeService(IBookingManager client, ISessionBagService sessionBagService, IBookingService bookingService, IResourcesService resourceService, IOptions <AppSettings> appSettings) : base(appSettings) { _client = client ?? throw new ArgumentNullException(nameof(client)); _sessionBagService = sessionBagService ?? throw new ArgumentNullException(nameof(sessionBagService)); _resourceService = resourceService ?? throw new ArgumentNullException(nameof(resourceService)); _bookingService = bookingService ?? throw new ArgumentNullException(nameof(bookingService)); }
public PaymentsService(ISessionBagService sessionBag, IUserSessionService userSessionService, IBookingManager bookingManagerClient, IVoucherManager voucherManagerClient, IBookingService bookingService, IOptions <AppSettings> appSettings) : base(appSettings) { _sessionBag = sessionBag ?? throw new ArgumentNullException(nameof(sessionBag)); _bookingService = bookingService ?? throw new ArgumentNullException(nameof(bookingService)); _bookingManagerClient = bookingManagerClient ?? throw new ArgumentNullException(nameof(bookingManagerClient)); _voucherManagerClient = voucherManagerClient ?? throw new ArgumentNullException(nameof(voucherManagerClient)); }
public BookingService(ISessionBagService sessionBag, IUserSessionService userSessionService, IBookingManager client, IOptions <AppSettings> appSettings) : base(appSettings) { _sessionBag = sessionBag ?? throw new ArgumentNullException(nameof(sessionBag)); _userSessionService = userSessionService ?? throw new ArgumentNullException(nameof(userSessionService)); _commitBookingSettings = appSettings.Value.CommitBookingSettings; _client = client ?? throw new ArgumentNullException(nameof(client)); }
private async Task StoreBookingComment(string newComment, ISessionBagService sessionBag, List <string> comments) { if (comments == null) { comments = new List <string>(); } comments.Add(_commentPrefix + " " + newComment); await sessionBag.SetPostCommitBookingComments(comments); }
public async static Task <string> GetCustomSessionValue(this ISessionBagService sessionBagService, string sessionKey) { var customSessionValues = await sessionBagService.CustomSessionValues(); if (customSessionValues != null && customSessionValues.ContainsKey(sessionKey)) { return(customSessionValues[sessionKey]); } return(null); }
public ResourcesService(IMemoryCache cache, IMapper mapper, ISessionBagService sessionBag, IUtilitiesManager client, IUserSessionService userSessionService, IOptions <AppSettings> appSettings, IOptions <AppSettings> airlineSettings) : base(appSettings) { _cache = cache ?? throw new ArgumentNullException(nameof(cache));; _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); _sessionBag = sessionBag ?? throw new ArgumentNullException(nameof(sessionBag)); _client = client ?? throw new ArgumentNullException(nameof(client)); _userSessionService = userSessionService ?? throw new ArgumentNullException(nameof(userSessionService)); _airlineSettings = airlineSettings != null && airlineSettings.Value != null ? airlineSettings.Value : throw new ArgumentNullException(nameof(airlineSettings)); }
public TestController(IPaymentsService paymentService, ISessionBagService sessionBag, IUserSessionService userSessionService, IMapper mapper, IPassengersService passengersService, IBookingService bookingService, IFlightsService flightService, IContactsService contactsService, IHttpContextAccessor httpContextAccessor, IQueueService queueService) { _paymentService = paymentService; _mapper = mapper; _flightsService = flightService; _contactsService = contactsService; _passengersService = passengersService; _bookingService = bookingService; _sessionBag = sessionBag; _userSessionService = userSessionService; _httpContextAccessor = httpContextAccessor; _queueService = queueService; }
public FlightsService(ISessionBagService sessionBag, IUserSessionService userSessionService, IBookingManager client, IResourcesService resourcesService, IBookingService bookingService, ILogger <FlightsService> logger, IOptions <AppSettings> appSettings, IPassengersService passengerService, ISsrsService ssrsService) : base(appSettings) { _sessionBag = sessionBag ?? throw new ArgumentNullException(nameof(sessionBag)); _userSessionService = userSessionService ?? throw new ArgumentNullException(nameof(userSessionService)); _resourcesService = resourcesService ?? throw new ArgumentNullException(nameof(resourcesService)); _bookingService = bookingService ?? throw new ArgumentNullException(nameof(bookingService)); _bookingSettings = appSettings.Value.AvailabilitySettings; _passengerService = passengerService ?? throw new ArgumentNullException(nameof(passengerService)); _ssrsService = ssrsService ?? throw new ArgumentNullException(nameof(ssrsService)); _perfLogSettings = appSettings.Value.PerformanceLoggingSettings ?? throw new ArgumentNullException(nameof(appSettings)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _client = client ?? throw new ArgumentNullException(nameof(client)); }
public static async Task SetCustomSessionValue(this ISessionBagService sessionBagService, string sessionKey, string value) { var customSessionValues = await sessionBagService.CustomSessionValues(); if (customSessionValues == null) { customSessionValues = new Dictionary <string, string>(); } if (customSessionValues.ContainsKey(sessionKey)) { customSessionValues[sessionKey] = value; } else { customSessionValues.Add(sessionKey, value); } await sessionBagService.SetCustomSessionValues(customSessionValues); }
public UserSessionService(IMemoryCache cache, ISessionBagService sessionBag, IAgentManager agentClient, IPersonManager personClient, nsk.ISessionManager client, IMapper mapper, IHttpContextAccessor httpContextAccessor, IOptions <AppSettings> appSettings) : base(appSettings) { _cache = cache ?? throw new ArgumentNullException(nameof(cache)); _sessionBag = sessionBag ?? throw new ArgumentNullException(nameof(sessionBag)); _agentClient = agentClient ?? throw new ArgumentNullException(nameof(agentClient)); _personClient = personClient ?? throw new ArgumentNullException(nameof(personClient)); _client = client ?? throw new ArgumentNullException(nameof(client)); _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); _defLogonRequestData = new LogonRequestData { DomainCode = _newskiesSettings.AgentDomain, AgentName = _newskiesSettings.AnonymousAgentName, Password = _newskiesSettings.AnonymousAgentPassword, RoleCode = _newskiesSettings.AnonymousAgentRole }; var localIpAddress = Task.Run(async() => await httpContextAccessor.HttpContext.GetServerIP()).Result; _sharedSignatureCacheKey = "_sharedSignature_" + localIpAddress.ToString(); _newskiesIdleTimeout = appSettings.Value.ApplicationSessionOptions != null ? appSettings.Value.ApplicationSessionOptions.NewskiesIdleTimeout : throw new ArgumentNullException(nameof(appSettings.Value.ApplicationSessionOptions)); }
public CheckinService(ISessionBagService sessionBag, IOperationManager client, IOptions <AppSettings> appSettings) : base(appSettings) { _sessionBag = sessionBag ?? throw new ArgumentNullException(nameof(sessionBag)); _client = client ?? throw new ArgumentNullException(nameof(client)); }
public SessionController(ISessionBagService sessionBag, IUserSessionService userSessionService) { _sessionBag = sessionBag ?? throw new ArgumentNullException(nameof(sessionBag)); _userSessionService = userSessionService ?? throw new ArgumentNullException(nameof(userSessionService)); }
public AccountService(ISessionBagService sessionBag, IAccountManager accountClient, IOptions <AppSettings> appSettings) : base(appSettings) { _sessionBag = sessionBag ?? throw new ArgumentNullException(nameof(sessionBag)); _accountClient = accountClient ?? throw new ArgumentNullException(nameof(accountClient)); }
private async Task ValidateTravelDoc(PassengerTravelDocument doc, Booking booking, string nationalityCode, List <string> comments, ISessionBagService sessionBag, Dictionary <string, string> settings, IMemoryCache cache) { if (comments != null && comments.Count > 0) { var existingComment = comments.Find( c => c.StartsWith(_commentPrefix) && c.Contains("DocNum=" + doc.DocNumber)); if (!string.IsNullOrEmpty(existingComment)) { return; } } if (booking.BookingComments != null && booking.BookingComments.Length > 0) { var existingComment = booking.BookingComments.ToList().Find( c => c.CommentText.StartsWith(_commentPrefix) && c.CommentText.Contains("DocNum=" + doc.DocNumber)); if (existingComment != null) { return; } } var isRestingFromYakeenChecks = cache.Get <bool>("Yakeen_RestingFromChecks"); if (isRestingFromYakeenChecks) { // dont do yakeen check var newComment = string.Format("NotPerformed. Tries=0, DocNum={0}, DocType={1}, Reason={2}", doc.DocNumber, doc.DocTypeCode, "Excessive service timeouts"); await StoreBookingComment(newComment, sessionBag, comments); return; } var yakeenCountSessionKey = string.Format("yakeenCountSession_{0}_{1}", doc.DocNumber, doc.DocTypeCode); var sessionStr = await sessionBag.GetCustomSessionValue(yakeenCountSessionKey) ?? "0"; int.TryParse(sessionStr, out int validationFailureCount); if (!int.TryParse(settings["YakeenMaxFailures"], out int yakeenMaxFailures)) { yakeenMaxFailures = 2; } if (validationFailureCount >= yakeenMaxFailures) { return; } try { var logId = await ValidateAtYakeen(doc, nationalityCode, settings["YakeenUsername"], settings["YakeenPassword"], settings["YakeenChargeCode"], settings["YakeenServiceUrl"], settings["YakeenTimeoutSeconds"]); if (logId == 0) // 0 means no validation was required at yakeen therefore not performed { return; } var newComment = string.Format("Success. LogId={0}, DocNum={1}, DocType={2}", logId, doc.DocNumber, doc.DocTypeCode); await StoreBookingComment(newComment, sessionBag, comments); } catch (Exception e) { validationFailureCount++; Logger logger = LogManager.GetCurrentClassLogger(); logger.Warn(string.Format("[{0}] Tries={1}, DocNum={2}, DocType={3} Reason={4}", ResponseErrorCode.TravelDocumentValidationFailure.ToString(), validationFailureCount, doc.DocNumber, doc.DocTypeCode, e.Message)); sessionBag.SetCustomSessionValue(yakeenCountSessionKey, validationFailureCount.ToString()).GetAwaiter().GetResult(); var isTimeout = e is TimeoutException || (e.InnerException != null && e.InnerException is TimeoutException); if (validationFailureCount >= yakeenMaxFailures) { var reason = isTimeout ? "Query timeout" : e.Message; var newComment = string.Format("Failed. Tries={0}, DocNum={1}, DocType={2}, Reason={3}", validationFailureCount, doc.DocNumber, doc.DocTypeCode, reason); await StoreBookingComment(newComment, sessionBag, comments); return; } if (isTimeout) { if (!int.TryParse(settings["YakeenExcessiveTimeoutCount"], out int excessiveTimeoutCountSetting)) { excessiveTimeoutCountSetting = 20; } if (!int.TryParse(settings["YakeenExcessiveTimeoutRestSeconds"], out int excessiveTimeoutRestSecondsSetting)) { excessiveTimeoutRestSecondsSetting = 3600; } if (!int.TryParse(settings["YakeenExcessiveTimeoutPeriodSeconds"], out int excessiveTimeoutPeriodSecondsSetting)) { excessiveTimeoutPeriodSecondsSetting = 300; } lock (_syncRoot) { var timePeriodIsRunning = cache.Get <bool>("Yakeen_PeriodIsRunning"); var globalTimeoutCount = timePeriodIsRunning ? cache.Get <int>("Yakeen_GlobalTimeoutCount") + 1 : 1; cache.Set("Yakeen_GlobalTimeoutCount", globalTimeoutCount); if (timePeriodIsRunning) { if (globalTimeoutCount >= excessiveTimeoutCountSetting) { cache.Set("Yakeen_RestingFromChecks", true, new TimeSpan(0, 0, excessiveTimeoutRestSecondsSetting)); cache.Remove("Yakeen_GlobalTimeoutCount"); cache.Remove("Yakeen_PeriodIsRunning"); } } else { cache.Set("Yakeen_PeriodIsRunning", true, new TimeSpan(0, 0, excessiveTimeoutPeriodSecondsSetting)); } } } throw; } }
private async Task ValidateTravelDocsAtYakeen(Dictionary <string, string> settings, UpdatePassengersRequestData requestData, ActionExecutingContext context, ISessionBagService sessionBag, Booking booking, Passenger[] passengers) { if (settings == null) { return; } if (!settings.ContainsKey("YakeenCheckEnabled") || string.IsNullOrEmpty(settings["YakeenCheckEnabled"])) { return; } bool.TryParse(settings["YakeenCheckEnabled"], out bool yakeenCheckEnabled); if (!yakeenCheckEnabled) { return; } if (!settings.ContainsKey("YakeenMaxFailures") || string.IsNullOrEmpty(settings["YakeenMaxFailures"]) || !settings.ContainsKey("YakeenServiceUrl") || string.IsNullOrEmpty(settings["YakeenServiceUrl"]) || !settings.ContainsKey("YakeenTimeoutSeconds") || string.IsNullOrEmpty(settings["YakeenTimeoutSeconds"]) || !settings.ContainsKey("YakeenUsername") || string.IsNullOrEmpty(settings["YakeenUsername"]) || !settings.ContainsKey("YakeenPassword") || string.IsNullOrEmpty(settings["YakeenPassword"]) || !settings.ContainsKey("YakeenChargeCode") || string.IsNullOrEmpty(settings["YakeenChargeCode"]) || !settings.ContainsKey("YakeenExcessiveTimeoutCount") || string.IsNullOrEmpty(settings["YakeenExcessiveTimeoutCount"]) || !settings.ContainsKey("YakeenExcessiveTimeoutPeriodSeconds") || string.IsNullOrEmpty(settings["YakeenExcessiveTimeoutPeriodSeconds"]) || !settings.ContainsKey("YakeenExcessiveTimeoutRestSeconds") || string.IsNullOrEmpty(settings["YakeenExcessiveTimeoutRestSeconds"])) { throw new ResponseErrorException(ResponseErrorCode.InternalException, "Missing document validation settings. "); } var cache = context.HttpContext.RequestServices.GetService(typeof(IMemoryCache)) as IMemoryCache; var comments = await sessionBag.PostCommitBookingComments(); var invalid = false; foreach (var pax in passengers) { if (pax.PassengerTravelDocuments != null) { foreach (var doc in pax.PassengerTravelDocuments) { try { await ValidateTravelDoc(doc, booking, pax.PassengerInfo.Nationality, comments, sessionBag, settings, cache); } catch { invalid = true; } } } } if (invalid) { throw new ResponseErrorException(ResponseErrorCode.TravelDocumentValidationFailure, "Unable to validate travel document. Please try again. "); } }