Example #1
0
        void updatePluginsBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            IEnumerable <IPluginDescription> installedPlugins = (IEnumerable <IPluginDescription>)e.Argument;
            var remotePlugins = installationManager.GetRemotePluginList();
            // if there is a local plugin with same name and same major and minor version then it's an update
            var pluginsToUpdate = from remotePlugin in remotePlugins
                                  let matchingLocalPlugins = from installedPlugin in installedPlugins
                                                             where installedPlugin.Name == remotePlugin.Name
                                                             where installedPlugin.Version.Major == remotePlugin.Version.Major
                                                             where installedPlugin.Version.Minor == remotePlugin.Version.Minor
                                                             where IsNewerThan(remotePlugin, installedPlugin)
                                                             select installedPlugin
                                                             where matchingLocalPlugins.Count() > 0
                                                             select remotePlugin;

            if (pluginsToUpdate.Count() > 0)
            {
                bool cancelled;
                installationManager.Update(pluginsToUpdate, out cancelled);
                if (!cancelled)
                {
                    pluginManager.DiscoverAndCheckPlugins();
                }
                e.Cancel = false;
            }
            else
            {
                e.Cancel = true;
            }
        }
        void refreshServerPluginsBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            RefreshBackgroundWorkerResult result = new RefreshBackgroundWorkerResult();

            result.RemotePlugins  = installationManager.GetRemotePluginList();
            result.RemoteProducts = installationManager.GetRemoteProductList();
            e.Result = result;
        }
 public void GetRemotePluginListTest() {
   string pluginDir = Environment.CurrentDirectory;
   try {
     InstallationManager target = new InstallationManager(pluginDir);
     var pluginList = target.GetRemotePluginList();
     Assert.IsTrue(pluginList != null);
   } catch (Exception e) {
     Assert.Fail("Connection to the update service failed. " + e.Message);
   }
 }
Example #4
0
 private void CheckUpdatesAvailableAsync() {
   string pluginPath = Path.GetFullPath(Application.StartupPath);
   var task = Task.Factory.StartNew<bool>(() => {
     var installationManager = new InstallationManager(pluginPath);
     IEnumerable<IPluginDescription> installedPlugins = pluginManager.Plugins.OfType<IPluginDescription>();
     var remotePlugins = installationManager.GetRemotePluginList();
     // if there is a local plugin with same name and same major and minor version then it's an update
     var pluginsToUpdate = from remotePlugin in remotePlugins
                           let matchingLocalPlugins = from installedPlugin in installedPlugins
                                                      where installedPlugin.Name == remotePlugin.Name
                                                      where installedPlugin.Version.Major == remotePlugin.Version.Major
                                                      where installedPlugin.Version.Minor == remotePlugin.Version.Minor
                                                      where Util.IsNewerThan(remotePlugin, installedPlugin)
                                                      select installedPlugin
                           where matchingLocalPlugins.Count() > 0
                           select remotePlugin;
     return pluginsToUpdate.Count() > 0;
   });
   task.ContinueWith(t => {
     try {
       t.Wait();
       updatesAvailable = t.Result;
       UpdateApplicationsList();
     }
     catch (AggregateException ae) {
       ae.Handle(ex => {
         if (ex is InstallationManagerException) {
           // this is expected when no internet connection is available => do nothing 
           return true;
         } else {
           return false;
         }
       });
     }
   });
 }