コード例 #1
0
ファイル: Program.cs プロジェクト: tmbx/TeamboxUpdater
        /// <summary>
        /// Check for the update of one installed product.
        /// </summary>
        private void WebCheckProduct()
        {
            string statusText;
            Product webCheckProduct = m_localProducts[0];

            m_localProducts.RemoveAt(0);

            statusText = "Checking for installed product updates online.";
            ProgressForm.Status = statusText;
            ProgressTray.Status = statusText;

            m_currentTask = new WebCheck(webCheckProduct);
            m_currentTask.TaskDone += new TaskActionEventHandler(OnWebCheckDone);
            m_currentTask.TaskError += new TaskErrorEventHandler(OnTaskError);
            m_currentTask.Start();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: tmbx/TeamboxUpdater
        /// <summary>
        /// Download the update for one updatable product.
        /// </summary>
        private void WebDownload()
        {
            string statusText;
            Product webProduct = m_updateProducts[0];

            m_updateProducts.RemoveAt(0);

            statusText = "Downloading update for " + webProduct.Name + ".";
            ProgressForm.Status = statusText;
            ProgressTray.Status = statusText;

            m_currentTask = new WebDownload(webProduct);
            m_currentTask.TaskDone += new TaskActionEventHandler(OnWebDownloadDone);
            m_currentTask.TaskError += new TaskErrorEventHandler(OnTaskError);
            m_currentTask.Start();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: tmbx/TeamboxUpdater
        /// <summary>
        /// Called when an installer is finished downloading
        /// </summary>
        private void OnWebDownloadDone(object sender, TaskActionEventArgs ev)
        {
            Task evTask = sender as Task;

            if (ev.Partial)
            {
                string statusText = "Downloading update ... " + ev.ProgressPct + "%";

                ProgressForm.Status = statusText;
                ProgressTray.Status = statusText;

                // If this is a partial result, update the progress form with
                // a new % of progress.
                ProgressForm.Progress = ev.ProgressPct;
            }
            else
            {
                // Add the product to the queue of installable product.s
                m_installableProducts.Add(evTask.TaskProduct);

                m_currentTask = null;

                // Run the next task.
                RunCurrentStep();
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: tmbx/TeamboxUpdater
        /// <summary>
        /// Called when a product update data has been fetched online.
        /// </summary>
        private void OnWebCheckDone(object sender, TaskActionEventArgs ev)
        {
            Task evTask = sender as Task;

            // We don't care about partial results.
            if (ev.Partial)
            {
                // Just update the progress bar.
                ProgressForm.Progress = ev.ProgressPct;
            }
            else
            {
                // Compare the version.
                if (Misc.LaterVersion(evTask.TaskProduct.LocalVersion, evTask.TaskProduct.WebVersion))
                {
                    m_updateProducts.Add(evTask.TaskProduct);
                }

                m_currentTask = null;

                RunCurrentStep();
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: tmbx/TeamboxUpdater
        private void OnTaskError(object sender, TaskErrorEventArgs ev)
        {
            string statusText;

            // Dump the stacktrace of the exception in a file so it may useful
            // to debug problems.
            if (ev.Exception != null)
            {
                string logPath = Path.Combine(Path.GetTempPath(), "TeamboxUpdater.log");
                FileStream exFile = null;
                StreamWriter exStream = null;

                try
                {
                    exFile = new FileStream(logPath, FileMode.Create, FileAccess.Write);
                    exStream = new StreamWriter(exFile);
                    exStream.WriteLine(ev.Exception.ToString());
                }
                catch (Exception) { }
                finally
                {
                    if (exStream != null) exStream.Flush();
                    if (exFile != null) exFile.Close();
                }
            }

            // If webcheck fails, this may be because of a lack of connectivity. Just
            // show a warning and don't bother the user.
            if (m_currentTask is WebCheck)
            {
                statusText = "Could not check for updates. Will retry later.";
                ProgressTray.Warning(
                    "Teambox Update", statusText,
                    5);
                ProgressTray.Status = statusText;
                ProgressForm.Status = statusText;
                DelayClose(10);
                return;
            }

            // If the download or the installed failed to run, show an error message.

            if (m_currentTask is WebDownload)
            {
                statusText = "Failed to download update for " + m_currentTask.TaskProduct.Name + ".";
                ProgressTray.Error("Teambox Update", statusText, 10);
                ProgressTray.Status = statusText;
                ProgressForm.Status = statusText;
            }

            if (m_currentTask is Installer)
            {
                statusText = "Error while installing update for " + m_currentTask.TaskProduct.Name + ".";
                ProgressTray.Error("Teambox Update", statusText, 10);
                ProgressTray.Status = statusText;
                ProgressForm.Status = statusText;
            }

            m_gotError = true;
            m_currentTask = null;

            DelayClose(30);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: tmbx/TeamboxUpdater
        /// <summary>
        /// Called when an installer is done running.
        /// </summary>
        private void OnInstallDone(object sender, TaskActionEventArgs ev)
        {
            Task evTask = sender as Task;

            m_currentTask = null;

            // Run the next task.
            RunCurrentStep();
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: tmbx/TeamboxUpdater
        /// <summary>
        /// Start the installer for one updatable product.
        /// </summary>
        private void InstallProduct()
        {
            string statusText;
            Product installProduct = m_installableProducts[0];
            m_installableProducts.RemoveAt(0);

            statusText = "Installing update for " + installProduct.Name + ".";
            ProgressForm.Status = statusText;
            ProgressForm.Status = statusText;

            m_currentTask = new Installer(installProduct);
            m_currentTask.TaskDone += new TaskActionEventHandler(OnInstallDone);
            m_currentTask.TaskError += new TaskErrorEventHandler(OnTaskError);
            m_currentTask.Start();

            // Disable the cancel button.
            ProgressForm.Cancellable = false;
        }