/// <summary> /// Updates event subscriptions list by user checked check boxes. /// </summary> /// <remarks>The configuration controls include check boxes used to get the selected DocuSign event subscriptions</remarks> private void UpdateSelectedEvents() { ActivityUi activityUi = Storage.CrateContentsOfType <StandardConfigurationControlsCM>().First(); //get selected check boxes (i.e. user wanted to subscribe these DocuSign events to monitor for) var curSelectedDocuSignEvents = new List <string> { activityUi.EnvelopeSentOption.Selected?activityUi.EnvelopeSentOption.Name : string.Empty, activityUi.EnvelopeRecievedOption.Selected ? activityUi.EnvelopeRecievedOption.Name : string.Empty, activityUi.EnvelopeSignedOption.Selected ? activityUi.EnvelopeSignedOption.Name : string.Empty }; if (curSelectedDocuSignEvents.Contains(RecipientSignedEventName)) { if (!curSelectedDocuSignEvents.Contains(RecipientCompletedEventName)) { curSelectedDocuSignEvents.Add(RecipientCompletedEventName); } } else { curSelectedDocuSignEvents.Remove(RecipientCompletedEventName); } //create standard event subscription crate with user selected DocuSign events EventSubscriptions.Subscriptions.Clear(); EventSubscriptions.Manufacturer = "DocuSign"; EventSubscriptions.AddRange(curSelectedDocuSignEvents.Where(x => !string.IsNullOrEmpty(x))); }
public async Task EventSubsriptionsShouldThrowErrorForEventThatDoesNotHaveAStore() { //Arrange var e = new EmployeeAddedEvent( new Employee(new Company(1, "", new List <EldProvider>() { new JjKellerEldProvider("sdlkfj") }), 1, "", "", ""), DateTime.Now); var store = new TestEventHanlderStore(); var service = new EventSubscriptions(new List <IntegrationStore>() { store }); //Act try { await service.GetSubscriptions <EmployeeAddedEvent>(e); } catch (Exception exception) { //Assert Assert.AreEqual("IntegrationStore for integration type JjKeller has not implemented.", exception?.InnerException?.Message); throw; } }
public override Task Initialize() { //build a controls crate to render the pane var textBlock = UiBuilder.GenerateTextBlock("Monitor Fr8 Events", "This Activity doesn't require any configuration.", "well well-lg"); AddControls(textBlock); // var planActivatedCrate = CrateManager.CreateManifestDescriptionCrate("Available Run-Time Objects", "RouteActivated", "13", AvailabilityType.RunTime); // var planDeactivatedCrate = CrateManager.CreateManifestDescriptionCrate("Available Run-Time Objects", "RouteDeactivated", "13", AvailabilityType.RunTime); // var containerLaunched = CrateManager.CreateManifestDescriptionCrate("Available Run-Time Objects", "ContainerLaunched", "13", AvailabilityType.RunTime); // var containerExecutionComplete = CrateManager.CreateManifestDescriptionCrate("Available Run-Time Objects", "ContainerExecutionComplete", "13", AvailabilityType.RunTime); // var actionExecuted = CrateManager.CreateManifestDescriptionCrate("Available Run-Time Objects", "ActionExecuted", "13", AvailabilityType.RunTime); // Storage.Add(planActivatedCrate); // Storage.Add(planDeactivatedCrate); //Storage.Add(containerLaunched); // Storage.Add(containerExecutionComplete); // Storage.Add(actionExecuted); EventSubscriptions.Manufacturer = "Fr8Core"; EventSubscriptions.AddRange("RouteActivated", "RouteDeactivated", "ContainerLaunched", "ContainerExecutionComplete", "ActionExecuted"); return(Task.FromResult(0)); }
public async Task EventSubsriptionsShouldThrowErrorForTwoStoreOfTheSameIntegrationProvider() { //Arrange var e = new EmployeeAddedEvent( new Employee(new Company(1, "", new List <EldProvider>() { new KeepTruckinEldProvider("sdlkfj") }), 1, "", "", ""), DateTime.Now); var store = new TestEventHanlderStore(); var store2 = new TestEventHanlderDuplicateStore(); var service = new EventSubscriptions(new List <IntegrationStore>() { store, store2 }); //Act try { await service.GetSubscriptions <EmployeeAddedEvent>(e); } catch (Exception exception) { //Assert Assert.AreEqual("There are more than one IntegrationStores for integration KeepTruckin", exception?.InnerException?.Message); throw; } }
static void Main(string[] args) { Core.StartApplication(); OrderRepository repo = new OrderRepository(); EventSubscriptions subscribeService = new EventSubscriptions(); EventPublisher events = new EventPublisher(subscribeService); Basket basket = new Basket(repo, events); List <Product> products = new List <Product>(); products.Add(new Product() { price = 2, prodId = 1, quantity = 3 }); products.Add(new Product() { price = 23, prodId = 2, quantity = 1 }); products.Add(new Product() { price = 4, prodId = 4, quantity = 4 }); basket.Submit(products); basket.Submit(products); Console.ReadLine(); }
public async override Task Initialize() { EventSubscriptions.Manufacturer = "Google"; EventSubscriptions.Add("GmailInbox"); CrateSignaller.MarkAvailableAtRuntime <StandardEmailMessageCM>(RuntimeCrateLabel); }
public override async Task Initialize() { var oAuthToken = AuthorizationToken.Token; ActivityUI.ChannelList.ListItems = (await _slackIntegration.GetChannelList(oAuthToken, false)) .OrderBy(x => x.Key) .Select(x => new ListItem { Key = $"#{x.Key}", Value = x.Value }) .ToList(); EventSubscriptions.Manufacturer = "Slack"; EventSubscriptions.Add("Slack Outgoing Message"); CrateSignaller.MarkAvailableAtRuntime <StandardPayloadDataCM>(ResultPayloadCrateLabel) .AddField("token") .AddField("team_id") .AddField("team_domain") .AddField("service_id") .AddField("timestamp") .AddField("channel_id") .AddField("channel_name") .AddField("user_id") .AddField("user_name") .AddField("text"); }
protected override void DoRunLoopSubscriptions(string resp) { WebSocketSubscriptionEvent eventSubscr = JsonConvert.DeserializeObject <WebSocketSubscriptionEvent>(resp); if (ResponseRequestSubscriptions.ContainsKey(eventSubscr.GetSubscriptionEvent())) { if (eventSubscr.table == _ORDER && EventSubscriptions.ContainsKey(eventSubscr.GetSubscriptionEvent())) { WebSocketExecutionReportEvent execReportEvent = JsonConvert.DeserializeObject <WebSocketExecutionReportEvent>(resp); WebSocketSubscriptionEvent subscrEvent = EventSubscriptions[eventSubscr.GetSubscriptionEvent()]; subscrEvent.RunEvent(execReportEvent); } else if (eventSubscr.table == _EXECUTIONS && EventSubscriptions.ContainsKey(eventSubscr.GetSubscriptionEvent())) { WebSocketExecutionReportEvent execReportEvent = JsonConvert.DeserializeObject <WebSocketExecutionReportEvent>(resp); WebSocketSubscriptionEvent subscrEvent = EventSubscriptions[eventSubscr.GetSubscriptionEvent()]; subscrEvent.RunEvent(execReportEvent); } else { //Log what we are receiving here because we are getting events that we didn't expect } } }
public static void Run() { //register interface container IoC.Container.RegisterType <ISubscriptionService, EventSubscriptions>(); IoC.Container.RegisterType <IEventPublisher, EventPublisher>(); IoC.Container.RegisterType <IOrderService, OrderService>(); //event global add EventSubscriptions.Add <OrderEmailSend>(); EventSubscriptions.Add <OrderNotifyWarehouse>(); EventSubscriptions.Add <OrderSendSmsOwner>(); }
public static void StartApplication() { try { Container.RegisterService(typeof(ILogger), typeof(ConsoleLogger)); EventSubscriptions.Register(); } catch (Exception ex) { Logger.Write(ex.StackTrace); StopApplication(); } }
public override Task FollowUp() { if (EventSubscriptions.Subscriptions != null) { EventSubscriptions.Subscriptions.Clear(); } EventSubscriptions.Manufacturer = "Atlassian"; EventSubscriptions.Add(ActivityUI.ProjectSelector.selectedKey); return(Task.FromResult(0)); }
public override Task Initialize() { EventSubscriptions.Manufacturer = "Facebook"; EventSubscriptions.Add(FacebookFeed); CrateSignaller.MarkAvailableAtRuntime <StandardPayloadDataCM>(RuntimeCrateLabel) .AddField(FacebookFeedIdField) .AddField(FacebookFeedMessageField) .AddField(FacebookFeedStoryField) .AddField(FacebookFeedCreatedTimeField); return(Task.FromResult(0)); }
public override async Task Initialize() { EventSubscriptions.Manufacturer = "Instagram"; EventSubscriptions.Add(InstagramMedia); CrateSignaller.MarkAvailableAtRuntime <StandardPayloadDataCM>(RuntimeCrateLabel) .AddField(InstagramMediaId) .AddField(InstagramCaptionId) .AddField(InstagramCaptionText) .AddField(InstagramCaptionCreatedTimeField) .AddField(InstagramImageUrl) .AddField(InstagramImageUrlStandardResolution); }
public void SubscribeEvents(string topic, OnEvent pOnSubscriptionEvent) { WebSocketSubscriptionEvent msg = new WebSocketSubscriptionEvent() { topic = topic, }; msg.SetEvent(pOnSubscriptionEvent); if (EventSubscriptions == null) { throw new Exception(string.Format("Event Subscriptions Dictionary has not been initialized")); } EventSubscriptions.Add(topic, msg); }
// GET: Home public async Task <ActionResult> Index() { //add event subscriptions EventSubscriptions.Add <EmailOrderConfirmation>(); EventSubscriptions.Add <NotifyWarehouse>(); EventSubscriptions.Add <DeductOnHandInventory>(); //publish IEventPublisher eventPublisher = new EventPublisherLibrary.EventPublisher(new EventSubscriptions()); await eventPublisher.PublishAsync <OrderSubmittedEvent>(new OrderSubmittedEvent { OrderId = Guid.NewGuid().ToString() }); await eventPublisher.PublishAsync <OrderSubmittedEvent>(new OrderSubmittedEvent { OrderId = Guid.NewGuid().ToString() }); return(Content("OK")); }
private void PackEventSubscriptionsCrate() { var curSfChosenObject = ActivityUI.SalesforceObjectList.selectedKey; EventSubscriptions.Subscriptions?.Clear(); EventSubscriptions.Manufacturer = "Salesforce"; if (ActivityUI.Created.Selected) { EventSubscriptions.Add($"{curSfChosenObject}{CreatedEventname}"); } if (ActivityUI.Updated.Selected) { EventSubscriptions.Add($"{curSfChosenObject}{UpdatedEventname}"); } }
public override async Task Initialize() { var googleAuth = GetGoogleAuthToken(); var forms = await _googleDrive.GetGoogleForms(googleAuth); ActivityUI.FormsList.ListItems = forms .Select(x => new ListItem { Key = x.Value, Value = x.Key }) .ToList(); EventSubscriptions.Manufacturer = "Google"; EventSubscriptions.Add("Google Form Response"); CrateSignaller.MarkAvailableAtRuntime <StandardTableDataCM>(RunTimeCrateLabel); }
public override Task Initialize() { Storage.Clear(); /* * Discussed with Alexei and it is required to have empty Standard UI Control in the crate. * So we create a text block which informs the user that this particular aciton does not require any configuration. */ var textBlock = UiBuilder.GenerateTextBlock("Monitor All DocuSign events", "This Action doesn't require any configuration.", "well well-lg"); AddControl(textBlock); //create a Standard Event Subscription crate EventSubscriptions.Manufacturer = "DocuSign"; EventSubscriptions.AddRange(DocuSignEventNames.GetAllEventNames()); return(Task.FromResult(0)); }
static void Main(string[] args) { //add event subscriptions EventSubscriptions.Add <EmailOrderConfirmation>(); EventSubscriptions.Add <NotifyWarehouse>(); EventSubscriptions.Add <DeductOnHandInventory>(); //publish IEventPublisher eventPublisher = new EventPublisher(new EventSubscriptions()); eventPublisher.PublishAsync <OrderSubmittedEvent>(new OrderSubmittedEvent { OrderId = Guid.NewGuid().ToString() }); eventPublisher.PublishAsync <OrderSubmittedEvent>(new OrderSubmittedEvent { OrderId = Guid.NewGuid().ToString() }); //Console.ReadKey(); }
public override async Task Initialize() { EventSubscriptions.Manufacturer = "Google"; EventSubscriptions.Add("GoogleSpreadsheet"); var spreadsheets = await _googleSheet.GetSpreadsheets(GetGoogleAuthToken()); var spreadsheetListItems = spreadsheets .Select(x => new ListItem { Key = x.Value, Value = ExtractFileId(x.Key) }) .ToList(); ActivityUI.SpreadsheetList.ListItems = spreadsheetListItems; CrateSignaller .MarkAvailableAtRuntime <StandardTableDataCM>(RunTimeCrateLabel, true) .AddField(new FieldDTO(SpreadsheetIdLabel)) .AddField(new FieldDTO(SpreadsheetNameLabel)); }
protected override void DoRunLoopSubscriptions(string resp) { WebSocketSubscriptionEvent eventSubscr = JsonConvert.DeserializeObject <WebSocketSubscriptionEvent>(resp); if (ResponseRequestSubscriptions.ContainsKey(eventSubscr.GetSubscriptionEvent())) { if (eventSubscr.table == _ORDERBOOK_L2 && EventSubscriptions.ContainsKey(eventSubscr.GetSubscriptionEvent())) { WebSocketOrderBookL2Event orderBookL2Event = JsonConvert.DeserializeObject <WebSocketOrderBookL2Event>(resp); WebSocketSubscriptionEvent subscrEvent = EventSubscriptions[eventSubscr.GetSubscriptionEvent()]; subscrEvent.RunEvent(orderBookL2Event); } else if (eventSubscr.table == _TRADE && EventSubscriptions.ContainsKey(eventSubscr.GetSubscriptionEvent())) { WebSocketTradeEvent tradeEvent = JsonConvert.DeserializeObject <WebSocketTradeEvent>(resp); WebSocketSubscriptionEvent subscrEvent = EventSubscriptions[eventSubscr.GetSubscriptionEvent()]; subscrEvent.RunEvent(tradeEvent); } else if (eventSubscr.table == _QUOTE && EventSubscriptions.ContainsKey(eventSubscr.GetSubscriptionEvent())) { WebSocketQuoteEvent quoteEvent = JsonConvert.DeserializeObject <WebSocketQuoteEvent>(resp); WebSocketSubscriptionEvent subscrEvent = EventSubscriptions[eventSubscr.GetSubscriptionEvent()]; subscrEvent.RunEvent(quoteEvent); } else if (eventSubscr.table == _1_DAY_TRADE_BINS && EventSubscriptions.ContainsKey(eventSubscr.GetSubscriptionEvent())) { //TODO: I have to ask BitMex why aren't they retrieveing high and low for the 1 day bin //and they are for the 1 hour bin } else { //Log what we are receiving here because we are getting events that we didn't expect } } }
private void PackEventSubscriptionsCrate() { ActivityUi activityUi = ConfigurationControls; EventSubscriptions.Manufacturer = "DocuSign"; EventSubscriptions.Subscriptions?.Clear(); if (activityUi.EnvelopeSentOption.Selected) { EventSubscriptions.Add(EnvelopeSentEventname); } if (activityUi.EnvelopeRecievedOption.Selected) { EventSubscriptions.Add(EnvelopeRecievedEventName); } if (activityUi.EnvelopeSignedOption.Selected) { EventSubscriptions.Add(RecipientSignedEventName); EventSubscriptions.Add(RecipientCompletedEventName); } }
public async Task EventSubsriptionsShouldReturnListOfValidHandlers() { //Arrange var e = new EmployeeAddedEvent( new Employee(new Company(1, "", new List <EldProvider>() { new KeepTruckinEldProvider("sdlkfj") }), 1, "", "", ""), DateTime.Now); var store = new TestEventHanlderStore(); var service = new EventSubscriptions(new List <IntegrationStore>() { store }); //Act var subscriptions = await service.GetSubscriptions <EmployeeAddedEvent>(e); //Assert Assert.AreEqual(1, subscriptions.Count()); }
public async Task EventSubsriptionsShouldReturnEmptyListWhenEventProviderListDoesNotMatchProvidersReturnedFromSubscription() { //Arrange var e = new EmployeeAddedEvent( new Employee(new Company(1, "", new List <EldProvider>() { new JjKellerEldProvider("sdlkfj") }), 1, "", "", ""), DateTime.Now); var store = new TestEventHanlderStore(); var store2 = new TestJjKellerEventHanlderStore(); var service = new EventSubscriptions(new List <IntegrationStore>() { store, store2 }); //Act var subscriptions = await service.GetSubscriptions <EmployeeAddedEvent>(e); //Assert Assert.AreEqual(0, subscriptions.Count()); }
public void SubscribeToEvent <TEvent, TEventHandler>() where TEvent : IEvent where TEventHandler : IEventHandler <TEvent> { var type = typeof(TEvent); var handler = typeof(TEventHandler); if (!EventSubscriptionExists(type)) { EventSubscriptions.Add(type, new HashSet <Type>() { handler }); Subscribe(type.Name); return; } if (!EventSubscriptions[type].Contains(handler)) { EventSubscriptions[type].Add(handler); } Subscribe(type.Name); }
public async Task TerminateSubscription(string eventSubscriptionId) { await EventSubscriptions.DeleteOneAsync(x => x.Id == eventSubscriptionId); }
public async Task <IEnumerable <EventSubscription> > GetSubcriptions(string eventName, string eventKey) { return(EventSubscriptions.AsQueryable() .Where(x => x.EventName == eventName && x.EventKey == eventKey).ToList()); }
public async Task <string> CreateEventSubscription(EventSubscription subscription) { await EventSubscriptions.InsertOneAsync(subscription); return(subscription.Id); }
public override async Task FollowUp() { if (!string.IsNullOrEmpty(ActivityUI.ExistingGroupsList.Value)) { var previousGroup = SelectedGroup; if (string.IsNullOrEmpty(previousGroup) || !string.Equals(previousGroup, ActivityUI.ExistingGroupsList.Value)) { var stats = await _statXIntegration.GetStatsForGroup(StatXUtilities.GetStatXAuthToken(AuthorizationToken), ActivityUI.ExistingGroupsList.Value); if (stats.Any(x => string.IsNullOrEmpty(x.Title))) { StatXUtilities.AddAdvisoryMessage(Storage); } else { if (Storage.CratesOfType <AdvisoryMessagesCM>().FirstOrDefault() != null) { ActivityUI.ExistingGroupStats.ListItems = stats.Select(x => new ListItem { Key = string.IsNullOrEmpty(x.Title) ? x.Id : x.Title, Value = x.Id }).ToList(); } Storage.RemoveByLabel("Advisories"); } ActivityUI.ExistingGroupStats.ListItems = stats .Select(x => new ListItem { Key = string.IsNullOrEmpty(x.Title) ? x.Id : x.Title, Value = x.Id }).ToList(); var firstStat = stats.FirstOrDefault(); if (firstStat != null) { ActivityUI.ExistingGroupStats.SelectByValue(firstStat.Id); } CrateSignaller.ClearAvailableCrates(); CrateSignaller.MarkAvailableAtRuntime <StandardPayloadDataCM>(RunTimeCrateLabel) .AddFields(CreateStatValueFields(StatXUtilities.MapToStatItemCrateManifest(firstStat))); } SelectedGroup = ActivityUI.ExistingGroupsList.Value; ActivityUI.ExistingGroupsList.ListItems = (await _statXIntegration.GetGroups(StatXUtilities.GetStatXAuthToken(AuthorizationToken))) .Select(x => new ListItem { Key = x.Name, Value = x.Id }).ToList(); ActivityUI.ExistingGroupsList.Value = SelectedGroup; } else { ActivityUI.ExistingGroupStats.ListItems.Clear(); ActivityUI.ExistingGroupStats.selectedKey = string.Empty; ActivityUI.ExistingGroupStats.Value = string.Empty; SelectedGroup = string.Empty; } if (!string.IsNullOrEmpty(ActivityUI.ExistingGroupStats.Value)) { var previousStat = SelectedStat; var stats = await _statXIntegration.GetStatsForGroup(StatXUtilities.GetStatXAuthToken(AuthorizationToken), ActivityUI.ExistingGroupsList.Value); if (stats.Any(x => string.IsNullOrEmpty(x.Title))) { StatXUtilities.AddAdvisoryMessage(Storage); } else { if (Storage.CratesOfType <AdvisoryMessagesCM>().FirstOrDefault() != null) { ActivityUI.ExistingGroupStats.ListItems = stats.Select(x => new ListItem { Key = string.IsNullOrEmpty(x.Title) ? x.Id : x.Title, Value = x.Id }).ToList(); } Storage.RemoveByLabel("Advisories"); } if (string.IsNullOrEmpty(previousStat) || !string.Equals(previousStat, ActivityUI.ExistingGroupStats.Value)) { var currentStat = stats.FirstOrDefault(x => x.Id == ActivityUI.ExistingGroupStats.Value); if (currentStat != null) { CrateSignaller.ClearAvailableCrates(); CrateSignaller.MarkAvailableAtRuntime <StandardPayloadDataCM>(RunTimeCrateLabel).AddFields(CreateStatValueFields(StatXUtilities.MapToStatItemCrateManifest(currentStat))); } } SelectedStat = ActivityUI.ExistingGroupStats.Value; ActivityUI.ExistingGroupStats.ListItems = stats.Select(x => new ListItem { Key = string.IsNullOrEmpty(x.Title) ? x.Id : x.Title, Value = x.Id }).ToList(); ActivityUI.ExistingGroupStats.Value = SelectedStat; EventSubscriptions.Subscriptions?.Clear(); EventSubscriptions.Manufacturer = "StatX"; EventSubscriptions.Add("StatXValueChange_" + SelectedStat.Substring(0, 18)); } else { CrateSignaller.ClearAvailableCrates(); ActivityUI.ExistingGroupStats.ListItems.Clear(); ActivityUI.ExistingGroupStats.selectedKey = string.Empty; ActivityUI.ExistingGroupStats.Value = string.Empty; SelectedStat = string.Empty; } }
private bool EventSubscriptionExists(Type eventType) { return(EventSubscriptions != null && EventSubscriptions.ContainsKey(eventType)); }