コード例 #1
0
 public void InvalidAllConfigs()
 {
     RemoteConfigSectionCollection lstParams = new RemoteConfigSectionCollection(this.config.ApplicationName);
     lock (this.configLocker)
     {
         foreach (ConfigEntry entry in this.configEntries.Values)
         {
             if (entry.IsSet)
             {
                 lstParams.AddSection(entry.Name, entry.MajorVersion, entry.MinorVersion);
             }
         }
     }
     this.InvalidConfigs(lstParams);
 }
コード例 #2
0
 public void InvalidConfig(string name, int majorVersion)
 {
     RemoteConfigSectionCollection lstParams = new RemoteConfigSectionCollection(this.config.ApplicationName);
     lock (this.configLocker)
     {
         foreach (ConfigEntry entry in this.configEntries.Values)
         {
             if (entry.Name == name)
             {
                 if (entry.IsSet && entry.MajorVersion == majorVersion)
                 {
                     int arg_63_0 = entry.MinorVersion;
                     lstParams.AddSection(entry.Name, entry.MajorVersion, entry.MinorVersion);
                     break;
                 }
                 break;
             }
         }
     }
     this.InvalidConfigs(lstParams);
 }
コード例 #3
0
 private void TimerCallback(object sender, ElapsedEventArgs args)
 {
     RemoteConfigSectionCollection lstParams = new RemoteConfigSectionCollection(this.config.ApplicationName);
     lock (this.configLocker)
     {
         foreach (ConfigEntry entry in this.configEntries.Values)
         {
             if (entry.IsSet)
             {
                 lstParams.AddSection(entry.Name, entry.MajorVersion, entry.MinorVersion);
             }
         }
     }
     if (lstParams.Count == 0)
     {
         return;
     }
     lstParams = this.GetServerVersions(lstParams);
     if (lstParams.Count == 0)
     {
         return;
     }
     foreach (RemoteConfigSectionParam param in lstParams.Sections)
     {
         System.Threading.ThreadPool.QueueUserWorkItem(delegate (object obj)
         {
             RemoteConfigurationManager.DownloadParam dp = (RemoteConfigurationManager.DownloadParam)obj;
             RemoteConfigurationManager.Download(dp.Name, dp.Url, dp.LocalPath, dp.Checker);
         }, new RemoteConfigurationManager.DownloadParam(param.SectionName, param.DownloadUrl, this.GetPath(param.SectionName), new RemoteConfigurationManager.DownloadChecker(this.CheckDownloadStream)));
     }
 }
