Beispiel #1
0
 private void CheckForUpdateCallback(IAsyncResult result)
 {
     try
     {
         var func = (Func <ApplicationUpdate>)result.AsyncState;
         ApplicationUpdate update = func.EndInvoke(result);
         if (update != null)
         {
             if (NewVersionAvailable(update.Version))
             {
                 ShowUpdate(update);
             }
             else if (_userInvoked)
             {
                 Owner.Invoke(new Action(() => _messageBoxView.ShowInformation(Owner, String.Format(CultureInfo.CurrentCulture,
                                                                                                    "{0} is already up-to-date.", Application.NameAndVersion), Owner.Text)), null);
             }
         }
     }
     catch (Exception ex)
     {
         Logger.ErrorFormat(ex, "{0}", ex.Message);
         if (_userInvoked)
         {
             string message = String.Format(CultureInfo.CurrentCulture, "{0} encountered the following error while checking for an update:{1}{1}{2}.",
                                            Application.NameAndVersion, Environment.NewLine, ex.Message);
             Owner.Invoke(new Action(() => _messageBoxView.ShowError(Owner, message, Owner.Text)), null);
         }
     }
     finally
     {
         CheckInProgress = false;
     }
 }
        public UpdateDialog(ApplicationUpdate update, string applicationName, string applicationVersion)
        {
            InitializeComponent();

            UpdateData         = update;
            ApplicationName    = applicationName;
            ApplicationVersion = applicationVersion;
        }
Beispiel #3
0
 public static void SerializeToXml(ApplicationUpdate update, string filePath)
 {
     using (TextWriter stream = new StreamWriter(filePath, false, Encoding.UTF8))
     {
         var s = new XmlSerializer(typeof(ApplicationUpdate));
         s.Serialize(stream, update);
     }
 }
Beispiel #4
0
 public UpdatePresenter(Action <Exception> exceptionLogger, ApplicationUpdate updateData,
                        IWebProxy proxy, string applicationName, string applicationVersion)
 {
     _exceptionLogger = exceptionLogger;
     _updateData      = updateData;
     _proxy           = proxy;
     _updateView      = new UpdateDialog(updateData, applicationName, applicationVersion);
     _saveFileView    = new harlam357.Windows.Forms.SaveFileDialogView();
     _updateView.AttachPresenter(this);
 }
Beispiel #5
0
 public UpdatePresenter(Action <Exception> exceptionLogger, ApplicationUpdate updateData,
                        IWebProxy proxy, IUpdateView updateView, harlam357.Windows.Forms.ISaveFileDialogView saveFileView,
                        IWebOperation webOperation)
 {
     _exceptionLogger = exceptionLogger;
     _updateData      = updateData;
     _proxy           = proxy;
     _updateView      = updateView;
     _saveFileView    = saveFileView;
     _webOperation    = webOperation;
     _updateView.AttachPresenter(this);
 }
Beispiel #6
0
        private void ShowUpdate(ApplicationUpdate update)
        {
            if (Owner.InvokeRequired)
            {
                Owner.Invoke(new Action(() => ShowUpdate(update)), null);
                return;
            }

            var updatePresenter = new UpdatePresenter(ExceptionLogger,
                                                      update, _proxy, Application.Name, Application.VersionWithRevision);

            updatePresenter.Show(Owner);
            HandleUpdatePresenterResults(updatePresenter);
        }