Beispiel #1
0
        private void OnVersionUpToDateEvent(object sender, EventArgs e)
        {
            VersionCheckEventArgs eventArgs = (VersionCheckEventArgs)e;

            var container = TinyIoCContainer.Current;

            IDialogMessage service = container.Resolve <IDialogMessage>(ContainerNSR.DLG_OPEN_MESSAGE);

            RootDispatcher.Dispatcher.Invoke((Action) delegate {
                service.ShowMessage(String.Format("Version {0} is up to date", eventArgs.Version), "Version information");
            });
        }
Beispiel #2
0
        private void OnNetworkErrorEvent(object sender, EventArgs e)
        {
            VersionCheckEventArgs eventArgs = (VersionCheckEventArgs)e;

            var container = TinyIoCContainer.Current;

            IDialogMessage service = container.Resolve <IDialogMessage>(ContainerNSR.DLG_OPEN_MESSAGE);

            RootDispatcher.Dispatcher.Invoke((Action) delegate
            {
                service.ShowMessage(eventArgs.ErrorMessage, "Network error");
            });
        }
Beispiel #3
0
        void Service_NewVersionFoundEvent(object sender, System.EventArgs e)
        {
            VersionCheckEventArgs eventArgs = (VersionCheckEventArgs)e;

            var container = TinyIoCContainer.Current;

            IDialogMessage service = container.Resolve <IDialogMessage>(ContainerNSR.DLG_OPEN_MESSAGE);

            MSG_RESPONSE response = MSG_RESPONSE.CANCEL;

            RootDispatcher.Dispatcher.Invoke(() =>
            {
                response = service.ShowMessage(string.Format("A new version ( {0} ) is available. Do you want to download it?", eventArgs.Version), "Version information", true);

                if (response == MSG_RESPONSE.OK)
                {
                    if (RequestHomepageEvent != null)
                    {
                        RequestHomepageEvent(sender, e);
                    }
                }
            });
        }
Beispiel #4
0
        void CheckForUpdates()
        {
            var container = TinyIoCContainer.Current;

            IResourceProvider resource = container.Resolve <IResourceProvider>(ContainerNSR.RESOURCE_PROVIDER);

            IConfigProvider config = container.Resolve <IConfigProvider>(ContainerNSR.APP_SETTINGS);

            ServiceUpdater updater = new ServiceUpdater();

            IWebProxy proxy = null;

            if (config.EnableProxy)
            {
                proxy = new System.Net.WebProxy(config.Host, config.Port);
                if (config.EnableCredentials)
                {
                    proxy.Credentials = new System.Net.NetworkCredential(config.User, config.Password, config.Domain);
                }
            }

            System.Version currentVersion = Utility.GetVersionInfo(this.GetType().Assembly);

            Task.Factory.StartNew(() => {
                ServiceUpdater.VersionInfo version = updater.GetMetaInfoVersion(resource.VersionCheckUri.ToString());

                return(version);
            }).ContinueWith((o) => {
                if (o.Status != TaskStatus.Faulted)
                {
                    System.Version latestVersion = o.Result.LatestVersion;

                    bool isVersionUpToDate = latestVersion <= currentVersion;

                    VersionCheckEventArgs eventArgs = new VersionCheckEventArgs {
                        Version = latestVersion
                    };

                    if (isVersionUpToDate == false)
                    {
                        System.Diagnostics.Debug.WriteLine("New version found: " + eventArgs.Version.ToString());

                        IDialogMessage service = container.Resolve <IDialogMessage>(ContainerNSR.DLG_OPEN_MESSAGE);

                        MSG_RESPONSE response = MSG_RESPONSE.CANCEL;

                        RootDispatcher.Dispatcher.Invoke((System.Action) delegate
                        {
                            response = service.ShowMessage(String.Format("A new version ( {0} ) is available. Do you want to download it?", eventArgs.Version), "Version information", true);

                            if (response == MSG_RESPONSE.OK)
                            {
                                if (RequestHomepageEvent != null)
                                {
                                    RequestHomepageEvent(this, eventArgs);
                                }
                            }
                        });
                    }
                }
            });
        }