Пример #1
0
 protected void FireTaskError(TaskErrorEventArgs ev)
 {
     if (TaskError != null) TaskError(this, ev);
 }
Пример #2
0
        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);
        }