Example #1
0
        public void Execute(IndoorAssetReportMessage message)
        {
            // if edge doesn't exist
            if (_edgeRepo.RetrieveAsync(message.HardwareSerial).Result == null)
            {
                _edgeRepo.SetAsync(message.HardwareSerial, new EdgeData()).Wait();
                Console.WriteLine($"added new edge ({message.HardwareSerial})");
            }

            var newEdgeRef = _edgeRepo.GetDocument(message.HardwareSerial);
            var batch      = _firebaseClient.GetFirestoreDb().StartBatch();

            foreach (var payload in message.IndoorTagPayloadInfo)
            {
                _assetService.UpdateEdgeAsync(batch, new AssetData
                {
                    MacAddress     = payload.MacAddress,
                    LastReportTime = Timestamp.GetCurrentTimestamp(),
                    BatteryLevel   = payload.BatteryLevel,
                    SignalStrength = payload.Rss,
                    EdgeRef        = newEdgeRef
                }).Wait();
            }

            batch.CommitAsync().Wait();
        }
Example #2
0
        public FirestoreRepositoryBase(IFirebaseClient fbClient, IConfigOperator config)
        {
            _db = fbClient.GetFirestoreDb();

            string tenantName = config.GetTenant();

            _tenantPath = String.IsNullOrWhiteSpace(tenantName)?"":$"tenants/{tenantName}/";
        }