Esempio n. 1
0
        public static byte[] Get(string url)
        {
            var f = new Fetch();

            f.Load(url);
            return(f.ResponseData);
        }
Esempio n. 2
0
        private void bwFetchManifest_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                var remoteUri = new Uri(this._localConfig.RemoteConfigUri);

                Log.Write("Fetching '{0}'.", remoteUri.AbsoluteUri);

                var http = new Fetch {
                    Retries = 5, RetrySleep = 30000, Timeout = 30000
                };

                http.Load(remoteUri.AbsoluteUri);

                if (!http.Success)
                {
                    Log.Write("Fetch error: {0}", http.Response.StatusDescription);
                    this._remoteConfig = null;
                    return;
                }

                string data = Encoding.UTF8.GetString(http.ResponseData);
                this._remoteConfig = new Manifest(data);

                if (this._remoteConfig == null)
                {
                    return;
                }

                if (this._localConfig.SecurityToken != this._remoteConfig.SecurityToken)
                {
                    Log.Write("Security token mismatch.");
                    return;
                }

                Log.Write("Remote config is valid.");
                Log.Write("Local version is  {0}.", this._localConfig.Version);
                Log.Write("Remote version is {0}.", this._remoteConfig.Version);

                if (this._remoteConfig.Version == this._localConfig.Version)
                {
                    Log.Write("Versions are the same.");
                    Log.Write("Check ending.");
                    return;
                }

                if (this._remoteConfig.Version < this._localConfig.Version)
                {
                    Log.Write("Remote version is older. That's weird.");
                    Log.Write("Check ending.");
                    return;
                }

                Log.Write("Remote version is newer. Updating.");

                ManifestSuccess = true;
            }

            catch
            {
                ManifestSuccess = false;
            }
        }