/// <summary> /// Creates a new instance of the <see cref="Controller"/> class. /// </summary> public Controller() { globals = Globals.Instance(); log = new QueueEventLogger(100); crawler = null; stats = new long[10]; proxy = CrawlWaveServerProxy.Instance(globals); }
/// <summary> /// Performs the update of the Client's version. It queries an available server for /// the latest version and if a new version exists it goes on with the update. /// </summary> private void UpdateClient() { try { while (!InternetUtils.ConnectedToInternet()) { Thread.Sleep(updateBackoff.Next()); } //proxy = WebServiceProxy.Instance(); proxy = CrawlWaveServerProxy.Instance(globals); string latest = String.Empty; SerializedException sx = proxy.SendLatestVersion(globals.Client_Info, out latest); if (sx != null) { globals.SystemLog.LogError("CrawlWave Client Scheduler failed to retrieve the latest version of the Client:" + sx.Message); return; } Version latestVersion = new Version(latest); if (GetClientVersion() < latestVersion) { //we must update the client. First of all download the update. updating = true; byte [] buffer = new byte[0]; sx = proxy.SendUpdatedVersion(globals.Client_Info, latest, out buffer); if (sx != null || buffer.Length == 0) { globals.SystemLog.LogError("CrawlWave Client Scheduler failed to retrieve the latest version of the Client: " + sx.Message); updating = false; return; } //save the compressed file to disk. If necessary launch the installer. string updateFileName = globals.AppPath + latest + ".zip"; FileStream outputStream = new FileStream(updateFileName, FileMode.Create); outputStream.Write(buffer, 0, buffer.Length); outputStream.Close(); string mustLaunchInstaller = ExtractUpdatedFiles(updateFileName); if (mustLaunchInstaller != String.Empty) { //Launch Installer and exit Process.Start(mustLaunchInstaller); } } } catch {} finally { updating = false; } }
private Globals globals; //Provides access to the global variables and application settings #endregion #region Constructor and Singleton Instance Members /// <summary> /// The constructor is private so that only the class itself can create an instance. /// </summary> private HostBanFilter() { //Initialize the storage for the banned host entries hostTable = new Hashtable(); //Get a reference to the global variables and application settings globals = Globals.Instance(); //Initialize the list of banned hosts //proxy = WebServiceProxy.Instance(); proxy = CrawlWaveServerProxy.Instance(globals); InitializeBannedHosts(); }