Example #1
0
        protected ComparisonRow BuildUnmappedVehicleHistoryRow(bool siteComparison)
        {
            var vehicleHistories = BaseVehicleDataAccess.GetVehicleHistoryQueryable(Parameters, DataContext, true, true);

            if (vehicleHistories == null)
            {
                return(new ComparisonRow());
            }

            var startDate = Parameters.GetDateFromDictionary(DictionaryParameter.StartDate);

            vehicleHistories = from hd in vehicleHistories
                               where hd.TimeStamp == startDate
                               select hd;


            var historyGroups = from v in vehicleHistories
                                select new { v.VehicleHistoryId, cg = v.Vehicle.CarGroup, country = v.Vehicle.OwningCountry, lastLocation = v.LocationCode };

            IQueryable <int> matchedSet;

            if (siteComparison)
            {
                matchedSet = from hg in historyGroups
                             join loc in DataContext.LOCATIONs.Select(d => d.location1).Distinct()
                             on hg.lastLocation equals loc
                             select hg.VehicleHistoryId;
            }
            else
            {
                var carGroups = (from cg in DataContext.CAR_GROUPs
                                 select new { cg = cg.car_group1, cg.CAR_CLASS.CAR_SEGMENT.country }).Distinct();

                matchedSet = from hg in historyGroups
                             join cg in carGroups on new { hg.cg, hg.country }
                equals new { cg.cg, cg.country }
                select hg.VehicleHistoryId;
            }


            var unmappedCars = from vh in vehicleHistories.Where(d => !matchedSet.Any(m => m == d.VehicleHistoryId))
                               select vh;


            if (!unmappedCars.Any())
            {
                return(null);
            }

            var totalRow = new ComparisonRow
            {
                Key            = NotFoundKeyName,
                FleetCount     = unmappedCars.Count(),
                NonRevCount    = unmappedCars.Sum(d => d.IsNonRev ? 1 : 0),
                ReasonsEntered = unmappedCars.Sum(d => d.RemarkId == null ? 0 : 1),
            };

            return(totalRow);
        }
Example #2
0
        protected static ComparisonRow BuildTotalRow(List <ComparisonRow> comparisonData)
        {
            var totalRow = new ComparisonRow
            {
                Key            = TotalKeyName,
                FleetCount     = comparisonData.Where(d => d != null).Sum(d => d.FleetCount),
                DaysNonRev     = comparisonData.Where(d => d != null).Sum(d => d.DaysNonRev),
                NonRevCount    = comparisonData.Where(d => d != null).Sum(d => d.NonRevCount),
                ReasonsEntered = comparisonData.Where(d => d != null).Sum(d => d.ReasonsEntered)
            };

            return(totalRow);
        }
Example #3
0
        public static void CompareRowFromDocumentWithCreatingRow()
        {
            string sourcePath =
                @"GroupDocs.Comparison.Samples.Words.Components.data.CompareRowFromDocumentWithCreatingRow.source.docx";

            // Create to stream of document
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   sourceStream = assembly.GetManifestResourceStream(sourcePath);

            // Opening source document
            IComparisonDocument sourceDocument = new ComparisonDocument(sourceStream);

            Console.WriteLine("Document with source path: " + sourcePath + " was loaded.");

            // Getting first Row from source document
            IComparisonRow sourceRow = (sourceDocument.Sections[0].Body.GetChildNodes(ComparisonNodeType.Table, false)[0] as IComparisonTable).Rows[0];

            // Creating Row
            IComparisonRow       targetRow = new ComparisonRow(new double[] { 100, 100, 100 }, 20);
            IComparisonParagraph paragraph = targetRow.Cells[0].AddParagraph();

            paragraph.AddRun("This is cell.");
            paragraph = targetRow.Cells[1].AddParagraph();
            paragraph.AddRun("This is Cell of target table.");
            paragraph = targetRow.Cells[2].AddParagraph();
            paragraph.AddRun("This is Cell.");
            Console.WriteLine("New Row was created.");

            // Creating settings for comparison of Rows
            WordsComparisonSettings settings = new WordsComparisonSettings();
            // Comparing Rows
            IWordsCompareResult compareResult = sourceRow.CompareWith(targetRow, settings);

            Console.WriteLine("Rows was compared.");

            // Saving result of comparison to new document
            string resultPath          = @"./../../Components/testresult/CompareRowFromDocumentWithCreatingRow/result.docx";
            IComparisonDocument result = compareResult.GetDocument();
            Stream resultStream        = new FileStream(resultPath, FileMode.Create);

            result.Save(resultStream, ComparisonSaveFormat.Docx);
            resultStream.Close();
            Console.WriteLine("Result of comparison was saved to document with the following source path" +
                              resultPath + ".");
            Console.WriteLine("===============================================");
            Console.WriteLine("");
        }
