private static void requestor_OnRequestCompleted(HttpRequestor sender, bool success, object tag, string url, byte[] data)
        {
            if (success == true)
            {
                // Fetch version information
                int    newversion = 0;
                string updatelink = null;
                try
                {
                    string page = UTF8Encoding.UTF8.GetString(data);
                    string x    = "##" + updatecode.ToString() + "##";
                    x = x.ToUpper();
                    int i = page.IndexOf(x);
                    if (i == -1)
                    {
                        requestor.OnRequestCompleted += new HttpRequestor.RequestCompletedHandler(requestor_OnRequestCompleted);
                        requestor = null;
                        return;
                    }
                    page = page.Substring(i + x.Length);
                    i    = page.IndexOf("##");
                    if (i == -1)
                    {
                        requestor.OnRequestCompleted += new HttpRequestor.RequestCompletedHandler(requestor_OnRequestCompleted);
                        requestor = null;
                        return;
                    }
                    string versionstr = page.Substring(0, i);
                    newversion = int.Parse(versionstr);
                    page       = page.Substring(i + 2);
                    i          = page.IndexOf("##");
                    if (i == -1)
                    {
                        requestor.OnRequestCompleted += new HttpRequestor.RequestCompletedHandler(requestor_OnRequestCompleted);
                        requestor = null;
                        return;
                    }
                    updatelink = page.Substring(0, i);
                }
                catch (Exception ex)
                {
                    OpenSource.Utilities.EventLogger.Log(ex);
                    requestor.OnRequestCompleted += new HttpRequestor.RequestCompletedHandler(requestor_OnRequestCompleted);
                    requestor = null;
                    return;
                }

                // Compare to existing version
                if (existingversion < newversion)
                {
                    updateform = new AutoUpdate(newversion);
                    parentform.Invoke(new System.Threading.ThreadStart(ShowUpdateForm));
                }
            }
            requestor.OnRequestCompleted += new HttpRequestor.RequestCompletedHandler(requestor_OnRequestCompleted);
            requestor = null;
        }
Exemplo n.º 2
0
        private static void requestor_OnRequestCompleted(HttpRequestor sender, bool success, object tag, string url, byte[] data)
        {
            if (success == true)
            {
                // Fetch version information
                int newversion = 0;
                string updatelink = null;
                try
                {
                    string page = UTF8Encoding.UTF8.GetString(data);
                    string x = "##" + updatecode.ToString() + "##";
                    x = x.ToUpper();
                    int i = page.IndexOf(x);
                    if (i == -1)
                    {
                        requestor.OnRequestCompleted += new HttpRequestor.RequestCompletedHandler(requestor_OnRequestCompleted);
                        requestor = null;
                        return;
                    }
                    page = page.Substring(i + x.Length);
                    i = page.IndexOf("##");
                    if (i == -1)
                    {
                        requestor.OnRequestCompleted += new HttpRequestor.RequestCompletedHandler(requestor_OnRequestCompleted);
                        requestor = null;
                        return;
                    }
                    string versionstr = page.Substring(0, i);
                    newversion = int.Parse(versionstr);
                    page = page.Substring(i + 2);
                    i = page.IndexOf("##");
                    if (i == -1)
                    {
                        requestor.OnRequestCompleted += new HttpRequestor.RequestCompletedHandler(requestor_OnRequestCompleted);
                        requestor = null;
                        return;
                    }
                    updatelink = page.Substring(0, i);
                }
                catch (Exception ex)
                {
                    OpenSource.Utilities.EventLogger.Log(ex);
                    requestor.OnRequestCompleted += new HttpRequestor.RequestCompletedHandler(requestor_OnRequestCompleted);
                    requestor = null;
                    return;
                }

                // Compare to existing version
                if (existingversion < newversion)
                {
                    updateform = new AutoUpdate(newversion);
                    parentform.Invoke(new System.Threading.ThreadStart(ShowUpdateForm));
                }
            }
            requestor.OnRequestCompleted += new HttpRequestor.RequestCompletedHandler(requestor_OnRequestCompleted);
            requestor = null;
        }