/// <summary> /// Writes an error to the error log /// </summary> /// <param name="errorToLog">The error to write</param> public static void LogError(string errorToLog) { string path = FilePathSystem.GetFilePath("Logs", "Error"); using (StreamWriter w = new StreamWriter(path, true)) { w.WriteLine(errorToLog); } }
public static string GetFileJSON(string filePath, string fileName) { string specsPath = FilePathSystem.GetFilePath(filePath, fileName); string json = null; if (File.Exists(specsPath)) { using (StreamReader r = new StreamReader(specsPath)) { json = r.ReadToEnd(); } } return(json); }
private static string GetSecretKey() { // Find the location for the secret key we're using string[] secretKeyFileLocation = new string[2]; // Check if the secret key location has been set correctly... if (ConfigurationManager.AppSettings.Get("CryptoKeyLocation") == null) { // .. if not use the default location. secretKeyFileLocation[0] = "Misc"; secretKeyFileLocation[1] = "HashKey"; } else { secretKeyFileLocation = ConfigurationManager.AppSettings.Get("CryptoKeyLocation").Split('|'); } // Load the char names list into memory string path = FilePathSystem.GetFilePath(secretKeyFileLocation[0], secretKeyFileLocation[1]); CryptoSecret secretKey = new CryptoSecret(); if (File.Exists(path)) { using (StreamReader r = new StreamReader(path)) { string json = r.ReadToEnd(); secretKey = JsonConvert.DeserializeObject <CryptoSecret>(json); } } if (secretKey.key != null) { return(secretKey.key); } else { return("No key file found!"); } }
public static string GetWebHookToken(string serviceName) { // Variable for the return string string returnString = ""; // Get the right path, and work out if the file exists. string path = FilePathSystem.GetFilePath("SlackWebHooks", "SlackWebHook_" + serviceName); // Check if the file exists if (!File.Exists(path)) { // If they don't exist inform the requestee as to how to create a new integration returnString = "Can't find custom integration file, please create one."; // TODO Implement a way for people to create these. } else { // Load the Token Details SlackWebHook swh = new SlackWebHook(); // Use a stream reader to read the file in (based on the path) using (StreamReader r = new StreamReader(path)) { // Create a new JSON string to be used... string json = r.ReadToEnd(); // ... get the informaiton from the the room information. swh = JsonConvert.DeserializeObject <SlackWebHook>(json); // Return the room description, exits, people and objects returnString = swh.Token; } } // Return the text output return(returnString); }