using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace MesAdaptor
{
    public enum MesType
    {
        none,
        shinewave,
        sajet,
        sajet2,
        test
    }

    public class SajetConnect
    {
        public static ISajetConnect Instance { get; private set; }

        //public static bool IsEmsEnabled { get; set; } = true;

        private static MesType _Type = MesType.none;
        public static MesType Type
        {
            get => _Type;
            set
            {
                _Type = value;
                switch (_Type)
                {
                    case MesType.none:
                        Instance = null;
                        break;
                    case MesType.sajet:
                        Instance = new SajectConnectSajet();
                        break;
                    case MesType.shinewave:
                        Instance = new SajetConnectShinewave();
                        break;
                    case MesType.test:
                        Instance = new SajectConnectTest();
                        break;
                }
            }
        }

        public static bool SajetTransStart() => Instance.SajetTransStart();
        public static bool SajetTransClose() => Instance.SajetTransClose();
        public static bool SajetTransSignIn(ref string data) => Instance.SajetTransSignIn(ref data);
        public static bool SajetTransWoCheck(ref string workOrder) => Instance.SajetTransWoCheck(ref workOrder);
        public static bool SajetTransSnCheck(ref string serialNumber) => Instance.SajetTransWoCheck(ref serialNumber);
        public static bool SajetTranFinishSuccess() => Instance.SajetTranFinishSuccess();
        public static bool SajetTranFinishFail(MesErrorCode errorCode) => Instance.SajetTranFinishFail(errorCode);
        public static string SajetTransRegisterHeader(string model, string header) => Instance.SajetTransRegisterHeader(model, header);
        public static bool SajetTransReport(Dictionary<string, string> reportPair) => Instance.SajetTransReport(reportPair);
        public static bool SajetTransLog(string data) => Instance.SajetTransLog(data);
    }
}