Example #4
0
        public static void CompareRowFromPresentationsWithCreatingRow()
        {
            string sourcePath =
                @"GroupDocs.Comparison.Samples.Slides.Components.data.CompareRowFromPresentationsWithCreatingRow.old.pptx";

            // Create to stream of presentation
            Assembly assembly     = Assembly.GetExecutingAssembly();
            Stream   sourceStream = assembly.GetManifestResourceStream(sourcePath);

            // Opening source presentation
            ComparisonPresentationBase sourcePresentation = new ComparisonPresentation(sourceStream);

            Console.WriteLine("Presentation with source path: " + sourcePath + " was loaded.");

            // Getting first Row from source presentation
            ComparisonRowBase sourceRow = (sourcePresentation.Slides[0].Shapes[0] as ComparisonTableBase).Rows[0];
            // Creating Row
            ComparisonRowBase       targetRow  = new ComparisonRow(new double[] { 200, 200 }, 50);
            ComparisonParagraphBase paragraph0 = new ComparisonParagraph();

            paragraph0.Text = "This is first cell in Row that was created.";
            targetRow[0].TextFrame.Paragraphs.Add(paragraph0);
            ComparisonParagraphBase paragraph1 = new ComparisonParagraph();

            paragraph1.Text = "This is second cell in Row that was created.";
            targetRow[1].TextFrame.Paragraphs.Add(paragraph1);
            Console.WriteLine("New Row was created.");

            // Creating settings for comparison of Rows
            SlidesComparisonSettings SlidesComparisonSettings = new SlidesComparisonSettings();
            // Comparing Rows
            ISlidesCompareResult compareResult = sourceRow.CompareWith(targetRow, SlidesComparisonSettings);

            Console.WriteLine("Rows was compared.");

            // Saving result of comparison to new presentation
            string resultPath = @"./../../Components/testresult/CompareRowFromPresentationsWithCreatingRow/result.pptx";
            ComparisonPresentationBase result = compareResult.GetPresentation();
            Stream resultStream = new FileStream(resultPath, FileMode.Create);

            result.Save(resultStream, ComparisonSaveFormat.Pptx);
            resultStream.Close();
            Console.WriteLine("Result of comparison was saved to presentation with the folloving source path" +
                              resultPath + ".");
            Console.WriteLine("===============================================");
            Console.WriteLine("");
        }
Example #5
0
        public static void CompareTwoCreatingRows()
        {
            // Creating Rows
            ComparisonRowBase       sourceRow        = new ComparisonRow(new double[] { 200, 200 }, 50);
            ComparisonParagraphBase sourceParagraph0 = new ComparisonParagraph();

            sourceParagraph0.Text = "This is first cell in source Row.";
            sourceRow[0].TextFrame.Paragraphs.Add(sourceParagraph0);
            ComparisonParagraphBase sourceParagraph1 = new ComparisonParagraph();

            sourceParagraph1.Text = "This is second cell in source Row.";
            sourceRow[1].TextFrame.Paragraphs.Add(sourceParagraph1);
            Console.WriteLine("New Row was created.");

            ComparisonRowBase       targetRow        = new ComparisonRow(new double[] { 200, 200 }, 50);
            ComparisonParagraphBase targetParagraph0 = new ComparisonParagraph();

            targetParagraph0.Text = "This is first cell in target Row.";
            targetRow[0].TextFrame.Paragraphs.Add(targetParagraph0);
            ComparisonParagraphBase targetParagraph1 = new ComparisonParagraph();

            targetParagraph1.Text = "This is second cell in target Row.";
            targetRow[1].TextFrame.Paragraphs.Add(targetParagraph1);
            Console.WriteLine("New Row was created.");

            // Creating settings for comparison of Rows
            SlidesComparisonSettings SlidesComparisonSettings = new SlidesComparisonSettings();
            // Comparing Rows
            ISlidesCompareResult compareResult = sourceRow.CompareWith(targetRow, SlidesComparisonSettings);

            Console.WriteLine("Rows was compared.");

            // Saving result of comparison to new presentation
            string resultPath = @"./../../Components/testresult/CompareTwoCreatingRows/result.pptx";
            ComparisonPresentationBase result = compareResult.GetPresentation();
            Stream resultStream = new FileStream(resultPath, FileMode.Create);

            result.Save(resultStream, ComparisonSaveFormat.Pptx);
            resultStream.Close();
            Console.WriteLine("Result of comparison was saved to presentation with the folloving source path" +
                              resultPath + ".");
            Console.WriteLine("===============================================");
            Console.WriteLine("");
        }
        private void CalculateTotals(List <ComparisonRow> comparisonData)
        {
            var totalNonRev = comparisonData.Sum(d => d.NonRevCount);
            var totalFleet  = comparisonData.Sum(d => d.FleetCount);

            comparisonData.ForEach(d => d.CalculatePercentOfTotalNonRev(totalNonRev));
            comparisonData.ForEach(d => d.CalculatePercentOfTotalFleet(totalFleet));

            var totalRow = new ComparisonRow
            {
                Key         = NonRevBaseDataAccess.TotalKeyName,
                FleetCount  = comparisonData.Where(d => d != null).Sum(d => d.FleetCount),
                DaysNonRev  = comparisonData.Where(d => d != null).Sum(d => d.DaysNonRev),
                NonRevCount = comparisonData.Where(d => d != null).Sum(d => d.NonRevCount),
                PercentNonRevOfTotalNonRev = comparisonData.Where(d => d != null).Sum(d => d.PercentNonRevOfTotalNonRev),
                ReasonsEntered             = comparisonData.Where(d => d != null).Sum(d => d.ReasonsEntered)
            };


            comparisonData.Add(totalRow);
        }
