コード例 #1
0
        /// <summary>
        /// Get status for observation database.
        /// </summary>
        /// <param name="status">
        /// The status.
        /// </param>
        private void GetObservationDatabaseStatus(Dictionary <Int32, List <WebResourceStatus> > status)
        {
            Boolean           ping;
            String            address, informationEnglish, informationSwedish;
            WebResourceStatus resourceStatus;

            address = null;

            try
            {
                address            = ObservationsdatabasenServer.GetAddress();
                informationEnglish = null;
                informationSwedish = null;
                using (ObservationsdatabasenServer database = new ObservationsdatabasenServer())
                {
                    ping = database.Ping();
                }

                if (!ping)
                {
                    informationEnglish = WebService.Settings.Default.DatabaseStatusErrorEnglish;
                    informationSwedish = WebService.Settings.Default.DatabaseStatusErrorSwedish;
                }
            }
            catch (Exception exception)
            {
                ping = false;
                informationEnglish = WebService.Settings.Default.DatabaseCommunicationFailureEnglish + " " +
                                     WebService.Settings.Default.ErrorMessageEnglish + " = " + exception.Message;
                informationSwedish = WebService.Settings.Default.DatabaseCommunicationFailureSwedish + " " +
                                     WebService.Settings.Default.ErrorMessageSwedish + " = " + exception.Message;
            }

            resourceStatus              = new WebResourceStatus();
            resourceStatus.AccessType   = WebService.Settings.Default.ResourceAccessTypeReadSwedish;
            resourceStatus.Address      = address;
            resourceStatus.Information  = informationSwedish;
            resourceStatus.Name         = DatabaseName.Observation.ToString();
            resourceStatus.ResourceType = WebServiceBase.GetResourceType(ResourceTypeIdentifier.Database,
                                                                         (Int32)(LocaleId.sv_SE));
            resourceStatus.Status = ping;
            resourceStatus.Time   = DateTime.Now;
            status[(Int32)(LocaleId.sv_SE)].Add(resourceStatus);

            resourceStatus              = new WebResourceStatus();
            resourceStatus.AccessType   = WebService.Settings.Default.ResourceAccessTypeReadEnglish;
            resourceStatus.Address      = address;
            resourceStatus.Information  = informationEnglish;
            resourceStatus.Name         = DatabaseName.Observation.ToString();
            resourceStatus.ResourceType = WebServiceBase.GetResourceType(ResourceTypeIdentifier.Database,
                                                                         (Int32)(LocaleId.en_GB));
            resourceStatus.Status = ping;
            resourceStatus.Time   = DateTime.Now;
            status[(Int32)(LocaleId.en_GB)].Add(resourceStatus);
        }
コード例 #2
0
        public void GetSpeciesObservations()
        {
            ObservationsdatabasenServer observationsdatabasenServer = new ObservationsdatabasenServer();
            DateTime changedTo   = new DateTime(2010, 09, 26);
            DateTime changedFrom = new DateTime(2010, 09, 28);

            using (DataReader dataReader = observationsdatabasenServer.GetSpeciesObservations(changedTo, changedFrom))
            {
                Assert.IsTrue(dataReader.Read());
            }
        }