Beispiel #1
0
        public async Task <ActionResult> GetDevice()
        {
            DeviceServices    ds  = new DeviceServices();
            IEnumerable <Dev> dev = null;

            try
            {
                dev = await ds.GetDevice("Dt desc");

                List <Dev> de = new List <Dev>();
                foreach (var item in dev)
                {
                    item.Dt.ToUniversalTime(); //.ToLocalTime();
                }
            }
            catch (Exception ex)
            {
                string mess = ex.Message;
            }
            return(Json(dev, JsonRequestBehavior.AllowGet));

            #region 直接调用

            /*
             * using (var db = new EFWorkContext())
             * {
             *  var dev = db.Device.Include(a => a.DeviceData).Select(c => new Dev() { DeviceId = c.DeviceId, DeviceName = c.DeviceName, DeviceTypeName = c.DeviceType.Name, Dt = c.DeviceData== null?DateTime.Now:c.DeviceData.Dt, Message = c.DeviceData.Message });
             *  IEnumerable<Dev> dd = null;
             *  try
             *  {
             *      dd = dev.OrderByDescending(a => a.Dt).Skip(0).Take(10).ToList();
             *  }
             *  catch (Exception ex)
             *  {
             *      string me = ex.Message;
             *  }
             *
             *  //var devi = db.Device.Include(a => a.DeviceData).Include(a => a.DeviceType).Select(a => new{ a.DeviceId,a.DeviceName,a.DeviceType.Name,a.DeviceData.Name as aa, })
             *
             *  var devices = db.Device.Include(a => a.DeviceData);//.Where(a=>a.DeviceData.DeviceId<3).ToList();//.Where(a=>a.DeviceData.Dt>)
             *  var d = devices.OrderBy(a => a.DeviceData.Dt).ToList();
             *  return Json(dd, JsonRequestBehavior.AllowGet);
             * }*/
            #endregion
        }
Beispiel #2
0
        public IActionResult Delete(int id)
        {
            var vm = _deviceServices.GetDevice(id);

            return(View(vm));
        }