/// <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> /// 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) { Microsoft.Xrm.Tooling.Connector.CrmServiceClient crmServiceClient = null; try { using (Core.Xrm.ToolingConnector toolingConnector = new Core.Xrm.ToolingConnector()) { Core.Xrm.CrmConnection crmConnection = this.selectedCrmConnection; crmServiceClient = toolingConnector.GetCrmServiceClient(crmConnection.ConnectionString); // Get Crm Solutions this.crmSolutions.Clear(); this.crmSolutions = toolingConnector.GetCrmSolutions(crmServiceClient); } } catch (Exception ex) { Log.Error(ex.Message, ex); if (!Properties.Settings.Default.DisableErrorReports) { throw; } } finally { if (crmServiceClient != null) { crmServiceClient.Dispose(); } } }
/// <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(); } } }
/// <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) { Microsoft.Xrm.Tooling.Connector.CrmServiceClient crmServiceClient = null; try { using (Core.Xrm.ToolingConnector toolingConnector = new Core.Xrm.ToolingConnector()) { List <Core.Xrm.CrmConnection> crmConnections = Core.Data.StorageExtensions.Load(MainWindow.EncryptionKey); Core.Xrm.CrmConnection crmConnection = crmConnections.Find(x => x.Name == this.selectedCrmConnection); crmServiceClient = toolingConnector.GetCrmServiceClient(crmConnection.ConnectionString); // Get Crm Solutions this.crmSolutions.Clear(); this.crmSolutions = toolingConnector.GetCrmSolutions(crmServiceClient); foreach (Core.Xrm.CrmSolution solution in this.localSolutions) { if (this.crmSolutions.Exists(x => x.UniqueName == solution.UniqueName)) { this.crmSolutions.Find(x => x.UniqueName == solution.UniqueName).LocalVersion = solution.LocalVersion; } } } } catch (Exception ex) { Log.Error(ex.Message, ex); if (!Properties.Settings.Default.DisableErrorReports) { throw; } } finally { if (crmServiceClient != null) { crmServiceClient.Dispose(); } } }