public ActionResult GetDeviceModel(long Id)
        {
            var model = DeviceModelReg.GetModel(Id);

            model.SetUrlHelper(Url);
            var m = new
            {
                DeviceId     = model.DeviceId.ToString(),
                LayerId      = model.LayerId.ToString(),
                LayerName    = model.LayerName,
                LayerKey     = model.LayerKey,
                DeviceKey    = model.DeviceKey,
                DeviceName   = model.DeviceName,
                IconFile     = model.IconFile.ToString(),
                IconFileUrl  = model.IconFileUrl,
                IconFileName = model.IconFileName,
                Lat          = model.Lat.ToString(),
                Lng          = model.Lng.ToString(),
                Note         = model.Note,
                DeviceUrl    = model.DeviceUrl,
            };
            var r = new
            {
                Model = m
            };

            return(Json(r));
        }
        public ActionResult EditDeviceAjax(DeviceModel model)
        {
            var loginInfo = SessionLoginInfo.GetInstance(Session);

            if (!ModelState.IsValid)
            {
                var r = new
                {
                    Success = false
                };
                return(Json(r));
            }

            bool bl = false;

            if (model.DeviceId > 0)
            {
                try
                {
                    var oldmodel = DeviceModelReg.GetModel(model.DeviceId);
                    oldmodel.DeviceKey  = model.DeviceKey;
                    oldmodel.DeviceName = model.DeviceName;
                    oldmodel.Lat        = model.Lat;
                    oldmodel.Lng        = model.Lng;
                    oldmodel.Note       = model.Note;
                    oldmodel.DeviceUrl  = model.DeviceUrl;
                    oldmodel.LastUserID = loginInfo.LoginID;
                    bl = DeviceModelReg.Update(oldmodel);
                }
                catch (Exception) { }
            }
            else
            {
                try
                {
                    model.OrganizationID = loginInfo.OrganizationID;
                    model.LastUserID     = loginInfo.LoginID;
                    bl = DeviceModelReg.Add(model);
                }
                catch (Exception) { }
            }
            var jsonObj = new
            {
                Success = bl
            };

            return(Json(jsonObj));
        }