public IHttpActionResult CabinetMap() { if (!UserController.LoginDictionary.ContainsKey(GetCookie("token"))) { return(Logout()); } UserInfo userCookie = UserController.LoginDictionary[GetCookie("token")]; if (userCookie == null) { return(Logout()); } try { List <Cabinet> cabinetList = Cabinet.GetAll(); List <Department> departList = Department.GetAll(); Department root = departList.Find(m => m.ID == userCookie.DepartmentID); return(Success(FindCabinetTree(root, departList, cabinetList))); } catch (Exception ex) { _logger.Error(ex); return(Failure(ex.Message)); } }
public IHttpActionResult GetAll() { try { var cabinetList = Cabinet.GetAll().FindAll(m => (m.Status == 1 || m.Status == 4)); foreach (var m in cabinetList) { var log = CabinetLog.GetOpenLog(m.ID); if (log == null || log.CreateTime.AddSeconds(60) < DateTime.Now) { m.Status = 3; Cabinet.Update(m); _logger.Info("自动重置关闭"); } } var list = Cabinet.GetAll(); var model = list.Select(m => new BxgModel { Name = m.Name, Mac = m.AndroidMac, IP = m.IP, IsOnline = m.IsOnline ?? false, LastOnlineTime = (m.LastOnlineTime == null) ? "" : m.LastOnlineTime?.ToString("yyyy-MM-dd HH:mm:ss"), //正常开门 = 1, //正常关门 = 3, //非工作时间开门 = 4, //非工作时间关门 = 5, //外部电源断开 = 6, //备份电源电压低 = 7, //未按规定关门 = 8, //强烈震动 = 9, //网络断开 = 10, Status = (m.Status == 1 || m.Status == 4) ? 1 : 0, StatusDes = (m.Status == null ? "" : Enum.GetName(typeof(OperatorTypeEnum), m.Status)), }).ToList(); var item = new ResultModel() { Success = 1, Message = "", Data = model }; return(Json <ResultModel>(item)); } catch (Exception ex) { logger.Error(ex); var item = new ResultModel() { Success = 0, Message = "获取数据失败", Data = null }; return(Json <ResultModel>(item)); } }
/// <summary> /// Refreshes items in cabinetBox according to chosen Corps /// </summary> void OnCorpsChanged(object sender, RoutedEventArgs rea) { cabinetBox.Items.Clear(); try { foreach (Cabinet cabinet in Cabinet.GetAll(corpsBox.SelectedItem as Corps)) { cabinetBox.Items.Add(cabinet); } cabinetBox.SelectedIndex = 0; } catch (NoSuchDataException) { } }
public AddDeviceDialog(SuperUserWindow parent) : base(parent) { // Picking N/A Corps as a default value in ComboBox for (int i = 0; i < corpsBox.Items.Count; i++) { var currentCorps = corpsBox.Items[i] as Corps; if (currentCorps.Name == "N/A") { corpsBox.SelectedIndex = i; } } // Picking cabinet according to Corps foreach (Cabinet cabinet in Cabinet.GetAll(corpsBox.SelectedItem as Corps)) { cabinetBox.Items.Add(cabinet); } cabinetBox.SelectedIndex = 0; // Hiding statusBox - any device addition means putting it into storage contentLayout.Children.Remove(checkBoxLayout); }
private void DisplayDeviceData() { serialNumberBox.Text = SelectedDevice.SerialNumber.ToString(); inventoryNumberBox.Text = SelectedDevice.InventoryNumber; networkNameBox.Text = SelectedDevice.NetworkName; try { for (int i = 0; i < deviceTypeBox.Items.Count; i++) { if (SelectedDevice.Type.ID == (deviceTypeBox.Items[i] as DeviceType).ID) { deviceTypeBox.SelectedIndex = i; break; } } } catch (NoSuchDataException) { } try { for (int i = 0; i < corpsBox.Items.Count; i++) { var currentCorps = corpsBox.Items[i] as Corps; if (SelectedDevicelastHistoryNote.CorpsID == currentCorps.ID) { corpsBox.SelectedIndex = i; break; } } } catch (NoSuchDataException) { for (int i = 0; i < corpsBox.Items.Count; i++) { var currentCorps = corpsBox.Items[i] as Corps; if (currentCorps.Name == "N/A") { corpsBox.SelectedIndex = i; break; } } } try { foreach (Cabinet cabinet in Cabinet.GetAll(corpsBox.SelectedItem as Corps)) { cabinetBox.Items.Add(cabinet); } for (int i = 0; i < cabinetBox.Items.Count; i++) { var currentHistoryNote = History.GetDeviceLastHistoryNote(SelectedDevice); if (currentHistoryNote.Cabinet.ID == (cabinetBox.Items[i] as Cabinet).ID) { cabinetBox.SelectedIndex = i; break; } } } catch (NullReferenceException) { } }