Пример #1
0
 private bool IsDeviceExisting(InvokeAction invokeAction)
 {
     var deviceId = invokeAction.DeviceId;
     if (ControlConfiguration.ContainsKey(deviceId))
         return true;
     Context.GetLogger().Warning($"Could not find device with id {deviceId}");
     return false;
 }
Пример #2
0
 public GroupingSearcher(
     InvokeAction[] invokeActions, ControlAction controlAction,
     QueueControlConfiguration controlConfiguration, Action<string> logWarning)
 {
     InvokeActions = invokeActions;
     ControlAction = controlAction;
     ControlConfiguration = controlConfiguration;
     LogWarning = logWarning;
 }
Пример #3
0
 private void QueueItems(InvokeAction[] invokeActions)
 {
     var itemsToProcess = new List<ActionToBeQueued>();
     foreach (var actionsOfTheSameType in invokeActions.Where(IsDeviceExisting).GroupBy(a => a.Action))
     {
         InvokeAction[] actions = actionsOfTheSameType.ToArray();
         var searcher = new GroupingSearcher(actions, actionsOfTheSameType.Key, ControlConfiguration, LogWarning);
         itemsToProcess.AddRange(searcher.FindActionsToBeQueued());
     }
     LogInvokeActionResult(invokeActions, itemsToProcess);
     foreach (ActionToBeQueued item in itemsToProcess)
     {
         var control = item.Control;
         QueueItem queueItem = new QueueItem(control, item.Action);
         IActorRef invoker = InvokerStore.GetOrCreate(control.PluginId, control.PluginControlId);
         invoker.Tell(queueItem);
     }
 }
Пример #4
0
 private static void LogInvokeActionResult(InvokeAction[] invokeActions, List<ActionToBeQueued> itemsToProcess)
 {
     var loggedInvokeActions = invokeActions.Select(a => new {a.Action.Name, a.DeviceId});
     var loggedItemsToProcess = itemsToProcess.Select(i => new
     {
         i.Action.Name,
         i.Control.PluginId,
         i.Control.ControlId
     });
     Context.GetSerilogger().SerlogInfo("OnInvokeActions", new Dictionary<string, object>
     {
         {"InvokeActionCount", invokeActions.Length},
         {"ActionsToProcessCount", itemsToProcess.Count},
         {"InvolvedPluginCount", itemsToProcess.Select(i => i.Control.PluginId).Distinct().Count()},
         {"InvokeActions", loggedInvokeActions.ToArray()},
         {"ActionsToProcess", loggedItemsToProcess.ToArray()}
     });
 }
Пример #5
0
 public static void TellActionQueue(this IActorContext context, InvokeAction[] message) => context.GetTaskQueue().Tell(message);