using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static FaceTransfer.TransferFace;

namespace FaceTransfer
{
    class TransferFaceDAO
    {
        public MachineInfo GetMachine(string emp, MySqlConnection connection)
        {
            MachineInfo machineInfo = new MachineInfo();
            string query = "SELECT a.*, b.machine_ip, b.port_number FROM attendance_machine_user a, attendance_machine b WHERE a.serial_number = " + emp + " AND a.is_deleted = 0 AND a.machine_id = b.machine_id LIMIT 1;";
            MySqlCommand cmd = new MySqlCommand(query, connection);
            MySqlDataReader reader = cmd.ExecuteReader();
            if (reader.Read())
            {
                machineInfo.MachineIp = reader.GetString("machine_ip");
                machineInfo.PortNumber = reader.GetInt32("port_number");
            }

            reader.Close();
            return machineInfo;
        }
    
    }
}
