private static LookupRequest NormalizeRequest(LookupRequest input) => new LookupRequest { Keys = { input.Keys.Select(k => k.Clone()).OrderBy(RenderKey) }, ProjectId = input.ProjectId, ReadOptions = input.ReadOptions };
public async Task <Konto> Lookup(LookupRequest request) { var requestUri = CreateLookupUri(request); var responseAsAccount = await GetAsModel <KatalogKonto>(requestUri).ConfigureAwait(false); return(Konto.FromKatalogModel(responseAsAccount)); }
public JsonResult Lookup(LookupRequest lr) { lr.q_word = lr.q_word ?? ""; var FilteredCountries = _country.All.Where(x => lr.q_word == "" || x.CountryName.Contains(lr.q_word) ); var PagedFilter = FilteredCountries.OrderBy(x => x.CountryName).Skip((lr.page_num - 1) * lr.per_page).Take(lr.per_page) .ToList(); return(Json( new { cnt = FilteredCountries.Count(), primary_key = PagedFilter.Select(x => x.CountryId), candidate = PagedFilter.Select(x => x.CountryName), cnt_page = PagedFilter.Count() } )); }
public override IRemoteSupplier lookup(System.String supplierName) { MessageEnvelope message = new MessageEnvelope(); MessageBody body = new MessageBody(); LookupRequest request = new LookupRequest(); request.SupplierName = supplierName; body.selectLookupRequest(request); message.Body = body; message.Id = this.ToString(); IRemoteSupplier supplier = null; lock (clients) { foreach (ITransport client in clients) { MessageEnvelope result = client.call(message, callTimeout); if (result.Body.LookupResult.Code.Value == LookupResultCode.EnumType.success) { supplier = new RemoteSupplier(supplierName, client); break; } } } if (supplier == null) { throw new Exception("Error when accessing to supplier '" + supplierName + "'! Unable to find any suitable supplier!"); } return(supplier); }
public async stt::Task LookupRequestObjectAsync() { moq::Mock <Datastore.DatastoreClient> mockGrpcClient = new moq::Mock <Datastore.DatastoreClient>(moq::MockBehavior.Strict); LookupRequest request = new LookupRequest { ReadOptions = new ReadOptions(), Keys = { new Key(), }, ProjectId = "project_id43ad98b0", }; LookupResponse expectedResponse = new LookupResponse { Found = { new EntityResult(), }, Missing = { new EntityResult(), }, Deferred = { new Key(), }, }; mockGrpcClient.Setup(x => x.LookupAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <LookupResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); LookupResponse responseCallSettings = await client.LookupAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); LookupResponse responseCancellationToken = await client.LookupAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void CanGenerateApiXmlWithLookupControl() { //Arrange string expexcted = new XElement("LookupRequest", new XAttribute("name", "/Schema/Attribute Sets/Översättningsattribut"), new XElement("LookupControls", new XElement("AttributesToReturn", new XAttribute("namelist", "members")), new XElement("LanguagesToReturn", new XElement("Language", new XAttribute("id", "10"))))).ToString(); var lookupBuilder = new LookupControlBuilder(); lookupBuilder.AttributeNamelist("members").ReturnLanguages(LanguageToReturn.WithLanguageId(10)); //Act var req = new LookupRequest("/Schema/Attribute Sets/Översättningsattribut", lookupBuilder.Build()); var actual = req.ToAdsml(); var batchRequest = new BatchRequest(req); Console.WriteLine(actual); //Assert Assert.That(actual.ToString(), Is.EqualTo(expexcted)); Assert.DoesNotThrow(() => batchRequest.ToAdsml().ValidateAdsmlDocument("adsml.xsd")); }
private static void QueueLookup(LookupRequest lookupRequest) { LookupRequest inProgressLookup = (from lookup in m_inProgressLookups where lookup.Key == lookupRequest.id() select lookup.Value).FirstOrDefault(); if (inProgressLookup == null) { m_inProgressLookups.TryAdd(lookupRequest.id(), lookupRequest); m_queuedLookups.Enqueue(lookupRequest); logger.LogDebug("DNSManager lookup queued for " + lookupRequest.QueryType + " " + lookupRequest.Hostname + ", queue size=" + m_queuedLookups.Count + ", in progress=" + m_queuedLookups.Count + "."); m_lookupARE.Set(); } else { if (lookupRequest.CompleteEvent != null) { if (inProgressLookup.Duplicates == null) { inProgressLookup.Duplicates = new List <LookupRequest>() { lookupRequest }; } else { inProgressLookup.Duplicates.Add(lookupRequest); } logger.LogDebug("DNSManager duplicate lookup added for " + lookupRequest.QueryType + " " + lookupRequest.Hostname + ", queue size=" + m_queuedLookups.Count + ", in progress=" + m_queuedLookups.Count + "."); } } }
public override IRemoteSupplier lookup(System.String supplierName) { MessageEnvelope message = new MessageEnvelope(); MessageBody body = new MessageBody(); LookupRequest request = new LookupRequest(); request.SupplierName = supplierName; body.selectLookupRequest(request); message.Body = body; message.Id = this.ToString(); IRemoteSupplier supplier = null; lock (clients) { foreach(ITransport client in clients) { MessageEnvelope result = client.call(message, callTimeout); if (result.Body.LookupResult.Code.Value == LookupResultCode.EnumType.success) { supplier = new RemoteSupplier(supplierName, client); break; } } } if (supplier == null) throw new Exception("Error when accessing to supplier '" + supplierName + "'! Unable to find any suitable supplier!"); return supplier; }
public void ToXmlTest() { var request = new LookupRequest("monsters.com") { NoCache = true }; Assert.Equal( @"<OPS_envelope> <header> <version>0.9</version> </header> <body> <data_block> <dt_assoc> <item key=""protocol"">XCP</item> <item key=""action"">LOOKUP</item> <item key=""object"">DOMAIN</item> <item key=""attributes""> <dt_assoc> <item key=""domain"">monsters.com</item> <item key=""no_cache"">1</item> </dt_assoc> </item> </dt_assoc> </data_block> </body> </OPS_envelope>", request.ToXml().ToString()); }
public void CanInstatiateNewLookupRequest() { //Act var request = new LookupRequest("foo"); //Assert Assert.That(request, Is.Not.Null); }
public void CanInstatiateNewLookupRequestWithLookupControls() { //Act var request = new LookupRequest("foo", new LookupControl(null, null)); //Assert Assert.That(request, Is.Not.Null); }
public void ShouldUpdateLookupAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); LookupRequest lookup = CreateLookup(); // Act & Assert systemApi.UpdateLookupsAsync(new SqlQuery(), lookup).Wait(); }
private LookupResponse Lookup(LookupRequest request) { var user = _context.Find(u => u.AccessCode == request.AccessCode); return(Ok(new LookupResponse { AimeId = user?.CardId, RegisterLevel = RegisterLevel.None })); }
/// <summary> /// Retrieves the named object. /// </summary> /// <param name="name"> /// The name of the object to look up. /// </param> /// <returns> /// The object bound to name. /// </returns> public object Lookup(string name) { IChannel channel = EnsureChannel(); LookupRequest request = (LookupRequest) channel.MessageFactory.CreateMessage(LookupRequest.TYPE_ID); request.LookupName = name; return(channel.Request(request)); }
public object Post([FromBody] LookupRequest request) { var lookupData = PhoneNumberResource.Fetch( type: new List <string> { "carrier" }, pathPhoneNumber: new Twilio.Types.PhoneNumber($"{request.CountryCode}{request.PhoneNumber}") ); return(Ok(new { info = lookupData })); }
public async Task LookupCallsCatalogHandlerWithExpectedLookup() { var lookup = new LookupRequest( "testIdentifier", "testType", 3); var sut = _fixture.WithLookupAccount(new Konto()).CreateSut(); var actualAccount = await sut.Lookup(lookup).ConfigureAwait(false); _fixture.CatalogHandlerMock.Verify(_ => _.Lookup(lookup)); }
public void Lookup(string serverId, out string serverUrl) { LookupRequest request = NamingServiceMessageFactory.BuildLookupRequest(serverId); LookupResponse response = client.Lookup( request, deadline: DateTime.UtcNow.AddSeconds(30)); serverUrl = response.ServerUrl; }
public ActionResult <LookupResponse> LookupData([FromBody] LookupRequest lookupRequest) { try { ILookupService service = this._lookupProviders.CreateLookupService("SQL"); return(service.GetFeatures(lookupRequest)); } catch (Exception ex) { Log.Error(string.Format("Error: {0}", ex.Message)); return(NotFound()); } }
public override async Task <LookupResponse> Lookup(LookupRequest request, ServerCallContext context) { string serverId = request.ServerId; string serverUrl = await dispatcher.OnLookup(serverId); if (serverUrl != null) { return(new LookupResponse { ServerUrl = serverUrl }); } throw new RpcException(new Status(StatusCode.NotFound, "No Such Id")); }
/*================================================================================================================================== * Public Methods *=================================================================================================================================*/ public questStatus GetLookupOptions(LookupRequest lookupRequest, List <LookupArgument> lookupArgumentList, out List <OptionValuePair> lookupOptionList) { // Initialize questStatus status = null; // Get lookup options status = _dbLookupMgr.GetLookupOptions(lookupRequest, lookupArgumentList, out lookupOptionList); if (!questStatusDef.IsSuccess(status)) { return(status); } return(new questStatus(Severity.Success)); }
public override LookupResponse Lookup(LookupRequest request, CallSettings callSettings = null) { requests.Add(NormalizeRequest(request)); // Report "found" entities in the order they were presented in the constructor. // Report everything else as deferred. Ignore "missing"... var validKeys = keys.Where(k => request.Keys.Contains(k)); var response = new LookupResponse { Found = { validKeys.Take(maxPerRequest).Select(CreateEntityResult) }, Deferred = { validKeys.Skip(maxPerRequest) } }; return(response); }
public async Task <object> Post([FromBody] LookupRequest request) { try { var client = _clientFactory.CreateClient("lookup"); var uri = $"/v1/PhoneNumbers/{request.CountryCode}{request.PhoneNumber}/?Type=carrier"; var response = await client.GetAsJObjectAsync(uri); return(Ok(new { info = response })); } catch (Exception e) { throw new HttpRequestException(e.Message); } }
/// <summary>Snippet for Lookup</summary> public void Lookup_RequestObject() { // Snippet: Lookup(LookupRequest,CallSettings) // Create client DatastoreClient datastoreClient = DatastoreClient.Create(); // Initialize request argument(s) LookupRequest request = new LookupRequest { ProjectId = "", Keys = { }, }; // Make the request LookupResponse response = datastoreClient.Lookup(request); // End snippet }
private Uri CreateLookupUri(LookupRequest request) { var servicePath = $"{_katalogConfiguration.Path}/{LookupEndpoint}"; var query = $"?{IdentifyerQueryName}={request.Identifikator}&" + $"{MessageProtocolQueryName}={request.Meldingsprotokoll}&" + $"{AccessLevelQueryName}={request.Sikkerhetsniva}"; return(new UriBuilder( _katalogConfiguration.Scheme, _katalogConfiguration.Host, _katalogConfiguration.Port, servicePath, query) .Uri); }
public void ShouldCreateLookupAsync() { // Arrange ISystemApi systemApi = CreateSystemApi(); LookupRequest lookup = CreateLookup(); lookup.Id = null; // Act LookupResponse created = systemApi.CreateLookupsAsync(new SqlQuery(), lookup).Result.First(); // Assert created.Id.ShouldBe(1); Should.Throw <ArgumentException>(() => systemApi.CreateLookupsAsync(new SqlQuery())); }
public void CanGenerateBasicApiXml() { //Arrange string expected = new XElement("LookupRequest", new XAttribute("name", "/foo/bar")).ToString(); //Act var req = new LookupRequest("/foo/bar"); var actual = req.ToAdsml(); var batchRequest = new BatchRequest(req); Console.WriteLine(actual); //Assert Assert.That(actual.ToString(), Is.EqualTo(expected)); Assert.DoesNotThrow(() => batchRequest.ToAdsml().ValidateAdsmlDocument("adsml.xsd")); }
/// <summary> /// Look up entities by key. /// </summary> /// <param name="project_id">Project ID against which to make the request.</param> /// <param name="read_options">Options for this lookup request.</param> /// <param name="keys">Keys of entities to look up.</param> /// <param name="callSettings">If not null, applies overrides to this RPC call.</param> /// <returns>The RPC response.</returns> public override LookupResponse Lookup( string projectId, ReadOptions readOptions, IEnumerable <Key> keys, CallSettings callSettings = null) { LookupRequest request = new LookupRequest { ProjectId = projectId, ReadOptions = readOptions, Keys = { keys }, }; return(GrpcClient.Lookup( request, _clientHelper.BuildCallOptions(null, callSettings))); }
public async Task LookupAsync_RequestObject() { // Snippet: LookupAsync(LookupRequest,CallSettings) // Create client DatastoreClient datastoreClient = await DatastoreClient.CreateAsync(); // Initialize request argument(s) LookupRequest request = new LookupRequest { ProjectId = "", Keys = { }, }; // Make the request LookupResponse response = await datastoreClient.LookupAsync(request); // End snippet }
public void Lookup2() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); LookupRequest request = new LookupRequest { ProjectId = "projectId-1969970175", Keys = { }, }; LookupResponse expectedResponse = new LookupResponse(); mockGrpcClient.Setup(x => x.Lookup(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); LookupResponse response = client.Lookup(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task LookupAsync2() { Mock <Datastore.DatastoreClient> mockGrpcClient = new Mock <Datastore.DatastoreClient>(MockBehavior.Strict); LookupRequest request = new LookupRequest { ProjectId = "projectId-1969970175", Keys = { }, }; LookupResponse expectedResponse = new LookupResponse(); mockGrpcClient.Setup(x => x.LookupAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <LookupResponse>(Task.FromResult(expectedResponse), null, null, null, null)); DatastoreClient client = new DatastoreClientImpl(mockGrpcClient.Object, null); LookupResponse response = await client.LookupAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task <StockPriceResponse> RequestPriceAsync(StockPriceRequest request) { var lookUp = new LookupRequest { LookUpId = Guid.NewGuid(), Symbol = request.Symbol, ApiKey = request.ApiKey, }; lookUp.Context = request.Context switch { Context.Query => LookUpContext.Query, Context.Buy => LookUpContext.Buy, Context.Sell => LookUpContext.Sell, _ => throw new NotSupportedException() }; var options = new BoundedChannelOptions(1); options.FullMode = BoundedChannelFullMode.DropNewest; options.SingleReader = true; options.SingleWriter = true; var channel = Channel.CreateBounded <LookUpResponse>(options); while (!_writers.TryAdd(lookUp.LookUpId, channel.Writer)) { ; } _queue.Enqueue(lookUp, (int)lookUp.Context); if (!await channel.Reader.WaitToReadAsync()) { throw new NotSupportedException(); } return(new StockPriceResponse { Price = (await channel.Reader.ReadAsync()).Price }); } }
private static void QueueLookup(LookupRequest lookupRequest) { lock (m_inProgressLookups) { LookupRequest inProgressLookup = (from lookup in m_inProgressLookups where lookup.QueryType.ToString() == lookupRequest.QueryType.ToString() && lookup.Hostname == lookupRequest.Hostname select lookup).FirstOrDefault(); if (inProgressLookup == null) { m_inProgressLookups.Add(lookupRequest); lock (m_queuedLookups) { m_queuedLookups.Enqueue(lookupRequest); } logger.Debug("DNSManager lookup queued for " + lookupRequest.QueryType + " " + lookupRequest.Hostname + ", queue size=" + m_queuedLookups.Count + ", in progress=" + m_queuedLookups.Count + "."); m_lookupARE.Set(); } else { if (lookupRequest.CompleteEvent != null) { lock (m_queuedLookups) { if (inProgressLookup.Duplicates == null) { inProgressLookup.Duplicates = new List<LookupRequest>() { lookupRequest }; } else { inProgressLookup.Duplicates.Add(lookupRequest); } } logger.Debug("DNSManager duplicate lookup added for " + lookupRequest.QueryType + " " + lookupRequest.Hostname + ", queue size=" + m_queuedLookups.Count + ", in progress=" + m_queuedLookups.Count + "."); } } } }
private void AddRequest(Object jsonRequest) { DebugWrite("AddRequest starting!", 6); Thread.CurrentThread.Name = "AddRequest"; Hashtable parsedRequest = (Hashtable)JSON.JsonDecode((String)jsonRequest); String pluginName = String.Empty; String pluginMethod = String.Empty; String playerName = String.Empty; RequestTypeEnum requestType = RequestTypeEnum.ClanTag; if (!parsedRequest.ContainsKey("pluginName")) { ConsoleError("Parsed commands didn't contain a pluginName!"); return; } else { pluginName = (String)parsedRequest["pluginName"]; } if (!parsedRequest.ContainsKey("pluginMethod")) { ConsoleError("Parsed commands didn't contain a pluginMethod!"); return; } else { pluginMethod = (String)parsedRequest["pluginMethod"]; } if (!parsedRequest.ContainsKey("playerName")) { ConsoleError("Parsed commands didn't contain a playerName!"); return; } else { playerName = (String)parsedRequest["playerName"]; } if (!parsedRequest.ContainsKey("requestType")) { ConsoleError("Parsed commands didn't contain a requestType!"); return; } else { switch (parsedRequest["requestType"].ToString().ToLower()) { case "overview": requestType = RequestTypeEnum.Overview; break; case "weapon": requestType = RequestTypeEnum.Weapon; break; case "vehicle": requestType = RequestTypeEnum.Vehicle; break; case "clantag": requestType = RequestTypeEnum.ClanTag; break; default: ConsoleWarn("The parsed requestType '" + parsedRequest["requestType"].ToString() + "' was not recognized. Using default type 'clanTag'"); break; } } LookupRequest request = new LookupRequest(pluginName, pluginMethod, playerName, requestType); DebugWrite("AddRequest locking lookupRequests (adding new request)", 6); lock (lookupRequestLock) { lookupRequests.Add(request); } DebugWrite("AddRequest releasing lookupRequests (adding new request)", 6); requestLoopHandle.Set(); DebugWrite("AddRequest finished!", 6); }