public override void OnReceive(Context context, Intent intent) { _sessionManagerWorkStorage = new WorkSessionManager(context); var wifiFound = false; if (!intent.Action.Equals(WifiManager.ScanResultsAvailableAction)) { return; } WifiNetworks = WifiManager.ScanResults.ToDomainWifiNetworks().ToList(); foreach (var availableSsid in _availableSsids) { var wifi = WifiNetworks.FirstOrDefault(n => n.Ssid == availableSsid); if (wifi == null) { _wifiLost = true; continue; } _wifiLost = false; if (_sessionManagerWorkStorage.GetIsAtWork()) { continue; } wifiFound = true; FoundNetworkNotify(context, wifi); } if (!wifiFound & _wifiLost) { if (_sessionManagerWorkStorage.GetIsAtWork()) { LostNetworkNotify(context); } } Task.Run(() => { Thread.Sleep((long)TimeSpan.FromSeconds(5).TotalMilliseconds); WifiManager.StartScan(); }); }
public override void OnReceive(Context context, Intent intent) { _workStorage = AndroidObjectFactory.GetWorkStorage(context); _userStorage = AndroidObjectFactory.GetUserStorage(context); _eventService = AndroidObjectFactory.GetEventService(); if (!(_userStorage.GetIsLoggedIn() & (!_workStorage.GetIsAtWork()))) { return; } _workStorage.SaveEntryDate(DateTime.Now); _workStorage.SaveAtWork(true); _eventService.Add(new StartWorkEvent(DateTime.Now)); }
public override void OnReceive(Context context, Intent intent) { _userStorage = AndroidObjectFactory.GetUserStorage(context); _workStorage = AndroidObjectFactory.GetWorkStorage(context); _eventService = AndroidObjectFactory.GetEventService(); if (!(_userStorage.GetIsLoggedIn()) & _workStorage.GetIsAtWork()) { return; } _workStorage.SaveLeavingDate(DateTime.Now); _workStorage.SaveAtWork(false); _eventService.Add(new EndWorkEvent(DateTime.Now)); SummaryNotify(context); }