コード例 #1
0
 public void NotifyBeaconEvent(Beacon beacon, BeaconEventType eventType)
 {
     BeaconEvent?.Invoke(this, new BeaconEventArgs()
     {
         Beacon = beacon, EventType = eventType
     });
 }
コード例 #2
0
 public async Task <bool> SaveBeaconEventState(string pid, BeaconEventType enter)
 {
     LastEventState[pid] = new BackgroundEvent()
     {
         BeaconId = pid, EventTime = DateTimeOffset.Now, LastEvent = enter
     };
     return(true);
 }
コード例 #3
0
        private void AddBeaconArgs(Beacon beacon, BeaconEventType eventType)
        {
            var args = new BeaconEventArgs();

            args.Beacon    = beacon;
            args.EventType = eventType;
            _beaconArgs.Add(args);
        }
コード例 #4
0
        public async Task <bool> SaveBeaconEventState(string pid, BeaconEventType type)
        {
            StorageFolder folder = await GetFolder(BackgroundSettingsFolder, true);

            StorageFile file = await folder.CreateFileAsync(pid, CreationCollisionOption.OpenIfExists);

            return(await RetryWriting(file, FileStorageHelper.BeaconEventStateToString(pid, type, DateTimeOffset.Now)));
        }
コード例 #5
0
 public static Request ToRequest(string uuid, ushort man, ushort beaconId, BeaconEventType type)
 {
     return(new Request(new BeaconEventArgs()
     {
         Beacon = new Beacon()
         {
             Id1 = uuid, Id2 = man, Id3 = beaconId
         }, EventType = type
     }, SdkData.NextId()));
 }
コード例 #6
0
        public void TestHistoryEventParsing(string query, string beaconId, string eventTime, BeaconEventType beaconEventType, bool send)
        {
            HistoryEvent e = FileStorageHelper.EventFromString(query);

            //fallback for unparsable data
            if (beaconId == null && eventTime == null)
            {
                Assert.IsNull(e);
                return;
            }

            Assert.AreEqual(beaconId, e.BeaconId);
            Assert.AreEqual(eventTime, e.EventTime);
            Assert.AreEqual((int) beaconEventType, e.Trigger);
        }
コード例 #7
0
ファイル: Storage.cs プロジェクト: WombatWorks/windows10-sdk
        /// <summary>
        /// 
        /// </summary>
        /// <param name="resolvedAction"></param>
        /// <param name="dueTime"></param>
        /// <param name="beaconPid"></param>
        /// <param name="eventTypeDetectedByDevice"></param>
        /// <returns></returns>
        public async Task SaveDelayedActionAsync(
            ResolvedAction resolvedAction, DateTimeOffset dueTime, string beaconPid, BeaconEventType eventTypeDetectedByDevice)
        {
            string actionAsString = ResolvedAction.Serialize(resolvedAction);

            DBDelayedAction delayedAction = new DBDelayedAction()
            {
                ResolvedAction = actionAsString,
                DueTime = dueTime,
                BeaconPid = beaconPid,
                EventTypeDetectedByDevice = (int)eventTypeDetectedByDevice,
                Executed = false
            };

            await _db.InsertAsync(delayedAction);
        }
コード例 #8
0
 private async Task <bool> SaveBeaconEventStateRetry(string pid, BeaconEventType enter, int retry)
 {
     if (retry < 0)
     {
         return(false);
     }
     try
     {
         if (await Storage.SaveBeaconEventState(pid, enter))
         {
             return(true);
         }
         return(await SaveBeaconEventStateRetry(pid, enter, --retry));
     }
     catch (UnauthorizedAccessException)
     {
         return(await SaveBeaconEventStateRetry(pid, enter, --retry));
     }
     catch (FileNotFoundException)
     {
         return(await SaveBeaconEventStateRetry(pid, enter, --retry));
     }
 }
コード例 #9
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);
            }
        }
コード例 #10
0
 public void NotifyBeaconEvent(Beacon beacon, BeaconEventType eventType)
 {
     BeaconEvent?.Invoke(this, new BeaconEventArgs() { Beacon = beacon, EventType = eventType });
 }