コード例 #4
0
 private void TimerCallback(object stat = null)
 {
     try
     {
         RemoteConfigSectionCollection lstParams = new RemoteConfigSectionCollection(this.config.ApplicationName);
         lock (this.configLocker)
         {
             foreach (ConfigEntry entry in this.configEntries.Values)
             {
                 if (entry.IsSet)
                 {
                     lstParams.AddSection(entry.Name, entry.MajorVersion, entry.MinorVersion);
                 }
             }
         }
         if (lstParams.Count != 0)
         {
             lstParams = this.GetServerVersions(lstParams);
             if (lstParams.Count != 0)
             {
                 BaseConfigurationManager.Log(string.Format("获得新的配置文件:SectionName:{0} MajorVersion:{1} MinorVersion:{2}", lstParams[0].SectionName, lstParams[0].MajorVersion, lstParams[0].MinorVersion));
                 foreach (RemoteConfigSectionParam param in lstParams.Sections)
                 {
                     System.Threading.ThreadPool.QueueUserWorkItem(delegate (object obj)
                     {
                         RemoteConfigurationManager.DownloadParam dp = (RemoteConfigurationManager.DownloadParam)obj;
                         RemoteConfigurationManager.Download(dp.Name, dp.Url, dp.LocalPath, dp.Checker);
                     }, new RemoteConfigurationManager.DownloadParam(param.SectionName, param.DownloadUrl, this.GetPath(param.SectionName), new RemoteConfigurationManager.DownloadChecker(this.CheckDownloadStream)));
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         BaseConfigurationManager.Log(ex.ToString());
     }
     finally
     {
         this.timer.Change(this.config.TimerInterval, -1);
     }
 }
コード例 #5
0
 private void InvalidConfigs(RemoteConfigSectionCollection lstParams)
 {
     if (lstParams.Count == 0)
     {
         return;
     }
     RemoteConfigSectionCollection newParams = this.GetServerVersions(lstParams);
     if (newParams.Count == 0)
     {
         return;
     }
     System.Collections.Generic.Dictionary<string, RemoteConfigSectionParam> tblOldParam = new System.Collections.Generic.Dictionary<string, RemoteConfigSectionParam>(lstParams.Count);
     foreach (RemoteConfigSectionParam item in lstParams)
     {
         tblOldParam.Add(item.SectionName, item);
     }
     foreach (RemoteConfigSectionParam param in newParams.Sections)
     {
         string localPath = this.GetPath(param.SectionName);
         if (!RemoteConfigurationManager.Download(param.SectionName, param.DownloadUrl, localPath, new RemoteConfigurationManager.DownloadChecker(this.CheckDownloadStream)))
         {
             throw new ConfigurationErrorsException(string.Concat(new string[]
             {
                 "Unabled to download '",
                 param.DownloadUrl,
                 "' to '",
                 localPath,
                 "'"
             }));
         }
         FileWatcher.Instance.ProcessFileChanged(localPath);
         BaseConfigurationManager.Log(string.Format("Minor version of config '{0}({1})' has been updated manually from {2} to {3}", new object[]
         {
             param.SectionName,
             param.MajorVersion,
             tblOldParam[param.SectionName].MinorVersion,
             param.MinorVersion
         }));
     }
 }
コード例 #6
0
 private RemoteConfigSectionCollection GetServerVersions(RemoteConfigSectionCollection lstInputParams)
 {
     RemoteConfigSectionCollection result;
     try
     {
         System.IO.MemoryStream ms = new System.IO.MemoryStream();
         XmlSerializer ser = new XmlSerializer(typeof(RemoteConfigSectionCollection));
         ser.Serialize(ms, lstInputParams);
         HttpWebRequest req = (HttpWebRequest)WebRequest.Create(this.config.RemoteConfigurationUrl);
         req.ContentType = "text/xml";
         req.Proxy = null;
         req.Method = "POST";
         req.Timeout = this.config.Timeout;
         req.ReadWriteTimeout = this.config.ReadWriteTimeout;
         req.ContentLength = ms.Length;
         req.ServicePoint.Expect100Continue = false;
         req.ServicePoint.UseNagleAlgorithm = false;
         req.KeepAlive = false;
         using (System.IO.Stream stream = req.GetRequestStream())
         {
             byte[] buf = ms.ToArray();
             stream.Write(buf, 0, buf.Length);
             stream.Close();
         }
         RemoteConfigSectionCollection lstOutput;
         using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse())
         {
             using (System.IO.Stream stream2 = rsp.GetResponseStream())
             {
                 lstOutput = (RemoteConfigSectionCollection)ser.Deserialize(stream2);
                 stream2.Close();
             }
             rsp.Close();
         }
         result = lstOutput;
     }
     catch (System.Exception ex)
     {
         BaseConfigurationManager.HandleException(ex, "Unabled to GetServerVersions from '" + this.config.RemoteConfigurationUrl + "'", "RemoteConfigurationManager");
         result = new RemoteConfigSectionCollection();
     }
     return result;
 }
コード例 #7
0
 private RemoteConfigSectionParam GetServerVersion(string name, int majorVersion)
 {
     RemoteConfigSectionCollection lstParams = new RemoteConfigSectionCollection(this.config.ApplicationName);
     lstParams.AddSection(name, majorVersion, 0);
     lstParams = this.GetServerVersions(lstParams);
     if (lstParams.Count == 0)
     {
         return null;
     }
     return lstParams[0];
 }