Esempio n. 1
0
        /// <summary>
        /// Converts service status to Visibility. Used for enabling/disabling of 'Start' and 'Stop' service buttons from Service Configuration.
        /// </summary>
        /// <param name="value">StrategyStatus</param>
        /// <param name="targetType">not used</param>
        /// <param name="parameter">not used</param>
        /// <param name="culture">not used</param>
        /// <returns>bool</returns>
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                ServiceStatus status = (ServiceStatus)value;

                // If parameter is Invert, then use inverted logic for button visibility
                if (parameter != null && ((string)parameter).Equals("Invert"))
                {
                    if (status.Equals(ServiceStatus.Running))
                    {
                        return(System.Windows.Visibility.Visible);
                    }
                    else
                    {
                        return(System.Windows.Visibility.Collapsed);
                    }
                }
                else
                {
                    if (status.Equals(ServiceStatus.Stopped))
                    {
                        return(System.Windows.Visibility.Visible);
                    }
                    else
                    {
                        return(System.Windows.Visibility.Collapsed);
                    }
                }
            }

            // Default visibility for Start button is visible
            return(System.Windows.Visibility.Visible);
        }
 public string GetLinkSolution(string request)
 {
     if (!ServiceStatus.Equals(BaseServicesStatuses.ServiceLaunched))
     {
         return(null);
     }
     lock (locker)
     {
         var current = _tasks.FirstOrDefault(t => t.RequestUrl.Equals(request));
         if (!ReferenceEquals(current, null))
         {
             return(current.GeneratedUrl);
         }
     }
     return(null);
 }
Esempio n. 3
0
        private void ReportServiceDown(IServiceAddress address, ServiceType type, ServiceStatus status)
        {
            // Default old status,
            ServiceStatus oldStatus = ServiceStatus.Up;

            // Search and return,
            lock (monitoredServers) {
                TrackedService tracked = null;
                foreach (TrackedService s in monitoredServers)
                {
                    if (s.ServiceAddress.Equals(address) &&
                        s.ServiceType == type)
                    {
                        tracked = s;
                        break;
                    }
                }

                if (tracked == null)
                {
                    // Not found so add it to the tracker,
                    monitoredServers.Add(new TrackedService(address, type, status));
                }
                else
                {
                    oldStatus             = tracked.CurrentStatus;
                    tracked.CurrentStatus = status;
                }
            }

            // Fire the event if the status changed,
            if (!oldStatus.Equals(status))
            {
                if (StatusChange != null)
                {
                    StatusChange(this, new ServiceStatusEventArgs(address, type, oldStatus, status));
                }
            }
        }