示例#1
0
        public void DoWork(IEnumerable <JObject> data)
        {
            DateTime date    = GetRandomDate();
            string   address = GetRandomAddress();
            int      count   = 0;

            foreach (JObject obj in data)
            {
                string   objAddress    = (string)obj.Property("address").Value;
                string   objDateString = (string)obj.Property("date").Value;
                DateTime objDateTime   = DateTime.Parse(objDateString);

                if (objAddress.Contains(address) && objDateTime.CompareTo(date) > 0)
                {
                    ++count;
                }
            }

            AddressCount addressCount = new AddressCount
            {
                Count   = count,
                Address = address,
                Date    = date.ToString("dd-MM-yyyy HH:mm")
            };

            this.addressCountRepository.InsertAddressCount(addressCount);
            mqttService.PublishMessage("address", JsonConvert.SerializeObject(addressCount));
        }
示例#2
0
        public void DoWork(IEnumerable <JObject> data)
        {
            DateTime date     = GetRandomDate();
            double   accuracy = GetRandomAccuracy();
            int      count    = 0;

            foreach (JObject obj in data)
            {
                double   objAccuracy   = (double)obj.Property("accuracy").Value;
                string   objDateString = (string)obj.Property("time").Value;
                DateTime objDateTime   = DateTime.Parse(objDateString);

                if (objAccuracy >= accuracy && objDateTime.CompareTo(date) > 0)
                {
                    ++count;
                }
            }

            LocationAccuracy locationAccuracy = new LocationAccuracy
            {
                Count    = count,
                Accuracy = accuracy,
                Time     = date.ToString("dd-MM-yyyy HH:mm")
            };

            this.locationAccuracyRepository.InsertLocationAccuracy(locationAccuracy);
            mqttService.PublishMessage("location", JsonConvert.SerializeObject(locationAccuracy));
        }
        public void DoWork(IEnumerable <JObject> data)
        {
            DateTime date       = GetRandomDate();
            string   capability = GetRandomCapability();
            int      count      = 0;

            foreach (JObject obj in data)
            {
                string objCapabilities = (string)obj.Property("capabilities").Value;
                string objDateString   = (string)obj.Property("time").Value;
                objDateString = objDateString.Substring(0, objDateString.Length - 22);
                DateTime objDateTime = DateTime.Parse(objDateString);

                if (objCapabilities.Contains(capability) && objDateTime.CompareTo(date) > 0)
                {
                    ++count;
                }
            }

            WifiCapability wifiCapability = new WifiCapability
            {
                Capability = capability,
                Count      = count,
                Time       = date.ToString("dd-MM-yyyy HH:mm")
            };

            this.wifiCapabilityRepository.InsertWifiCapability(wifiCapability);
            mqttService.PublishMessage("wifi", JsonConvert.SerializeObject(wifiCapability));
        }