private async Task <List <ReplicaMonitoringInfo> > GetDeployedApplicationReplicaOrInstanceListAsync(Uri applicationNameFilter)
        {
            var deployedApps = await this.FabricClientInstance.QueryManager.GetDeployedApplicationListAsync(this.NodeName, applicationNameFilter).ConfigureAwait(true);

            var currentReplicaInfoList = new List <ReplicaMonitoringInfo>();

            foreach (var deployedApp in deployedApps)
            {
                var serviceList = await this.FabricClientInstance.QueryManager.GetServiceListAsync(deployedApp.ApplicationName).ConfigureAwait(true);

                ServiceList filteredServiceList = null;

                var app = this.targetList.Where(x => x.Target.ToLower() == deployedApp.ApplicationName.OriginalString.ToLower() &&
                                                (!string.IsNullOrEmpty(x.ServiceExcludeList) ||
                                                 !string.IsNullOrEmpty(x.ServiceIncludeList)))?.FirstOrDefault();
                if (app != null)
                {
                    filteredServiceList = new ServiceList();

                    if (!string.IsNullOrEmpty(app.ServiceExcludeList))
                    {
                        string[] list = app.ServiceExcludeList.Split(',');

                        // Excludes...?
                        foreach (var service in serviceList)
                        {
                            if (!list.Any(l => service.ServiceName.OriginalString.Contains(l)))
                            {
                                filteredServiceList.Add(service);
                            }
                        }
                    }
                    else if (!string.IsNullOrEmpty(app.ServiceIncludeList))
                    {
                        string[] list = app.ServiceIncludeList.Split(',');

                        // Includes...?
                        foreach (var service in serviceList)
                        {
                            if (list.Any(l => service.ServiceName.OriginalString.Contains(l)))
                            {
                                filteredServiceList.Add(service);
                            }
                        }
                    }
                }

                var replicasOrInstances = await this.GetDeployedPrimaryReplicaAsync(deployedApp.ApplicationName, filteredServiceList ?? serviceList).ConfigureAwait(true);

                currentReplicaInfoList.AddRange(replicasOrInstances);

                // This is for reporting...
                this.replicaOrInstanceList.AddRange(replicasOrInstances);
            }

            return(currentReplicaInfoList);
        }
        // {apiroot/id}
        /// <summary>
        ///  gets all the services with the EsdId provided
        /// 
        ///  this call, doesn't call the service cache, it calls
        ///  the umbraco objects and gets all teh info from there
        /// </summary>
        public HttpResponseMessage Get(string id)
        {
            var serviceList = new ServiceList();

            var roots = Umbraco.TypedContentAtRoot();

            foreach(var root in roots)
            {
                IEnumerable<IPublishedContent> nodes = null;
                if (Open311Settings.Current.useEsdAsId)
                {
                    nodes = root.Descendants()
                        .Where(x => x.IsVisible()
                        && x.GetPropertyValue<string>(Open311Settings.Current.Fields.EsdId) == id);
                }
                else
                {
                    nodes = root.Descendants()
                        .Where(x => x.IsVisible() && x.GetKey().ToString() == id);
                }

                if (nodes!= null && nodes.Any())
                {
                    foreach(var node in nodes)
                    {
                        serviceList.Add(GetServiceFromNode(node, true));
                    }
                    break;
                }
            }
            return GetReturnData(serviceList);
        }
        public void PagedServiceListSerializationTest()
        {
            ServiceList serviceList = new ServiceList();

            serviceList.ContinuationToken = "ServiceId4238539259";
            serviceList.Add(new StatefulService(
                                this.random.CreateRandom <Uri>(),
                                this.random.CreateRandom <string>(),
                                this.random.CreateRandom <string>(),
                                this.random.CreateRandom <bool>(),
                                this.random.CreateRandom <HealthState>(),
                                this.random.CreateRandom <ServiceStatus>()));
            serviceList.Add(new StatelessService(
                                this.random.CreateRandom <Uri>(),
                                this.random.CreateRandom <string>(),
                                this.random.CreateRandom <string>(),
                                this.random.CreateRandom <HealthState>(),
                                this.random.CreateRandom <ServiceStatus>()));
            TestUsingSerializer(this.Serializer, serviceList);
        }
 private void ChangeParentService(int?parentServiceId)
 {
     ServiceList.Clear();
     if (!parentServiceId.HasValue)
     {
         return;
     }
     foreach (var source in _requestService.GetServices(parentServiceId.Value).OrderBy(s => s.Name))
     {
         ServiceList.Add(source);
     }
     OnPropertyChanged(nameof(ServiceList));
 }
예제 #5
0
 private void ExecuteInsertMethod(object obj)
 {
     if (!Check(SelectedService))
     {
         return;
     }
     else
     {
         _serviceRepository.InsertService(SelectedService);
         ServiceList.Add(SelectedService);
         ServiceList     = new ObservableCollection <ServiceVo>(_serviceRepository.GetServices());
         SelectedService = new ServiceVo();
     }
 }
예제 #6
0
        private static void InsertPlugin(Plugin plugin, string[] args)
        {
            switch (plugin.PluginType)
            {
            case PluginType.Application:
                ApplicationList.Add((ApplicationPlugin)plugin);
                Logger.Origin($"应用 \"{plugin.Name}\" 已经加载完毕。");
                break;

            case PluginType.Service:
            default:
                ServicePlugin svcPlugin = (ServicePlugin)plugin;
                svcPlugin.Execute(args);
                ServiceList.Add(svcPlugin);
                Logger.Origin($"服务 \"{svcPlugin.Name}\" 已经加载完毕。");
                break;
            }
        }
