internal static ConfigurationSet GetConfiguration(string id, string env, string localFile, bool skipSave = false) { ConfigurationSet configData; var req = WebRequest.Create(CreateRequestUriString(id, env)) as HttpWebRequest; req.Method = "GET"; req.Accept = "application/json"; req.ContentType = "application/json"; req.Headers.Add("Accept-Language", "en-us"); req.UserAgent = "StardustProxy/1.0"; req.Credentials = new NetworkCredential( ConfigurationManagerHelper.GetValueOnKey("stardust.configUser"), ConfigurationManagerHelper.GetValueOnKey("stardust.configPassword"), ConfigurationManagerHelper.GetValueOnKey("stardust.configDomain")); req.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip; var resp = req.GetResponse(); using (var reader = new StreamReader(resp.GetResponseStream())) { configData = JsonConvert.DeserializeObject <ConfigurationSet>(reader.ReadToEnd()); if (!skipSave) { ConfigCacheHelper.UpdateCache(localFile, configData, new ConfigWrapper { Set = configData, Environment = env, Id = id }); } } return(configData); }
public static void UpdateConfigSets() { Logging.DebugMessage("Updating files"); var configSets = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "\\App_Data"); foreach (var configSet in configSets) { var cs = JsonConvert.DeserializeObject <ConfigWrapper>(File.ReadAllText(configSet)); var newConfigSet = ConfigCacheHelper.GetConfiguration(cs.Id, cs.Environment, configSet, true); ConfigCacheHelper.UpdateCache(configSet, newConfigSet, cs); } }