internal ReportResult AllSamples(LongLineTrip trip)
        {
            var repo = TubsDataService.GetRepository<LongLineCatch>(MvcApplication.CurrentSession);
            var samples = repo.FilterBy(s => s.FishingSet.Trip.Id == trip.Id).OrderBy(s => s.FishingSet.SetNumber);

            // It would be cool if I could use LINQ like I do for Purse Seine, but NHibernate doesn't like the
            // cool LINQ project necessary to find the Lat/Lon for the start of set
            // Latitude = s.FishingSet.EventList.Where(sh => sh.ActivityType == Spc.Ofp.Tubs.DAL.Common.HaulActivityType.StartOfSet).First().Latitude

            IList<LengthSampleLineItem> items = new List<LengthSampleLineItem>(samples.Count());
            foreach (var sample in samples)
            {
                string latitude = String.Empty;
                string longitude = String.Empty;
                string eez = String.Empty;

                var startOfSet = sample.FishingSet.EventList.Where(sh => sh.ActivityType == Spc.Ofp.Tubs.DAL.Common.HaulActivityType.StartOfSet).FirstOrDefault();
                if (null != startOfSet)
                {
                    latitude = startOfSet.Latitude;
                    longitude = startOfSet.Longitude;
                    eez = startOfSet.EezCode;
                }
                items.Add(new LengthSampleLineItem()
                {
                    SetDate = sample.FishingSet.SetDate,
                    Latitude = latitude,
                    Longitude = longitude,
                    Eez = eez,
                    SetNumber = sample.FishingSet.SetNumber.HasValue ? sample.FishingSet.SetNumber.Value : -1,
                    SequenceNumber = sample.SampleNumber.HasValue ? sample.SampleNumber.Value : -1, // All 1 for obstrip_id 4177?
                    SpeciesCode = sample.SpeciesCode,
                    Length = sample.Length.HasValue ? sample.Length.Value : -1
                });

            }

            var report = new Report(items.ToReportSource());
            report.TextFields.Title = string.Format("Length frequency summary for trip {0}", trip.SpcTripNumber);
            return new ReportResult(report);
        }
        public ReportResult ExportIndex(string tufman, string gear, string vesselName, string year, string fleet, string criteria, string fishingCompany, int? minNbDays)
        {
            GetUserDetails();
            if (_role == RoleList.Country && !tufman.Equals(_country))
            {
                WebSecurity.Logout();
                return null;
            }
            fleet = (String.IsNullOrEmpty(fleet) || fleet.Equals("0")) ? null : fleet;
            fishingCompany = (String.IsNullOrEmpty(fishingCompany) || fishingCompany.Equals("0")) ? null : fishingCompany;

            List<VmsTufmanReconModel> modelLst = new List<VmsTufmanReconModel>();
            List<VmsTufmanRecon> reconLst = _reconRepo.FilterRecon(tufman, gear, vesselName, year, fleet, criteria, fishingCompany);
            string eez;
            if (fleet != null && fleet.Equals(_nationalFleetCode))
            {
                foreach (VmsTufmanRecon recon in reconLst)
                    modelLst.Add(new VmsTufmanReconModel(recon, true));
                eez = "WCPFC Convention Area";
            }
            else
            {
                foreach (VmsTufmanRecon recon in reconLst)
                    modelLst.Add(new VmsTufmanReconModel(recon, false));
                eez = _repo.Get<Entity>(tufman).Label;
            }
            //Remove any Recon where the logsheet or the vms duration is less than the minNbDays parameter
            if (minNbDays > 0)
                modelLst.RemoveAll(x => ((x.VmsTripId != 0 && x.VmsNbDays < minNbDays) || (x.LogsheetTripId != 0 && x.LogsheetNbDays < minNbDays)));

            var report = new Report(modelLst.ToReportSource());
            report.TextFields.Title = "VMS - Logsheet Reconciliation Detail";
            report.DataFields["VmsTripId"].Hidden = true;
            report.DataFields["VesselId"].Hidden = true;
            report.DataFields["LogsheetTripId"].Hidden = true;
            report.DataFields["Country"].Hidden = true;
            report.DataFields["VesselFlag"].FormatAs<Entity>(x => x.Label);
            report.DataFields["Gear"].FormatAs<Gear>(x => x.Label);

            report.RenderHints.Orientation = ReportOrientation.Landscape;

            year = (String.IsNullOrEmpty(year) ? "ALL" : year);
            fishingCompany = (String.IsNullOrEmpty(fishingCompany) || fishingCompany.Equals("0")) ? "ALL" : fishingCompany;

            //var gearRepo = new Repository<Gear>(MvcApplication.UnitOfWork.Session);
            string gearDesc = _repo.Get<Gear>(gear).Label;
            string fleetDesc = (String.IsNullOrEmpty(fleet)) ? "ALL" : _repo.Get<Entity>(fleet).Label;

            report.TextFields.Header = string.Format(@"
            Gear:  {0}
            Fleet:  {1}
            Year:  {2}
            EEZ:  {3}
            Fishing Company:  {4}
            Criteria:  {5}
            Min Trip Duration:  {6}", gearDesc, fleetDesc, year, eez, fishingCompany, criteria, minNbDays);

            return new ReportResult(report);
        }