예제 #1
0
        private async void getDevices()
        {
            string query = "SELECT * FROM devices";

            var cmd    = new MySql.Data.MySqlClient.MySqlCommand(query, conn);
            var reader = cmd.ExecuteReader();

            devices = new List <Info.Combination>();

            while (reader.Read())
            {
                String DeviceName = (String)reader["DeviceName"];
                String DeviceId   = (String)reader["DeviceId"];
                String IP         = (String)reader["IP"];
                String Port       = (String)reader["Port"];
                String Mac        = (String)reader["Mac"];
                Int64  Id         = (Int64)reader["Id"];

                Info.Device device = new Info.Device();
                device.DeviceId   = DeviceId;
                device.DeviceName = DeviceName;
                device.IP         = IP;
                device.Port       = Port;
                device.Mac        = Mac;
                device.Id         = Id;

                await connectToDevice(device, UpdateUi);
            }
            reader.Close();
            UpdateUi(true);
        }
예제 #2
0
        private void getDevices()
        {
            string query = "SELECT * FROM devices where officeCode = '" + config + "'";

            var cmd    = new MySql.Data.MySqlClient.MySqlCommand(query, conn);
            var reader = cmd.ExecuteReader();

            devices = new List <Info.Combination>();

            List <Info.Device> tempDevices = new List <Info.Device>();

            while (reader.Read())
            {
                String DeviceName = (String)reader["device_name"];
                String DeviceId   = (String)reader["device_id"];
                String IP         = (String)reader["ip"];
                String Port       = (String)reader["port"];
                String Mac        = (String)reader["mac"];
                Int64  Id         = (Int64)reader["id"];
                String officeCode = (String)reader["officeCode"];

                Info.Device device = new Info.Device();
                device.DeviceId   = DeviceId;
                device.DeviceName = DeviceName;
                device.IP         = IP;
                device.Port       = Port;
                device.Mac        = Mac;
                device.Id         = Id;
                device.officeCode = officeCode;

                tempDevices.Add(device);
            }
            reader.Close();
            for (int ii = 0; ii < tempDevices.Count; ii++)
            {
                connectToDevice(tempDevices[ii]);
            }
        }