Exemple #1
0
        private void ProcessGpsMessage(GpsMessage gpsMsg)
        {
            if (gpsMsg == null)
            {
                return;
            }

            try
            {
                SmartDevice device = _gpsDevices.Find(x => x.DeviceId == gpsMsg.DeviceId);
                if (device != null)
                {
                    device.Latitude  = gpsMsg.Latitude;
                    device.Longitude = gpsMsg.Longitude;
                    BlobTable <SmartDevice> .Update(device);
                }

#if DEBUG
                Console.WriteLine(Scf.Net.IotHub.MessageHelper.ToString(gpsMsg));
#endif

                _gpsQueue.SendMessage(Scf.Net.IotHub.MessageHelper.ToString(gpsMsg));
            }
            catch (Exception ex)
            {
            }
        }
        public ActionResult SaveSelected(string data)
        {
            SelectedItem[]     checkedItems = JsonConvert.DeserializeObject <SelectedItem[]>(data);
            List <SmartDevice> items        = BlobTable <SmartDevice> .GetAllItems();

            if (items != null && items.Count > 0)
            {
                foreach (SelectedItem chkitem in checkedItems)
                {
                    int         index = items.FindIndex(i => i.Id == chkitem.Id);
                    SmartDevice item  = (index >= 0) ? items[index] : null;
                    if (item != null)
                    {
                        item.Selected = chkitem.Selected;
                        BlobTable <SmartDevice> .Update(item);
                    }
                }
            }
            //Task.Run(async () =>
            //{
            //    var tmpitem = await SmartMonitorDataManager<SmartDevice>.GetItemsAsync(d => !d.Completed);
            //    List<SmartDevice> items = tmpitem.ToList();
            //    foreach (SelectedItem chkitem in checkedItems)
            //    {
            //        int index = items.FindIndex(i => i.Id == chkitem.Id);
            //        SmartDevice item = (index >= 0) ? items[index] : null;
            //        if (item != null)
            //        {
            //            item.Selected = chkitem.Selected;
            //            await SmartMonitorDataManager<SmartDevice>.UpsertItemAsync(item);
            //        }
            //    }
            //});

            return(RedirectToAction("Index"));
        }