using BLWWS_BLL;
using System.Data;

namespace BLWWSCore.SOAP
{
    public class syncstatus:Isyncstatus
    {
         /// <summary>
        /// 获取客户记录
        /// </summary>
        /// <param name="code"></param>
        /// <param name="roomNumber"></param>
        /// <returns></returns>
        public DataSet GetRoomRecord(string code, string roomNumber, string tableName)
        {
            try
            {
                return BLL.GetRoomRecords(code, roomNumber, tableName);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return null;
        }
        /// <summary>
        /// 根据酒店ID，房号获取当前入住人信息
        /// </summary>
        /// <param name="hotelID">酒店ID</param>
        /// <param name="roomNumber">房号</param>
        /// <returns></returns>
        public string GetRoomCustomerByHotelID(int hotelID, string roomNumber, ref string phoneNumber)
        {
            try
            {
                return BLL.GetRoomCustomer(hotelID, roomNumber, ref phoneNumber);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return "";
        }
        /// <summary>
        /// 获取入住人信息
        /// </summary>
        /// <param name="checkInID"></param>
        /// <returns></returns>
        public DataSet GetRoomCustomer(long checkInID)
        {
            try
            {
                return BLL.GetRoomCustomer(checkInID);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return null;
        }
        /// <summary>
        /// 获取酒店编码
        /// </summary>
        /// <returns></returns>
        public DataSet GetHotelCode()
        {
            try
            {
                return BLL.GetHotelCode();
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return null;
        }
        /// <summary>
        /// 获取酒店编码
        /// </summary>
        /// <returns></returns>
        public DataTable GetHotelByCode(string code)
        {
            try
            {
                return BLL.GetHotelCode(code);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return null;
        }
        /// <summary>
        /// 定时获取酒店新的开房/退房/待租记录
        /// </summary>
        /// <param name="code">酒店编码</param>
        /// <returns></returns>
        public DataSet GetCheckInOrOutRecord(string code)
        {
            try
            {
                return BLL.GetCheckInOrOutRecord(code);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return null;
        }
        /// <summary>
        /// 获取人脸机设备信息
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public DataSet GetDevices(string code)
        {
            try
            {
                return BLL.GetDevices(code);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return null;
        }
        /// <summary>
        /// 人脸机绑定房号
        /// </summary>
        /// <param name="id"></param>
        /// <param name="hotelCode"></param>
        /// <param name="roomNumber"></param>
        /// <returns></returns>
        public int SaveDevice(long id, string hotelCode, string roomNumber)
        {
            try
            {
                return BLL.SaveDevice(id, hotelCode, roomNumber);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return 0;
        }
        /// <summary>
        /// 更新已同步的新开房/退房/待租状态
        /// </summary>
        /// <param name="code">酒店编码</param>
        /// <param name="id">记录ID</param>
        /// <param name="flag">0开房，1退房，2待租</param>
        /// <returns></returns>
        public int UpdateCheckInOrOutRecord(string code, Int64 id, int flag)
        {
            try
            {
                return BLL.UpdateCheckInOrOutRecord(code, id, flag);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return 0;
        }
        /// <summary>
        /// 判断验证码是否正确
        /// </summary>
        /// <param name="hotelID">酒店ID</param>
        /// <param name="roomNumber">房号</param>
        /// <param name="validateCode">用户输入验证码</param>
        /// <returns></returns>
        public bool ValidateNumber(int hotelID, string roomNumber, string validateCode)
        {
            try
            {
                return BLL.ValidateNumber(hotelID, roomNumber, validateCode);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return false;
        }
        /// <summary>
        /// 判断验证码是否正确
        /// </summary>
        /// <param name="code">酒店编码</param>
        /// <param name="roomNumber">房号</param>
        /// <param name="validateCode">用户输入验证码</param>
        /// <returns></returns>
        public bool ValidateNumberByCode(string code, string roomNumber, string validateCode)
        {
            try
            {
                return BLL.ValidateNumberByCode(code, roomNumber, validateCode);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return false;
        }
        /// <summary>
        /// 根据手机号获取当前入住记录信息
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        public DataTable GetCodeAndRoomNumberByPhone(string phone)
        {
            try
            {
                return BLL.GetCodeAndRoomNumberByPhone(phone);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return null;
        }
        /// <summary>
        /// 上传/变更图像及信息
        /// </summary>
        /// <param name="idType">证件类型：0身份证，1护照</param>
        /// <param name="idCard">证件号码</param>
        /// <param name="name">姓名</param>
        /// <param name="sex">性别：0女，1男</param>
        /// <param name="photo">图像</param>
        /// <returns></returns>
        public bool UploadPhoto(int idType, string idCard, string name, int sex, string birthday, byte[] photo)
        {
            try
            {
                if (BLL.UploadPhoto(idType, idCard, name, sex, birthday, photo) > 0)
                {
                    return true;
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return false;
        }
        /// <summary>
        /// 人脸识别
        /// </summary>
        /// <param name="photo"></param>
        /// <param name="idType"></param>
        /// <param name="idCard"></param>
        /// <param name="name"></param>
        /// <param name="sex"></param>
        /// <param name="matchPhoto"></param>
        /// <returns></returns>
        public bool FaceMatch(byte[] photo, ref int idType, ref string idCard, ref string name, ref int sex, ref byte[] matchPhoto)
        {
            try
            {
                return BLL.FaceMatch(photo, ref idType, ref idCard, ref name, ref sex, ref matchPhoto);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex.ToString());
            }
            return false;
        }
    }
}
