private void PrepareUpdate(object sender, RoutedEventArgs e) { if (false == HasWriteAccessToFolder("plugins")) { MessageBox.Show(Application.Current.MainWindow, "You do not have write permissions in the beRemote folder. This plugin will not offer all available functionality due to his missing permissions.", "Missing permissions"); return; } #region remove var plugin = (Plugin)GrdLockPluginDetails.DataContext; Canvas.SetZIndex(GrdLock, 102); GrdLockLoader.Visibility = Visibility.Visible; DirectoryInstance.UpdateListStateMessage = "Preparing plugin removal..."; new Thread(new ThreadStart(delegate { Kernel.RemovePlugin(plugin.FullQuallifiedAssemblyName); })).Start(); #endregion new Thread(new ThreadStart(delegate { using (var client = new PluginDirectoryClient(DirectoryInstance.BaseUrl)) { client.Login(); DirectoryInstance.UpdateListStateMessage = "Downloading plugin... please be patient"; var fi = client.DownloadPlugin(plugin); DirectoryInstance.UpdateListStateMessage = "Plugin downloaded."; if (fi != null) { // moving it to the install-on-next-start-folder try { Kernel.InsertPluginUpdate(fi); // If we reach this, all things gone right :) this.Dispatcher.BeginInvoke(new Action(delegate { MessageBox.Show(Application.Current.MainWindow, "The plugin update is prepared and will be executed upon the next beRemote restart.", "Update prepared!", MessageBoxButton.OK, MessageBoxImage.Information); })); this.Dispatcher.BeginInvoke(new Action(delegate { GrdLockLoader.Visibility = Visibility.Collapsed; GrdLock.Visibility = Visibility.Collapsed; GrdLockPluginDetails.Visibility = Visibility.Collapsed; plugin.IsUpdateable = false; plugin.IsInstalled = true; })); } catch (Exception ex) { String message = ex.Message; if (ex.InnerException != null) { message += "\r\n" + ex.InnerException.Message; } DirectoryInstance.UpdateListStateMessage = message; this.Dispatcher.BeginInvoke(new Action(delegate { MessageBox.Show(Application.Current.MainWindow, message, "Error in plugin container", MessageBoxButton.OK, MessageBoxImage.Error); })); } } } })).Start(); }
private void DoInstall(bool withMessage) { if (withMessage) { if (false == HasWriteAccessToFolder("plugins")) { MessageBox.Show(Application.Current.MainWindow, "You do not have write permissions in the beRemote folder. This plugin will not offer all available functionality due to his missing permissions.", "Missing permissions"); return; } } // Changes the order to lock the listview, and to stay over everything of the UI Canvas.SetZIndex(GrdLock, 102); GrdLockLoader.Visibility = Visibility.Visible; DirectoryInstance.UpdateListStateMessage = "Preparing plugin installation..."; var plugin = (Plugin)GrdLockPluginDetails.DataContext; new Thread(new ThreadStart(delegate { using (var client = new PluginDirectoryClient(DirectoryInstance.BaseUrl)) { client.Login(); DirectoryInstance.UpdateListStateMessage = "Downloading plugin... please be patient"; var fi = client.DownloadPlugin(plugin); DirectoryInstance.UpdateListStateMessage = "Plugin downloaded."; if (fi != null) { // moving it to the install-on-next-start-folder try { Kernel.InsertPluginUpdate(fi); // If we reach this, all things gone right :) if (withMessage) { this.Dispatcher.BeginInvoke(new Action(delegate { MessageBox.Show(Application.Current.MainWindow, "The plugin installation is prepared and will be executed after beRemote is restarted.", "Installation prepared!", MessageBoxButton.OK, MessageBoxImage.Information); })); } this.Dispatcher.BeginInvoke(new Action(delegate { GrdLockLoader.Visibility = Visibility.Collapsed; GrdLock.Visibility = Visibility.Collapsed; GrdLockPluginDetails.Visibility = Visibility.Collapsed; plugin.IsUpdateable = false; plugin.IsInstalled = true; })); } catch (Exception ex) { String message = ex.Message; if (ex.InnerException != null) { message += "\r\n" + ex.InnerException.Message; } DirectoryInstance.UpdateListStateMessage = message; this.Dispatcher.BeginInvoke(new Action(delegate { MessageBox.Show(Application.Current.MainWindow, message, "Error in plugin container", MessageBoxButton.OK, MessageBoxImage.Error); })); } } } })).Start(); }