private void TabsExtractOrPack_Selected(object sender, TabControlEventArgs e) { if (e.Action == TabControlAction.Selected && e.TabPage == tabSettings) { txtCoreTools.Text = CoreToolsDownloader.GetSolutionPackagerVersion()?.ToString() ?? Resources.SOLUTIONPACKAGER_MISSING; } }
public SolutionPackagerControl(Type pluginType) { this.pluginType = pluginType; InitializeComponent(); pluginViewModel = new PluginViewModel(); asyncWorkQueue = new AsyncWorkQueue(this, pluginViewModel); coreToolsDownloader = new CoreToolsDownloader(asyncWorkQueue, pluginViewModel); solutionPackagerCaller = new SolutionPackagerCaller(this, asyncWorkQueue, txtOutput); crmSolutionManager = new CrmSolutionManager(this, asyncWorkQueue, solutionPackagerCaller, cmbCrmSolutions); localOrCrm.DataBindings.Add(nameof(localOrCrm.Enabled), pluginViewModel, nameof(pluginViewModel.HasConnection)); grpExportSolution.DataBindings.Add(nameof(grpExportSolution.Visible), pluginViewModel, nameof(pluginViewModel.LocalOrCrm)); btnRefreshSolutions.DataBindings.Add(nameof(btnRefreshSolutions.Enabled), pluginViewModel, nameof(pluginViewModel.LocalOrCrm)); tabsExtractOrPack.DataBindings.Add(nameof(tabsExtractOrPack.Enabled), pluginViewModel, nameof(pluginViewModel.AllowRequests)); txtCoreTools.DataBindings.Add(nameof(txtCoreTools.Text), pluginViewModel, nameof(pluginViewModel.SolutionPackagerVersion)); pluginViewModel.PropertyChanged += PluginViewModel_PropertyChanged; cmbLanguage.Items.AddRange(new object[] { CultureInfo.GetCultureInfo("en"), CultureInfo.GetCultureInfo("it") }); cmbLanguage.SelectedIndex = 0; cmbPackageTypeExtract.SelectedIndex = 0; cmbSourceLocaleExtract.SelectedIndex = 0; cmbErrorLevelExtract.SelectedIndex = 0; cmbPackageTypePack.SelectedIndex = 0; cmbErrorLevelPack.SelectedIndex = 0; }
private void TabsExtractOrPack_Selected(object sender, TabControlEventArgs e) { if (e.Action == TabControlAction.Selected && e.TabPage == tabSettings) { pluginViewModel.SolutionPackagerVersion = CoreToolsDownloader.GetSolutionPackagerVersion()?.ToString(); } }
public SolutionPackagerControl(Type pluginType) { this.pluginType = pluginType; InitializeComponent(); IMyToolFactory myToolFactory = MyToolFactory.GetMyToolFactory(this); toolViewModel = myToolFactory.NewToolViewModel(); /* backgroundWorkHandler = */ myToolFactory.BackgroundWorkHandler(); coreToolsDownloader = myToolFactory.NewCoreToolsDownloader(); crmSolutionImporter = myToolFactory.NewCrmSolutionImporter(); solutionPackagerCaller = myToolFactory.NewSolutionPackagerCaller(txtOutput, crmSolutionImporter); crmSolutionManager = myToolFactory.NewCrmSolutionDownloader(solutionPackagerCaller, cmbCrmSolutions); localOrCrm.Bind(_ => _.Enabled, toolViewModel, _ => _.HasConnection); btnRefreshSolutions.Bind(_ => _.Enabled, toolViewModel, _ => _.LocalOrCrm); chkImportSolution.Bind(_ => _.Enabled, toolViewModel, _ => _.HasConnection); tabsExtractOrPack.Bind(_ => _.Enabled, toolViewModel, _ => _.AllowRequests); txtCoreTools.Bind(_ => _.Text, toolViewModel, _ => _.SolutionPackagerVersion); toolViewModel.PropertyChanged += PluginViewModel_PropertyChanged; cmbLanguage.Items.AddRange(new object[] { CultureInfo.GetCultureInfo("en"), CultureInfo.GetCultureInfo("it") }); cmbLanguage.SelectedIndex = 0; cmbPackageTypeExtract.SelectedIndex = 0; cmbSourceLocaleExtract.SelectedIndex = 0; cmbErrorLevelExtract.SelectedIndex = 0; cmbPackageTypePack.SelectedIndex = 0; cmbErrorLevelPack.SelectedIndex = 0; }
private void BtnPack_Click(object sender, EventArgs e) { errorProvider.Clear(); int nrErrors = 0; if (txtInputPack.Text.Length == 0) { errorProvider.SetError(txtInputPack, Resources.INPUT_FOLDER_NOT_SPECIFIED); nrErrors += 1; } if (CoreToolsDownloader.GetSolutionPackagerVersion() == null) { errorProvider.SetError(chkImportSolution, Resources.SOLUTIONPACKAGER_MISSING); nrErrors += 1; } if (txtOutputPack.Text.Length == 0) { errorProvider.SetError(txtOutputPack, Resources.ZIP_FILE_NOT_SPECIFIED); nrErrors += 1; } if (nrErrors > 0) { errorProvider.SetError(btnPack, nrErrors == 1 ? Resources.EXPORT_ERROR : string.Format(CultureInfo.InvariantCulture, Resources.EXPORT_ERRORS, nrErrors)); return; } var parameters = new SolutionPackagerCaller.Parameters() { Action = "Pack", ZipFile = txtOutputPack.Text, OutputFolder = txtInputPack.Text, PackageType = packageTypes[cmbPackageTypePack.SelectedIndex], ErrorLevel = errorLevels[cmbErrorLevelPack.SelectedIndex], MapFile = txtMapPack.Text, NoLogo = chkNoLogoPack.Checked, LogFile = txtLogPack.Text, Arguments = txtArgumentsPack.Text }; if (chkImportSolution.Checked) { parameters.ImportSolutionParams = new CrmSolutionImporter.Parameters() { ImportDependencies = chkImportDependencies.Checked, ImportManaged = chkImportManaged.Checked, ImportOverwrite = chkImportOverwrite.Checked, ImportPublishWorkflows = chkImportPublishWorkflows.Checked, HoldingSolution = chkImportHoldingSolution.Checked, PreferManaged = cmbPackageTypePack.SelectedIndex == 3 && radPreferManaged.Checked }; } solutionPackagerCaller.ManageSolution(parameters); }
public SolutionPackagerControl() { InitializeComponent(); pluginViewModel = new PluginViewModel(); asyncWorkQueue = new AsyncWorkQueue(this, pluginViewModel); coreToolsDownloader = new CoreToolsDownloader(asyncWorkQueue, txtCoreTools); solutionPackagerCaller = new SolutionPackagerCaller(asyncWorkQueue, txtOutput); crmSolutionManager = new CrmSolutionManager(this, asyncWorkQueue, solutionPackagerCaller, cmbCrmSolutions); localOrCrm.DataBindings.Add(nameof(localOrCrm.Enabled), pluginViewModel, nameof(pluginViewModel.HasConnection)); grpExportSolution.DataBindings.Add(nameof(grpExportSolution.Visible), pluginViewModel, nameof(pluginViewModel.LocalOrCrm)); btnRefreshSolutions.DataBindings.Add(nameof(btnRefreshSolutions.Enabled), pluginViewModel, nameof(pluginViewModel.LocalOrCrm)); tabsExtractOrPack.DataBindings.Add(nameof(tabsExtractOrPack.Enabled), pluginViewModel, nameof(pluginViewModel.AllowRequests)); }
private void btnPack_Click(object sender, EventArgs e) { int nrErrors = 0; if (txtInputPack.Text.Length == 0) { errorProvider.SetError(txtInputPack, Resources.INPUT_FOLDER_NOT_SPECIFIED); nrErrors += 1; } if (CoreToolsDownloader.GetSolutionPackagerVersion() == null) { errorProvider.SetError(localOrCrm, Resources.SOLUTIONPACKAGER_MISSING); nrErrors += 1; } if (txtOutputPack.Text.Length == 0) { errorProvider.SetError(txtOutputPack, Resources.ZIP_FILE_NOT_SPECIFIED); nrErrors += 1; } if (nrErrors > 0) { errorProvider.SetError(btnPack, nrErrors == 1 ? Resources.EXPORT_ERROR : string.Format(CultureInfo.InvariantCulture, Resources.EXPORT_ERRORS, nrErrors)); return; } var parameters = new SolutionPackagerCaller.Parameters() { Action = "Pack", ZipFile = txtOutputPack.Text, OutputFolder = txtInputPack.Text, PackageType = packageTypes[cmbPackageTypePack.SelectedIndex], ErrorLevel = errorLevels[cmbErrorLevelPack.SelectedIndex], MapFile = txtMapPack.Text, NoLogo = chkNoLogoPack.Checked, LogFile = txtLogPack.Text, Arguments = txtArgumentsPack.Text }; solutionPackagerCaller.ManageSolution(parameters); }
private void BtnExtract_Click(object sender, EventArgs e) { int nrErrors = 0; if (txtOutputExtract.Text.Length == 0) { errorProvider.SetError(txtOutputExtract, Resources.OUTPUT_FOLDER_NOT_SPECIFIED); nrErrors += 1; } if (CoreToolsDownloader.GetSolutionPackagerVersion() == null) { errorProvider.SetError(localOrCrm, Resources.SOLUTIONPACKAGER_MISSING); nrErrors += 1; } if (localOrCrm.Checked) { if (cmbCrmSolutions.SelectedIndex < 0) { errorProvider.SetError(cmbCrmSolutions, Resources.NO_SOLUTION_SELECTED); nrErrors += 1; } } else { if (!File.Exists(txtInputExtract.Text)) { errorProvider.SetError(txtInputExtract, Resources.ZIP_FILE_DOES_NOT_EXIST); nrErrors += 1; } } if (nrErrors > 0) { errorProvider.SetError(btnExtract, nrErrors == 1 ? Resources.EXPORT_ERROR : string.Format(CultureInfo.InvariantCulture, Resources.EXPORT_ERRORS, nrErrors)); return; } var parameters = new SolutionPackagerCaller.Parameters() { Action = "Extract", ZipFile = txtInputExtract.Text, OutputFolder = txtOutputExtract.Text, PackageType = packageTypes[cmbPackageTypeExtract.SelectedIndex], AllowWrite = chkAllowWriteExtract.Checked, AllowDelete = radAllowDeleteYes.Checked ? true : (radAllowDeleteNo.Checked ? false : default(bool?)), Clobber = chkClobberExtract.Checked, ErrorLevel = errorLevels[cmbErrorLevelExtract.SelectedIndex], MapFile = txtMapExtract.Text, NoLogo = chkNoLogoExtract.Checked, LogFile = txtLogExtract.Text, Arguments = txtArgumentsExtract.Text, SourceLocale = languageCodes[cmbSourceLocaleExtract.SelectedIndex], Localize = chkLocalizeExtract.Checked, FormatXml = chkFormatDocumentExtract.Checked }; if (localOrCrm.Checked) { crmSolutionManager.DownloadSolution( new CrmSolutionManager.DownloadSolutionParams( cmbCrmSolutions.SelectedItem as Models.Solution, zipDirectory: txtInputExtract.Text, solutionPackagerParameters: parameters, managed: parameters.PackageType == "Both" ? new bool[] { true, false } : new bool[] { radManaged.Checked }, exportAutoNumberingSettings: chkExportAutoNumbering.Checked, exportCalendarSettings: chkExportCalendar.Checked, exportCustomizationSettings: chkExportCustomization.Checked, exportEmailTrackingSettings: chkExportEmailTracking.Checked, exportExternalApplications: chkExportExternalApplications.Checked, exportGeneralSettings: chkExportGeneralSettings.Checked, exportIsvConfig: chkExportISVConfig.Checked, exportMarketingSettings: chkExportMarketing.Checked, exportOutlookSynchronizationSettings: chkExportOutlookSynchronization.Checked, exportRelationshipRoles: chkExportRelationshipRoles.Checked, exportSales: chkExportSales.Checked)); } else { solutionPackagerCaller.ManageSolution(parameters); } }
private void ExtractSolution(BackgroundWorker worker, DoWorkEventArgs args) { var @params = args.Argument as Parameters ?? throw new ArgumentNullException(nameof(args.Argument)); string dir = CoreToolsDownloader.GetToolDirectory(); string solutionPackagerFile = Path.Combine(dir, CoreToolsDownloader.solutionPackagerName); if (!File.Exists(solutionPackagerFile)) { args.Result = Resources.SOLUTIONPACKAGER_MISSING; return; } Process process = new Process() { StartInfo = { FileName = solutionPackagerFile, Arguments = $"/action:{@params.Action} /zipfile:\"{@params.ZipFile}\" /folder:\"{@params.OutputFolder}\"", WorkingDirectory = dir, UseShellExecute = false, CreateNoWindow = true, RedirectStandardError = true, RedirectStandardInput = true, RedirectStandardOutput = true }, EnableRaisingEvents = true }; if (!string.IsNullOrEmpty(@params.PackageType)) { process.StartInfo.Arguments += " /packagetype:" + @params.PackageType; } if ([email protected] && @params.Action != "Pack") { process.StartInfo.Arguments += " /allowWrite:No"; } if (@params.AllowDelete.HasValue) { process.StartInfo.Arguments += " /allowDelete:" + (@params.AllowDelete.Value ? "Yes" : "No"); } if (@params.Clobber) { process.StartInfo.Arguments += " /clobber"; } if (!string.IsNullOrEmpty(@params.ErrorLevel)) { process.StartInfo.Arguments += " /errorlevel:" + @params.ErrorLevel; } if (!string.IsNullOrEmpty(@params.MapFile)) { process.StartInfo.Arguments += $" /map:\"{@params.MapFile}\""; } if (@params.NoLogo) { process.StartInfo.Arguments += " /nologo"; } if (!string.IsNullOrEmpty(@params.LogFile)) { process.StartInfo.Arguments += $" /log:\"{@params.LogFile}\""; } if (!string.IsNullOrEmpty(@params.Arguments)) { process.StartInfo.Arguments += $" \"{@params.Arguments}\""; } if (!string.IsNullOrEmpty(@params.SourceLocale)) { process.StartInfo.Arguments += $" /sourceLoc:{@params.SourceLocale}"; } if (@params.Localize) { process.StartInfo.Arguments += " /localize"; } //Report call parameters worker.ReportProgress(0, @params); process.Start(); if (!process.StandardOutput.EndOfStream) { worker.ReportProgress(10); char[] buffer = new char[deleteFilesQuestion.Length]; char[] ringBuffer = new char[deleteFilesQuestion.Length]; int ringBufferPosition = 0; int lastNewLine = buffer.Length; while (!process.StandardOutput.EndOfStream) { var chars = process.StandardOutput.ReadBlock(buffer, 0, lastNewLine); lastNewLine = buffer.Length; for (int i = 0; i < chars; i++) { if (buffer[i] == '\n') { lastNewLine = i + 1; } ringBuffer[ringBufferPosition] = buffer[i]; ringBufferPosition = (ringBufferPosition + 1) % ringBuffer.Length; } worker.ReportProgress(20, new string(buffer, 0, chars)); bool isDeleteFilesQuestion = true; for (int i = deleteFilesQuestion.Length - 1; i >= 0; i--) { if (deleteFilesQuestion[i] != ringBuffer[(ringBufferPosition + i) % ringBuffer.Length]) { isDeleteFilesQuestion = false; break; } } if (isDeleteFilesQuestion) { @params.StandardInput = process.StandardInput; worker.ReportProgress(21, @params); } } worker.ReportProgress(30); } if (!process.StandardError.EndOfStream) { worker.ReportProgress(40); while (!process.StandardError.EndOfStream) { worker.ReportProgress(50, process.StandardError.ReadLine()); } worker.ReportProgress(60); } process.WaitForExit(); worker.ReportProgress(70, "Ended"); if (@params.FormatXml) { var tempFile = Path.GetTempFileName(); foreach (var xmlFile in Directory.GetFiles(@params.OutputFolder, "*.xml", SearchOption.AllDirectories)) { worker.ReportProgress(80, new FileInfo(xmlFile)); XmlDocument document = new XmlDocument(); document.Load(xmlFile); XmlWriterSettings writerSettings = new XmlWriterSettings() { Indent = true, NewLineHandling = NewLineHandling.Replace, NewLineOnAttributes = true }; using (StreamWriter sw = new StreamWriter(tempFile, append: false)) using (XmlWriter writer = XmlWriter.Create(sw, writerSettings)) { document.WriteContentTo(writer); } File.Copy(tempFile, xmlFile, overwrite: true); worker.ReportProgress(90, new FileInfo(xmlFile)); } } }