Example #7
0
        public static void CompareTwoCreatingRows()
        {
            // Creating Rows
            IComparisonRow       sourceRow = new ComparisonRow(new double[] { 100, 100 }, 20);
            IComparisonParagraph paragraph = sourceRow.Cells[0].AddParagraph();

            paragraph.AddRun("This is cell.");
            paragraph = sourceRow.Cells[1].AddParagraph();
            paragraph.AddRun("This is Cell of source table.");
            Console.WriteLine("New Row was created.");

            IComparisonRow targetRow = new ComparisonRow(new double[] { 100, 100 }, 20);

            paragraph = targetRow.Cells[0].AddParagraph();
            paragraph.AddRun("This is cell.");
            paragraph = targetRow.Cells[1].AddParagraph();
            paragraph.AddRun("This is Cell of target table.");
            Console.WriteLine("New Row was created.");

            // Creating settings for comparison of Rows
            WordsComparisonSettings settings = new WordsComparisonSettings();
            // Comparing Rows
            IWordsCompareResult compareResult = sourceRow.CompareWith(targetRow, settings);

            Console.WriteLine("Rows was compared.");

            // Saving result of comparison to new document
            string resultPath          = @"./../../Components/testresult/CompareTwoCreatingRows/result.docx";
            IComparisonDocument result = compareResult.GetDocument();
            Stream resultStream        = new FileStream(resultPath, FileMode.Create);

            result.Save(resultStream, ComparisonSaveFormat.Docx);
            resultStream.Close();
            Console.WriteLine("Result of comparison was saved to document with the following source path" +
                              resultPath + ".");
            Console.WriteLine("===============================================");
            Console.WriteLine("");
        }
Example #8
0
        protected ComparisonRow BuildUnmappedVehicleRow(bool siteComparison)
        {
            var vehicles = BaseVehicleDataAccess.GetVehicleQueryable(Parameters, DataContext, true, true);

            if (vehicles == null)
            {
                return(new ComparisonRow());
            }

            IQueryable <int> matchedSet;

            if (siteComparison)
            {
                var locationCountry = Parameters[DictionaryParameter.LocationCountry];
                if (!string.IsNullOrEmpty(locationCountry))
                {
                    return(null);
                }

                matchedSet = from v in vehicles
                             join loc in DataContext.LOCATIONs.Select(d => d.location1).Distinct()
                             on v.LastLocationCode equals loc
                             select v.VehicleId;
            }
            else
            {
                var owningCountry = Parameters[DictionaryParameter.OwningCountry];
                if (!string.IsNullOrEmpty(owningCountry))
                {
                    return(null);
                }

                var carGroups = (from cg in DataContext.CAR_GROUPs
                                 select new { cg = cg.car_group1, cg.CAR_CLASS.CAR_SEGMENT.country }).Distinct();

                matchedSet = from v in vehicles
                             join cg in carGroups on new { cg = v.CarGroup, country = v.OwningCountry }
                equals new { cg.cg, cg.country }
                select v.VehicleId;
            }



            var unmappedCars = from vh in vehicles.Where(d => !matchedSet.Any(m => m == d.VehicleId))
                               select vh;

            if (!unmappedCars.Any())
            {
                return(null);
            }

            var remData = from rem in DataContext.VehicleNonRevPeriodEntryRemarks
                          join l in DataContext.LOCATIONs on
                          rem.VehicleNonRevPeriodEntry.VehicleNonRevPeriod.Vehicle.LastLocationCode equals l.location1
                          where unmappedCars.Any(d => d.VehicleId == rem.VehicleNonRevPeriodEntry.VehicleNonRevPeriod.Vehicle.VehicleId)
                          where rem.VehicleNonRevPeriodEntry.VehicleNonRevPeriod.Active
                          group rem by rem.VehicleNonRevPeriodEntry.VehicleNonRevPeriod.VehicleId
                          into g
                          join rem2 in DataContext.VehicleNonRevPeriodEntryRemarks
                          on g.Max(d => d.VehicleNonRevPeriodEntryRemarkId) equals rem2.VehicleNonRevPeriodEntryRemarkId
                          select g.Key;


            var totalRow = new ComparisonRow
            {
                Key            = NotFoundKeyName,
                FleetCount     = unmappedCars.Count(),
                NonRevCount    = unmappedCars.Sum(d => d.IsNonRev ? 1 : 0),
                ReasonsEntered = remData.Count(),
            };

            return(totalRow);
        }