/// <summary>
        /// Handle automatic update of information.
        /// </summary>
        private void UpdateInformation()
        {
            TimeSpan          sleepTime, sleeping;
            WebServiceContext context;

            _lastCacheTime = DateTime.Now - new TimeSpan(24, 0, 0);
            sleepTime      = new TimeSpan(0, 3, 0); // Wait 3 minutes before update starts.
            while (!_stopUpdate)
            {
                Thread.Sleep(sleepTime);
                if (!_stopUpdate)
                {
                    // Check if it is time to update taxon and project parameter information.
                    sleeping = DateTime.Now - _lastCacheTime;
                    if ((sleeping.TotalHours > 12) &&
                        (4 == DateTime.Now.Hour))
                    {
                        context = new WebServiceContextCached(WebServiceData.WebServiceManager.Name, ApplicationIdentifier.ArtDatabankenSOA.ToString());

                        // Update taxon and project parameter information in the middle of the night.
                        _lastCacheTime = DateTime.Now;
                        try
                        {
                            HarvestManager.UpdateTaxonInformation(context);
                            HarvestManager.UpdateProjectParameterInformation(new ArtportalenServer(), context);
                        }
                        catch (Exception exception)
                        {
                            // All errors are catched.
                            // Keep information update thread alive
                            // so that it will try again to update information.
                            WebServiceData.LogManager.LogError(context, exception);
                        }

                        try
                        {
                            Boolean isUpdateSpeciesObservationsSuccessful = UpdateSpeciesObservations(context);

                            if (!isUpdateSpeciesObservationsSuccessful)
                            {
                                WebServiceData.LogManager.Log(context, "Error in UpdateSpeciesObservations", LogType.SpeciesObservationUpdate, "Read details in LogUpdateError.");
                            }

                            HarvestManager.DeleteUnnecessaryChanges(context);
                        }
                        catch (Exception exception)
                        {
                            // All errors are catched.
                            // Keep information update thread alive
                            // so that it will try again to update information.
                            WebServiceData.LogManager.LogError(context, exception);
                        }
                    }
                }
            }
        }
Exemple #2
0
        public void GetUserUnknownUserError()
        {
            WebClientToken clientToken;

            ArtDatabanken.WebService.Data.WebUser user;

            // Get none existing user.
            clientToken = new WebClientToken("None existing user", "No application identifier", WebServiceData.WebServiceManager.Key);
            using (WebServiceContext context = new WebServiceContextCached(clientToken, false))
            {
                user = GetUserManager().GetUser(context);
                Assert.IsNull(user);
            }
        }
        public void DeleteTrace()
        {
            List <WebLogRow> logRows;

            // Check that we have no trace items.
            LogManager.DeleteTrace(GetContext());
            logRows = LogManager.GetLog(GetContext(), LogType.Trace, TEST_USER_NAME, 1);
            Assert.IsTrue(logRows.IsEmpty());

            // Create trace log items.
            GetContext().StartTrace(null);
            using (WebServiceContext context = new WebServiceContextCached(new WebClientToken(TEST_USER_NAME, ApplicationIdentifier, WebServiceData.WebServiceManager.Key).Token, "StartTrace"))
            {
                // Do something.
            }
            GetContext().StopTrace();
            logRows = LogManager.GetLog(GetContext(), LogType.Trace, TEST_USER_NAME, 1);
            Assert.IsTrue(logRows.IsNotEmpty());

            // Delete trace log.
            LogManager.DeleteTrace(GetContext());
            logRows = LogManager.GetLog(GetContext(), LogType.Trace, TEST_USER_NAME, 1);
            Assert.IsTrue(logRows.IsEmpty());
        }
Exemple #4
0
        /// <summary>
        /// Handle automatic species facts update.
        /// </summary>
        private void UpdateSpeciesFacts()
        {
            TimeSpan          sleepTime, sleeping;
            WebServiceContext context;

            _lastSpeciesFactsUpdate = DateTime.Now - new TimeSpan(24, 0, 0);
            sleepTime = new TimeSpan(0, 3, 0); // Wait 3 minutes before update starts.
            while (!_stopUpdate)
            {
                Thread.Sleep(sleepTime);
                if (!_stopUpdate)
                {
                    // Check if it is time to update taxon and project parameter information.
                    sleeping = DateTime.Now - _lastSpeciesFactsUpdate;
                    if ((sleeping.TotalHours > 12) &&
                        (3 == DateTime.Now.Hour))
                    {
                        context = new WebServiceContextCached(WebServiceData.WebServiceManager.Name, ApplicationIdentifier.ArtDatabankenSOA.ToString());

                        // Update species facts information in the middle of the night.
                        _lastSpeciesFactsUpdate = DateTime.Now;
                        try
                        {
                            TaxonUpdateManager.UpdateTaxonSpeciesFacts(context);
                        }
                        catch (Exception exception)
                        {
                            // All errors are catched.
                            // Keep information update thread alive
                            // so that it will try again to update information.
                            WebServiceData.LogManager.LogError(context, exception);
                        }
                    }
                }
            }
        }
        public void UpdateInformation()
        {
            TimeSpan          sleepTime, sleeping;
            WebServiceContext context;

            context = new WebServiceContextCached(WebServiceData.WebServiceManager.Name,
                                                  ApplicationIdentifier.ArtDatabankenSOA.ToString());
            _lastCacheTime = DateTime.Now - new TimeSpan(24, 0, 0);
            sleepTime      = new TimeSpan(1, 0, 0);
            while (!_stopUpdate)
            {
                //Thread.Sleep(sleepTime);
                if (!_stopUpdate)
                {
                    // Check if it is time to update taxon information.
                    sleeping = DateTime.Now - _lastCacheTime;
                    if (sleeping.TotalHours > 12)
                    {
                        // Update taxon information in the middle of the night.
                        _lastCacheTime = DateTime.Now;
                        try
                        {
                            HarvestManager.UpdateTaxonInformation(context);
                            UpdateSpeciesObservations(context);
                        }
                        catch (Exception exception)
                        {
                            // All errors are catched.
                            // Keep information update thread alive
                            // so that it will try again to update information.
                            WebServiceData.LogManager.LogError(context, exception);
                        }
                    }
                }
            }
        }