예제 #1
0
        internal ReportResult Summary(PurseSeineTrip trip)
        {
            // Empty spreadsheet
            if (null == trip || null == trip.SeaDays || 0 == trip.SeaDays.Count)
                return new ReportResult(new Report());

            var activities =
                from d in trip.SeaDays
                from a in d.Activities
                select new ActivityLogLineItem
                {
                    ShipsTime = a.LocalTime.Value,
                    Latitude = a.Latitude,
                    Longitude = a.Longitude,
                    Activity = a.ActivityType.HasValue ? a.ActivityType.Value.ToString() : String.Empty,
                    WindDirection = a.WindDirection,
                    WindSpeed = a.WindSpeed,
                    SeaCode = a.SeaCode.HasValue ? a.SeaCode.Value.ToString() : String.Empty,
                    Comments = a.Comments
                };

            var sets =
                from fset in trip.FishingSets
                select new SetLogLineItem
                {
                    SetNumber = fset.SetNumber,
                    VesselLogDate = fset.Activity.LocalTime.Value,
                    SkiffOff = fset.SkiffOff,
                    WinchOn = fset.WinchOn,
                    RingsUp = fset.RingsUp,
                    BrailStart = fset.BeginBrailing,
                    BrailEnd = fset.EndBrailing,
                    EndOfSet = fset.EndOfSet,
                    SumOfBrails = Sum(fset.SumOfBrail1, fset.SumOfBrail2), // Regular addition operator doesn't work as expected
                    TotalCatch = fset.TotalCatch
                };

            // From here (see jshannon99 response of 9 November)
            // http://doddlereport.codeplex.com/discussions/283107
            var writer = new DoddleReport.OpenXml.ExcelReportWriter();
            var activityReport = new Report(activities.ToReportSource(), writer);
            var setReport = new Report(sets.ToReportSource(), writer);

            // Set up some labels
            activityReport.TextFields.Title = trip.ToString();
            activityReport.RenderHints["SheetName"] = "Activity Log";
            setReport.RenderHints["SheetName"] = "Set Log";

            // TODO:  Consider adding confidentiality footers to the report
            activityReport.AppendReport(setReport);
            return new ReportResult(activityReport, writer);
        }