From 529231af2e9541b65b18d3554b6e8688ec55e0c1 Mon Sep 17 00:00:00 2001 From: Betim Beja <11160171+BetimBeja@users.noreply.github.com> Date: Fri, 4 Feb 2022 11:15:44 +0100 Subject: [PATCH] Added scrollbar for small screens --- .../AlbanianXrm.SolutionPackager.Tool.csproj | 6 +- .../CoreToolsDownloader.cs | 34 +++++----- .../CrmSolutionDownloader.cs | 50 +++++++------- .../CrmSolutionImporter.cs | 30 ++++---- .../Interfaces/IMyToolFactory.cs | 4 +- .../MyToolFactory.cs | 9 +-- .../SolutionPackagerCaller.cs | 68 +++++++++---------- .../SolutionPackagerControl.cs | 13 ++-- .../SolutionPackagerControl.resx | 37 +++++++--- .../AlbanianXrm.SolutionPackager.csproj | 2 +- .../AlbanianXrm.SolutionPackager.nuspec | 5 +- .../ILMergeConfig.json | 8 +-- 12 files changed, 134 insertions(+), 132 deletions(-) diff --git a/AlbanianXrm.SolutionPackager.Tool/AlbanianXrm.SolutionPackager.Tool.csproj b/AlbanianXrm.SolutionPackager.Tool/AlbanianXrm.SolutionPackager.Tool.csproj index 67500b9..e244ca0 100644 --- a/AlbanianXrm.SolutionPackager.Tool/AlbanianXrm.SolutionPackager.Tool.csproj +++ b/AlbanianXrm.SolutionPackager.Tool/AlbanianXrm.SolutionPackager.Tool.csproj @@ -44,9 +44,9 @@ $(OutputPath)$(AssemblyName).xml - - - + + + diff --git a/AlbanianXrm.SolutionPackager.Tool/CoreToolsDownloader.cs b/AlbanianXrm.SolutionPackager.Tool/CoreToolsDownloader.cs index b374d01..ac0c9e7 100644 --- a/AlbanianXrm.SolutionPackager.Tool/CoreToolsDownloader.cs +++ b/AlbanianXrm.SolutionPackager.Tool/CoreToolsDownloader.cs @@ -1,5 +1,6 @@ -using AlbanianXrm.SolutionPackager.Properties; -using AlbanianXrm.XrmToolBox.Shared; +using AlbanianXrm.BackgroundWorker; +using AlbanianXrm.SolutionPackager.Properties; +using AlbanianXrm.XrmToolBox.Shared.Extensions; using NuGet.Common; using NuGet.Packaging; using NuGet.Protocol; @@ -8,7 +9,6 @@ using System.Diagnostics; using System.IO; using System.Linq; -using System.Net; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -19,11 +19,11 @@ internal class CoreToolsDownloader { public const string coreToolsId = "Microsoft.CrmSdk.CoreTools"; public const string solutionPackagerName = "SolutionPackager.exe"; - private readonly BackgroundWorkHandler backgroundWorkHandler; + private readonly AlBackgroundWorkHandler backgroundWorkHandler; private readonly SolutionPackagerControl solutionPackagerControl; private readonly ToolViewModel toolViewModel; - public CoreToolsDownloader(BackgroundWorkHandler backgroundWorkHandler, SolutionPackagerControl solutionPackagerControl, ToolViewModel toolViewModel) + public CoreToolsDownloader(AlBackgroundWorkHandler backgroundWorkHandler, SolutionPackagerControl solutionPackagerControl, ToolViewModel toolViewModel) { this.backgroundWorkHandler = backgroundWorkHandler ?? throw new ArgumentNullException(nameof(backgroundWorkHandler)); this.solutionPackagerControl = solutionPackagerControl ?? throw new ArgumentNullException(nameof(solutionPackagerControl)); @@ -32,12 +32,10 @@ public CoreToolsDownloader(BackgroundWorkHandler backgroundWorkHandler, Solution public void DownloadCoreTools(string nuGetFeed) { - backgroundWorkHandler.EnqueueAsyncWork( - Resources.DOWNLOADING_CORE_TOOLS, - DownloadCoreToolsAsync, - nuGetFeed, - DownloadCoreToolsCompleted - ); + backgroundWorkHandler.EnqueueBackgroundWork( + AlBackgroundWorkerFactory.NewAsyncWorker(DownloadCoreToolsAsync, nuGetFeed, DownloadCoreToolsCompleted) + .WithViewModel(toolViewModel) + .WithMessage(solutionPackagerControl, Resources.DOWNLOADING_CORE_TOOLS)); } public static Version GetSolutionPackagerVersion() @@ -79,7 +77,7 @@ public async Task DownloadCoreToolsAsync(string nugetSource) var metadata = (await packageSearch.SearchAsync(coreToolsId, new SearchFilter(false, SearchFilterType.IsLatestVersion), 0, 1, logger, cancellationToken)).FirstOrDefault(); var version = (await metadata.GetVersionsAsync()).Max(v => v.Version); - System.Diagnostics.Debug.WriteLine($"Version {version}"); + using (MemoryStream packageStream = new MemoryStream()) { if (!await findPackageById.CopyNupkgToStreamAsync( @@ -112,18 +110,18 @@ public async Task DownloadCoreToolsAsync(string nugetSource) return GetSolutionPackagerVersion(dir); } - private void DownloadCoreToolsCompleted(BackgroundWorkResult args) + private void DownloadCoreToolsCompleted(string source, object value, Exception exception) { - if (args.Exception != null) + if (exception != null) { - solutionPackagerControl.WriteErrorLog("The following error occured while downloading core tools: \r\n{0}", args.Exception); - MessageBox.Show(args.Exception.Message, Resources.MBOX_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); + solutionPackagerControl.WriteErrorLog("The following error occured while downloading core tools: \r\n{0}", exception); + MessageBox.Show(exception.Message, Resources.MBOX_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); } - else if (args.Value is string errorMessage) + else if (value is string errorMessage) { MessageBox.Show(errorMessage, Resources.MBOX_INFORMATION, MessageBoxButtons.OK, MessageBoxIcon.Information); } - else if (args.Value is Version version) + else if (value is Version version) { toolViewModel.SolutionPackagerVersion = version.ToString(); } diff --git a/AlbanianXrm.SolutionPackager.Tool/CrmSolutionDownloader.cs b/AlbanianXrm.SolutionPackager.Tool/CrmSolutionDownloader.cs index fff6234..be7048d 100644 --- a/AlbanianXrm.SolutionPackager.Tool/CrmSolutionDownloader.cs +++ b/AlbanianXrm.SolutionPackager.Tool/CrmSolutionDownloader.cs @@ -1,6 +1,7 @@ -using AlbanianXrm.SolutionPackager.Models; +using AlbanianXrm.BackgroundWorker; +using AlbanianXrm.SolutionPackager.Models; using AlbanianXrm.SolutionPackager.Properties; -using AlbanianXrm.XrmToolBox.Shared; +using AlbanianXrm.XrmToolBox.Shared.Extensions; using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; @@ -16,11 +17,11 @@ namespace AlbanianXrm.SolutionPackager internal class CrmSolutionDownloader { private readonly SolutionPackagerControl solutionPackagerControl; - private readonly BackgroundWorkHandler asyncWorkQueue; + private readonly AlBackgroundWorkHandler asyncWorkQueue; private readonly SolutionPackagerCaller solutionPackagerCaller; private readonly ComboBox cmbCrmSolutions; - public CrmSolutionDownloader(SolutionPackagerControl solutionPackagerControl, BackgroundWorkHandler asyncWorkQueue, SolutionPackagerCaller solutionPackagerCaller, ComboBox cmbCrmSolutions) + public CrmSolutionDownloader(SolutionPackagerControl solutionPackagerControl, AlBackgroundWorkHandler asyncWorkQueue, SolutionPackagerCaller solutionPackagerCaller, ComboBox cmbCrmSolutions) { this.solutionPackagerControl = solutionPackagerControl ?? throw new ArgumentNullException(nameof(solutionPackagerControl)); this.asyncWorkQueue = asyncWorkQueue ?? throw new ArgumentNullException(nameof(asyncWorkQueue)); @@ -30,12 +31,10 @@ public CrmSolutionDownloader(SolutionPackagerControl solutionPackagerControl, Ba public void DownloadSolution(Parameters @params) { - asyncWorkQueue.EnqueueWork( - string.Format(CultureInfo.InvariantCulture, Resources.DOWNLOADING_SOLUTION, @params.Solution.FriendlyName), - DownloadSolutionInner, - @params, - DownloadSolutionCompleted - ); + asyncWorkQueue.EnqueueBackgroundWork( + AlBackgroundWorkerFactory.NewWorker(DownloadSolutionInner, @params, DownloadSolutionCompleted) + .WithViewModel(solutionPackagerControl.toolViewModel) + .WithMessage(solutionPackagerControl, string.Format(CultureInfo.InvariantCulture, Resources.DOWNLOADING_SOLUTION, @params.Solution.FriendlyName))); } private SolutionPackagerCaller.Parameters DownloadSolutionInner(Parameters @params) @@ -73,31 +72,30 @@ private SolutionPackagerCaller.Parameters DownloadSolutionInner(Parameters @para return @params.SolutionPackagerParameters; } - private void DownloadSolutionCompleted(BackgroundWorkResult args) + private void DownloadSolutionCompleted(Parameters args, SolutionPackagerCaller.Parameters value, Exception exception) { - if (args.Exception is FaultException crmError) + if (exception is FaultException crmError) { solutionPackagerControl.WriteErrorLog("The following error occurred while downloading the solution:\r\n{0}", crmError); MessageBox.Show(crmError.Message, Resources.MBOX_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); } - else if (args.Exception != null) + else if (exception != null) { - solutionPackagerControl.WriteErrorLog("The following error occurred while downloading the solution:\r\n{0}", args.Exception); - MessageBox.Show(args.Exception.Message, Resources.MBOX_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); + solutionPackagerControl.WriteErrorLog("The following error occurred while downloading the solution:\r\n{0}", exception); + MessageBox.Show(exception.Message, Resources.MBOX_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { - solutionPackagerCaller.ManageSolution(args.Value); + solutionPackagerCaller.ManageSolution(value); } } public void RefreshSolutionList() { - asyncWorkQueue.EnqueueWork( - Resources.REFRESHING_SOLUTION_LIST, - RefreshSolutionListInner, - RefreshSolutionListCompleted - ); + asyncWorkQueue.EnqueueBackgroundWork( + AlBackgroundWorkerFactory.NewWorker(RefreshSolutionListInner, RefreshSolutionListCompleted) + .WithViewModel(solutionPackagerControl.toolViewModel) + .WithMessage(solutionPackagerControl, Resources.REFRESHING_SOLUTION_LIST)); } private object[] RefreshSolutionListInner() @@ -111,18 +109,18 @@ private object[] RefreshSolutionListInner() return solutionPackagerControl.Service.RetrieveMultiple(query).Entities.Select(solution => solution.ToEntity()).ToArray(); } - private void RefreshSolutionListCompleted(BackgroundWorkResult args) + private void RefreshSolutionListCompleted(object[] value, Exception exception) { - if (args.Exception != null) + if (exception != null) { - solutionPackagerControl.WriteErrorLog("The following error occurred while refreshing the solution list:\r\n{0}", args.Exception); - MessageBox.Show(args.Exception.Message, Resources.MBOX_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); + solutionPackagerControl.WriteErrorLog("The following error occurred while refreshing the solution list:\r\n{0}", exception); + MessageBox.Show(exception.Message, Resources.MBOX_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { cmbCrmSolutions.BeginUpdate(); cmbCrmSolutions.Items.Clear(); - cmbCrmSolutions.Items.AddRange(args.Value); + cmbCrmSolutions.Items.AddRange(value); cmbCrmSolutions.EndUpdate(); } } diff --git a/AlbanianXrm.SolutionPackager.Tool/CrmSolutionImporter.cs b/AlbanianXrm.SolutionPackager.Tool/CrmSolutionImporter.cs index 6abba9f..37872e0 100644 --- a/AlbanianXrm.SolutionPackager.Tool/CrmSolutionImporter.cs +++ b/AlbanianXrm.SolutionPackager.Tool/CrmSolutionImporter.cs @@ -1,5 +1,7 @@ -using AlbanianXrm.SolutionPackager.Properties; +using AlbanianXrm.BackgroundWorker; +using AlbanianXrm.SolutionPackager.Properties; using AlbanianXrm.XrmToolBox.Shared; +using AlbanianXrm.XrmToolBox.Shared.Extensions; using Microsoft.Xrm.Sdk.Messages; using System; using System.Globalization; @@ -11,11 +13,11 @@ namespace AlbanianXrm.SolutionPackager internal class CrmSolutionImporter { private readonly SolutionPackagerControl solutionPackagerControl; - private readonly BackgroundWorkHandler asyncWorkQueue; + private readonly AlBackgroundWorkHandler asyncWorkQueue; private readonly ToolViewModel toolViewModel; private SolutionImportStatus solutionImportStatus; - public CrmSolutionImporter(SolutionPackagerControl solutionPackagerControl, BackgroundWorkHandler asyncWorkQueue, ToolViewModel pluginViewModel) + public CrmSolutionImporter(SolutionPackagerControl solutionPackagerControl, AlBackgroundWorkHandler asyncWorkQueue, ToolViewModel pluginViewModel) { this.solutionPackagerControl = solutionPackagerControl; this.asyncWorkQueue = asyncWorkQueue; @@ -30,12 +32,10 @@ public void ImportSolution(Parameters @params) fileInfo = new FileInfo(fileInfo.FullName.Substring(0, fileInfo.FullName.Length - fileInfo.Extension.Length) + "_managed" + fileInfo.Extension); @params.CustomizationFile = fileInfo.FullName; } - asyncWorkQueue.EnqueueWork( - string.Format(CultureInfo.InvariantCulture, Resources.IMPORT_SOLUTION, fileInfo.Name), - ImportSolutionInner, - @params, - ImportSolutionStarted - ); + asyncWorkQueue.EnqueueBackgroundWork( + AlBackgroundWorkerFactory.NewWorker(ImportSolutionInner, @params, ImportSolutionStarted) + .WithViewModel(toolViewModel) + .WithMessage(solutionPackagerControl, string.Format(CultureInfo.InvariantCulture, Resources.IMPORT_SOLUTION, fileInfo.Name))); } private Models.ImportSolutionRequest ImportSolutionInner(Parameters @params) @@ -53,23 +53,23 @@ private Models.ImportSolutionRequest ImportSolutionInner(Parameters @params) CustomizationFile = File.ReadAllBytes(@params.CustomizationFile) } }; - return new Models.ImportSolutionRequest() + return new Models.ImportSolutionRequest() { ImportJobId = importJobId, ExecuteAsyncResponse = solutionPackagerControl.Service.Execute(importSolutionRequest) as ExecuteAsyncResponse }; } - private void ImportSolutionStarted(BackgroundWorkResult args) + private void ImportSolutionStarted(Parameters @params, Models.ImportSolutionRequest value, Exception exception) { - if (args.Exception != null) + if (exception != null) { - solutionPackagerControl.WriteErrorLog("The following error occurred while importing the solution:\r\n{0}", args.Exception); - MessageBox.Show(args.Exception.Message, Resources.MBOX_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); + solutionPackagerControl.WriteErrorLog("The following error occurred while importing the solution:\r\n{0}", exception); + MessageBox.Show(exception.Message, Resources.MBOX_ERROR, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - solutionImportStatus = new SolutionImportStatus(args.Value.ExecuteAsyncResponse.AsyncJobId, args.Value.ImportJobId, solutionPackagerControl, toolViewModel); + solutionImportStatus = new SolutionImportStatus(value.ExecuteAsyncResponse.AsyncJobId, value.ImportJobId, solutionPackagerControl, toolViewModel); solutionImportStatus.Show(solutionPackagerControl); } diff --git a/AlbanianXrm.SolutionPackager.Tool/Interfaces/IMyToolFactory.cs b/AlbanianXrm.SolutionPackager.Tool/Interfaces/IMyToolFactory.cs index c31231c..5b7825d 100644 --- a/AlbanianXrm.SolutionPackager.Tool/Interfaces/IMyToolFactory.cs +++ b/AlbanianXrm.SolutionPackager.Tool/Interfaces/IMyToolFactory.cs @@ -1,4 +1,4 @@ -using AlbanianXrm.XrmToolBox.Shared; +using AlbanianXrm.BackgroundWorker; using System.Windows.Forms; namespace AlbanianXrm.SolutionPackager.Interfaces @@ -6,7 +6,7 @@ namespace AlbanianXrm.SolutionPackager.Interfaces interface IMyToolFactory { ToolViewModel NewToolViewModel(); - BackgroundWorkHandler BackgroundWorkHandler(); + AlBackgroundWorkHandler BackgroundWorkHandler(); CoreToolsDownloader NewCoreToolsDownloader(); CrmSolutionImporter NewCrmSolutionImporter(); SolutionPackagerCaller NewSolutionPackagerCaller(RichTextBox txtOutput, CrmSolutionImporter crmSolutionImporter); diff --git a/AlbanianXrm.SolutionPackager.Tool/MyToolFactory.cs b/AlbanianXrm.SolutionPackager.Tool/MyToolFactory.cs index 55a68c9..3ba5a3d 100644 --- a/AlbanianXrm.SolutionPackager.Tool/MyToolFactory.cs +++ b/AlbanianXrm.SolutionPackager.Tool/MyToolFactory.cs @@ -1,4 +1,5 @@ -using AlbanianXrm.SolutionPackager.Interfaces; +using AlbanianXrm.BackgroundWorker; +using AlbanianXrm.SolutionPackager.Interfaces; using AlbanianXrm.XrmToolBox.Shared; using System.Windows.Forms; @@ -8,13 +9,13 @@ internal class MyToolFactory : IMyToolFactory { private readonly SolutionPackagerControl solutionPackagerControl; private readonly ToolViewModel toolViewModel; - private readonly BackgroundWorkHandler backgroundWorkHandler; + private readonly AlBackgroundWorkHandler backgroundWorkHandler; private MyToolFactory(SolutionPackagerControl solutionPackagerControl) { this.solutionPackagerControl = solutionPackagerControl; this.toolViewModel = new ToolViewModel(); - this.backgroundWorkHandler = new BackgroundWorkHandler(solutionPackagerControl, toolViewModel); + this.backgroundWorkHandler = new AlBackgroundWorkHandler(); } public static IMyToolFactory GetMyToolFactory(SolutionPackagerControl solutionPackagerControl) @@ -22,7 +23,7 @@ public static IMyToolFactory GetMyToolFactory(SolutionPackagerControl solutionPa return new MyToolFactory(solutionPackagerControl); } - public BackgroundWorkHandler BackgroundWorkHandler() + public AlBackgroundWorkHandler BackgroundWorkHandler() { return backgroundWorkHandler; } diff --git a/AlbanianXrm.SolutionPackager.Tool/SolutionPackagerCaller.cs b/AlbanianXrm.SolutionPackager.Tool/SolutionPackagerCaller.cs index 1124d78..dc2bfef 100644 --- a/AlbanianXrm.SolutionPackager.Tool/SolutionPackagerCaller.cs +++ b/AlbanianXrm.SolutionPackager.Tool/SolutionPackagerCaller.cs @@ -1,6 +1,6 @@ -using AlbanianXrm.SolutionPackager.Models; +using AlbanianXrm.BackgroundWorker; using AlbanianXrm.SolutionPackager.Properties; -using AlbanianXrm.XrmToolBox.Shared; +using AlbanianXrm.XrmToolBox.Shared.Extensions; using System; using System.Diagnostics; using System.Drawing; @@ -8,20 +8,19 @@ using System.IO; using System.Windows.Forms; using System.Xml; -using XrmToolBox.Extensibility; namespace AlbanianXrm.SolutionPackager { internal class SolutionPackagerCaller { - private readonly BackgroundWorkHandler backgroundWorkHandler; + private readonly AlBackgroundWorkHandler backgroundWorkHandler; private readonly RichTextBox txtOutput; private readonly SolutionPackagerControl solutionPackagerControl; private readonly CrmSolutionImporter crmSolutionImporter; private const string deleteFilesQuestion = "Delete files? [Yes/No/List]:"; - public SolutionPackagerCaller(SolutionPackagerControl solutionPackagerControl, BackgroundWorkHandler backgroundWorkHandler, RichTextBox txtOutput, CrmSolutionImporter crmSolutionImporter) + public SolutionPackagerCaller(SolutionPackagerControl solutionPackagerControl, AlBackgroundWorkHandler backgroundWorkHandler, RichTextBox txtOutput, CrmSolutionImporter crmSolutionImporter) { this.solutionPackagerControl = solutionPackagerControl ?? throw new ArgumentNullException(nameof(solutionPackagerControl)); this.backgroundWorkHandler = backgroundWorkHandler ?? throw new ArgumentNullException(nameof(backgroundWorkHandler)); @@ -31,16 +30,13 @@ public SolutionPackagerCaller(SolutionPackagerControl solutionPackagerControl, B public void ManageSolution(Parameters @params) { - backgroundWorkHandler.EnqueueWork>( - string.Format(CultureInfo.InvariantCulture, @params.Action == "Pack" ? Resources.PACKING_SOLUTION : Resources.EXTRACTING_SOLUTION, Path.GetFileName(@params.ZipFile)), - ExtractSolution, - @params, - ExtractSolutionProgress, - ExtractSolutionCompleted - ); + backgroundWorkHandler.EnqueueBackgroundWork( + AlBackgroundWorkerFactory.NewWorker(ExtractSolution, @params, ExtractSolutionProgress, ExtractSolutionCompleted) + .WithViewModel(solutionPackagerControl.toolViewModel) + .WithMessage(solutionPackagerControl, string.Format(CultureInfo.InvariantCulture, @params.Action == "Pack" ? Resources.PACKING_SOLUTION : Resources.EXTRACTING_SOLUTION, Path.GetFileName(@params.ZipFile)))); } - private string ExtractSolution(Parameters @params, Reporter> worker) + private string ExtractSolution(Parameters @params, Reporter worker) { string dir = CoreToolsDownloader.GetToolDirectory(); string solutionPackagerFile = Path.Combine(dir, CoreToolsDownloader.solutionPackagerName); @@ -122,12 +118,12 @@ private string ExtractSolution(Parameters @params, Reporter } //Report call parameters - worker.ReportProgress(new ProgressData() { ProgressPercentage = 0, UserState = @params }); + worker.ReportProgress(0, @params); process.Start(); if (!process.StandardOutput.EndOfStream) { - worker.ReportProgress(new ProgressData() { ProgressPercentage = 10 }); + worker.ReportProgress(10, null); char[] buffer = new char[deleteFilesQuestion.Length]; char[] ringBuffer = new char[deleteFilesQuestion.Length]; int ringBufferPosition = 0; @@ -145,7 +141,7 @@ private string ExtractSolution(Parameters @params, Reporter ringBuffer[ringBufferPosition] = buffer[i]; ringBufferPosition = (ringBufferPosition + 1) % ringBuffer.Length; } - worker.ReportProgress(new ProgressData() { ProgressPercentage = 20, UserState = new string(buffer, 0, chars) }); + worker.ReportProgress(20, new string(buffer, 0, chars)); bool isDeleteFilesQuestion = true; for (int i = deleteFilesQuestion.Length - 1; i >= 0; i--) { @@ -158,20 +154,20 @@ private string ExtractSolution(Parameters @params, Reporter if (isDeleteFilesQuestion) { @params.StandardInput = process.StandardInput; - worker.ReportProgress(new ProgressData() { ProgressPercentage = 21, UserState = @params }); + worker.ReportProgress(21, @params); } } - worker.ReportProgress(new ProgressData() { ProgressPercentage = 30 }); + worker.ReportProgress(30, null); } if (!process.StandardError.EndOfStream) { - worker.ReportProgress(new ProgressData() { ProgressPercentage = 40 }); + worker.ReportProgress(40, null); while (!process.StandardError.EndOfStream) { - worker.ReportProgress(new ProgressData() { ProgressPercentage = 50, UserState = process.StandardError.ReadLine() }); + worker.ReportProgress(50, process.StandardError.ReadLine()); } - worker.ReportProgress(new ProgressData() { ProgressPercentage = 60 }); + worker.ReportProgress(60, null); } process.WaitForExit(); @@ -181,14 +177,14 @@ private string ExtractSolution(Parameters @params, Reporter return Resources.SOLUTIONPACKAGER_ERROR; } - worker.ReportProgress(new ProgressData() { ProgressPercentage = 70, UserState = "Ended" }); + worker.ReportProgress(70, "Ended"); if (@params.FormatXml) { var tempFile = Path.GetTempFileName(); foreach (var xmlFile in Directory.GetFiles(@params.OutputFolder, "*.xml", SearchOption.AllDirectories)) { - worker.ReportProgress(new ProgressData() { ProgressPercentage = 80, UserState = new FileInfo(xmlFile) }); + worker.ReportProgress(80, new FileInfo(xmlFile)); XmlDocument document = new XmlDocument(); document.Load(xmlFile); XmlWriterSettings writerSettings = new XmlWriterSettings() @@ -205,7 +201,7 @@ private string ExtractSolution(Parameters @params, Reporter } File.Copy(tempFile, xmlFile, overwrite: true); - worker.ReportProgress(new ProgressData() { ProgressPercentage = 90, UserState = new FileInfo(xmlFile) }); + worker.ReportProgress(90, new FileInfo(xmlFile)); } } @@ -228,13 +224,13 @@ private void AppendArgument(string argument, string value = null) txtOutput.AppendText(value); } - private void ExtractSolutionProgress(ProgressData args) + private void ExtractSolutionProgress(int ProgressPercentage, object UserState) { - switch (args.ProgressPercentage) + switch (ProgressPercentage) { case 0: { - var @params = args.UserState as Parameters ?? throw new ArgumentNullException(nameof(args.UserState)); + var @params = UserState as Parameters ?? throw new ArgumentNullException(nameof(UserState)); txtOutput.Text = ""; txtOutput.SelectionStart = 0; @@ -310,12 +306,12 @@ private void ExtractSolutionProgress(ProgressData args) break; case 20: case 50: - txtOutput.AppendText(args.UserState as string); + txtOutput.AppendText(UserState as string); break; case 40: case 60: txtOutput.SelectionStart = txtOutput.TextLength; - txtOutput.SelectionColor = args.ProgressPercentage == 40 ? Color.Red : txtOutput.ForeColor; + txtOutput.SelectionColor = ProgressPercentage == 40 ? Color.Red : txtOutput.ForeColor; txtOutput.AppendText(Environment.NewLine); break; case 70: @@ -323,7 +319,7 @@ private void ExtractSolutionProgress(ProgressData args) break; case 21: { - var @params = args.UserState as Parameters; + var @params = UserState as Parameters; DialogResult dialogResponse; using (var dialog = new SolutionPackagerDialog()) { @@ -337,16 +333,16 @@ private void ExtractSolutionProgress(ProgressData args) } } - private void ExtractSolutionCompleted(BackgroundWorkResult args) + private void ExtractSolutionCompleted(Parameters @params, string value, Exception exception) { - if (args.Exception != null) + if (exception != null) { - solutionPackagerControl.WriteErrorLog("An error occurred while calling SolutionPackager.exe. Details:\r\n{0}", args.Exception); - MessageBox.Show(args.Exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + solutionPackagerControl.WriteErrorLog("An error occurred while calling SolutionPackager.exe. Details:\r\n{0}", exception); + MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } - else if (args.Value != null) + else if (value != null) { - MessageBox.Show(args.Value.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show(value.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } diff --git a/AlbanianXrm.SolutionPackager.Tool/SolutionPackagerControl.cs b/AlbanianXrm.SolutionPackager.Tool/SolutionPackagerControl.cs index afb0cbe..575da9d 100644 --- a/AlbanianXrm.SolutionPackager.Tool/SolutionPackagerControl.cs +++ b/AlbanianXrm.SolutionPackager.Tool/SolutionPackagerControl.cs @@ -1,7 +1,7 @@ -using AlbanianXrm.SolutionPackager.Extensions; +using AlbanianXrm.BackgroundWorker; +using AlbanianXrm.SolutionPackager.Extensions; using AlbanianXrm.SolutionPackager.Interfaces; using AlbanianXrm.SolutionPackager.Properties; -using AlbanianXrm.XrmToolBox.Shared; using McTools.Xrm.Connection; using Microsoft.Xrm.Sdk; using System; @@ -31,8 +31,8 @@ public void ShowAboutDialog() new SolutionPackagerAbout().ShowDialog(this); } - private readonly ToolViewModel toolViewModel; - private readonly BackgroundWorkHandler backgroundWorkHandler; + internal readonly ToolViewModel toolViewModel; + // private readonly AlBackgroundWorkHandler backgroundWorkHandler; private readonly CoreToolsDownloader coreToolsDownloader; private readonly CrmSolutionDownloader crmSolutionManager; @@ -48,9 +48,10 @@ public SolutionPackagerControl(Type pluginType) { this.pluginType = pluginType; InitializeComponent(); - IMyToolFactory myToolFactory = MyToolFactory.GetMyToolFactory(this); + IMyToolFactory myToolFactory = MyToolFactory.GetMyToolFactory(this); toolViewModel = myToolFactory.NewToolViewModel(); - backgroundWorkHandler = myToolFactory.BackgroundWorkHandler(); + /* backgroundWorkHandler = */ + myToolFactory.BackgroundWorkHandler(); coreToolsDownloader = myToolFactory.NewCoreToolsDownloader(); crmSolutionImporter = myToolFactory.NewCrmSolutionImporter(); solutionPackagerCaller = myToolFactory.NewSolutionPackagerCaller(txtOutput, crmSolutionImporter); diff --git a/AlbanianXrm.SolutionPackager.Tool/SolutionPackagerControl.resx b/AlbanianXrm.SolutionPackager.Tool/SolutionPackagerControl.resx index 5fd49eb..001bd86 100644 --- a/AlbanianXrm.SolutionPackager.Tool/SolutionPackagerControl.resx +++ b/AlbanianXrm.SolutionPackager.Tool/SolutionPackagerControl.resx @@ -129,6 +129,12 @@ 0, 0 + + True + + + GrowAndShrink + 3 @@ -2131,7 +2137,7 @@ You can use the short form of the command: /loc. SolutionPackagerControl - XrmToolBox.Extensibility.PluginControlBase, XrmToolBox.Extensibility, Version=1.2020.12.43, Culture=neutral, PublicKeyToken=null + XrmToolBox.Extensibility.PluginControlBase, XrmToolBox.Extensibility, Version=1.2021.12.53, Culture=neutral, PublicKeyToken=null MiddleLeft @@ -2217,11 +2223,14 @@ You can use the short form of the command: /loc. 3, 3 + + 0, 0, 20, 0 + 4 - 426, 766 + 446, 766 31 @@ -2248,7 +2257,7 @@ You can use the short form of the command: /loc. 3, 3, 3, 3 - 432, 772 + 452, 772 0 @@ -2268,6 +2277,9 @@ You can use the short form of the command: /loc. 0 + + True + 3 @@ -3531,11 +3543,14 @@ You can use the short form of the command: /loc. 3, 3 + + 0, 0, 20, 0 + 4 - 426, 766 + 446, 766 0 @@ -3562,7 +3577,7 @@ You can use the short form of the command: /loc. 3, 3, 3, 3 - 432, 772 + 452, 772 1 @@ -3688,7 +3703,7 @@ You can use the short form of the command: /loc. 0, 0, 0, 0 - 40, 102 + 60, 102 2 @@ -3997,7 +4012,7 @@ You can use the short form of the command: /loc. 3 - 426, 766 + 446, 766 18 @@ -4024,7 +4039,7 @@ You can use the short form of the command: /loc. 3, 3, 3, 3 - 432, 772 + 452, 772 2 @@ -4057,7 +4072,7 @@ You can use the short form of the command: /loc. 5, 5, 5, 6 - 440, 800 + 460, 800 0 @@ -4093,7 +4108,7 @@ You can use the short form of the command: /loc. 0, 0 - 356, 800 + 336, 800 0 @@ -4129,7 +4144,7 @@ You can use the short form of the command: /loc. 800, 800 - 440 + 460 1 diff --git a/AlbanianXrm.SolutionPackager/AlbanianXrm.SolutionPackager.csproj b/AlbanianXrm.SolutionPackager/AlbanianXrm.SolutionPackager.csproj index d3fe00b..5087dec 100644 --- a/AlbanianXrm.SolutionPackager/AlbanianXrm.SolutionPackager.csproj +++ b/AlbanianXrm.SolutionPackager/AlbanianXrm.SolutionPackager.csproj @@ -44,7 +44,7 @@ MinimumRecommendedRules.ruleset - + diff --git a/AlbanianXrm.SolutionPackager/AlbanianXrm.SolutionPackager.nuspec b/AlbanianXrm.SolutionPackager/AlbanianXrm.SolutionPackager.nuspec index 4b2fec7..45a5f09 100644 --- a/AlbanianXrm.SolutionPackager/AlbanianXrm.SolutionPackager.nuspec +++ b/AlbanianXrm.SolutionPackager/AlbanianXrm.SolutionPackager.nuspec @@ -14,14 +14,13 @@ Uses SolutionPackager.exe from the SDK which can be downloaded from any NuGet source (even local directory for isolated environments). This is a GUI for SolutionPackager.exe (it shows the command line used to help with the parameters) v$version$: -- Updated CoreToolsDownloader to use NuGet v3. -- Using AlbanianXrm.XrmToolBox.Shared for BackgroundWork and ToolViewModel. +- Added scrollbar for small screens * For older releases go here: https://github.com/albanian-xrm/Solution-Packager/releases Copyright 2021 XrmToolBox Plugins Xrm AlbanianXrm SolutionPackager - + diff --git a/AlbanianXrm.SolutionPackager/ILMergeConfig.json b/AlbanianXrm.SolutionPackager/ILMergeConfig.json index 812e140..93f7e73 100644 --- a/AlbanianXrm.SolutionPackager/ILMergeConfig.json +++ b/AlbanianXrm.SolutionPackager/ILMergeConfig.json @@ -2,13 +2,7 @@ "General": { "OutputFile": "$(TargetDir)XrmToolBox\\Plugins\\AlbanianXrm.SolutionPackager\\$(TargetFileName)", "InputAssemblies": [ - "AlbanianXrm.XrmToolBox.Shared.dll", - "NuGet.Common.dll", - "NuGet.Configuration.dll", - "NuGet.Frameworks.dll", - "NuGet.Packaging.dll", - "NuGet.Protocol.dll", - "NuGet.Versioning.dll" + "AlbanianXrm.XrmToolBox.Shared.dll" ] }, "Advanced": {