예제 #7
0
 public virtual void AddService(Service child)
 {
     child.Invoice = this;
     ServiceList.Add(child);
 }
예제 #8
0
 private void GetAllServers(ServiceList sl)
 {
     try
     {
         foreach (Server leaf in leafs)
         {
             sl.Add(leaf);
             leaf.GetAllServers(sl);
         }
     }
     catch (Exception ex)
     {
         p_core.SendLogMessage("Server", "GetAllServers(2)", BlackLight.Services.Error.Errors.ERROR, "Problem", "", ex.Message, ex.StackTrace);
     }
 }
예제 #9
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Returns a list of all servers linked to this instance
 /// </summary>
 /// <returns></returns>
 /// <remarks>
 /// </remarks>
 /// <history>
 /// 	[Caleb]	6/18/2005	Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public ServiceList GetAllServers()
 {
     try
     {
         ServiceList sl = new ServiceList();
         foreach (Server leaf in leafs)
         {
             sl.Add(leaf);
             leaf.GetAllServers(sl);
         }
         return sl;
     }
     catch (Exception ex)
     {
         p_core.SendLogMessage("Server", "GetAllServers", BlackLight.Services.Error.Errors.ERROR, "Problem", "", ex.Message, ex.StackTrace);
     return null;
     }
 }
예제 #10
0
 public void RegisterService <TService, TImplementation>() where TService : class where TImplementation : class, TService
 {
     ServiceList.Add(typeof(TService), typeof(TImplementation));
 }
예제 #11
0
 public void RegisterService <TService>() where TService : class
 {
     ServiceList.Add(typeof(TService), null);
 }
예제 #12
0
        private void OnServiceUpdate(object sender, EventArgs e)
        {
            Console.WriteLine("Atualizando lista de serviços WMI");

            try
            {
                string query;
                if (ServiceFilter != null)
                {
                    query = $"{_serviceQuery} WHERE DisplayName LIKE '%{ServiceFilter}%'";
                }
                else
                {
                    query = _serviceQuery;
                }

                AllServices = Session.QueryInstances(@"root\cimv2", "WQL", query);


                if (ServiceList.Count() > 0)
                {
                    //Loop through all services
                    foreach (CimInstance oneService in AllServices)
                    {
                        Services s       = CimInstanceConvert(oneService);
                        Services service = ServiceList.FirstOrDefault(i => i.Name == s.Name);

                        if (service.State != s.State)
                        {
                            service.Update(s);
                            string       subtitle;
                            PackIconKind icon;

                            switch (s.State)
                            {
                            case "Running":
                                subtitle = "Serviço foi inicializado";
                                icon     = PackIconKind.Notifications;
                                break;

                            case "Start Pending":
                                subtitle = "Serviço esta sendo inicializado";
                                icon     = PackIconKind.InfoCircle;
                                break;

                            case "Stopped":
                                subtitle = "Serviço foi parado";
                                icon     = PackIconKind.Dangerous;
                                break;

                            case "Stop Pending":
                                subtitle = "Serviço esta sendo parado";
                                icon     = PackIconKind.Warning;
                                break;

                            default:
                                subtitle = "Estado não encontrado";
                                icon     = PackIconKind.SackPercent;
                                break;
                            }

                            if (_enableNotification)
                            {
                                _notifier.ShowNotification(s.DisplayName, subtitle, icon, s.State, null, declineAction: n => CloseNotification(n));
                            }
                        }
                    }
                }
                else
                {
                    //Loop through all services
                    foreach (CimInstance oneService in AllServices)
                    {
                        Services s = CimInstanceConvert(oneService);
                        ServiceList.Add(s);
                    }
                }

                IsLoading   = false;
                IsConnected = true;
            }
            catch (Exception ex)
            {
                IsConnected = false;
                IsLoading   = false;
                snackMessageQueue.Enqueue(ex.Message);
                SnackbarNotify.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#D20101"));
                _task.Stop();
                //ServiceList.Clear();
                log.Error(ex.Message);
            }
        }
        /// <summary>
        ///  gets the service list from either the cache or umbraco.
        /// </summary>
        /// <returns></returns>
        private ServiceList GetServiceList()
        {
            var cache = ApplicationContext.Current.ApplicationCache.RuntimeCache;

            ServiceList serviceList = cache.GetCacheItem<ServiceList>(Open311Settings.Current.CacheName);

            if (serviceList == null)
            {
                serviceList = new ServiceList();

                var siteRoots = Umbraco.TypedContentAtRoot();
                foreach(var root in siteRoots)
                {
                    IEnumerable<IPublishedContent> nodes = null;
                    if (Open311Settings.Current.useEsdAsId)
                    {
                        nodes = root.Descendants()
                            .Where(x => x.IsVisible() && x.HasValue(Open311Settings.Current.Fields.EsdId));
                    }
                    else
                    {
                        nodes = root.Descendants()
                            .Where(x => x.IsVisible());
                    }

                    if (nodes != null && nodes.Any())
                    {
                        foreach (var node in nodes)
                        {
                            serviceList.Add(GetServiceFromNode(node));
                        }
                    }
                }

                cache.InsertCacheItem<ServiceList>(Open311Settings.Current.CacheName,
                    () => serviceList, priority: CacheItemPriority.Default);

            }

            return serviceList;
        }