/// <summary> /// Copy a zip file's contents to the tools folder and loop through its .properties /// files adding the tools to the tools menu. /// </summary> /// <param name="parent">Parent window for alerts and forms</param> /// <param name="fullpath">The full path to the zipped folder containing the tools</param> /// <param name="install">Installation function</param> public static void InstallZipTool(Control parent, string fullpath, InstallProgram install) { ToolInstaller.UnzipToolReturnAccumulator result = null; var toolListStart = ToolList.CopyTools(Settings.Default.ToolList); Exception xFailure = null; try { result = ToolInstaller.UnpackZipTool(fullpath, new InstallZipToolHelper(parent, install)); } catch (ToolExecutionException x) { MessageDlg.ShowException(parent, x); } catch (Exception x) { xFailure = x; } if (xFailure != null) { MessageDlg.ShowWithException(parent, TextUtil.LineSeparate(String.Format(Resources.ConfigureToolsDlg_UnpackZipTool_Failed_attempting_to_extract_the_tool_from__0_, Path.GetFileName(fullpath)), xFailure.Message), xFailure); } if (result != null) { foreach (var message in result.MessagesThrown) { MessageDlg.Show(parent, message); } } else { // If result is Null, then we want to discard changes made to the ToolsList Settings.Default.ToolList = toolListStart; } }
private void InstallUpdates(ICollection <ToolUpdateInfo> tools) { if (tools != null && tools.Count != 0 && !TestingDownloadOnly) { var failedUpdates = new Dictionary <string, string>(); var successfulUpdates = new Collection <string>(); int installCount = 0; foreach (var tool in tools) { labelOperation.Text = string.Format(Resources.ToolUpdatesDlg_InstallUpdates_Installing_updates_to__0_, tool._packageName); var toolList = ToolList.CopyTools(Settings.Default.ToolList); bool exceptionThrown = false; ToolInstaller.UnzipToolReturnAccumulator result = null; try { result = _updateHelper.UnpackZipTool(tool.FilePath, new ToolInstallUI.InstallZipToolHelper(_parent.InstallProgram)); } catch (ToolExecutionException x) { failedUpdates.Add(tool._packageName, x.Message); exceptionThrown = true; } catch (IOException x) { failedUpdates.Add(tool._packageName, TextUtil.LineSeparate(string.Format(Resources.ConfigureToolsDlg_UnpackZipTool_Failed_attempting_to_extract_the_tool_from__0_, Path.GetFileName(tool.FilePath)), x.Message)); exceptionThrown = true; } progressBar.Value = Convert.ToInt32((((((double)++installCount) / tools.Count) * 100) / 2) + 50); if (result == null) { // user cancelled if (!exceptionThrown) { failedUpdates.Add(tool._packageName, Resources.ToolUpdatesDlg_InstallUpdates_User_cancelled_installation); } // reset tool list Settings.Default.ToolList = toolList; continue; } // tool was successfully updated result.MessagesThrown.ForEach(message => MessageDlg.Show(this, message)); successfulUpdates.Add(tool._packageName); } // clean-up DirectoryEx.SafeDelete(ToolDir.FullName); progressBar.Value = 100; DisplayInstallSummary(successfulUpdates, failedUpdates); } }