using IOB_UT_NEXT;
using IOB_WIN_WS.Iob;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IOB_WIN_WS
{
    public class AdapterFormNext : IOB_WIN_FORM.AdapterForm
    {

        /// <summary>
        /// Avvio MainForm
        /// </summary>
        /// <param name="codIOB"></param>
        public AdapterFormNext(string codIOB) : base(codIOB)
        {
        }
        /// <summary>
        /// carica IOB richiesto
        /// </summary>
        protected override async Task loadIobType()
        {
            if (IOBConfFull != null)
            {
                switch (tipoScelto)
                {

                    case tipoAdapter.IcoelSoap:
                        iobObj = new IobWs.IcoelSoap(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.REST:
                        iobObj = new IobWs.RestBase(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.REST_CITIZEN:
                        iobObj = new IobWs.Citizen(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.REST_EMMEGI_FPW:
                        iobObj = new IobWs.EmmegiFPW(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SOAP_GOMBA:
                        iobObj = new IobWs.Gomba(this, IOBConfFull);
                        btnStart.Enabled = true;
                        break;

                    case tipoAdapter.SIMULA:
                    case tipoAdapter.ND:
                    default:
                        iobObj = new IOB_WIN_FORM.Iob.Simula(this, IOBConfFull);
                        btnStart.Enabled = false;
                        break;
                }
                if (!await iobInitAsync())
                {
                    return;
                }
                UpdateDisplTypeIobSel();
            }
        }
    }
}
