Esempio n. 1
0
        private void getListfromServer()
        {
            IList<PluginModel> remote = null;

            var localPluginsInfo = ServiceProvider.Resolve<IPluginsInfo>();
            IEnumerable<PluginModel> local = localPluginsInfo.GetPluginsInfo();

            var background = new BackgroundWorker();
            background.DoWork += (DoWorkEventHandler)((sender, e) =>
                {
                    Exception error = WcfHelper.Execute<IServicePlugin>(client =>
                        {
                            remote = client.GetPluginList();
                        });

                    if (error != null)
                    {
                        throw new OgpPluginException("Erreur de recuperation de liste de plugins", error);
                    }
                });

            background.RunWorkerCompleted += (RunWorkerCompletedEventHandler)((sender, e) =>
                {
                    if (remote != null)
                    {
                        this.availablePluginList.Clear();
                        foreach (PluginModel plugin in remote)
                        {
                            PluginContext newContext = new PluginContext(plugin);
                            if (local.Contains<PluginModel>(plugin))
                            {
                                newContext.CanDownload = false;
                                newContext.ProgressBarStatus = System.Windows.Visibility.Visible;
                                newContext.Progress = 100.0;
                            }
                            else
                            {
                                newContext.CanDownload = true;
                            }
                            newContext.CanUninstall = false;
                            this.availablePluginList.Add(newContext);
                        }
                        showAvailablePlugins();
                        //Thread.Sleep(2000);
                        RibbonWindowViewModel.ServerDockInstance.DoSomethingWhenBackgroundEnd();
                    }
                });

            RibbonWindowViewModel.ServerDockInstance.DoSomethingWhenBackgroundBegin();
            background.RunWorkerAsync();
        }
Esempio n. 2
0
        /// <summary>
        /// retrive plugins list from local memory
        /// </summary>
        private void getListFromLocal()
        {
            var localPluginsInfo = ServiceProvider.Resolve<IPluginsInfo>();
            localPluginsInfo.RefreshMenu();
            IEnumerable<PluginModel> local = localPluginsInfo.GetPluginsInfo();

            this.availablePluginList.Clear();
            foreach (PluginModel plugin in local)
            {
                PluginContext newContext = new PluginContext(plugin);
                newContext.CanDownload = false;
                newContext.CanUninstall = true;
                this.availablePluginList.Add(newContext);
            }

            showAvailablePlugins();
        }