/// <summary> /// 更新设备 /// </summary> public bool UpdateDevice() { try { AMS_DeviceModel samedevice = AMS_DeviceBLL.GetDevicebyNo(_Number); if (samedevice == null || samedevice.Id == _Id) { AMS_DeviceModel newdevice = new AMS_DeviceModel(); newdevice.CampusId = _Campusid; newdevice.Id = _Id; newdevice.CaputrePath = _Caputrepath; newdevice.CaputreTime = _Caputretime; newdevice.IsDel = _Isdel; newdevice.Number = _Number; newdevice.Flag = true; newdevice.Describe = _Describe; if (AMS_DeviceBLL.UpdateDeviceModel(newdevice) == AdvertManage.Model.Enum.HandleResult.Failed) { throw new Exception("设备更新失败!详情请查看日志文件"); } return(true); } else { throw new Exception("该设备编号已存在!"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return(false); } }
/// <summary> /// 添加设备 /// </summary> public bool AddDevice() { try { AMS_DeviceModel samedevice = AMS_DeviceBLL.GetDevicebyNo(_Number); if (samedevice == null) { AMS_DeviceModel newdevice = new AMS_DeviceModel(); if (_Campusid == 0) { throw new Exception("请选择校区!"); } newdevice.CampusId = _Campusid; newdevice.IsDel = _Isdel; newdevice.Number = _Number; newdevice.Flag = _Flag; newdevice.Describe = _Describe; if (AMS_DeviceBLL.AddDeviceModel(newdevice) == AdvertManage.Model.Enum.HandleResult.Failed) { throw new Exception("设备添加失败!详情请查看日志文件"); } return(true); } else { throw new Exception("该设备编号已存在!"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return(false); } }
/// <summary> /// 获取校区信息 /// </summary> /// <param name="schoolid">所要查询的学校,输入0为查询全部学校</param> public void GetData(int schoolid) { try { _CampusList.Clear(); List <AMS_CampusModel> campuslist = AMS_CampusBLL.GetCampusInfoListBySchoolId(schoolid); foreach (AMS_CampusModel campus in campuslist) { CampusInfoViewModel campusMV = new CampusInfoViewModel(); List <AMS_DeviceModel> devicecount = AMS_DeviceBLL.GeDeviceModelByCampusNum(campus.Number); campusMV.DeviceCount = devicecount.Count; campusMV.Describe = campus.Describe; campusMV.Id = campus.Id; campusMV.Name = campus.Name; campusMV.Number = campus.Number; campusMV.Schoolid = campus.SchoolId; campusMV.Schoolname = campus.SchoolName; campusMV.Schoolnum = campus.SchoolNum; _CampusList.Add(campusMV); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
/// <summary> /// 获取设备列表 /// </summary> /// <param name="schoolid"></param> /// <param name="campusid"></param> public void DateGet(string schoolno, string campusno) { try { List <AMS_DeviceModel> deviceinfolist = new List <AMS_DeviceModel>(); if (string.IsNullOrEmpty(schoolno)) { deviceinfolist = AMS_DeviceBLL.GeDeviceModelByCampusNum(null); } else { if (string.IsNullOrEmpty(campusno)) { deviceinfolist = AMS_DeviceBLL.GeDeviceModelBySchoolNum(schoolno, false); } else { deviceinfolist = AMS_DeviceBLL.GeDeviceModelByCampusNum(campusno); } } _DeviceList.Clear(); DateTime nowdt = ServerDateTime.Now.Value; foreach (AMS_DeviceModel device in deviceinfolist) { DeviceInfoViewModel deviceVM = new DeviceInfoViewModel(); deviceVM.Campusid = device.CampusId; deviceVM.Campusname = device.CampusName; deviceVM.Campusnumber = device.CampusNumber; deviceVM.Caputrepath = device.CaputrePath; if (device.CaputreTime != null) { deviceVM.LastCaputreTime = (nowdt - device.CaputreTime.Value).TotalMinutes.ToString("0.0") + "分钟前"; } deviceVM.Caputretime = device.CaputreTime; deviceVM.Describe = device.Describe; deviceVM.Flag = device.Flag; deviceVM.Id = device.Id; deviceVM.Isdel = device.IsDel; deviceVM.Number = device.Number; deviceVM.Schoolid = device.SchoolId; deviceVM.Schoolnumber = device.SchoolNumber; deviceVM.Schooname = device.SchooName; _DeviceList.Add(deviceVM); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
/// <summary> /// 数据获取 /// </summary> public bool DataGet() { try { _SchoolList.Clear(); List <AMS_SchoolModel> schoolinfolist = AMS_SchoolBLL.GetAllSchoolInfo(); foreach (AMS_SchoolModel school in schoolinfolist) { SchoolInfoViewModel schoolVM = new SchoolInfoViewModel(); schoolVM.Id = school.Id; schoolVM.Name = school.Name; schoolVM.Number = school.Number; schoolVM.ConnectionString = school.ConnectionString; schoolVM.Describe = school.Describe; schoolVM.DTUip = school.DTUip; if (school.Flag == 1) { schoolVM.Flag = true; } else { schoolVM.Flag = false; } List <AMS_CampusModel> campuslist = AMS_CampusBLL.GetCampusInfoListBySchoolNum(school.Number); List <AMS_DeviceModel> devicelist = AMS_DeviceBLL.GeDeviceModelBySchoolNum(school.Number, false); schoolVM.CampusCount = campuslist.Count; schoolVM.DeviceCount = devicelist.Count; _SchoolList.Add(schoolVM); } return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return(false); } }