internal void UpdateSubscriptions(Models.Settings.Device.Subscription theUpdatedSubscriptions) { bool SubChangesMade = false; BBSubscription Subscription = null; bool CreateNew = string.Equals(theUpdatedSubscriptions.SubscriptionGuid, "new", System.StringComparison.OrdinalIgnoreCase); BBOutput OutputSearch = null; OutputSearch = Outputs.FirstOrDefault(o => o.Name == theUpdatedSubscriptions.OutputId); if (OutputSearch != null && !CreateNew) { Subscription = OutputSearch.Subscriptions.FirstOrDefault(s => s.Guid == theUpdatedSubscriptions.SubscriptionGuid); } if (CreateNew && OutputSearch != null) { OutputSearch.Add(theUpdatedSubscriptions.SubscriptionId, new BBSubscriptionProperties { HighSubject = theUpdatedSubscriptions.HighKey, HighValue = theUpdatedSubscriptions.HighValue, LowSubject = theUpdatedSubscriptions.LowKey, LowValue = theUpdatedSubscriptions.LowValue }); SubChangesMade = true; } else { if (Subscription != null) { if (Subscription.Id != theUpdatedSubscriptions.SubscriptionId) { SubChangesMade = true; Subscription.Id = theUpdatedSubscriptions.SubscriptionId; } Subscription.Update(new BBSubscriptionProperties { HighSubject = theUpdatedSubscriptions.HighKey, HighValue = theUpdatedSubscriptions.HighValue, LowSubject = theUpdatedSubscriptions.LowKey, LowValue = theUpdatedSubscriptions.LowValue }); } } if (SubChangesMade) { ConstructSubscriptions(); } }
public void Add(string theEventId, string theGuid, BBSubscriptionProperties theProperties) { theProperties.IOLine = m_Line; var NewSubscription = new BBSubscription { EventConsumer = (m_Line != null) ? new BBEventConsumer(theProperties) : null, Guid = theGuid, Id = theEventId }; NewSubscription.Update(theProperties); Subscriptions.Add(NewSubscription); }
public BBOutput(string theName) { Name = theName; // TEMP UIToggleEvent.Description = "UI Toggle for IO " + Name; var Defaults = CreateDefaultSubscriptionProperties(); var NewSubscription = new BBSubscription { Guid = System.Guid.NewGuid().ToString(), Id = UIToggleEvent.Id }; NewSubscription.Update(Defaults); NewSubscription.EventConsumer = new BBEventConsumer(Defaults); Subscriptions.Add(NewSubscription); }