コード例 #11
0
        public void TestHistoryEventParsing(string query, string beaconId, string eventTime, BeaconEventType beaconEventType, bool send)
        {
            HistoryEvent e = FileStorageHelper.EventFromString(query);

            //fallback for unparsable data
            if (beaconId == null && eventTime == null)
            {
                Assert.IsNull(e);
                return;
            }

            Assert.AreEqual(beaconId, e.BeaconId);
            Assert.AreEqual(eventTime, e.EventTime);
            Assert.AreEqual((int)beaconEventType, e.Trigger);
        }
コード例 #12
0
 public static HistoryEvent ToHistoryEvent(string pid, DateTimeOffset timestamp, BeaconEventType eventType, string location)
 {
     return(new HistoryEvent()
     {
         BeaconId = pid, EventTime = timestamp.ToString(History.Timeformat), Trigger = (int)eventType, Location = location
     });
 }
コード例 #13
0
 public async Task<bool> SaveBeaconEventState(string pid, BeaconEventType enter)
 {
     LastEventState[pid] = new BackgroundEvent() {BeaconId = pid, EventTime = DateTimeOffset.Now, LastEvent = enter};
     return true;
 }
コード例 #14
0
 private async Task <bool> SaveDelayedActionsRetry(ResolvedAction action, DateTimeOffset dueTime, string beaconPid, BeaconEventType eventTypeDetectedByDevice, string location, int retry)
 {
     if (retry < 0)
     {
         return(false);
     }
     try
     {
         if (await Storage.SaveDelayedAction(action, dueTime, beaconPid, eventTypeDetectedByDevice, location))
         {
             return(true);
         }
         return(await SaveDelayedActionsRetry(action, dueTime, beaconPid, eventTypeDetectedByDevice, location, --retry));
     }
     catch (UnauthorizedAccessException)
     {
         return(await SaveDelayedActionsRetry(action, dueTime, beaconPid, eventTypeDetectedByDevice, location, --retry));
     }
     catch (FileNotFoundException)
     {
         return(await SaveDelayedActionsRetry(action, dueTime, beaconPid, eventTypeDetectedByDevice, location, --retry));
     }
 }
コード例 #15
0
 public static string DelayedActionToString(ResolvedAction action, DateTimeOffset dueTime, string beaconPid, BeaconEventType beaconEventType, string location)
 {
     return DelayedActionToString(action, dueTime, beaconPid, beaconEventType, Guid.NewGuid(), location);
 }
コード例 #16
0
 private async Task<bool> SaveHistoryActionRetry(string uuid, string beaconPid, DateTimeOffset now, BeaconEventType beaconEventType, string location, int retry)
 {
     if (retry < 0)
     {
         return false;
     }
     try
     {
         HistoryAction action = FileStorageHelper.ToHistoryAction(uuid, beaconPid, now, beaconEventType, location);
         if (await Storage.SaveHistoryAction(action))
         {
             return true;
         }
         return await SaveHistoryActionRetry(uuid, beaconPid, now, beaconEventType, location, --retry);
     }
     catch (UnauthorizedAccessException)
     {
         return await SaveHistoryActionRetry(uuid, beaconPid, now, beaconEventType, location, --retry);
     }
     catch (FileNotFoundException)
     {
         return await SaveHistoryActionRetry(uuid, beaconPid, now, beaconEventType, location, --retry);
     }
 }
コード例 #17
0
 public async Task<bool> SaveHistoryEvent(string pid, DateTimeOffset timestamp, BeaconEventType eventType, string location)
 {
     return await SaveHistoryEventRetry(pid, timestamp, eventType, location, MaxRetries);
 }
コード例 #18
0
 public static HistoryEvent ToHistoryEvent(string pid, DateTimeOffset timestamp, BeaconEventType eventType, string location)
 {
     return new HistoryEvent() { BeaconId = pid, EventTime = timestamp.ToString(History.Timeformat), Trigger = (int)eventType, Location = location};
 }
コード例 #19
0
 public async Task<bool> SaveHistoryAction(string uuid, string beaconPid, DateTimeOffset now, BeaconEventType beaconEventType, string location)
 {
     return await SaveHistoryActionRetry(uuid, beaconPid, now, beaconEventType, location, MaxRetries);
 }
