////void IConnectorServer.CreateSpeciesObservations(WebServiceContext context, List<HarvestSpeciesObservation> speciesObservations, WebSpeciesObservationDataProvider dataProvider, out int noOfCreated, out int noOfErrors)
        ////{
        ////    throw new NotImplementedException();
        ////    //   CreateSpeciesObservations(context, speciesObservations, dataProvider, out noOfCreated, out noOfErrors);
        ////}
        ///// <summary>
        ///// Insert all new (created) observations into a DataTable
        ///// First check the observation
        ///// If ok, add it to SpeciesObservationTable and DarwinCoreTable
        ///// If there are errors add the observation to speciesObservationErrorFieldTable
        ///// </summary>
        ///// <param name="context">Web service request context.</param>
        ///// <param name="speciesObservations">Created species observations.</param>
        ///// <param name="dataProvider">Species observation data source.</param>
        ///// <param name="noOfCreated">Created </param>
        ///// <param name="noOfErrors">Errors </param>
        ////public static void CreateSpeciesObservations(WebServiceContext context,
        ////                                              List<HarvestSpeciesObservation> speciesObservations,
        ////                                              WebSpeciesObservationDataProvider dataProvider,
        ////                                              out int noOfCreated, out int noOfErrors)
        ////{
        ////    noOfCreated = 0;
        ////    noOfErrors = 0;
        ////    if (speciesObservations.IsNotEmpty())
        ////    {
        ////        DataTable darwinCoreTable = HarvestManager.GetDarwinCoreTable(CREATE);

        ////        DataTable speciesObservationFieldTable = HarvestManager.GetSpeciesObservationFieldTable(CREATE);
        ////        DataTable speciesObservationErrorFieldTable = HarvestManager.GetSpeciesObservationErrorFieldTable();

        ////        // Save all species observations into tables.
        ////        foreach (HarvestSpeciesObservation speciesObservation in speciesObservations)
        ////        {
        ////            string catalogNumber;
        ////            Dictionary<SpeciesObservationPropertyId, string> errors;
        ////            if (HarvestManager.CheckSpeciesObservation(speciesObservation, context, out errors, out catalogNumber))
        ////            {
        ////              //  HarvestManager.SpeciesObservationId++;
        ////                HarvestManager.AddToTempSpeciesObservation(speciesObservation,
        ////                                            darwinCoreTable,
        ////                                            speciesObservationFieldTable,
        ////                                            HarvestManager.SpeciesObservationId,
        ////                                            dataProvider,
        ////                                            catalogNumber);
        ////                noOfCreated++;
        ////            }
        ////            else
        ////            {
        ////                HarvestManager.CreateSpeciesObservationError(speciesObservation,
        ////                                              speciesObservationErrorFieldTable,
        ////                                              dataProvider,
        ////                                              errors,
        ////                                              CREATE);
        ////                noOfErrors++;
        ////            }
        ////        }

        ////        // Save tables to database.
        ////        context.GetSpeciesObservationDatabase().AddTableData(speciesObservationFieldTable);
        ////        context.GetSpeciesObservationDatabase().AddTableData(darwinCoreTable);
        ////        if (noOfErrors > 0)
        ////            context.GetSpeciesObservationDatabase().AddTableData(speciesObservationErrorFieldTable);
        ////    }

        ////}

        /// <summary>
        /// Insert all changed (updated) observations into a DataTable
        /// First check the observation
        /// If ok, add it to SpeciesObservationUpdateTable and DarwinCoreUpdateTable
        /// If there are errors add the observation to speciesObservationErrorFieldTable.
        /// </summary>
        /// <param name="context">Web service request context.</param>
        /// <param name="speciesObservations">Updated species observations.</param>
        /// <param name="dataProvider">The dataProvider.</param>
        /// <param name="noOfUpdated">No of updated species observations.</param>
        /// <param name="noOfUpdatedErrors">No of updating errors.</param>
        public static void UpdateSpeciesObservations(WebServiceContext context,
                                                     List <HarvestSpeciesObservation> speciesObservations,
                                                     WebSpeciesObservationDataProvider dataProvider,
                                                     out int noOfUpdated,
                                                     out int noOfUpdatedErrors)
        {
            noOfUpdated       = 0;
            noOfUpdatedErrors = 0;

            if (!speciesObservations.IsNotEmpty())
            {
                return;
            }

            DataTable darwinCoreTable = HarvestManager.GetDarwinCoreTable(HarvestManager.UPDATE);
            DataTable speciesObservationFieldTable      = HarvestManager.GetSpeciesObservationFieldTable(HarvestManager.UPDATE);
            DataTable speciesObservationErrorFieldTable = HarvestManager.GetSpeciesObservationErrorFieldTable();

            // Save all species observations into tables.
            foreach (HarvestSpeciesObservation speciesObservation in speciesObservations)
            {
                string  catalogNumber;
                Boolean someError = true;
                Dictionary <SpeciesObservationPropertyId, string> errors;
                if (HarvestManager.CheckSpeciesObservation(speciesObservation, context, out errors, out catalogNumber))
                {
                    try
                    {
                        HarvestManager.AddToTempSpeciesObservation(speciesObservation,
                                                                   darwinCoreTable,
                                                                   speciesObservationFieldTable,
                                                                   -1,
                                                                   dataProvider,
                                                                   catalogNumber);
                        noOfUpdated++;
                        someError = false;
                    }
                    catch (Exception ex)
                    {
                        var prop = (SpeciesObservationPropertyId)Enum.Parse(typeof(SpeciesObservationPropertyId), ex.Message);
                        if (prop.IsNotNull())
                        {
                            errors.Add(prop, ex.InnerException.Message);
                        }
                        else
                        {
                            errors.Add(SpeciesObservationPropertyId.Id, ex.InnerException.ToString());
                        }
                    }
                }

                if (someError)
                {
                    HarvestManager.CreateSpeciesObservationError(speciesObservation,
                                                                 speciesObservationErrorFieldTable,
                                                                 dataProvider,
                                                                 errors,
                                                                 HarvestManager.UPDATE);
                    noOfUpdatedErrors++;
                }
            }

            // Save tables to database.
            context.GetSpeciesObservationDatabase().AddTableData(speciesObservationFieldTable);
            context.GetSpeciesObservationDatabase().AddTableData(darwinCoreTable);
            if (noOfUpdatedErrors > 0)
            {
                context.GetSpeciesObservationDatabase().AddTableData(speciesObservationErrorFieldTable);
            }
        }