/// <summary> /// Background Worker Event DoWork /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param> private void Worker_DoWork(object sender, DoWorkEventArgs e) { if (this.localPath == null) { return; } if (this.crmSolutions == null) { return; } if (this.crmConnection == null) { return; } foreach (Core.Xrm.CrmSolution crmSolution in this.crmSolutions) { if (this.managed) { Core.Xrm.ToolingConnector toolingConnector = new Core.Xrm.ToolingConnector(); toolingConnector.DownloadSolution(toolingConnector.GetCrmServiceClient(this.crmConnection.ConnectionString), crmSolution.UniqueName, this.localPath, true); } if (this.unmanaged) { Core.Xrm.ToolingConnector toolingConnector = new Core.Xrm.ToolingConnector(); toolingConnector.DownloadSolution(toolingConnector.GetCrmServiceClient(this.crmConnection.ConnectionString), crmSolution.UniqueName, this.localPath); } this.progress = this.progress + this.progressStep; this.worker.ReportProgress(Convert.ToInt16(this.progress)); } }
/// <summary> /// Main logic for the command line /// </summary> /// <param name="args">Command Line Args</param> public static void Main(string[] args) { InitParameters(args); Core.Xrm.ToolingConnector toolingConnector = null; try { toolingConnector = new Core.Xrm.ToolingConnector(); using (CrmServiceClient client = toolingConnector.GetCrmServiceClient(GetParameter("connection-string"))) { if (HasParameter("timeout")) { client.OrganizationServiceProxy.Timeout = TimeSpan.FromMinutes( Convert.ToDouble(GetParameter("timeout")) ); } if (client.IsReady) { string solutionName = GetParameter("solution-name"); string localPath = GetParameter("local-path"); toolingConnector.DownloadSolution(client, solutionName, localPath); Console.WriteLine("Download completed: " + Path.Combine(localPath, solutionName + ".zip").ToString()); if (Convert.ToBoolean(GetParameter("action"))) { // Extract Solution Core.Xrm.CrmSolutionPackager packager = new Core.Xrm.CrmSolutionPackager(); string log = packager.ExtractCustomizing(Path.Combine(localPath, solutionName + ".zip").ToString(), localPath); Console.Write(log); } } } toolingConnector.Dispose(); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); Console.Write(ex.StackTrace); Console.ResetColor(); Console.ReadLine(); } finally { if (toolingConnector != null) { ((IDisposable)toolingConnector).Dispose(); } } }
/// <summary> /// Main logic for the command line /// </summary> /// <param name="args">Command Line Args</param> public static void Main(string[] args) { GetParameter(args); Core.Xrm.ToolingConnector toolingConnector = null; try { toolingConnector = new Core.Xrm.ToolingConnector(); using (CrmServiceClient client = toolingConnector.GetCrmServiceClient(parameters.SingleOrDefault(x => x.Name == "connection-string").Value)) { if (client.IsReady) { string solutionName = parameters.SingleOrDefault(x => x.Name == "solution-name").Value; string localPath = parameters.SingleOrDefault(x => x.Name == "local-path").Value; toolingConnector.DownloadSolution(client, solutionName, localPath); Console.WriteLine("Download completed: " + Path.Combine(localPath, solutionName + ".zip").ToString()); if (Convert.ToBoolean(parameters.SingleOrDefault(x => x.Name == "action").Value)) { // Extract Solution Core.Xrm.CrmSolutionPackager packager = new Core.Xrm.CrmSolutionPackager(); string log = packager.ExtractCustomizing(Path.Combine(localPath, solutionName + ".zip").ToString(), localPath); Console.Write(log); } } } toolingConnector.Dispose(); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex.Message); Console.Write(ex.StackTrace); Console.ResetColor(); Console.ReadLine(); } finally { if (toolingConnector != null) { ((IDisposable)toolingConnector).Dispose(); } } }