/// <summary> ///Get error message /// </summary> /// <param name="string locale">Locale to use - Example: en-us</param> /// <param name="IExceptionHandler exceptionHandler">Exception handler - if null default will be used</param> /// <returns>String</returns> public string getException(string locale, string exceptionId) { string message = ""; //Check if the locale is set and set to default if not if (String.IsNullOrEmpty(locale)) { locale = "en-us"; } //Get path where to fin the transltions files string localesPath = new InternalConfigurations().localesFolderPath; //Get Configuration file path string configPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Combine the locale file path string path = configPath + localesPath + locale + ".txt"; //Get all translations string allTranslations = File.ReadAllText(new Uri(path).LocalPath); //Select required translation var translationsDictionary = allTranslations.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries).Select(part => part.Split('=')) .ToDictionary(split => split[0], split => split[1]); message = translationsDictionary[exceptionId]; //Return error message return(message); }
/// <summary> ///Create a directory for the input files /// </summary> /// <param name="string operationId">Id of the opperation - used as a sub folder name</param> /// <returns>string</returns> private string getDirectory(string operationId) { try { //Get configuration options string configurationFilePath = new InternalConfigurations().configurationFilePath; string configPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); new ConfigLoader(configPath + configurationFilePath).LoadConfigs(Configs); string path = String.Concat(Configs.workingdirectory, "/" + operationId + "/", Configs.inputdirname); //Create sub folder original in the temppath folder DirectoryInfo di = new DirectoryInfo(path); try { di.Create(); return(di.FullName); } catch (DocumentsToolsException) { throw new GdtFileNotFoundException(locale, this.exceptionHandler); } } catch (DocumentsToolsException) { throw new GdtNullReferenceException(locale, this.exceptionHandler); } }