コード例 #20
0
 public static HistoryAction ToHistoryAction(string uuid, string beaconPid, DateTimeOffset now, BeaconEventType beaconEventType, string location)
 {
     return new HistoryAction() { BeaconId = beaconPid, ActionTime = now.ToString(History.Timeformat), EventId = uuid, Trigger = (int)beaconEventType, Location = location};
 }
コード例 #21
0
 public static string BeaconEventStateToString(string pid, BeaconEventType type, DateTimeOffset now)
 {
     return string.Format("{0},{1},{2}", pid, (int)type, now.ToUnixTimeMilliseconds());
 }
コード例 #22
0
 public static string DelayedActionToString(ResolvedAction action, DateTimeOffset dueTime, string beaconPid, BeaconEventType beaconEventType, Guid guid, string location)
 {
     string serializeObject = JsonConvert.SerializeObject(new SerializedAction() {Action = action, Time = dueTime, Beacon = beaconPid, Event = beaconEventType});
     return DelayedActionToString(Convert.ToBase64String(Encoding.UTF8.GetBytes(serializeObject)), dueTime, false, guid.ToString(), location);
 }
コード例 #23
0
 private async Task <bool> SaveHistoryActionRetry(string uuid, string beaconPid, DateTimeOffset now, BeaconEventType beaconEventType, string location, int retry)
 {
     if (retry < 0)
     {
         return(false);
     }
     try
     {
         HistoryAction action = FileStorageHelper.ToHistoryAction(uuid, beaconPid, now, beaconEventType, location);
         if (await Storage.SaveHistoryAction(action))
         {
             return(true);
         }
         return(await SaveHistoryActionRetry(uuid, beaconPid, now, beaconEventType, location, --retry));
     }
     catch (UnauthorizedAccessException)
     {
         return(await SaveHistoryActionRetry(uuid, beaconPid, now, beaconEventType, location, --retry));
     }
     catch (FileNotFoundException)
     {
         return(await SaveHistoryActionRetry(uuid, beaconPid, now, beaconEventType, location, --retry));
     }
 }
コード例 #24
0
ファイル: Layout.cs プロジェクト: WombatWorks/windows10-sdk
        /// <summary>
        /// Resolves the beacon actions associated with the given PID and event type.
        /// </summary>
        /// <param name="pid"></param>
        /// <param name="eventType"></param>
        /// <returns>A list of actions based on the given values or an empty list if none found.</returns>
        public IList<ResolvedAction> GetResolvedActionsForPidAndEvent(string pid, BeaconEventType eventType)
        {
            List<ResolvedAction> actions = new List<ResolvedAction>();

            foreach (ResolvedAction item in ResolvedActions)
            {
                if (item.BeaconPids.ContainsKey(pid)
                    && (item.EventTypeDetectedByDevice == eventType || item.EventTypeDetectedByDevice == BeaconEventType.EnterExit))
                { 
                    actions.Add(item);
                }
            }

            return actions;
        }
コード例 #25
0
 private async Task <bool> SaveHistoryEventRetry(string pid, DateTimeOffset timestamp, BeaconEventType eventType, string location, int retry)
 {
     if (retry < 0)
     {
         return(false);
     }
     try
     {
         if (await Storage.SaveHistoryEvents(FileStorageHelper.ToHistoryEvent(pid, timestamp, eventType, location)))
         {
             return(true);
         }
         return(await SaveHistoryEventRetry(pid, timestamp, eventType, location, --retry));
     }
     catch (UnauthorizedAccessException)
     {
         return(await SaveHistoryEventRetry(pid, timestamp, eventType, location, --retry));
     }
     catch (FileNotFoundException)
     {
         return(await SaveHistoryEventRetry(pid, timestamp, eventType, location, --retry));
     }
 }
コード例 #26
0
 public static string BeaconEventStateToString(string pid, BeaconEventType type, DateTimeOffset now)
 {
     return(string.Format("{0},{1},{2}", pid, (int)type, now.ToUnixTimeMilliseconds()));
 }
