public ViewResult DeliveryOperator(string operatorName) { Order order = (Order)Session["Order"]; order.DeliveryOperator = DeliveryFactory.CreateDeliveryOperator(operatorName); return(View("DiscountSelection")); }
static void Main(string[] args) { try { using (ISession session = Configuration.Sessions.GetSession()) { // Open the session session.Open(); // Define a stream to retrieve level 1 content... using (IStream stream = DeliveryFactory.CreateStream( new ItemStream.Params().Session(session) .Name("EUR=") .OnRefresh((s, msg) => Console.WriteLine(msg)) .OnUpdate((s, msg) => Console.WriteLine(msg)) .OnError((s, err) => Console.WriteLine(err)) .OnStatus((s, msg) => Console.WriteLine(msg)))) { // Open the stream... stream.Open(); // Wait for data to come in then hit any key to close the stream... Console.ReadKey(); } } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }
static void Main(string[] args) { // Complete image of the concatenation our MarketByPrice level 2 initial refreshes JObject image = new JObject(); // Create a session into the platform. ISession session = GlobalSettings.Sessions.GetSession(); // Open the session session.Open(); // Define a MarketByPrice stream specifying the Domain "MarketByPrice" // For each refresh, we merge the contents into the image object. Once all refresh segments have arrived, the // OnComplete is executed and the completed image details are presented for display. using (IStream stream = DeliveryFactory.CreateStream( new ItemStream.Params().Session(session) .Name("BB.TO") .WithDomain("MarketByPrice") .OnRefresh((s, msg) => image.Merge(msg)) .OnComplete(s => DumpImage(image)) .OnUpdate((s, msg) => DumpUpdate(msg)) .OnStatus((s, msg) => Console.WriteLine(msg)))) { // Open the stream... stream.Open(); // Wait for data to come in then hit any key to close the stream... Console.ReadKey(); } }
internal DeliveryTestBase() { var parser = new StreetSpecificationParser(); var factory = new DeliveryFactory(); var fileResult = parser.ParseStreetSpecification("..\\..\\SpecificationExamples\\street1.txt"); DeliveryMethod = factory.CreateDeliveryMethod <T>(fileResult.StreetSpecification); }
static void Main(string[] args) { const string dataGridEndpoint = "https://api.refinitiv.com/data/datagrid/beta1/"; try { // Create the platform session. using (ISession session = Configuration.Sessions.GetSession()) { // Open the session session.Open(); IEndpoint endpoint = DeliveryFactory.CreateEndpoint(new Endpoint.Params().Session(session) .Url(dataGridEndpoint)); // Simple request var response = endpoint.SendRequest(new Endpoint.Request.Params().WithMethod(Endpoint.Request.Method.POST) .WithBodyParameters(new JObject() { { "universe", new JArray("TRI.N", "IBM.N") }, { "fields", new JArray("TR.Revenue", "TR.GrossProfit") } })); DisplayResponse(response); // Global parameters response = endpoint.SendRequest(new Endpoint.Request.Params().WithMethod(Endpoint.Request.Method.POST) .WithBodyParameters(new JObject() { { "universe", new JArray("GOOG.O", "AAPL.O") }, { "fields", new JArray("TR.Revenue", "TR.GrossProfit") }, { "parameters", new JObject() { { "SDate", "0CY" }, { "Curn", "CAD" } } } })); DisplayResponse(response); // Historical data with specific date range response = endpoint.SendRequest(new Endpoint.Request.Params().WithMethod(Endpoint.Request.Method.POST) .WithBodyParameters(new JObject() { { "universe", new JArray("BHP.AX") }, { "fields", new JArray("TR.AdjmtFactorAdjustmentDate", "TR.AdjmtFactorAdjustmentFactor") }, { "parameters", new JObject() { { "SDate", "1980-01-01" }, { "EDate", "2018-09-29" } } } })); DisplayResponse(response); } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }
public void getDeliveryTest() { domain.delivery.impl.DeliveryImpl delivery = DeliveryFactory.getDelivery("Summer Greens", "Pizza", "Jane Doe", "25/12/2016", 21); Assert.AreEqual("Summer Greens", delivery.Destination); Assert.AreEqual("Pizza", delivery.Description); Assert.AreEqual("Jane Doe", delivery.Recipient); Assert.AreEqual("25/12/2016", delivery.DueDate); }
static void Main(string[] args) { // Set Logger level to Trace Log.Level = NLog.LogLevel.Trace; bool useRDP = false; ISession session; if (!useRDP) { System.Console.WriteLine("Start DeploytedPlatformSession"); session = CoreFactory.CreateSession(new DeployedPlatformSession.Params() .Host(WebSocketHost) .WithDacsUserName(TREPUser) .WithDacsApplicationID(appID) .WithDacsPosition(position) .OnState((s, state, msg) => { Console.WriteLine($"{DateTime.Now}: {msg}. (State: {state})"); _sessionState = state; }) .OnEvent((s, eventCode, msg) => Console.WriteLine($"{DateTime.Now}: {msg}. (Event: {eventCode})"))); } else { System.Console.WriteLine("Start RDP PlatformSession"); session = CoreFactory.CreateSession(new PlatformSession.Params() .OAuthGrantType(new GrantPassword().UserName(RDPUser) .Password(RDPPassword)) .AppKey(RDPAppKey) .WithTakeSignonControl(true) .OnState((s, state, msg) => { Console.WriteLine($"{DateTime.Now}: {msg}. (State: {state})"); _sessionState = state; }) .OnEvent((s, eventCode, msg) => Console.WriteLine($"{DateTime.Now}: {msg}. (Event: {eventCode})"))); } session.Open(); if (_sessionState == Session.State.Opened) { System.Console.WriteLine("Session is now Opened"); System.Console.WriteLine("Sending MRN_STORY request"); using (IStream stream = DeliveryFactory.CreateStream( new ItemStream.Params().Session(session) .Name("MRN_STORY") .WithDomain("NewsTextAnalytics") .OnRefresh((s, msg) => Console.WriteLine($"{msg}\n\n")) .OnUpdate((s, msg) => ProcessMRNUpdateMessage(msg)) .OnError((s, msg) => Console.WriteLine(msg)) .OnStatus((s, msg) => Console.WriteLine($"{msg}\n\n")))) { stream.Open(); Thread.Sleep(runtime); } } }
static void Main(string[] args) { try { // Create the platform session. using (ISession session = Configuration.Sessions.GetSession()) { // Open the session session.Open(); var endpoint = DeliveryFactory.CreateEndpoint(new Endpoint.Params().Session(session) .Url(symbolLookupEndpoint)); // RIC to multiple identifiers Console.WriteLine("\nRIC to multiple identifiers..."); Display(endpoint.SendRequest(new Endpoint.Request.Params().WithMethod(Endpoint.Request.Method.POST) .WithBodyParameters(new JObject() { ["from"] = new JArray( new JObject() { ["identifierTypes"] = new JArray("RIC"), ["values"] = new JArray("MSFT.O") }), ["to"] = new JArray( new JObject() { ["identifierTypes"] = new JArray("ISIN", "LEI", "ExchangeTicker") }), ["type"] = "auto" }))); // Legal Entity Identifier (LEI) to multiple RICs Console.WriteLine("LEI to multiple RICs..."); Display(endpoint.SendRequest(new Endpoint.Request.Params().WithMethod(Endpoint.Request.Method.POST) .WithBodyParameters(new JObject() { ["from"] = new JArray( new JObject() { ["identifierTypes"] = new JArray("LEI"), ["values"] = new JArray("INR2EJN1ERAN0W5ZP974") }), ["to"] = new JArray( new JObject() { ["identifierTypes"] = new JArray("RIC") }), ["type"] = "auto" }))); } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }
static void Main(string[] args) { /* Todos esse caso os dicionario Location vai criar apenas um objeto na memória, pois todos eles tem o mesmo endereço(Rua e cidade) * Apenas Paulo vai ser um novo registro*/ var factory = new DeliveryFactory(); factory.CreateDelivery(factory, "Luiz", "20A", "Av Brasil", "SP"); factory.CreateDelivery(factory, "Helena", "300", "Av Brasil", "SP"); factory.CreateDelivery(factory, "Joana", "512", "Av Brasil", "SP"); factory.CreateDelivery(factory, "Paulo", "125", "Domingos Javaroni", "SP"); var locations = factory.GetLocations(); Console.WriteLine($"{locations.Count}"); }
static void Main(string[] _) { try { // Choose a WebSocket Implementation Console.WriteLine("\nChoose a WebSocket Implementation:"); Console.WriteLine("\t1 - ClientWebSocket (Microsoft implementation)"); Console.WriteLine("\t2 - WebSocket4Net (originated from SuperWebSocket)"); Console.WriteLine("\t3 - WebSocketSharp"); Console.Write("\t==> "); string input = Console.ReadLine(); int ver; if (int.TryParse(input, out ver)) { switch (ver) { case 1: // The default in the library break; case 2: // How to specify a version available within the library DeliveryFactory.RegisterWebSocket(DeliveryFactory.WebSocketImpl.WebSocket4Net); break; case 3: // Override with your own custom implementation DeliveryFactory.RegisterWebSocketImpl = () => new WebSocketSharpImpl(); break; default: return; } using (ISession session = Configuration.Sessions.GetSession(false)) { if (session.Open() == Session.State.Opened) { TestStreaming(); } } } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }
public void should_throw_when_arguments_are_null() { // arrange var factory = new DeliveryFactory(); var scheduler = UseTestSchedulers().CurrentThread; var eventObserver = EventBus.Current.Observable <NewDeliveryRegisteredEvent>() .CreateTestObserver(scheduler); // act / assert Assert.Throws <ArgumentException>(() => factory.Create(null, null, null)); eventObserver.AssertNoErrors(); eventObserver.AssertValuesCount(0); }
public async Task OpenItemAsync(string item, Refinitiv.DataPlatform.Core.ISession RdpSession, Type modelType) { var fieldnameList = modelType.GetProperties() .SelectMany(p => p.GetCustomAttributes(typeof(JsonPropertyAttribute)) .Cast <JsonPropertyAttribute>()) .Select(prop => prop.PropertyName) .ToArray(); if (RdpSession != null) { await Task.Run(() => { ItemStream.Params itemParams; if (!fieldnameList.Any()) { // First, prepare our item stream details including the fields of interest and where to capture events... itemParams = new ItemStream.Params().Session(RdpSession) .OnRefresh(processOnRefresh) .OnUpdate(processOnUpdate) .OnStatus(processOnStatus); } else { // First, prepare our item stream details including the fields of interest and where to capture events... itemParams = new ItemStream.Params().Session(RdpSession) .WithFields(fieldnameList) .OnRefresh(processOnRefresh) .OnUpdate(processOnUpdate) .OnStatus(processOnStatus); } var stream = DeliveryFactory.CreateStream(itemParams.Name(item)); if (_streamCache.TryAdd(item, stream)) { stream.OpenAsync(); } else { var msg = $"Unable to open new stream for item {item}."; RaiseOnError(msg); } }); } else { throw new ArgumentNullException("RDP Session is null."); } }
static void Main(string[] args) { try { // Create the platform session. using (ISession session = Configuration.Sessions.GetSession()) { // Open the session if (session.Open() == Session.State.Opened) { // ******************************************************************************************************************************* // Requesting for multiple instruments. // The ItemStream interface supports the ability to request/stream a single item. The following code segment utilizes the power // of the .NET asynchronous libraries to send a collection of requests and monitor the whole collection for completion. // ******************************************************************************************************************************* List <Task <Stream.State> > tasks = new List <Task <Stream.State> >(); // First, prepare our item stream details including the fields of interest and where to capture events... var itemParams = new ItemStream.Params().Session(session).WithFields("DSPLY_NAME", "BID", "ASK") .OnRefresh((s, msg) => DumpMsg(msg)) .OnUpdate((s, msg) => DumpMsg(msg)) .OnStatus((s, msg) => Console.WriteLine(msg)); // Next, iterate through the collection of items, applying each to our parameters specification. Send each request asynchronously... foreach (var item in new[] { "EUR=", "GBP=", "CAD=" }) { // Create our stream IStream stream = DeliveryFactory.CreateStream(itemParams.Name(item)); // Open the stream asynchronously and keep track of the task tasks.Add(stream.OpenAsync()); } // Monitor the collection for completion. We are intentionally blocking here waiting for the whole collection to complete. Task.WhenAll(tasks).GetAwaiter().GetResult(); Console.WriteLine("\nInitial response for all instruments complete. Updates will follow based on changes in the market..."); // Wait for updates... Console.ReadKey(); } } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }
// ** CHANGES BELOW ARE NOT REQUIRED UNLESS YOUR ACCESS REQUIRES ADDITIONAL PARAMETERS ** // GetSession // Based on the above Session Type, retrieve the Session used to define how you want to access the platform. // public static ISession GetSession(bool overrideWebSocketIfNecessary = true) { if (overrideWebSocketIfNecessary) { // Note: // The default RDP Library for .NET WebSocket implementation is based on Microsoft's WebSocketClient. This implementation // is only available on Windows 8 and above or if an application targets .NET Core 2.1 or greater. Because all example // applications within this package are built using .NET Framework 4.5.2, if the Windows OS is anything less than Windows 8, // the WebSocket4Net implementation will be used. var ver = Environment.OSVersion.Version; if (ver.Major <= 6 && ver.Minor <= 1) { DeliveryFactory.RegisterWebSocket(DeliveryFactory.WebSocketImpl.WebSocket4Net); } } switch (SessionType) { case SessionTypeEnum.RDP: return(CoreFactory.CreateSession(new PlatformSession.Params() .WithOAuthGrantType(new GrantPassword().UserName(Credentials.RDPUser) .Password(Credentials.RDPPassword)) .AppKey(Credentials.AppKey) .WithTakeSignonControl(true) .OnState((s, state, msg) => Console.WriteLine($"{DateTime.Now}:{msg}. (State: {state})")) .OnEvent((s, eventCode, msg) => Console.WriteLine($"{DateTime.Now}:{msg}. (Event: {eventCode})")))); case SessionTypeEnum.DEPLOYED: return(CoreFactory.CreateSession(new PlatformSession.Params().WithHost(Credentials.TREPHost) .OnState((s, state, msg) => Console.WriteLine($"{DateTime.Now}: State: {state}. {msg}")) .OnEvent((s, eventCode, msg) => Console.WriteLine($"{DateTime.Now}: Event: {eventCode}. {msg}")))); case SessionTypeEnum.DESKTOP: return(CoreFactory.CreateSession(new DesktopSession.Params().AppKey(Credentials.AppKey) .OnState((s, state, msg) => Console.WriteLine($"{DateTime.Now}:{msg}. (State: {state})")) .OnEvent((s, eventCode, msg) => Console.WriteLine($"{DateTime.Now}:{msg}. (Event: {eventCode})")))); case SessionTypeEnum.DEPLOYED_DEPRECATED: return(CoreFactory.CreateSession(new DeployedPlatformSession.Params().Host(Credentials.TREPHost) .OnState((s, state, msg) => Console.WriteLine($"{DateTime.Now}:{msg}. (State: {state})")) .OnEvent((s, eventCode, msg) => Console.WriteLine($"{DateTime.Now}:{msg}. (Event: {eventCode})")))); default: throw new IndexOutOfRangeException($"Unknown Session Type: {SessionType}"); } }
private static DeliveryService CreateDeliveryService(DeliveryStatusEnum deliveryStatus) { var factory = new DeliveryFactory(); Delivery delivery = factory.CreateDelivery(); delivery.Status = deliveryStatus; bool deliveriesAreExpired = deliveryStatus != DeliveryStatusEnum.Available; var repository = new Mock <IRepository>(); repository.Setup(r => r.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(delivery); var policy = new Mock <IExpirationPolicy>(); policy.Setup(m => m.IsExpired(It.IsAny <Delivery>(), It.IsAny <DateTime>())).Returns(deliveriesAreExpired); return(new DeliveryService(repository.Object, policy.Object)); }
private static void TestStreaming() { string item1 = "EUR="; string item2 = "CAD="; try { IStream stream1 = DeliveryFactory.CreateStream( new ItemStream.Params().Session(Session.DefaultSession) .Name(item1) .OnRefresh((s, msg) => Console.WriteLine($"{DateTime.Now}:{msg}")) .OnUpdate((s, msg) => DumpMsg(msg)) .OnStatus((s, msg) => Console.WriteLine($"{DateTime.Now} => Status1: {msg}")) .OnError((s, msg) => Console.WriteLine($"Stream1 error: {DateTime.Now}:{msg}"))); if (stream1.Open() != Stream.State.Opened) { Console.WriteLine($"Stream did not open: {stream1.OpenState}"); } IStream stream2 = DeliveryFactory.CreateStream( new ItemStream.Params().Session(Session.DefaultSession) .Name(item2) .OnRefresh((s, msg) => Console.WriteLine($"{DateTime.Now}:{msg}")) .OnUpdate((s, msg) => DumpMsg(msg)) .OnStatus((s, msg) => Console.WriteLine($"{DateTime.Now} => Status2: {msg}")) .OnError((s, msg) => Console.WriteLine($"Stream2 error: {DateTime.Now}:{msg}"))); stream2.Open(); Console.ReadKey(); stream1.Close(); Console.WriteLine($"Stream {item1} has been closed. Hit any key to close the {item2} stream..."); Console.ReadKey(); stream2.Close(); } catch (PlatformNotSupportedException e) { Console.WriteLine($"\n******{e.Message} Choose an alternative WebSocket implementation.\n"); } catch (Exception e) { Console.WriteLine(e); } }
static void Main(string[] args) { // Create a session to connect into the platform. ISession session = GlobalSettings.Sessions.GetSession(); // Open the session session.Open(); // Define a stream to retrieve level 1 content... using (IStream stream = DeliveryFactory.CreateStream( new ItemStream.Params().Session(session) .Name("EUR=") .OnRefresh((s, msg) => Console.WriteLine(msg)) .OnUpdate((s, msg) => Console.WriteLine(msg)) .OnStatus((s, msg) => Console.WriteLine(msg)))) { // Open the stream... stream.Open(); // Wait for data to come in then hit any key to close the stream... Console.ReadKey(); } }
public async Task OpenItemAsync(string item, Refinitiv.DataPlatform.Core.ISession RdpSession, IEnumerable <string> fieldNameList = null, bool streamRequest = false) { if (RdpSession != null) { await Task.Run(() => { var itemParams = new ItemStream.Params().Session(RdpSession) .WithStreaming(streamRequest) .OnRefresh(processOnRefresh) .OnUpdate(processOnUpdate) .OnStatus(processOnStatus); var nameList = (fieldNameList ?? Array.Empty <string>()).ToList(); if (nameList.Any()) { // First, prepare our item stream details including the fields of interest and where to capture events... itemParams.WithFields(nameList); } var stream = DeliveryFactory.CreateStream(itemParams.Name(item)); if (_streamCache.TryAdd(item, stream)) { stream.OpenAsync(); } else { var msg = $"Unable to open new stream for item {item}."; RaiseOnError(msg); } }).ConfigureAwait(false); } else { throw new ArgumentNullException("RDP Session is null."); } }
static void Main(string[] args) { try { // Create the platform session. ISession session = GlobalSettings.Sessions.GetSession(); // Open the session session.Open(); // ******************************************************************************************** // Headline Alert Endpoint URL. // ******************************************************************************************** const string alertHeadlinesEndpoint = "https://api.refinitiv.com/alerts/v1/news-headlines-subscriptions"; // Determine if we are using an existing queue or creating one. The QueueManager will assist us here. IQueueManager manager = DeliveryFactory.CreateQueueManager(new QueueManager.Params().Session(session) .Endpoint(alertHeadlinesEndpoint) .OnError((qm, err) => Console.WriteLine(err))); // First, check to see if we have any news headline queues active in the cloud, if not, create one. List <IQueue> queues = manager.GetAllQueues(); // Determine if we retrieved anything...create one if not. IQueue queue = (queues?.Count > 0 ? queues[0] : manager.CreateQueue()); // Ensure our queue is created if (queue != null) { Console.WriteLine($"{Environment.NewLine}{(queues.Count > 0 ? "Using existing" : "Created a new")} queue..."); // Start polling for news headline messages from the queue // A QueueSubscriber provides the mechanisms to poll the queue and capture each headline alert via lambda expressions IQueueSubscriber subscriber = DeliveryFactory.CreateQueueSubscriber( new AWSQueueSubscriber.Params().Queue(queue) .WithMessagePollingInterval(1) .OnResponse((s, response) => { if (response.IsSuccess) { DisplayHeadline(response.Data.Raw); } else { Console.WriteLine(response.Status); } })); // Open the subscriber to begin polling for messages subscriber.StartPolling(); Console.WriteLine("Polling for messages from the queue...hit any key to stop polling"); // Hit any key to stop... Console.ReadKey(); // Close the subscription - stops polling for messages subscriber.StopPolling(); Console.WriteLine($"{Environment.NewLine}Stopped polling for messages from the queue."); // Prompt the user to delete the queue Console.Write("Delete the queue (Y/N) [N]: "); var delete = Console.ReadLine(); if (delete?.ToUpper() == "Y") { if (manager.DeleteQueue(queue)) { Console.WriteLine("Successfully deleted queue."); } else { Console.WriteLine($"Issues deleting queue {manager.Error}"); } } } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n***************"); } }
public Repository_IntegrationTests(Type repositoryType) { RepositoryType = repositoryType; Repository = Root.Resolve(RepositoryType) as IRepository; Factory = Root.Resolve <DeliveryFactory>(); }
public SpecificationIsNull() { _deliveryFactory = new DeliveryFactory(); }
public HomeController(DeliveryFactory deliveryFactory) { _deliveryFactory = deliveryFactory; }
public void Setup() { factory = new DeliveryFactory(TestUrl, TestApiKey, null); }
static void Main(string[] _) { const string researchEndpoint = "https://api.refinitiv.com/message-services/v1/research/subscriptions"; try { using (ISession session = Configuration.Sessions.GetSession()) { if (session.Open() == Session.State.Opened) { // Create a QueueManager to actively manage our queues IQueueManager manager = DeliveryFactory.CreateQueueManager(new QueueManager.Params().Session(session) .Endpoint(researchEndpoint) .OnError((qm, err) => Console.WriteLine(err))); // First, check to see if we have any news headline queues active in the cloud... List <IQueue> queues = manager.GetAllQueues(); // Check the error property to determine the result of the last request if (manager.Error == null) { // Prepare Research criteria if we plan to create a new AWS queue - we must supply a research ID. JObject criteria = new JObject() { ["transport"] = new JObject() { ["transportType"] = "AWS-SQS" }, ["payloadVersion"] = "2.0", ["userID"] = Configuration.Credentials.ResearchID }; // If no existing queue exists, create one. IQueue queue = (queues.Count > 0 ? queues[0] : manager.CreateQueue(criteria)); if (queue != null) { Console.WriteLine($"{Environment.NewLine}{(queues.Count > 0 ? "Using existing" : "Created a new")} queue..."); // Subscribe to the queue. // Note: The subscriber interface has 2 mechanisms to retrieve data from the queue. The first mechanism is to selectively // poll the queue for new messages. The second mechanism is to define a callback/lambda expression and notify the // the subscriber to poll for messages as they come in - this mechansim provides a near realtime result. // // The following example demonstrates the first mechanism. IQueueSubscriber subscriber = DeliveryFactory.CreateQueueSubscriber(new AWSQueueSubscriber.Params().Queue(queue)); Console.WriteLine("Attempt to retrieve research messages. Hit any key to interrupt fetching..."); // Instead of defining a lambda callback, we manually poll the queue until we hit any key on the keyboard. // Each poll will timeout after 5 seconds. bool noMsgAvailable = false; while (!Console.KeyAvailable) { IQueueResponse result = subscriber.GetNextMessage(5); if (result.IsSuccess) { if (result.IsMessageAvailable) { DisplayResearch(result); } else { Console.Write(noMsgAvailable ? "." : "No Message available from GetNextMessage"); } noMsgAvailable = !result.IsMessageAvailable; } else { Console.WriteLine(result.Status); } } Console.ReadKey(); // Prompt the user to delete the queue Console.Write("\nDelete the queue (Y/N) [N]: "); var delete = Console.ReadLine(); if (delete?.ToUpper() == "Y") { if (manager.DeleteQueue(queue)) { Console.WriteLine("Successfully deleted queue."); } else { Console.WriteLine($"Issues deleting queue {manager.Error}"); } } } } } } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }
public CreateJob(IDeliveryPolicy policy, DeliveryService service, DeliveryFactory factory) { Policy = policy; Service = service; Factory = factory; }
public OptionChain(ISession session) { endpoint = DeliveryFactory.CreateEndpoint(new Endpoint.Params().Session(session) .Url(ChainEndpointUrl)); }
static void Main(string[] _) { const string newsHeadlinesEndpoint = "https://api.refinitiv.com/message-services/v1/news-headlines/subscriptions"; try { // Create the platform session. using (ISession session = Configuration.Sessions.GetSession()) { // Open the session session.Open(); // Create a QueueManager to actively manage our queues IQueueManager manager = DeliveryFactory.CreateQueueManager(new QueueManager.Params().Session(session) .Endpoint(newsHeadlinesEndpoint) .OnError((qm, err) => Console.WriteLine(err))); // First, check to see if we have any news headline queues active in the cloud... List <IQueue> queues = manager.GetAllQueues(); // Check the error property to determine the result of the last request if (manager.Error == null) { // Determine if we retrieved an active headline queue...create one if not. IQueue queue; if (queues.Count > 0) { queue = queues[0]; } else { queue = CreateQueue(manager, "AA"); // Create a Queue with the new query expression ("AA" - alerts only) } // Ensure our queue is created if (queue != null) { Console.WriteLine($"{Environment.NewLine}{(queues.Count > 0 ? "Using existing" : "Created a new")} queue. Waiting for headlines..."); // Subscribe to the queue. // Note: The subscriber interface has 2 mechanisms to retrieve data from the queue. The first mechanism is to selectively // poll the queue for new messages. The second mechanism is to define a callback/lambda expression and notify the // the subscriber to poll for messages as they come in - this mechansim provides a near realtime result. // // The following example demonstrates the first mechanism. IQueueSubscriber subscriber = DeliveryFactory.CreateQueueSubscriber(new AWSQueueSubscriber.Params().Queue(queue)); // Poll the queue until we hit any key on the keyboard. // Each poll will timeout after 5 seconds. while (!Console.KeyAvailable) { IQueueResponse result = subscriber.GetNextMessage(5); if (result.IsSuccess) { DisplayHeadline(result); } else { Console.WriteLine(result.Status); } } Console.ReadKey(); // Prompt the user to delete the queue Console.Write("\nDelete the queue (Y/N) [N]: "); var delete = Console.ReadLine(); if (delete?.ToUpper() == "Y") { if (manager.DeleteQueue(queue)) { Console.WriteLine("Successfully deleted queue."); } else { Console.WriteLine($"Issues deleting queue {manager.Error}"); } } } } } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }
static void Main(string[] _) { const string newsStoriesEndpoint = "https://api.refinitiv.com/message-services/v1/news-stories/subscriptions"; try { using (ISession session = Configuration.Sessions.GetSession()) { // Open the session session.Open(); // Create a QueueManager to actively manage our queues IQueueManager manager = DeliveryFactory.CreateQueueManager(new QueueManager.Params().Session(session) .Endpoint(newsStoriesEndpoint) .OnError((qm, err) => Console.WriteLine(err))); // First, check to see if we have any news headline queues active in the cloud... List <IQueue> queues = manager.GetAllQueues(); // Check the error property to determine the result of the last request if (manager.Error == null) { // If no existing queue exists, create one. IQueue queue = (queues.Count > 0 ? queues[0] : manager.CreateQueue()); // Ensure our queue is created if (queue != null) { Console.WriteLine($"{Environment.NewLine}{(queues.Count > 0 ? "Using existing" : "Created a new")} queue. Waiting for stories..."); // Subscribe to the queue. // Note: The subscriber interface has 2 mechanisms to retrieve data from the queue. The first mechanism is to selectively // poll the queue for new messages. The second mechanism is to define a callback/lambda expression and notify the // the subscriber to poll for messages as they come in - this mechansim provides a near realtime result. // // The following example demonstrates the second mechanism. IQueueSubscriber subscriber = DeliveryFactory.CreateQueueSubscriber( new AWSQueueSubscriber.Params().Queue(queue) .OnResponse((s, response) => { if (response.IsSuccess) { DisplayStory(response); } else { Console.WriteLine(response.Status); } })); // Open the subscriber to begin polling for messages. Use Async() as this method is a long running task. subscriber.StartPollingAsync(); Console.ReadKey(); // Close the subscription - stops polling for messages subscriber.StopPolling(); Console.WriteLine("Stopped polling for messages from the queue."); // Prompt the user to delete the queue Console.Write("Delete the queue (Y/N) [N]: "); var delete = Console.ReadLine(); if (delete?.ToUpper() == "Y") { if (manager.DeleteQueue(queue)) { Console.WriteLine("Successfully deleted queue."); } else { Console.WriteLine($"Issues deleting queue {manager.Error}"); } } } } } } catch (Exception e) { Console.WriteLine($"\n**************\nFailed to execute: {e.Message}\n{e.InnerException}\n***************"); } }
public RegisterNewDeliveryCommandHnadler(IRepository <Delivery> deliveries, DeliveryFactory factory) { _deliveries = deliveries; _factory = factory; }