Exemplo n.º 1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            var logger = new CmdletLoggerPS(this, false);

            try
            {
                var generatedFiles = new List <string>();

                var solutionRepository  = new SolutionRepository(new CrmServiceClient(ConnectionString), logger);
                var solutionAuditor     = new CrmAuditor(solutionRepository, logger);
                var publishersToInclude = RequiredPublishers.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList();


                var crmInstance = solutionAuditor.AuditCrmInstance(InstanceName, publishersToInclude);

                logger.Verbose("About to generate HTML report");
                var htmlWriter = new HtmlReport(OutputDir);
                var htmlFiles  = htmlWriter.SaveSolutionAudit(crmInstance);
                generatedFiles.Add(htmlFiles.First(x => x.Contains("Home_")));
                logger.Verbose("HTML report completed");

                if (GenerateExcelReport)
                {
                    logger.Verbose("About to generate Excel report");
                    var excelWriter = new ExcelReport(OutputDir);
                    generatedFiles.AddRange(excelWriter.SaveSolutionAudit(crmInstance));
                    logger.Verbose("Excel report completed");
                }

                if (GenerateJsonReport)
                {
                    logger.Verbose("About to generate JSON report");
                    var jsonWriter = new JsonReport(OutputDir);
                    generatedFiles.AddRange(jsonWriter.SaveSolutionAudit(crmInstance));
                    logger.Verbose("JSON report completed");
                }

                if (GenerateXmlReport)
                {
                    logger.Verbose("About to generate XML report");
                    var xmlWriter = new XmlReport(OutputDir);
                    generatedFiles.AddRange(xmlWriter.SaveSolutionAudit(crmInstance));
                    logger.Verbose("XML report completed");
                }

                if (!string.IsNullOrWhiteSpace(SendGridKey) && !string.IsNullOrWhiteSpace(ReportsToRecipients))
                {
                    SendReportsToRecipients(SendGridKey, ReportsToRecipients, crmInstance.Name.Replace(".dynamics.com", ""), generatedFiles, ReportName);
                }
            }
            catch (Exception exception)
            {
                var errorMessage = $"Dynamics365 solution audit failed: {exception.Message}";
                logger.Verbose(errorMessage);
                logger.Error(errorMessage);
                throw;
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var _logger         = new ConsoleLogger();
            var repository      = new SolutionRepository(new CrmServiceClient(CrmConnectionString), _logger);
            var solutionAuditor = new CrmAuditor(repository, _logger);
            var publisherFilter = new List <string> {
                "Dynamics 365"
            };

            var crmInstance = solutionAuditor.AuditCrmInstance(InstanceName, publisherFilter);

            var excelReport = new ExcelReport(_downloadsPath);

            excelReport.SaveSolutionAudit(crmInstance);

            var xmlReport = new XmlReport(_downloadsPath);

            xmlReport.SaveSolutionAudit(crmInstance);

            var htmlReport = new HtmlReport(_downloadsPath);

            htmlReport.SaveSolutionAudit(crmInstance);

            var jsonReport = new JsonReport(_downloadsPath);

            jsonReport.SaveSolutionAudit(crmInstance);
        }