コード例 #27
0
 private async Task<bool> SaveHistoryEventRetry(string pid, DateTimeOffset timestamp, BeaconEventType eventType, string location, int retry)
 {
     if (retry < 0)
     {
         return false;
     }
     try
     {
         if (await Storage.SaveHistoryEvents(FileStorageHelper.ToHistoryEvent(pid, timestamp, eventType, location)))
         {
             return true;
         }
         return await SaveHistoryEventRetry(pid, timestamp, eventType, location, --retry);
     }
     catch (UnauthorizedAccessException)
     {
         return await SaveHistoryEventRetry(pid, timestamp, eventType, location, --retry);
     }
     catch (FileNotFoundException)
     {
         return await SaveHistoryEventRetry(pid, timestamp, eventType, location, --retry);
     }
 }
コード例 #28
0
 public static string ActionToString(string uuid, string beaconPid, DateTimeOffset timestamp, BeaconEventType beaconEventType, string location)
 {
     return ActionToString(uuid, beaconPid, timestamp, (int) beaconEventType, false, false, location);
 }
コード例 #29
0
        public static string DelayedActionToString(ResolvedAction action, DateTimeOffset dueTime, string beaconPid, BeaconEventType beaconEventType, Guid guid, string location)
        {
            string serializeObject = JsonConvert.SerializeObject(new SerializedAction()
            {
                Action = action, Time = dueTime, Beacon = beaconPid, Event = beaconEventType
            });

            return(DelayedActionToString(Convert.ToBase64String(Encoding.UTF8.GetBytes(serializeObject)), dueTime, false, guid.ToString(), location));
        }
コード例 #30
0
 public async Task<bool> SaveDelayedAction(ResolvedAction action, DateTimeOffset dueTime, string beaconPid, BeaconEventType eventType, string location)
 {
     return await SaveDelayedActionsRetry(action, dueTime, beaconPid, eventType, location, MaxRetries);
 }
コード例 #31
0
 public static HistoryAction ToHistoryAction(string uuid, string beaconPid, DateTimeOffset now, BeaconEventType beaconEventType, string location)
 {
     return(new HistoryAction()
     {
         BeaconId = beaconPid, ActionTime = now.ToString(History.Timeformat), EventId = uuid, Trigger = (int)beaconEventType, Location = location
     });
 }
コード例 #32
0
 private async Task<bool> SaveDelayedActionsRetry(ResolvedAction action, DateTimeOffset dueTime, string beaconPid, BeaconEventType eventTypeDetectedByDevice, string location, int retry)
 {
     if (retry < 0)
     {
         return false;
     }
     try
     {
         if (await Storage.SaveDelayedAction(action, dueTime, beaconPid, eventTypeDetectedByDevice, location))
         {
             return true;
         }
         return await SaveDelayedActionsRetry(action, dueTime, beaconPid, eventTypeDetectedByDevice, location, --retry);
     }
     catch (UnauthorizedAccessException)
     {
         return await SaveDelayedActionsRetry(action, dueTime, beaconPid, eventTypeDetectedByDevice, location, --retry);
     }
     catch (FileNotFoundException)
     {
         return await SaveDelayedActionsRetry(action, dueTime, beaconPid, eventTypeDetectedByDevice, location, --retry);
     }
 }
コード例 #33
0
        public async Task <bool> SaveDelayedAction(ResolvedAction action, DateTimeOffset dueTime, string beaconPid, BeaconEventType eventType, string location)
        {
            StorageFolder folder = await GetFolder(Background?BackgroundActionsFolder : ForegroundActionsFolder, true);

            StorageFile file = await folder.CreateFileAsync(DelayedActionsFileName, CreationCollisionOption.OpenIfExists);

            string actionToString = FileStorageHelper.DelayedActionToString(action, dueTime, beaconPid, eventType, location);

            return(await RetryAppending(file, actionToString));
        }
コード例 #34
0
 public async Task<bool> SaveBeaconEventState(string pid, BeaconEventType enter)
 {
     return await SaveBeaconEventStateRetry(pid, enter,MaxRetries);
 }
コード例 #35
0
 /// <summary>
 /// For convenience.
 /// </summary>
 public async Task SaveExecutedResolvedActionAsync(BeaconAction beaconAction, string beaconPid, BeaconEventType beaconEventType, string location)
 {
     await ServiceManager.StorageService.SaveHistoryAction(beaconAction.Uuid, beaconPid, DateTime.Now, beaconEventType, location);
 }
