예제 #1
0
        /// <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;
            }
        }
예제 #2
0
        /// <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;
            }
        }