public void WriteCSV <T>(IList <T> collection, string fileNameWithoutExtension, string rootDir) { var filePath = ComputeFilePath(rootDir, string.Format("{0}.csv", fileNameWithoutExtension)); var repository = new CSVFileRepository <T>(filePath); repository.WriteData(collection); }
private static IDictionary<string, string> BuildCountriesDictionnary() { string message = string.Empty; var repository = new CSVFileRepository<CountryEntity>(CountriesLabelsAndCodesFileName); if (!repository.TestDbAccess(ref message)) { Logging.Logging.Instance.LogError( string.Format("Une erreur est survenue lors du chargement du dictionnaire des pays : {0}", message), ErrorLevel.Error); } return repository.GetData().ToDictionary(countryEntity => countryEntity.CountryName, countryEntity => countryEntity.CountryCode); }
private static IDictionary <string, string> GetReplacementValuesFromFile(string fileName) { string message = string.Empty; var repository = new CSVFileRepository <ReplacementEntity>(fileName); if (!repository.TestDbAccess(ref message)) { Logging.Logging.Instance.LogError(string.Format("Une erreur est survenue lors du chargement du dictionnaire '{0}': {1}", fileName, message), ErrorLevel.Error); } var dic = repository.GetData().ToDictionary(x => x.ValueToReplace.ToUpperInvariant(), x => x.ReplacementValue.ToUpperInvariant()); return(dic); }
private static IDictionary <string, string> BuildCountriesDictionnary() { string message = string.Empty; var repository = new CSVFileRepository <CountryEntity>(CountriesLabelsAndCodesFileName); if (!repository.TestDbAccess(ref message)) { Logging.Logging.Instance.LogError( string.Format("Une erreur est survenue lors du chargement du dictionnaire des pays : {0}", message), ErrorLevel.Error); } return(repository.GetData().ToDictionary(countryEntity => countryEntity.CountryName, countryEntity => countryEntity.CountryCode)); }
public static bool TryBuildProvider(string fileName, out IMIRecordsProvider provider) { if (string.IsNullOrEmpty(fileName)) { provider = null; return false; } string message = null; var res = new CSVFileRepository<MIDBRecord>(fileName).TestDbAccess(ref message); if (!res) { Logging.Logging.Instance.LogError(message, ErrorLevel.Error); provider = null; return false; } provider = new CSVFileProvider(fileName); return true; }
public static bool TryBuildProvider(string fileName, out IMIRecordsProvider provider) { if (string.IsNullOrEmpty(fileName)) { provider = null; return(false); } string message = null; var res = new CSVFileRepository <MIDBRecord>(fileName).TestDbAccess(ref message); if (!res) { Logging.Logging.Instance.LogError(message, ErrorLevel.Error); provider = null; return(false); } provider = new CSVFileProvider(fileName); return(true); }
private static IDictionary<string, string> GetReplacementValuesFromFile(string fileName) { string message = string.Empty; var repository = new CSVFileRepository<ReplacementEntity>(fileName); if (!repository.TestDbAccess(ref message)) { Logging.Logging.Instance.LogError(string.Format("Une erreur est survenue lors du chargement du dictionnaire '{0}': {1}", fileName, message), ErrorLevel.Error); } var dic = repository.GetData().ToDictionary(x => x.ValueToReplace.ToUpperInvariant(), x => x.ReplacementValue.ToUpperInvariant()); return dic; }
private CSVFileProvider(string fileName) { _miRecordsRepository = new CSVFileRepository<MIDBRecord>(fileName); }
private CSVFileProvider(string fileName) { _miRecordsRepository = new CSVFileRepository <MIDBRecord>(fileName); }