コード例 #36
0
 private async Task<bool> SaveBeaconEventStateRetry(string pid, BeaconEventType enter, int retry)
 {
     if (retry < 0)
     {
         return false;
     }
     try
     {
         if (await Storage.SaveBeaconEventState(pid, enter))
         {
             return true;
         }
         return await SaveBeaconEventStateRetry(pid, enter, --retry);
     }
     catch (UnauthorizedAccessException)
     {
         return await SaveBeaconEventStateRetry(pid, enter, --retry);
     }
     catch (FileNotFoundException)
     {
         return await SaveBeaconEventStateRetry(pid, enter, --retry);
     }
 }
コード例 #37
0
        public void TestHistoryActionParsing(string query, string uuid, string beaconId, string eventTime, BeaconEventType beaconEventType, bool send)
        {
            HistoryAction a = FileStorageHelper.ActionFromString(query);

            //fallback for unparsable data
            if (beaconId == null && eventTime == null)
            {
                Assert.IsNull(a);
                return;
            }

            Assert.AreEqual(beaconId, a.BeaconId);
            Assert.AreEqual(eventTime, a.ActionTime);
            Assert.AreEqual(uuid, a.EventId);
            Assert.AreEqual((int)beaconEventType, a.Trigger);
        }
コード例 #38
0
ファイル: Storage.cs プロジェクト: WombatWorks/windows10-sdk
 public async Task SaveBeaconBackgroundEvent(string pidIn,BeaconEventType triggerIn )
 {
     int eventType = (int)triggerIn;
     DateTimeOffset eventTime = DateTimeOffset.Now;
     DBBackgroundEventsHistory actions = new DBBackgroundEventsHistory() { BeaconPid = pidIn, EventType = eventType, EventTime = eventTime };
     await _db.InsertAsync(actions);
 }
コード例 #39
0
 public static Request ToRequest(string uuid, ushort man, ushort beaconId, BeaconEventType type)
 {
     return new Request(new BeaconEventArgs() {Beacon = new Beacon() {Id1 = uuid, Id2 = man, Id3 = beaconId }, EventType = type}, SdkData.NextId());
 }
コード例 #40
0
ファイル: Storage.cs プロジェクト: WombatWorks/windows10-sdk
 public async Task UpdateBackgroundEventAsync(string pidIn,BeaconEventType eventType)
 {
     int type = (int)eventType;
     DateTimeOffset eventTime = DateTimeOffset.Now;
     DBBackgroundEventsHistory backgroundEvent = new DBBackgroundEventsHistory() { BeaconPid = pidIn, EventTime = eventTime, EventType= type };
     await _db.UpdateAsync(backgroundEvent);
 }
コード例 #41
0
 public async Task <bool> SaveHistoryAction(string uuid, string beaconPid, DateTimeOffset now, BeaconEventType beaconEventType, string location)
 {
     return(await SaveHistoryActionRetry(uuid, beaconPid, now, beaconEventType, location, MaxRetries));
 }
コード例 #42
0
 public async Task <bool> SaveDelayedAction(ResolvedAction action, DateTimeOffset dueTime, string beaconPid, BeaconEventType eventType, string location)
 {
     DelayedActions.Add(new DelayedActionData()
     {
         BeaconPid = beaconPid, DueTime = dueTime, EventTypeDetectedByDevice = eventType, Id = Guid.NewGuid().ToString(), ResolvedAction = action, Location = location
     });
     return(true);
 }
コード例 #43
0
 public async Task <bool> SaveHistoryEvent(string pid, DateTimeOffset timestamp, BeaconEventType eventType, string location)
 {
     return(await SaveHistoryEventRetry(pid, timestamp, eventType, location, MaxRetries));
 }
コード例 #44
0
        public void TestHistoryActionParsing(string query, string uuid, string beaconId, string eventTime, BeaconEventType beaconEventType, bool send)
        {
            HistoryAction a = FileStorageHelper.ActionFromString(query);

            //fallback for unparsable data
            if (beaconId == null && eventTime == null)
            {
                Assert.IsNull(a);
                return;
            }

            Assert.AreEqual(beaconId, a.BeaconId);
            Assert.AreEqual(eventTime, a.ActionTime);
            Assert.AreEqual(uuid, a.EventId);
            Assert.AreEqual((int)beaconEventType, a.Trigger);
        }
