/// <summary> /// Get status for UserService. /// </summary> /// <param name='status'>Status for user service is saved in this object.</param> private void GetUserServiceStatus(Dictionary <Int32, List <WebResourceStatus> > status) { Boolean ping; WebResourceStatus resourceStatus; ping = WebServiceProxy.UserService.Ping(); resourceStatus = new WebResourceStatus(); resourceStatus.AccessType = Settings.Default.ResourceAccessTypeReadSwedish; resourceStatus.Address = WebServiceProxy.UserService.GetWebAddress(); resourceStatus.Name = ArtDatabanken.Data.ApplicationIdentifier.UserService.ToString(); resourceStatus.ResourceType = GetResourceType(ResourceTypeIdentifier.WebService, (Int32)(LocaleId.sv_SE)); resourceStatus.Status = ping; resourceStatus.Time = DateTime.Now; status[(Int32)(LocaleId.sv_SE)].Add(resourceStatus); resourceStatus = new WebResourceStatus(); resourceStatus.AccessType = Settings.Default.ResourceAccessTypeReadEnglish; resourceStatus.Address = WebServiceProxy.UserService.GetWebAddress(); resourceStatus.Name = ArtDatabanken.Data.ApplicationIdentifier.UserService.ToString(); resourceStatus.ResourceType = GetResourceType(ResourceTypeIdentifier.WebService, (Int32)(LocaleId.en_GB)); resourceStatus.Status = ping; resourceStatus.Time = DateTime.Now; status[(Int32)(LocaleId.en_GB)].Add(resourceStatus); }
/// <summary> /// Get status for user database. /// </summary> /// <param name="context">Web service request context.</param> /// <param name="status">Add database status to this parameter.</param> private void GetUserDatabaseStatus(WebServiceContext context, Dictionary <Int32, List <WebResourceStatus> > status) { Boolean ping; String address, informationEnglish, informationSwedish; WebResourceStatus resourceStatus; address = null; try { address = context.GetDatabase(DataServer.DatabaseId.User).GetAddress(); informationEnglish = null; informationSwedish = null; ping = DataServer.Ping(context, DataServer.DatabaseId.User); if (!ping) { informationEnglish = Settings.Default.DatabaseStatusErrorEnglish; informationSwedish = Settings.Default.DatabaseStatusErrorSwedish; } } catch (Exception exception) { ping = false; informationEnglish = Settings.Default.DatabaseCommunicationFailureEnglish + " " + Settings.Default.ErrorMessageEnglish + " = " + exception.Message; informationSwedish = Settings.Default.DatabaseCommunicationFailureSwedish + " " + Settings.Default.ErrorMessageSwedish + " = " + exception.Message; } resourceStatus = new WebResourceStatus(); resourceStatus.AccessType = Settings.Default.ResourceAccessTypeReadSwedish; resourceStatus.Address = address; resourceStatus.Information = informationSwedish; resourceStatus.Name = DatabaseName.User.ToString(); resourceStatus.ResourceType = 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 = Settings.Default.ResourceAccessTypeReadEnglish; resourceStatus.Address = address; resourceStatus.Information = informationEnglish; resourceStatus.Name = DatabaseName.User.ToString(); resourceStatus.ResourceType = GetResourceType(ResourceTypeIdentifier.Database, (Int32)(LocaleId.en_GB)); resourceStatus.Status = ping; resourceStatus.Time = DateTime.Now; status[(Int32)(LocaleId.en_GB)].Add(resourceStatus); }
/// <summary> /// Update status for this web service. /// </summary> /// <param name="context">Web service request context.</param> private void UpdateStatus(WebServiceContext context) { WebResourceStatus resourceStatus; if (IsTimeToUpdateStatus()) { lock (_lockObject) { // This dubbel check of last status update time // is necessary since things may have changed // during possible lock of this thread. if (IsTimeToUpdateStatus()) { try { _status = GetStatuses(context); } catch (Exception exception) { _status = new Dictionary <Int32, List <WebResourceStatus> >(); _status[(Int32)(LocaleId.en_GB)] = new List <WebResourceStatus>(); _status[(Int32)(LocaleId.sv_SE)] = new List <WebResourceStatus>(); resourceStatus = new WebResourceStatus(); resourceStatus.AccessType = "Läsa"; resourceStatus.Address = null; resourceStatus.Information = "Misslyckades med att hämta status. Fel = " + exception.Message; resourceStatus.Name = "Den här webbtjänsten"; resourceStatus.ResourceType = GetResourceType(ResourceTypeIdentifier.WebService, (Int32)(LocaleId.sv_SE)); resourceStatus.Status = false; resourceStatus.Time = DateTime.Now; _status[(Int32)(LocaleId.sv_SE)].Add(resourceStatus); resourceStatus = new WebResourceStatus(); resourceStatus.AccessType = "Read"; resourceStatus.Address = null; resourceStatus.Information = "Failed to retrieve status. Error = " + exception.Message; resourceStatus.Name = "This web service"; resourceStatus.ResourceType = GetResourceType(ResourceTypeIdentifier.Database, (Int32)(LocaleId.en_GB)); resourceStatus.Status = false; resourceStatus.Time = DateTime.Now; _status[(Int32)(LocaleId.en_GB)].Add(resourceStatus); } _ping = true; if (_status.IsNotEmpty()) { foreach (WebResourceStatus tempResourceStatus in _status[(Int32)(LocaleId.en_GB)]) { if (!tempResourceStatus.Status) { _ping = false; break; } } } _lastStatusUpdate = DateTime.Now; } } } }