/// <summary> /// Method check if there are master solutions available by solutions id and if present returns true. /// </summary> /// <param name="service">Organization service</param> /// <param name="solutionId">CRM Solution Id</param> /// <param name="tracingService">Tracing Service to trace error</param> /// <returns>returns boolean value</returns> public static bool IsDeletable(IOrganizationService service, string solutionId, ITracingService tracingService) { bool isDeletable = true; Guid solutionGuid = new Guid(solutionId); EntityCollection solutionlist = SolutionHelper.RetrieveSolutionById(service, solutionGuid, tracingService); if (solutionlist.Entities.Count == 0) { isDeletable = false; } return(isDeletable); }
/// <summary> /// To delete Merge Solution records. /// </summary> /// <param name="service">Organization service</param> /// <param name="sourceControlQueue">Dynamic Source Control entity GUID</param> /// <param name="tracingService">Tracing Service to trace error</param> public static void CreateSolutionDetail(IOrganizationService service, syed_sourcecontrolqueue sourceControlQueue, ITracingService tracingService) { //Copy feilds from Template Record. EntityCollection copyDynamicsTemplate = SolutionHelper.RetrieveDynamicsSourceControlTemplate(service, tracingService); foreach (syed_sourcecontrolqueue syed_Sourcecontrolqueue in copyDynamicsTemplate.Entities) { syed_sourcecontrolqueue _sourcecontrolqueue = new syed_sourcecontrolqueue(); _sourcecontrolqueue.syed_Branch = syed_Sourcecontrolqueue.syed_Branch; _sourcecontrolqueue.syed_RemoteName = syed_Sourcecontrolqueue.syed_RemoteName; _sourcecontrolqueue.syed_RepositoryUrl = syed_Sourcecontrolqueue.syed_RepositoryUrl; _sourcecontrolqueue.syed_SourceControl = syed_Sourcecontrolqueue.syed_SourceControl; _sourcecontrolqueue.Id = sourceControlQueue.Id; _sourcecontrolqueue.syed_IsShedulled = syed_Sourcecontrolqueue.syed_IsShedulled; _sourcecontrolqueue.syed_overwritesolutionstxt = syed_Sourcecontrolqueue.syed_overwritesolutionstxt; service.Update(_sourcecontrolqueue); break; } //Copy Master Solution Record from Template. EntityCollection copyTemplate = SolutionHelper.RetrieveMasterSolutionTemplate(service, tracingService); foreach (syed_solutiondetail solutionDetail in copyTemplate.Entities) { ExecuteOperations.CreateSolutionDetail(service, solutionDetail, sourceControlQueue); break; } EntityCollection crmSolution = SolutionHelper.RetrieveMasterSolutionById(service, sourceControlQueue.syed_CheckInBySolutionId, tracingService); if (crmSolution.Entities.Count > 0) { foreach (syed_mastersolutions mastersolutions in crmSolution.Entities) { ExecuteOperations.CreateSolutionDetail(service, mastersolutions, sourceControlQueue); break; } } else { EntityCollection solutionCollection = SolutionHelper.RetrieveSolutionById(service, new Guid(sourceControlQueue.syed_CheckInBySolutionId), tracingService); foreach (Solution sol in solutionCollection.Entities) { Guid id = ExecuteOperations.CreateMasterSolution(service, sol); syed_mastersolutions syed_Mastersolutions = service.Retrieve(syed_mastersolutions.EntityLogicalName.ToString(), id, new ColumnSet(true)).ToEntity <syed_mastersolutions>(); ExecuteOperations.CreateSolutionDetail(service, syed_Mastersolutions, sourceControlQueue); break; } } }