Exemple #1
0
        public async Task <ActionResult> IndexAsync()
        {
            //var items = await SmartMonitorDataManager<UserGroup>.GetItemsAsync(d => !d.Completed);
            List <UserGroup> items = await Task.Run(() => BlobTable <UserGroup> .GetAllItems());

            return(View(items));
        }
        public async Task <ActionResult> IndexAsync()
        {
            Account acct = null;

            List <Account> items = await Task.Run(() => BlobTable <Account> .GetAllItems());

            if (items != null && items.Count > 0)
            {
                acct = items[0];
            }
            //var items = await SmartMonitorDataManager<Account>.GetItemsAsync(d => !d.Completed);
            //if (items != null)
            //{
            //    List<Account> list = items.ToList();

            //    if (list.Count > 0)
            //        acct = list[0];
            //}

            if (acct == null)
            {
                acct = new Account();
            }

            return(View(acct));
        }
Exemple #3
0
        public async Task <ActionResult> IndexAsync()
        {
            //var items = await SmartMonitorDataManager<Parameter>.GetItemsAsync(d => !d.Completed);
            List <Parameter> items = BlobTable <Parameter> .GetAllItems();

            return(View(items));
        }
Exemple #4
0
        public void Refresh()
        {
            List <SmartDevice> items = BlobTable <SmartDevice> .GetAllItems();

            _devices.Clear();

            foreach (SmartDevice item in items)
            {
                if (item.GpsTracking)
                {
                    _devices.Add(item);
                }
            }
        }
Exemple #5
0
        public async Task <ActionResult> AlarmsAsync(string id)
        {
            Parameter item = null;

            //item = await SmartMonitorDataManager<Parameter>.GetItemAsync(id);
            item = BlobTable <Parameter> .GetItem(id);

            item.Alarms = BlobTable <Alarm> .GetAllItems();

            item.Alarms             = item.Alarms.FindAll(x => x.DeviceId == id);
            ViewData["parameterId"] = item.Id;

            return((item != null) ? PartialView(item.Alarms) : PartialView());
        }
Exemple #6
0
        public void Initialize()
        {
            Terminated = false;

            _gpsQueue = new BlobQueue("gpsmessages", blobConnectionString, this, this);
            _gpsQueue.Initialize();

            _iotHubReceiver = new Receiver(hubConnectionString, this);

            _iotHubReceiver.Initialize(this);

            BlobTable <SmartDevice> .Initialize(blobConnectionString);

            _gpsDevices = BlobTable <SmartDevice> .GetAllItems();
        }
        // GET: Communication
        public ActionResult Index()
        {
            Communication comm = new Communication();

            List <SmartDevice> list = BlobTable <SmartDevice> .GetAllItems();

            if (list != null)
            {
                comm.SelectedDevices = list;
            }
            //Task.Run(async () =>
            //{
            //    var items = await SmartMonitorDataManager<SmartDevice>.GetItemsAsync(d => !d.Completed);
            //    comm.SelectedDevices = items.ToList();
            //}).Wait();

            return(View(comm));
        }
        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"));
        }
        public ActionResult SendMessage(string message, string data)
        {
            string[]           checkedItems = JsonConvert.DeserializeObject <string[]>(data);
            List <SmartDevice> items        = BlobTable <SmartDevice> .GetAllItems();

            if (items != null && items.Count > 0)
            {
                foreach (string chkitem in checkedItems)
                {
                    int         index = items.FindIndex(i => i.Id == chkitem);
                    SmartDevice item  = (index >= 0) ? items[index] : null;
                    if (item != null)
                    {
                        Scf.Net.PushHub.PushMessage msg = new Scf.Net.PushHub.PushMessage();
                        msg.DeviceId = item.DeviceId;
                        msg.Message  = message;
                        msg.Type     = Scf.Net.PushHub.PushMessage.PushType.Unknown;

                        switch (item.Platform)
                        {
                        case SmartDevice.PlatformType.Android:
                            msg.Type = Scf.Net.PushHub.PushMessage.PushType.Android;
                            break;

                        case SmartDevice.PlatformType.Apple:
                            msg.Type = Scf.Net.PushHub.PushMessage.PushType.Apple;
                            break;

                        case SmartDevice.PlatformType.UWP:
                            msg.Type = Scf.Net.PushHub.PushMessage.PushType.Windows;
                            break;

                        case SmartDevice.PlatformType.Windows:
                            msg.Type = Scf.Net.PushHub.PushMessage.PushType.WindowsPhone;
                            break;
                        }
                        PushManager.SendMessage(msg);
                    }
                }
            }
            //Task.Run(async () =>
            //{
            //    var tmpitem = await SmartMonitorDataManager<SmartDevice>.GetItemsAsync(d => !d.Completed);
            //    List<SmartDevice> items = tmpitem.ToList();
            //    foreach (string itemid in checkedItems)
            //    {
            //        int index = items.FindIndex(i => i.Id == itemid);
            //        SmartDevice item = (index >= 0) ? items[index] : null;
            //        if (item != null)
            //        {
            //            PushMessage msg = new PushMessage();
            //            msg.DeviceId = item.DeviceId;
            //            msg.Message = message;
            //            msg.Type = PushMessage.PushType.Unknown;

            //            switch (item.Platform)
            //            {
            //                case SmartDevice.PlatformType.Android:
            //                    msg.Type = PushMessage.PushType.Android;
            //                    break;
            //                case SmartDevice.PlatformType.Apple:
            //                    msg.Type = PushMessage.PushType.Apple;
            //                    break;
            //                case SmartDevice.PlatformType.UWP:
            //                    msg.Type = PushMessage.PushType.Windows;
            //                    break;
            //                case SmartDevice.PlatformType.Windows:
            //                    msg.Type = PushMessage.PushType.Windows;
            //                    break;
            //            }
            //            PushNotificationManager.Instance.SendMessage(msg);
            //        }
            //    }
            //});
            return(RedirectToAction("Index"));
        }