using System;
using System.Data;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using SystemX.Net.BaseProtocol;
using SystemX.Net.XAdaptor;
using static SystemX.Net.XAdaptor.PC.XAdaptorPC;

namespace SystemX.Net.XAdaptor.PC
{
    public interface IDataSaveTable
    {
        string GetTableName();
    }
    public interface IXPCAdaptor
    {
        //Common query object
        DataSet WaitUserQuery(string strQuery);

        //bool Login(string strHost, string strSection, bool bUseUIM = false, bool bSimpleLookupOption = false);

        /// <summary>
        /// Requires running the program with administrator privileges.
        /// </summary>
        /// <param name="bAutoApplyWinTime"></param>
        /// <returns></returns>
        Task<bool> WaitSyncTimeServer(bool bAutoApplyWinTime = true);

        //bool WaitCheckServerState();

        Task<bool> RestoreConnAfterConfirmConn(bool bRetryAutoConnect = true);

        bool SetCustomPacket(params string[] strSetInfo);

        /*
        bool WaitCheckTestList(uint nStationID, string strProdNo_C,
           string strTestType,
           string strTestCode,
           string strTestListVersion,
           string strProductionCode);
        */

        Task<bool> AsyncWaitCheckTestList(uint nStationID, string strProdNo_C,
            string strTestType,
            string strTestCode,
            string strTestListVersion,
            string strProductionCode);

        bool QueryTestList(uint nStationID, string strProdNo_C,
            string strTestType,
            string strTestCode,
            string strTestListVersion,
            string strProductionCode);

        /*
        bool WaitQueryTestList(uint nStationID, string strProdNo_C,
            string strTestType,
            string strTestCode,
            string strTestListVersion,
            string strProductionCode);
        */
        Task<Tuple<string, int>> GetTestListQueryWithFilePath(string strFilePath, uint nStationID, string strProdNo_C,
          string strTestType,
          string strTestCode,
          string strTestListVersion,
          string strProductionCode,
          bool bCheckAfter = false);

        Task<bool> AsyncWaitQueryTestList(uint nStationID, string strProdNo_C,
            string strTestType,
            string strTestCode,
            string strTestListVersion,
            string strProductionCode);

        //File Transfer
        //FileSendRecvResult CPLogFileTransfer(string strFilePos, ushort usPalletIndex = 0);
        //bool CPLogFileTransfer(MemoryStream ms, ushort usPalletIndex);

        Task<eFileSendRecvResult> AsyncCPLogFileTransfer(string strFilePos,
           string targetStationName,
           int targetTestListNo,
           string targetProcNo_P,
           string targetProcNo_C,
           string targetTestType,
           string targetTestCode,
           string targetVersion,
           string targetProdCode);

        eFileSendRecvResult SendCustomFile(string strFilePos, bool bRecvResultWait = false, ushort usPalletIndex = 0);

        eSetConfigFileResult SetConfigureFile(string strFilePos);
    }
}
