private void ServiceControllerExecute(string serviceName) { ServiceQuery queryTask = new ServiceQuery(); queryTask.BuildEngine = new MockBuild(); queryTask.ServiceName = serviceName; Assert.IsTrue(queryTask.Execute(), "Execute query failed"); ServiceController task = new ServiceController(); task.BuildEngine = new MockBuild(); task.ServiceName = serviceName; if (ServiceQuery.UNKNOWN_STATUS.Equals(queryTask.Status)) { Assert.Ignore("Couldn't find the '{0}' service on '{1}'", queryTask.ServiceName, queryTask.MachineName); } else if (ServiceControllerStatus.Stopped.ToString().Equals(queryTask.Status)) { task.Action = "Start"; } else if (ServiceControllerStatus.Running.ToString().Equals(queryTask.Status)) { task.Action = "Restart"; } else { Assert.Ignore("'{0}' service on '{1}' is '{2}'", queryTask.ServiceName, queryTask.MachineName, queryTask.Status); } Assert.IsTrue(task.Execute(), "Execute Failed"); Assert.IsNotNull(task.Status, "Status Null"); }
public void ServiceQueryW3SVC() { ServiceQuery task = new ServiceQuery(); task.BuildEngine = new MockBuild(); task.ServiceName = "w3svc"; Assert.IsTrue(task.Execute(), "Execute Failed"); Assert.IsNotNull(task.Status, "Status Null"); }
private void DiscoverCapabilities() { var requestIq = new IQ(); var request = new ServiceQuery(); request.Node = Capabilities.DiscoveryInfoNode; requestIq.From = session.UserId; requestIq.ID = XmppIdentifierGenerator.Generate(); requestIq.To = ResourceId; requestIq.Type = IQType.Get; requestIq.Items.Add(request); pendingMessages.Add(requestIq.ID); session.Send(requestIq); }
public void DiscoverCapabilities() { IQ requestIq = new IQ(); ServiceQuery request = new ServiceQuery(); request.Node = this.DiscoveryInfoNode; requestIq.From = this.Session.UserId.ToString(); requestIq.ID = XmppIdentifierGenerator.Generate(); requestIq.To = this.resource.ResourceId.ToString(); requestIq.Type = IQType.Get; requestIq.Items.Add(request); this.pendingMessages.Add(requestIq.ID); this.Session.Send(requestIq); }
public void FixtureSetup() { MockBuild buildEngine = new MockBuild(); TaskUtility.makeTestDirectory(buildEngine); ServiceQuery squery = new ServiceQuery(); squery.BuildEngine = buildEngine; squery.ServiceName = "MSSQLSERVER"; if (!squery.Execute()) { Assert.Ignore("ServiceQuery for SqlServer failed."); } if (!squery.Exists){ Assert.Ignore("MS SqlServer is not installed"); } if (!squery.Status.Equals("Running", StringComparison.InvariantCultureIgnoreCase)) { Assert.Ignore("MS SqlServer is not running"); } }
public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext) { int headerPosition = request.Headers.FindHeader(QueryHeaderName, QueryHeaderNamespace); if (headerPosition > -1) { XmlDictionaryReader reader = request.Headers.GetReaderAtHeader(headerPosition); // Advance to contents, ReadServiceQuery expect to be on the QueryOption if (reader.IsStartElement(QueryPropertyName)) { reader.Read(); } ServiceQuery serviceQuery = MessageUtility.ReadServiceQuery(reader); request.Properties[QueryPropertyName] = serviceQuery; } return(null); }
public void GetElementsFromBodyTest_NoServiceQuery() { Message originalMessage; Message message; originalMessage = message = GetSampleMessage(false); ServiceQuery serviceQuery = MessageUtility.GetServiceQuery(ref message); // no service query Assert.AreEqual(null, serviceQuery, "service query not null"); // the message did not change, it should compare XmlDictionaryReader reader = MessageUtilityTest.CreateReaderFromMessage(message); MessageUtilityTest.CompareSampleMessage(reader); // cleanup reader.Close(); originalMessage.Close(); }
/// <summary> /// This function exists to isolate the FormConfig class from ServiceQuery to allow EmberMon /// configurations that run without remote support. /// </summary> /// <param name="cbx">Checkbox to fill-in</param> /// <param name="items">Dictionary receiving remote information</param> /// <param name="service_class">service class to search for</param> /// <param name="identity">identity to search for (if any)</param> /// <param name="port">port # to use</param> public static void Query(ComboBox cbx, Dictionary <string, string> items, string service_class, string identity, int port) { ServiceQuery sq = new ServiceQuery(service_class, identity, port); // populate power meter selection (non-server) if (sq.INFO.Length > 0) { foreach (Info info in sq.INFO) { string id = (info.hostname + ":" + info.identity).ToUpper(); if (cbx != null) { cbx.Items.Add(id); } if (!items.ContainsKey(id)) { items.Add(id, info.identity + ":" + info.endpoint); } } } }
public void FixtureSetup() { MockBuild buildEngine = new MockBuild(); TaskUtility.makeTestDirectory(buildEngine); ServiceQuery squery = new ServiceQuery(); squery.BuildEngine = buildEngine; squery.ServiceName = "MSSQLSERVER"; if (!squery.Execute()) { Assert.Ignore("ServiceQuery for SqlServer failed."); } if (!squery.Exists) { Assert.Ignore("MS SqlServer is not installed"); } if (!squery.Status.Equals("Running", StringComparison.InvariantCultureIgnoreCase)) { Assert.Ignore("MS SqlServer is not running"); } }
public void GetElementsFromBodyTest_WithServiceQuery() { Message originalMessage; Message message; originalMessage = message = GetSampleMessage(true); ServiceQuery serviceQuery = MessageUtility.GetServiceQuery(ref message); Assert.IsNotNull(serviceQuery); Assert.AreEqual(2, serviceQuery.QueryParts.Count()); ServiceQueryPart[] parts = serviceQuery.QueryParts.ToArray(); Assert.AreEqual(parts[0].ToString(), @"where=(it.City.StartsWith(""R"")&&(it.AddressID<400))"); Assert.AreEqual(parts[1].ToString(), "orderby=it.AddressId"); Assert.AreEqual(true, serviceQuery.IncludeTotalCount); Assert.AreEqual(2, serviceQuery.QueryParts.Count()); XmlDictionaryReader reader = MessageUtilityTest.CreateReaderFromMessage(message); MessageUtilityTest.CompareSampleMessage(reader); // cleanup reader.Close(); originalMessage.Close(); }
public ServicesController(ServiceQuery serviceQuery, IGlobalStoreManager globalStore) { GlobalStore = globalStore; this.serviceQuery = serviceQuery; }
/// <summary> /// Defines the entry point of the application. /// </summary> private void Main() { IQueryFor<EmptyParameter, IEnumerable<ServiceDto>> serviceQuery = new ServiceQuery(); services = serviceQuery.ExecuteQueryWith(new EmptyParameter()); services.ToList().ForEach(service => ServiceMonitor.SaveResults(ServiceMonitor.InvokeService(service))); }
public DBUpdateService(ElasticClientFactory clientFactory, IndexQuery indexQuery, IQueryFactory queryFactory, ILoggerFactory loggerFactory, MetadataQuery metadataQuery, ServiceQuery serviceQuery, ProcessQuery processQuery, ServiceManager serviceManager) { this.serviceManager = serviceManager; this.processQuery = processQuery; this.serviceQuery = serviceQuery; this.metadataQuery = metadataQuery; this.queryFactory = queryFactory; this.indexQuery = indexQuery; this.clientFactory = clientFactory; this.logger = loggerFactory.CreateLogger <DBUpdateService>(); }
protected override void OnServiceDiscoveryMessage(IQ message) { // Answers to Entity Capabilities and service discovery info requests if (message.Type == IQType.Get) { if (message.Items[0] is ServiceQuery) { var query = (ServiceQuery)message.Items[0]; var response = new ServiceQuery { Node = ((!String.IsNullOrEmpty(query.Node)) ? DiscoveryInfoNode : null) }; var responseIq = new IQ { From = session.UserId, ID = message.ID, To = message.From, Type = IQType.Result }; foreach (XmppServiceIdentity identity in Identities) { var supportedIdentity = new ServiceIdentity { Name = identity.Name, Category = identity.Category.ToString().ToLower(), Type = identity.Type }; response.Identities.Add(supportedIdentity); } foreach (XmppServiceFeature supportedFeature in Features) { var feature = new ServiceFeature { Name = supportedFeature.Name }; response.Features.Add(feature); } responseIq.Items.Add(response); session.Send(responseIq); //// Error response //IQ errorIq = new IQ(); //ServiceQuery response = new ServiceQuery(); //Error error = new Error(); //errorIq.From = this.session.UserId.ToString(); //errorIq.ID = e.QueryResult.ID; //errorIq.To = e.QueryResult.From; //errorIq.Type = IQType.Error; //errorIq.Error = error; //response.Node = query.Node; //error.Type = ErrorType.Cancel; //error.ItemNotFound = ""; //errorIq.Items.Add(response); //this.session.Send(errorIq); } } }
public IActionResult Query(ServiceQuery request) { var result = _serviceRepository.Query(request).ToList(); return(Json(result)); }
/// <summary> /// Reads the query options from the given reader and returns the resulting service query. /// It assumes that the reader is positioned on a stream containing the query options. /// </summary> /// <param name="reader">Reader to the stream containing the query options.</param> /// <returns>Extracted service query.</returns> internal static ServiceQuery ReadServiceQuery(XmlReader reader) { List<ServiceQueryPart> serviceQueryParts = new List<ServiceQueryPart>(); bool includeTotalCount = false; while (reader.IsStartElement(MessageUtility.QueryOptionElementName)) { string name = reader.GetAttribute(MessageUtility.QueryNameAttribute); string value = reader.GetAttribute(MessageUtility.QueryValueAttribute); if (name.Equals(MessageUtility.QueryIncludeTotalCountOption, StringComparison.OrdinalIgnoreCase)) { bool queryOptionValue = false; if (Boolean.TryParse(value, out queryOptionValue)) { includeTotalCount = queryOptionValue; } } else { serviceQueryParts.Add(new ServiceQueryPart { QueryOperator = name, Expression = value }); } MessageUtility.ReadElement(reader); } ServiceQuery serviceQuery = new ServiceQuery() { QueryParts = serviceQueryParts, IncludeTotalCount = includeTotalCount }; return serviceQuery; }