public static string GetLanguage(string applicationId, string langId) { var filePath = Path.Combine(LanguageFilesPath, applicationId, langId + ".json"); var language = JsonFileHelper.GetFileContents(filePath) ?? string.Empty; return(language); }
public MoAndLocationRepository() { var jsonData = JsonFileHelper.GetFileContents(_configurationFilePath); MoAndLocations = !string.IsNullOrEmpty(jsonData) ? JsonProcessor.DeserializeObject <MoAndLocationsData>(jsonData): new MoAndLocationsData(); }
public static string LanguageList(string applicationId) { var filePath = Path.Combine(LanguageFilesPath, applicationId, "languages.json"); var languages = JsonFileHelper.GetFileContents(filePath) ?? string.Empty; return(languages); }
public static TResponse GetTransactionLookupStatusResponse <TResponse>(string referenceNumber, Func <TrainingModeResponses, string> getFileName) { var instance = GetConfiguration(); var scenario = instance.Scenarios.SingleOrDefault(x => x.ReferenceNumber == referenceNumber && getFileName(x.Responses) != null); if (scenario?.Responses == null) { throw new TrainingModeException("STRKEY_TRAINING_ERROR_EDIT_TRAN_REF_NUMBER"); } var responseFilePath = Path.Combine(JsonFileHelper.ExecutingDir(), TrainingModeFolderName, scenario.SessionType.ToString(), referenceNumber ?? string.Empty, getFileName(scenario.Responses)); if (!File.Exists(responseFilePath)) { throw new FileNotFoundException($"Could not find Training Mode Transaction Lookup Status response file for referenceNumber:{referenceNumber}."); } try { return(JsonProcessor.DeserializeObject <TResponse>(JsonFileHelper.GetFileContents(responseFilePath), true)); } catch (Exception exception) { throw new InvalidDataException($"Could not deserialize Training Mode Transaction Lookup Status response for sessionType:{scenario.SessionType}, referenceNumber:{referenceNumber}.", exception); } }
public EnvironmentAgentRepository() { var jsonData = JsonFileHelper.GetFileContents(_configurationFilePath); Identities = !string.IsNullOrEmpty(jsonData) ? JsonProcessor.DeserializeObject <Dictionary <string, List <EnvironmentAgent> > >(jsonData) : null; Identities = Identities ?? new Dictionary <string, List <EnvironmentAgent> >(); }
private static UserSettings ReadSettingsFromFile() { var userSettingsFileContents = JsonFileHelper.GetFileContents(UserConfigFilePath); UserSettings settings = null; if (userSettingsFileContents != null) { settings = JsonConvert.DeserializeObject <UserSettings>(userSettingsFileContents); } return(settings); }
public EnvironmentRepository() { var jsonData = JsonFileHelper.GetFileContents(_configurationFilePath); Environments = !string.IsNullOrEmpty(jsonData) ? JsonProcessor.DeserializeObject <AcEnvironment>(jsonData)?.Environments .ToDictionary(x => x, x => x) : null; Environments = Environments ?? new Dictionary <string, string>(); }
public ServiceOptionRepository() { var jsonData = JsonFileHelper.GetFileContents(_configurationFilePath); ServiceOptions = !string.IsNullOrEmpty(jsonData) ? JsonProcessor.DeserializeObject <Dictionary <string, List <ServiceOption> > >(jsonData) .FirstOrDefault().Value? .ToDictionary(x => x.Code, x => x) : null; ServiceOptions = ServiceOptions ?? new Dictionary <string, ServiceOption>(); }
public RefundReasonRepository() { var jsonData = JsonFileHelper.GetFileContents(_configurationFilePath); RefundReasons = !string.IsNullOrEmpty(jsonData) ? JsonProcessor.DeserializeObject <Dictionary <string, List <EnumeratedIdentifierInfo> > >(jsonData) .FirstOrDefault().Value? .ToDictionary(x => x.Identifier, x => x) : null; RefundReasons = RefundReasons ?? new Dictionary <string, EnumeratedIdentifierInfo>(); }
public CountrySubdivisionRepository() { var jsonData = JsonFileHelper.GetFileContents(_configurationFilePath); Subdivisions = !string.IsNullOrEmpty(jsonData) ? JsonProcessor.DeserializeObject <Dictionary <string, List <CountrySubdivisionInfo> > >(jsonData) .FirstOrDefault().Value? .ToDictionary(x => x.CountryCode, x => x.Subdivisions) : null; Subdivisions = Subdivisions ?? new Dictionary <string, List <SubdivisionInfo> >(); }
public CurrencyRepository() { var jsonData = JsonFileHelper.GetFileContents(_configurationFilePath); Currencies = !string.IsNullOrEmpty(jsonData) ? JsonProcessor.DeserializeObject <Dictionary <string, List <CurrencyInfo> > >(jsonData) .FirstOrDefault().Value? .ToDictionary(x => x.CurrencyCode, x => x) : null; Currencies = Currencies ?? new Dictionary <string, CurrencyInfo>(); }
public AmountRangeRepository() { var jsonData = JsonFileHelper.GetFileContents(_configurationFilePath); AmountRanges = !string.IsNullOrEmpty(jsonData) ? JsonProcessor.DeserializeObject <Dictionary <string, List <AmountRange> > >(jsonData) .FirstOrDefault().Value? .ToDictionary(x => x.Code, x => x) : null; AmountRanges = AmountRanges ?? new Dictionary <string, AmountRange>(); }
/// <summary> /// Gets response for training mode scenario step specified by parameters /// </summary> /// <typeparam name="TResponse">Type of response to be deserialized</typeparam> /// <param name="sessionType">Type of session</param> /// <param name="referenceNumber">Reference number / MGI Session Id</param> /// <param name="getFileName">Expression to get required file name from TrainingModeResponses object</param> /// <returns>Response object if response is found, otherwise exception is thrown.</returns> public static TResponse GetResponse <TResponse>(SessionType?sessionType, string referenceNumber, Func <TrainingModeResponses, string> getFileName) { if ((sessionType == SessionType.SEND || sessionType == SessionType.BP) && referenceNumber != null && !IsStagedTransaction(sessionType, referenceNumber)) { referenceNumber = null; } TrainingModeConfiguration instance = GetConfiguration(); TrainingModeResponses responses = instance.Scenarios.SingleOrDefault(x => x.SessionType == sessionType && x.ReferenceNumber == referenceNumber)?.Responses; if (responses != null) { string sessionTypePath = sessionType != null?sessionType.ToString() : "AllTypes"; string responseFilePath = Path.Combine(JsonFileHelper.ExecutingDir(), TrainingModeFolderName, sessionTypePath, referenceNumber ?? string.Empty, getFileName(responses)); if (File.Exists(responseFilePath)) { try { return(JsonProcessor.DeserializeObject <TResponse>(JsonFileHelper.GetFileContents(responseFilePath), true)); } catch (Exception exception) { throw new InvalidDataException($"Could not deserialize Training Mode response for sessionType:{sessionType}, referenceNumber:{referenceNumber}.", exception); } } } else { switch (sessionType) { case SessionType.AMD: throw new TrainingModeException("STRKEY_TRAINING_ERROR_AMEND_REF_NUMBER"); case SessionType.SREV: throw new TrainingModeException("STRKEY_TRAINING_ERROR_SREV_REF_NUMBER"); case SessionType.RCV: throw new TrainingModeException("STRKEY_TRAINING_ERROR_RCV_REF_NUMBER"); } } throw new FileNotFoundException($"Could not find Training Mode response file for sessionType:{sessionType}, referenceNumber:{referenceNumber}."); }
private static TrainingModeConfiguration GetConfiguration() { if (!File.Exists(ConfigurationPath)) { throw new FileNotFoundException($"Could not find Training Mode configuration file under path: {ConfigurationPath}."); } try { return(JsonProcessor.DeserializeObject <TrainingModeConfiguration>(JsonFileHelper.GetFileContents(ConfigurationPath))); } catch (Exception exception) { throw new InvalidDataException($"Could not deserialize Training Mode configuration file under path: {ConfigurationPath}.", exception); } }
public static Dictionary <string, string> GetLanguages(string applicationId, Dictionary <string, DateTime> requestedLanguages) { var allLangFiles = Directory.GetFiles(Path.Combine(LanguageFilesPath, applicationId), "??-??.json", SearchOption.AllDirectories); var langFilesToReturn = requestedLanguages == null ? new List <string>(allLangFiles) : new List <string>(); if (requestedLanguages != null) { foreach (var langFile in allLangFiles) { var langCode = Path.GetFileNameWithoutExtension(langFile); if (requestedLanguages.ContainsKey(langCode)) { var versionNewer = requestedLanguages[langCode] == null ? true : File.GetLastWriteTime(langFile) > requestedLanguages[langCode]; if (versionNewer) { langFilesToReturn.Add(langFile); } } } } var languages = new Dictionary <string, string>(); foreach (var langFileName in langFilesToReturn) { var filePath = Path.Combine(LanguageFilesPath, applicationId, langFileName); var fileContents = JsonFileHelper.GetFileContents(filePath); if (fileContents != null) { languages.Add(Path.GetFileNameWithoutExtension(Path.Combine(LanguageFilesPath, applicationId, langFileName)), fileContents); } } return(languages); }