public ValidationResults Validate(CRMSolution solution) { ValidationResults allValidatorsResult = new ValidationResults(); if (Validators == null || Validators.Count == 0) { throw new InvalidOperationException("No Validators exist, please change the validation settings first"); } //publish all customizations first if the settings allow it if (MySettings.AlwaysPublish) { OnProgressChanged?.Invoke(this, new ProgressEventArgs("Publishing customizations")); PublishAllXmlRequest publishRequest = new PublishAllXmlRequest(); CRMService.Execute(publishRequest); } // start the validators foreach (IValidator validator in Validators) { validator.OnValidatorError += (s, e) => { OnError?.Invoke(s, e); }; validator.OnValidatorProgress += (s, e) => { OnProgressChanged?.Invoke(s, new ProgressEventArgs(e.Message)); }; ValidationResults validatorResult = validator.Validate(); allValidatorsResult.AddResultSet(validatorResult); } return(allValidatorsResult); }
public SlimSolutionManager(IOrganizationService service, CRMSolution solution, Settings mySettings) { Solution = solution; CRMService = service; MySettings = mySettings; Results = new ValidationResults(); Validators = GetValidators(); }
private void CheckSolution() { var selectedSolutionItem = lstSolutions.SelectedItem as ListBoxItem; if (selectedSolutionItem != null) { Entity solutionRecord = solutionEntities.FirstOrDefault(x => x.GetAttributeValue <string>("uniquename") == selectedSolutionItem.Name); crmSolution = new CRMSolution(solutionRecord); slimSolutionManager = new ValidatorsManager(Service, crmSolution, mySettings); ValidationResults finalResultsAndIssues = new ValidationResults(); gvResults.Rows.Clear(); WorkAsync(new WorkAsyncInfo { Message = "Checking solution components ... ", Work = (worker, args) => { slimSolutionManager.OnProgressChanged += (source, progressArgs) => { worker.ReportProgress(0, progressArgs.Message); }; finalResultsAndIssues = slimSolutionManager.Validate(crmSolution); }, PostWorkCallBack = (args) => { if (args.Error != null) { LogError("An error happened while checking the solution.", args.Error); MessageBox.Show(args.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (finalResultsAndIssues.ResultRecords.Count == 0) { MessageBox.Show($"The solution is in good state and there is nothing to cleanup"); return; } // bind the finalResults here foreach (Models.ValidationResult vr in finalResultsAndIssues.ResultRecords) { gvResults.Rows.Add(vr.Regarding, vr.Description, vr.Suggestions); } }, ProgressChanged = (progressArgs) => { SetWorkingMessage(progressArgs.UserState.ToString()); }, }); } else { MessageBox.Show("Please select a solution from the list first."); } }
public ComponentsValidator(IOrganizationService service, CRMSolution solution) { CRMService = service; Solution = solution; AllResults = new ValidationResults(); }
public ProcessValidator(IOrganizationService service, CRMSolution solution) { CRMService = service; Solution = solution; }