コード例 #45
0
 public async Task <bool> SaveDelayedAction(ResolvedAction action, DateTimeOffset dueTime, string beaconPid, BeaconEventType eventType, string location)
 {
     return(await SaveDelayedActionsRetry(action, dueTime, beaconPid, eventType, location, MaxRetries));
 }
コード例 #46
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);
            }
        }
コード例 #47
0
 public async Task <bool> SaveBeaconEventState(string pid, BeaconEventType enter)
 {
     return(await SaveBeaconEventStateRetry(pid, enter, MaxRetries));
 }
コード例 #48
0
 public static string DelayedActionToString(ResolvedAction action, DateTimeOffset dueTime, string beaconPid, BeaconEventType beaconEventType, string location)
 {
     return(DelayedActionToString(action, dueTime, beaconPid, beaconEventType, Guid.NewGuid(), location));
 }
コード例 #49
0
        /// <summary>
        /// Executes the given action, stores the event in event history and notifies the listeners.
        /// </summary>
        /// <param name="resolvedAction"></param>
        /// <param name="beaconPid"></param>
        /// <param name="beaconEventType"></param>
        private async Task ExecuteActionAsync(ResolvedAction resolvedAction, string beaconPid, BeaconEventType beaconEventType)
        {
            bool checkOnlyOnce = await _eventHistory.CheckSendOnlyOnceAsync(resolvedAction);
            bool shouldSupress = await _eventHistory.ShouldSupressAsync(resolvedAction);

            if (!shouldSupress && !checkOnlyOnce && resolvedAction.IsInsideTimeframes(DateTimeOffset.Now))
            {
                await _eventHistory.SaveExecutedResolvedActionAsync(resolvedAction.BeaconAction, beaconPid, beaconEventType);

                if (resolvedAction.ReportImmediately)
                {
                    await _eventHistory.FlushHistoryAsync();
                }

                if (BeaconActionResolved != null)
                {
                    BeaconActionResolved(this, resolvedAction.BeaconAction);
                }
            }
        }
コード例 #50
0
 public async Task<bool> SaveDelayedAction(ResolvedAction action, DateTimeOffset dueTime, string beaconPid, BeaconEventType eventType, string location)
 {
     DelayedActions.Add(new DelayedActionData() {BeaconPid = beaconPid,DueTime = dueTime, EventTypeDetectedByDevice =  eventType, Id = Guid.NewGuid().ToString(), ResolvedAction = action, Location = location});
     return true;
 }
コード例 #51
0
 private void AddBeaconArgs(Beacon beacon, BeaconEventType eventType)
 {
     var args = new BeaconEventArgs();
     args.Beacon = beacon;
     args.EventType = eventType;
     _beaconArgs.Add(args);
 }
コード例 #52
0
 /// <summary>
 /// For convenience.
 /// </summary>
 /// <param name="beaconAction"></param>
 /// <param name="beaconPid"></param>
 /// <param name="beaconActionType"></param>
 /// <returns></returns>
 public IAsyncAction SaveExecutedResolvedActionAsync(BeaconAction beaconAction, string beaconPid, BeaconEventType beaconEventType)
 {
     return _storage.SaveHistoryActionAsync(
         beaconAction.Uuid, beaconPid, DateTime.Now, (int)beaconEventType).AsAsyncAction();
 }
コード例 #53
0
 public static string ActionToString(string uuid, string beaconPid, DateTimeOffset timestamp, BeaconEventType beaconEventType, string location)
 {
     return(ActionToString(uuid, beaconPid, timestamp, (int)beaconEventType, false, false, location));
 }
コード例 #54
0
 /// <summary>
 /// For convenience.
 /// </summary>
 public async Task SaveExecutedResolvedActionAsync(BeaconAction beaconAction, string beaconPid, BeaconEventType beaconEventType, string location)
 {
     await ServiceManager.StorageService.SaveHistoryAction(beaconAction.Uuid, beaconPid, DateTime.Now, beaconEventType, location);
 }