Esempio n. 1
0
        public void Compare(IEnumerable <string> dealCodes, XPathDifferences xpathsToIgnore, IAlterXml[] xmlAlterations, IEnumerable <string> contractTypesToCheck, string messageType)
        {
            try
            {
                foreach (var dealCode in dealCodes)
                {
                    var rh1File = this.rh1MessageCreator.CreateXml(dealCode);
                    var rh2File = this.rh2MessageCreator.CreateXml(dealCode);
                    this.comparisonStrategy.Open(rh1File, rh2File, dealCode);
                }

                if (comparisonStrategy is IWriteComparisonToFile writeComparisonToFile)
                {
                    writeComparisonToFile.Write(xpathsToIgnore, xmlAlterations, contractTypesToCheck, messageType);
                    writeComparisonToFile.Dispose();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                Console.ReadLine();
            }
        }
Esempio n. 2
0
        public void Write(XPathDifferences xpathsToIgnore, IEnumerable <IAlterXml> xmlAlterations, IEnumerable <string> contractTypesToCheck, string messageType)
        {
            this.csvWriter = new StreamWriter($"differences_{messageType}.csv");
            csvWriter.WriteLine($"Deals: {results.Count}");

            if (contractTypesToCheck.Any())
            {
                csvWriter.WriteLine("Contract types");
                foreach (var contractType in contractTypesToCheck)
                {
                    csvWriter.WriteLine(contractType);
                }
            }
            else
            {
                csvWriter.WriteLine("No contract types selected");
            }
            csvWriter.WriteLine("---------------");
            csvWriter.WriteLine("Ignore XPaths");
            foreach (var xpath in xpathsToIgnore.Differences)
            {
                csvWriter.WriteLine($"{xpath.XPath}, {xpath.Reason}");
            }

            csvWriter.WriteLine("---------------");
            csvWriter.WriteLine("XML Alterations");
            foreach (var alteration in xmlAlterations)
            {
                csvWriter.WriteLine(alteration.GetDescriptionForReport());
            }

            csvWriter.WriteLine();
            csvWriter.WriteLine();
            csvWriter.WriteLine();
            csvWriter.WriteLine($"Unnacounted Differences, {dealDifferenceSummaries.UnaccountedForErrorAndCounts.Sum(s => s.Count)}");
            csvWriter.WriteLine("Difference, Count");
            foreach (var unaccountedDifferenceAndCount in dealDifferenceSummaries.UnaccountedForErrorAndCounts.OrderByDescending(s => s.Count))
            {
                csvWriter.WriteLine($"{unaccountedDifferenceAndCount.Difference}, {unaccountedDifferenceAndCount.Count}");
            }

            csvWriter.WriteLine();
            csvWriter.WriteLine();
            csvWriter.WriteLine();

            csvWriter.WriteLine($"Acounted Differences, {dealDifferenceSummaries.UnaccountedForErrorAndCounts.Sum(s => s.Count)}");
            csvWriter.WriteLine("Difference, Reason, Count");
            foreach (var accountedDifferenceAndCount in dealDifferenceSummaries.AccountedForErrorAndCounts.OrderByDescending(s => s.Count))
            {
                csvWriter.WriteLine($"{accountedDifferenceAndCount.Difference}, {accountedDifferenceAndCount.Reason}, {accountedDifferenceAndCount.Count}");
            }

            csvWriter.WriteLine();
            csvWriter.WriteLine();
            csvWriter.WriteLine();

            csvWriter.WriteLine();
            csvWriter.WriteLine("Difference, RH1, RH2");

            foreach (var result in this.results)
            {
                var dealCodeWithoutPrefixes = result.DealCode.Replace("_DC", "").Replace("_PR", "");
                csvWriter.WriteLine($"Deal code: {dealCodeWithoutPrefixes}");

                foreach (var difference in result.DifferenceAndXPaths)
                {
                    csvWriter.WriteLine($"{difference.Difference}, {difference.ComparisonXPath}, {difference.TargetXPath}");
                }

                csvWriter.WriteLine();
            }

            csvWriter.WriteLine();
            csvWriter.WriteLine();

            var allAccountedDifferences = dealDifferenceSummaries.AccountedForErrorAndCounts.Select(s => s.Difference).ToList();

            var allXpaths = this.results
                            .SelectMany(s => s.DifferenceAndXPaths)
                            .Where(w => allAccountedDifferences.Contains(w.Difference) == false)
                            .Select(s => s.ComparisonXPath.IsNullOrEmpty() ? s.TargetXPath : s.ComparisonXPath)
                            .Where(w => w.IsNullOrEmpty() == false);

            var countOfPaths = CountPaths(allXpaths).OrderBy(s => s.Count);

            csvWriter.WriteLine("Count Of Differences By Path");
            csvWriter.WriteLine("Path, Count");
            foreach (var pathAndCount in countOfPaths)
            {
                csvWriter.WriteLine($"{pathAndCount.Path}, {pathAndCount.Count}");
            }

            csvWriter.WriteLine();
            csvWriter.WriteLine();
            csvWriter.WriteLine("Deals that did not publish in RH2");
            foreach (var dealDidntPublishInRh2 in this.results.Where(s => s.DidNotPubllishInRH2))
            {
                csvWriter.Write(dealDidntPublishInRh2.DealCode);
                csvWriter.Write(" ");
            }
        }
Esempio n. 3
0
 public RavenMessageXmlCreator(XPathDifferences xPaths, params IAlterXml[] xmlAlterations)
 {
     this.xPaths         = xPaths;
     this.xmlAlterations = xmlAlterations;
 }