protected override void ProcessRecord() { base.ProcessRecord(); base.WriteVerbose(string.Format("Upgrading Solution: {0}", UniqueSolutionName)); // TODO: I think this is not necessary because you will get back an Id if you overload Guid.Empty if (ImportJobId == Guid.Empty) { ImportJobId = Guid.NewGuid(); } if (AsyncWaitTimeout == 0) { AsyncWaitTimeout = 15 * 60; base.WriteVerbose(string.Format("Setting Default AsyncWaitTimeout: {0}", AsyncWaitTimeout)); } if (SleepInterval == 0) { SleepInterval = 15; base.WriteVerbose(string.Format("Setting Default SleepInterval: {0}", SleepInterval)); } base.WriteCommandDetail(string.Format("ImportJobId {0}", ImportJobId)); var upgradeSolutionRequest = new DeleteAndPromoteRequest { UniqueName = UniqueSolutionName, RequestId = ImportJobId }; if (ImportAsync) { var asyncRequest = new ExecuteAsyncRequest { Request = upgradeSolutionRequest, RequestId = ImportJobId }; var asyncResponse = OrganizationService.Execute(asyncRequest) as ExecuteAsyncResponse; Guid asyncJobId = asyncResponse.AsyncJobId; WriteObject(asyncJobId); if (WaitForCompletion) { AwaitCompletion(asyncJobId); } } else { OrganizationService.Execute(upgradeSolutionRequest); } base.WriteVerbose(string.Format("{0} Upgrade Completed {1}", UniqueSolutionName, ImportJobId)); }
protected override void ProcessRecord() { base.ProcessRecord(); base.WriteVerbose(string.Format("Upgrading Solution: {0}", UniqueSolutionName)); if (AsyncWaitTimeout == 0) { AsyncWaitTimeout = 15 * 60; base.WriteVerbose(string.Format("Setting Default AsyncWaitTimeout: {0}", AsyncWaitTimeout)); } if (SleepInterval == 0) { SleepInterval = 15; base.WriteVerbose(string.Format("Setting Default SleepInterval: {0}", SleepInterval)); } var upgradeSolutionRequest = new DeleteAndPromoteRequest { UniqueName = UniqueSolutionName }; if (ImportAsync) { var asyncRequest = new ExecuteAsyncRequest { Request = upgradeSolutionRequest }; base.WriteVerbose("Applying using Async Mode"); var asyncResponse = OrganizationService.Execute(asyncRequest) as ExecuteAsyncResponse; Guid asyncJobId = asyncResponse.AsyncJobId; base.WriteVerbose(string.Format("Async JobId: {0}", asyncJobId)); WriteObject(asyncJobId); if (WaitForCompletion) { base.WriteVerbose("Waiting for completion"); AwaitCompletion(asyncJobId); } } else { OrganizationService.Execute(upgradeSolutionRequest); } base.WriteVerbose(string.Format("{0} Upgrade Completed", UniqueSolutionName)); VerifyUpgrade(); }
protected override void ProcessRecord() { base.ProcessRecord(); base.WriteVerbose(string.Format("Upgrading Solution: {0}", UniqueSolutionName)); var upgradeSolutionRequest = new DeleteAndPromoteRequest { UniqueName = UniqueSolutionName, }; OrganizationService.Execute(upgradeSolutionRequest); base.WriteVerbose(string.Format("{0} Upgrade Completed", UniqueSolutionName)); }
public virtual DeleteAndPromoteResponse DeleteAndPromoteSolution(string uniqueName) { Logger.Trace(CultureInfo.InvariantCulture, TraceMessageHelper.EnteredMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name); if (string.IsNullOrWhiteSpace(uniqueName)) { throw new ArgumentNullException(nameof(uniqueName)); } DeleteAndPromoteRequest req = new DeleteAndPromoteRequest { UniqueName = uniqueName }; DeleteAndPromoteResponse res = (DeleteAndPromoteResponse)OrganizationServiceContext.Execute(req); Logger.Trace(CultureInfo.InvariantCulture, TraceMessageHelper.ExitingMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name); return(res); }
static void Main(string[] args) { var solutionName = args[0]; string connectionString = args.Length == 3 ? args[1] + args[2] + ";" : ConfigurationManager.ConnectionStrings["CRM"].ConnectionString; if (string.IsNullOrEmpty(connectionString)) { throw new Exception("No ConnectionString found."); } CrmServiceClient client = new CrmServiceClient(connectionString); var request = new DeleteAndPromoteRequest { UniqueName = solutionName }; client.Execute(request); }
public SolutionApplyResult ApplySolution( string solutionName, bool importAsync, int sleepInterval, int asyncWaitTimeout ) { Logger.LogVerbose("Upgrading Solution: {0}", solutionName); if (SkipUpgrade(solutionName)) { return(new SolutionApplyResult() { Success = true, ApplySkipped = true }); } Exception syncApplyException = null; AsyncOperation asyncOperation = null; var upgradeSolutionRequest = new DeleteAndPromoteRequest { UniqueName = solutionName }; if (importAsync) { var asyncRequest = new ExecuteAsyncRequest { Request = upgradeSolutionRequest }; Logger.LogVerbose("Applying using Async Mode"); var asyncResponse = OrganizationService.Execute(asyncRequest) as ExecuteAsyncResponse; Guid asyncJobId = asyncResponse.AsyncJobId; Logger.LogInformation(string.Format("Async JobId: {0}", asyncJobId)); Logger.LogVerbose("Awaiting for Async Operation Completion"); AsyncOperationManager asyncOperationManager = new AsyncOperationManager( Logger, PollingOrganizationService); asyncOperation = asyncOperationManager.AwaitCompletion( asyncJobId, asyncWaitTimeout, sleepInterval, null); Logger.LogInformation("Async Operation completed with status: {0}", ((AsyncOperation_StatusCode)asyncOperation.StatusCode.Value).ToString()); Logger.LogInformation("Async Operation completed with message: {0}", asyncOperation.Message); } else { try { OrganizationService.Execute(upgradeSolutionRequest); } catch (Exception ex) { syncApplyException = ex; } } SolutionApplyResult result = VerifyUpgrade( solutionName, asyncOperation, syncApplyException); if (result.Success) { Logger.LogInformation("Solution Apply Completed Successfully"); } else { Logger.LogInformation("Solution Apply Failed"); } return(result); }