Beispiel #1
0
        private void service_GetLatestVersionCompleted(object sender, ConnectUO.Framework.Web.GetLatestVersionCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                return;
            }

            Invoke((MethodInvoker) delegate
            {
                if (e.Error != null)
                {
                    Program.Status    = UpdateStatus.Failure;
                    txtChangeLog.Text = string.Format("The following error occured while trying to get the lastest ConnectUO version information: \n {0}", e.Error.Message);
                    Complete();
                    return;
                }

                string url       = e.Result.Tables[0].Rows[0].Field <string>("UpdateUrl");
                string changeLog = e.Result.Tables[0].Rows[0].Field <string>("ChangeLog");

                txtChangeLog.Text = changeLog;
                txtChangeLog.Focus();
                txtChangeLog.Select(0, 0);

                FileSystemHelper.EnsureDirectoryExists(_destinationDirectory);

                DirectoryInfo dir = new DirectoryInfo(_destinationDirectory);
                FileInfo[] files  = dir.GetFiles();

                for (int i = 0; i < files.Length; i++)
                {
                    Tracer.Verbose("Removing old file {0}", files[i].Name);

                    try
                    {
                        files[i].Delete();
                    }
                    catch
                    {
                    }
                }

                _update = HttpDownload.CreateDownload(url, _destinationFile);

                _update.ProgressStarted   += new EventHandler <ProgressStartedEventArgs>(update_ProgressStarted);
                _update.ProgressUpdate    += new EventHandler <ProgressUpdateEventArgs>(update_ProgressUpdate);
                _update.ProgressCompleted += new EventHandler <ProgressCompletedEventArgs>(update_ProgressCompleted);

                _update.Begin();
            });
        }
Beispiel #2
0
        private void service_GetLatestVersionCompleted(object sender, ConnectUO.Framework.Web.GetLatestVersionCompletedEventArgs e)
        {
            if (e.Cancelled)
                return;

            Invoke((MethodInvoker)delegate
            {
                if (e.Error != null)
                {
                    Program.Status = UpdateStatus.Failure;
                    txtChangeLog.Text = string.Format("The following error occured while trying to get the lastest ConnectUO version information: \n {0}", e.Error.Message);
                    Complete();
                    return;
                }

                string url = e.Result.Tables[0].Rows[0].Field<string>("UpdateUrl");
                string changeLog = e.Result.Tables[0].Rows[0].Field<string>("ChangeLog");

                txtChangeLog.Text = changeLog;
                txtChangeLog.Focus();
                txtChangeLog.Select(0, 0);

                FileSystemHelper.EnsureDirectoryExists(_destinationDirectory);

                DirectoryInfo dir = new DirectoryInfo(_destinationDirectory);
                FileInfo[] files = dir.GetFiles();

                for (int i = 0; i < files.Length; i++)
                {
                    Tracer.Verbose("Removing old file {0}", files[i].Name);

                    try
                    {
                        files[i].Delete();
                    }
                    catch
                    {
                    }
                }

                _update = HttpDownload.CreateDownload(url, _destinationFile);

                _update.ProgressStarted += new EventHandler<ProgressStartedEventArgs>(update_ProgressStarted);
                _update.ProgressUpdate += new EventHandler<ProgressUpdateEventArgs>(update_ProgressUpdate);
                _update.ProgressCompleted += new EventHandler<ProgressCompletedEventArgs>(update_ProgressCompleted);

                _update.Begin();
            });
        }