示例#1
0
        public HttpResponseMessage Getdevice()
        {
            //bool result = false;
            string     errMessage  = "";
            ListDevice list_device = new ListDevice();
            string     SQL         = "SELECT id,room,status from device";
            DataSet    ds          = DeviceRepository.ReadData(SQL);

            //list_device.number = ds.Tables[0].Rows.Count;
            if (ds.Tables[0].Rows.Count > 0)
            {
                //list_user.number = ds.Tables[0].Rows.Count;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    Device item = new Device()
                    {
                        id     = dr["id"].ToString(),
                        room   = dr["room"].ToString(),
                        status = dr["status"].ToString(),
                    };

                    list_device.devices.Add(item);
                }
            }
            if (errMessage != "")
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, errMessage));
            }
            else
            {
                //Console.WriteLine(HttpStatusCode.OK);
                //return Request.CreateResponse(HttpStatusCode.OK, result);
                return(Request.CreateResponse(HttpStatusCode.OK, list_device));
            }
        }
示例#2
0
 /// <summary>
 /// Sets the walking mode for only device.
 /// </summary>
 private void setWalkingMode()
 {
     if (GridDeviceSelected.WalkingMode != chkWalkingMode.Checked)
     {
         SwapOrdinalDisplayDevice = ListDevice.FirstOrDefault(i => i.WalkingMode == true);
         ListDevice = ListDevice.Select(c => { c.WalkingMode = false; return(c); }).ToList();
         ListDevice.FirstOrDefault(i => i.DeviceId == GridDeviceSelected.DeviceId).WalkingMode = chkWalkingMode.Checked;
     }
 }
示例#3
0
        /// <summary>
        /// Sets the ordinal display.
        /// </summary>
        private void setOrdinalDisplay()
        {
            var ordinalDisplayCbo = int.Parse(cboOrdinalDisplay.SelectedValue.ToString());

            if (GridDeviceSelected.OrdinalDisplay != ordinalDisplayCbo)
            {
                var ordinalDisplayGrid = GridDeviceSelected.OrdinalDisplay;
                var lstDevice          = ListDevice.OrderBy(i => i.OrdinalDisplay).ToList();

                var selectIndex = ListDevice.FindIndex(i => i.OrdinalDisplay == ordinalDisplayCbo);
                var selectItem  = ListDevice[selectIndex];
                lstDevice[selectIndex] = GridDeviceSelected; lstDevice[selectIndex].OrdinalDisplay = ordinalDisplayCbo;

                var oldIndex = ListDevice.FindIndex(i => i.OrdinalDisplay == GridDeviceSelected.OrdinalDisplay);
                lstDevice[oldIndex] = selectItem; lstDevice[oldIndex].OrdinalDisplay = ordinalDisplayGrid;
                SwapDeviceSelected  = lstDevice[selectIndex];

                ListDevice = lstDevice;
                bindingDataGrid(ListDevice);
            }
        }