コード例 #1
0
ファイル: Shared.cs プロジェクト: marcellodash/xrns2xmod
        public static void CheckForUpdates(bool showMessageAnyway, WebProxy webProxy)
        {
            Task.Factory.StartNew(() => ServiceUpdater.CheckForUpdates(Globals.URI_UPDATER, webProxy)).ContinueWith(task =>
            {
                if (task.Result != null)
                {
                    ServiceUpdater.VersionInfo lastVersionInfo = task.Result;

                    Version productVersion = Shared.GetProductVersion();

                    if (lastVersionInfo.LatestVersion > productVersion)
                    {
                        DialogResult result = MessageBox.Show(String.Format("A new version ({0}) is avaible, do you want to go to the homepage?", lastVersionInfo.LatestVersion), "NEW VERSION", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                        if (result == DialogResult.Yes)
                        {
                            Process.Start(lastVersionInfo.LatestVersionUrl);
                        }
                    }
                    else if (showMessageAnyway)
                    {
                        MessageBox.Show(String.Format("This version is up to date", lastVersionInfo.LatestVersion), "No updates avaible", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    if (showMessageAnyway)
                    {
                        MessageBox.Show("Network error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            });
        }
コード例 #2
0
        void CheckForUpdates()
        {
            if (task == null || task.Status != TaskStatus.Running)
            {
                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 = 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)
                        {
                            OnNewVersionFoundEvent(this, eventArgs);
                        }
                        else
                        {
                            OnVersionUpToDateEvent(this, eventArgs);
                        }
                    }
                    else
                    {
                        VersionCheckEventArgs eventArgs = new VersionCheckEventArgs {
                            ErrorMessage = o.Exception.Message
                        };

                        OnNetworkErrorEvent(this, eventArgs);
                    }
                });
            }
        }
コード例 #3
0
        public void CheckForUpdates(Version version, Assembly assembly)
        {
            ServiceUpdater updater = new ServiceUpdater(Proxy);

            try
            {
                ServiceUpdater.VersionInfo latestVersionInfo = updater.GetMetaInfoVersion(Uri.AbsoluteUri);

                if (latestVersionInfo != null)
                {
                    Version productVersion = new Version(FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion);

                    //Version productVersion = Utils.Utility.GetProductVersion();

                    bool isVersionUpToDate = latestVersionInfo.LatestVersion <= productVersion;

                    VersionCheckEventArgs eventArgs = new VersionCheckEventArgs
                    {
                        Version = latestVersionInfo.LatestVersion
                    };

                    if (isVersionUpToDate == false)
                    {
                        System.Diagnostics.Debug.WriteLine("New version found: " + eventArgs.Version.ToString());
                        if (NewVersionFoundEvent != null)
                        {
                            NewVersionFoundEvent(this, eventArgs);
                        }
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine("Version is up to date: " + eventArgs.Version.ToString());
                        if (VersionUpToDateEvent != null)
                        {
                            VersionUpToDateEvent(this, eventArgs);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                VersionCheckEventArgs eventArgs = new VersionCheckEventArgs {
                    ErrorMessage = e.Message
                };

                if (NetworkErrorEvent != null)
                {
                    NetworkErrorEvent(this, eventArgs);
                }
            }
        }
コード例 #4
0
        public async Task DeployLocally(FileInfo csdl, string portString, bool seedData)
        {
            if (csdl != null)
            {
                app.Out.WriteLine($"Schema Path: {csdl.FullName}");
            }

            Random r    = new Random();
            int    port = r.Next(4000, 9000);

            if (!string.IsNullOrEmpty(portString))
            {
                port = int.Parse(portString);
            }

            string Schema = File.ReadAllText(csdl.FullName);

            var args = new ProjectRunArgs()
            {
                SeedData = seedData
            };

            var image = await imageProvider.GetCredentials();

            app.Out.WriteLine("Updating core service...");
            var updater = new ServiceUpdater(image);

            updater.UpdateService();

            using (var serverRunner = new LocalRunner(csdl.FullName, port, args, image))
            {
                Console.CancelKeyPress += (sender, args) =>
                {
                    // dispose server if terminated with Ctrl+C
                    serverRunner.Stop();
                    Environment.Exit(0);
                };

                serverRunner.OnError        = e => app.Error.WriteLine(e.Message);
                serverRunner.OnSchemaChange = () => app.Out.WriteLine($"Changes detected to {csdl.FullName}...");
                serverRunner.BeforeRestart  = (path, port) => app.Out.WriteLine("Restarting server...");
                serverRunner.AfterRestart   = (path, port) => app.Out.WriteLine($"Server running on http://localhost:{port}/odata");
                serverRunner.OnTerminate    = () => app.Out.WriteLine("Terminating server...");
                serverRunner.Start();

                app.Out.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }
        }
コード例 #5
0
    protected virtual void Start()
    {
        if (Serializer.IsLoading)
        {
            return;
        }
        populationManager = ReferenceManager.instance.populationManager;
        economyManager    = ReferenceManager.instance.economyManager;
        itemManager       = ReferenceManager.instance.itemManager;
        serviceUpdater    = UpdateServices;



        Autelia.Coroutines.CoroutineController.StartCoroutine(this, "UpdateService");
    }
コード例 #6
0
        void CheckForApplicationUpdates()
        {
            WebProxy proxy = null;

            if (enableProxy)
            {
                proxy             = new WebProxy(host, port);
                proxy.Credentials = new NetworkCredential(proxyUser, proxyPassword, proxyDomain);
            }

            ServiceUpdater updater = new ServiceUpdater(proxy);

            Task.Factory.StartNew(() =>
            {
                WpfPitchTuner.Business.ServiceUpdater.VersionInfo version = null;

                try
                {
                    version = updater.CheckForUpdates(UpdateUri);
                }
                catch (Exception)
                {
                }

                return(version);
            }).ContinueWith(o =>
            {
                WpfPitchTuner.Business.ServiceUpdater.VersionInfo lastVersionInfo = (WpfPitchTuner.Business.ServiceUpdater.VersionInfo)o.Result;

                if (lastVersionInfo != null)
                {
                    Version productVersion = Utility.GetProductVersion();

                    bool isVersionUpToDate = lastVersionInfo.LatestVersion <= productVersion;

                    RaiseEventInvoker(isVersionUpToDate ? SoftwareUpToDateEvent : SoftwareOutOfDateEvent, new DefaultEventArgs {
                        ObjArg = lastVersionInfo
                    });
                }
                else
                {
                    RaiseEventInvoker(NetworkErrorEvent);
                }
            });
        }
コード例 #7
0
ファイル: MainVM.cs プロジェクト: fstarred/wammp
        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);
                                }
                            }
                        });
                    }
                }
            });
        }
コード例 #8
0
 public virtual Version GetLatestVersion()
 {
     updater = new ServiceUpdater(this.Proxy);
     ServiceUpdater.VersionInfo version = updater.GetMetaInfoVersion(MetaInfoUrl);
     return(version.LatestVersion);
 }