protected override void OnExecute(object param) { try { //string packagename = Microsoft.VisualBasic.Interaction.InputBox("Enter package name that you want to unload.", "Load Library", ""); //if (string.IsNullOrEmpty(packagename)) //{ // //MessageBox.Show("Title/Command cannot be empty, Exiting Dialog install", "Info: Dialog Title Empty."); // return; //} PackageHelperMethods phm = new PackageHelperMethods(); UAReturn rlst = phm.ShowLoadedPackages(); string[] strarr = phm.GetUAReturnStringResult(rlst); //Create UI show list of installed packges so that user can select and load them SelectPackagesWindow spw = new SelectPackagesWindow(strarr); spw.header = "UnLoad Library(s)"; spw.ShowDialog(); IList<string> sel = spw.SelectedItems; if (sel == null) return; string[] selectedpackages = new string[sel.Count]; int i = 0; foreach (string s in sel) { selectedpackages[i] = s; i++; } //PackageHelperMethods phm = new PackageHelperMethods(); UAReturn r = phm.PackageFileUnload(selectedpackages);// PackageFileUnload(packagename); if (r != null && r.Success) { SendToOutputWindow( "Unload Package", r.CommandString); } else { string error = string.Empty; if(r!=null && r.Error!=null && r.Error.Length > 0) error = r.Error; SendToOutputWindow("Error Unloading Package", error); } } catch (Exception ex) { MessageBox.Show("Error while unloading package.", "Error Occurred!"); logService.WriteToLogLevel("Error:", LogLevelEnum.Error, ex); } }
private void dfltAddPackageButton_Click(object sender, RoutedEventArgs e) { #region This code is same as in LoadPackageFRomListCommand.cs in OnExecute() //get package name from another window PackageHelperMethods phm = new PackageHelperMethods(); UAReturn rlst = phm.ShowInstalledPackages(); string[] installedpkgs = phm.GetUAReturnStringResult(rlst); UAReturn rlst2 = phm.ShowLoadedPackages(); string[] loadededpkgs = phm.GetUAReturnStringResult(rlst2); string[] strarr = phm.GetStringArrayUncommon(installedpkgs, loadededpkgs); //Create UI show list of installed packges so that user can select and load them SelectPackagesWindow spw = new SelectPackagesWindow(strarr); spw.header = "Select Packages."; spw.ShowDialog(); IList<string> sel = spw.SelectedItems; if (sel == null) return; string[] selectedpackages = new string[sel.Count]; int i = 0; foreach (string s in sel) { selectedpackages[i] = s; i++; } #endregion foreach (string s in selectedpackages) dfltpackagelistbox.Items.Add(s); //ApplyPackageButton.IsEnabled = true; }