/// <summary>
        /// Get metadata for harvest job.
        /// </summary>
        /// <returns>
        /// The <see cref="HarvestJob"/>.
        /// </returns>
        public HarvestJob GetHarvestJob()
        {
            var harvestJob = new HarvestJob();

            using (DataReader dataReader = _context.GetSpeciesObservationDatabase().GetHarvestJob())
            {
                while (dataReader.Read())
                {
                    harvestJob.LoadHarvestJob(dataReader);
                }
            }

            using (DataReader dataReader = _context.GetSpeciesObservationDatabase().GetHarvestJobDataProviders())
            {
                harvestJob.DataProviders = new List <HarvestJobDataProvider>();

                while (dataReader.Read())
                {
                    harvestJob.LoadHarvestJobDataProviders(dataReader);
                }
            }

            using (DataReader dataReader = _context.GetSpeciesObservationDatabase().GetHarvestJobStatistics())
            {
                harvestJob.Statistics = new List <HarvestJobStatistic>();

                while (dataReader.Read())
                {
                    harvestJob.LoadHarvestJobStatistics(dataReader);
                }
            }

            return(harvestJob);
        }
 /// <summary>
 /// Populate harvest job information object with meta data by the data reader.
 /// </summary>
 /// <param name="harvestJob">Harvest job.</param>
 /// <param name="dataReader">Database reader.</param>
 public static void LoadHarvestJob(this HarvestJob harvestJob, ArtDatabanken.Database.DataReader dataReader)
 {
     harvestJob.JobStartDate       = dataReader.GetDateTime(HarvestJobTableData.JOBSTARTDATE, DateTime.MinValue);
     harvestJob.HarvestStartDate   = dataReader.GetDateTime(HarvestJobTableData.HARVESTSTARTDATE, DateTime.MinValue);
     harvestJob.HarvestCurrentDate = dataReader.GetDateTime(HarvestJobTableData.HARVESTCURRENTDATE, DateTime.MinValue);
     harvestJob.HarvestEndDate     = dataReader.GetDateTime(HarvestJobTableData.HARVESTENDDATE, DateTime.MinValue);
     harvestJob.JobEndDate         = dataReader.GetDateTime(HarvestJobTableData.JOBENDDATE, DateTime.MinValue);
     harvestJob.JobStatus          = (HarvestStatusEnum)Enum.Parse(typeof(HarvestStatusEnum), dataReader.GetString(HarvestJobTableData.JOBSTATUS), true);
 }
        /// <summary>
        /// Populate harvest job information object with data provider meta data by the data reader.
        /// </summary>
        /// <param name="harvestJob">Harvest job.</param>
        /// <param name="dataReader">Database reader.</param>
        public static void LoadHarvestJobDataProviders(this HarvestJob harvestJob, ArtDatabanken.Database.DataReader dataReader)
        {
            HarvestJobDataProvider harvestJobDataProvider = new HarvestJobDataProvider()
            {
                DataProviderId = dataReader.GetInt32(HarvestJobTableData.DATAPROVIDERID),
                ChangeId       = dataReader.GetInt64(HarvestJobTableData.CHANGEID, -1)
            };

            harvestJob.DataProviders.Add(harvestJobDataProvider);
        }
        /// <summary>
        /// Populate harvest job information object with harvest job meta data by the data reader.
        /// </summary>
        /// <param name="harvestJob">Harvest job.</param>
        /// <param name="dataReader">Database reader.</param>
        public static void LoadHarvestJobStatistics(this HarvestJob harvestJob, ArtDatabanken.Database.DataReader dataReader)
        {
            HarvestJobStatistic harvestJobStatistic = new HarvestJobStatistic()
            {
                DataProviderId = dataReader.GetInt32(HarvestJobTableData.DATAPROVIDERID),
                ChangeId       = -1,
                JobStatus      = (HarvestStatusEnum)Enum.Parse(typeof(HarvestStatusEnum), dataReader.GetString(HarvestJobTableData.JOBSTATUS), true),
                HarvestDate    = dataReader.GetDateTime(HarvestJobTableData.HARVESTDATE, DateTime.MinValue)
            };

            harvestJob.Statistics.Add(harvestJobStatistic);
        }
 /// <summary>
 /// Update metadata for harvest job's data provider.
 /// </summary>
 /// <param name="harvestJob">
 /// The harvest job.
 /// </param>
 public void SetHarvestJobDataProvider(HarvestJob harvestJob)
 {
     _context.GetSpeciesObservationDatabase().SetHarvestJobDataProvider(harvestJob);
 }