예제 #1
0
        /// <summary>
        /// Executes the given action, stores the event in event history and notifies the listeners.
        /// </summary>
        private async Task ExecuteActionAsync(ResolvedAction resolvedAction, string beaconPid, BeaconEventType beaconEventType, string location)
        {
            try
            {
                Logger.Debug("SDKEngine: ExecuteActionAsync " + beaconPid + " BeaconEventType: " + beaconEventType + " type: " + resolvedAction?.BeaconAction.Type);
                bool checkOnlyOnce = _eventHistory.CheckSendOnlyOnceAsync(resolvedAction);
                bool shouldSupress = _eventHistory.ShouldSupressAsync(resolvedAction);

                Logger.Trace("SDKEngine: ExecuteActionAsync " + beaconPid + " checkOnlyOnce: " + checkOnlyOnce + " shouldSupress:" + shouldSupress);
                if (!shouldSupress && !checkOnlyOnce && resolvedAction.IsInsideTimeframes(DateTimeOffset.Now))
                {
                    Logger.Trace("SDKEngine: ExecuteActionAsync " + beaconPid + " action resolved");
                    await _eventHistory.SaveExecutedResolvedActionAsync(resolvedAction.BeaconAction, beaconPid, beaconEventType, location);

                    if (resolvedAction.BeaconAction.Type != BeaconActionType.Silent)
                    {
                        BeaconActionResolved?.Invoke(this, resolvedAction.BeaconAction);
                    }
                }
                else
                {
                    Logger.Trace("SDKEngine: ExecuteActionAsync " + beaconPid + " action not resolved");
                }
            }
            catch (Exception e)
            {
                Logger.Error("Error during ExecuteActionAsync", e);
            }
        }