Beispiel #1
0
 Task TrackerPost(string queryString, MJDict body)
 {
     return(http.PostAsync(config["trackerBaseUrl"] + "/api" + queryString,
                           new StringContent(MiniJson.ToString(body), Encoding.UTF8, "application/json")
                           ).ContinueWith(c => {
         if (c.Exception != null)
         {
             AddMessage("Warning: Exception occurred while attempting to communicate with the tracker: " + c.Exception.ToString());
         }
     }, TaskContinuationOptions.OnlyOnFaulted));
 }
Beispiel #2
0
        // Mastro: This saves a JSON config file to a Olproxy application data folder (needed if no external Olproxy.exe is found).
        public bool SaveConfig(Dictionary <string, object> saveConfig, string alternateFileName = null)
        {
            string configPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Olproxy");

            if (Directory.Exists(configPath) == false)
            {
                Directory.CreateDirectory(configPath);
            }

            string configFileName = Path.Combine(configPath, "appsettings.json");
            string jsonString     = MiniJson.ToString(saveConfig);

            try { File.WriteAllText(configFileName, jsonString); } catch { return(false); }

            // Optionall update the appsettings.json placed in the same directory as Olproxy.exe.
            if (!String.IsNullOrEmpty(alternateFileName))
            {
                try { File.WriteAllText(alternateFileName, jsonString); } catch { return(false); }
            }

            return(true);
        }