using System.Collections.Generic;
using System.Linq;

namespace IOB_UT_NEXT.Config.Base
{
    /// <summary>
    /// Set comandi URI x chiamate server
    /// </summary>
    public class CmdUriDto
    {
        #region Public Constructors

        /// <summary>
        /// Init classe gestione comandi
        /// </summary>
        /// <param name="baseURI"></param>
        public CmdUriDto(string baseURI)
        {
            _baseUri = baseURI;
        }

        #endregion Public Constructors

        #region Public Properties

        /// <summary>
        /// comando base x USER LOG - salvataggio parametri extra sistema MAPO
        /// </summary>
        public string ULog { get; set; } = "IOB/ulog/";

        /// <summary>
        /// comando base x USER LOG - salvataggio parametri extra sistema MAPO in modalità JSON
        /// payload come lista
        /// </summary>
        public string ULogJson { get; set; } = "IOB/ulogJson/";

        #endregion Public Properties

        #region Public Methods

        /// <summary>
        /// Recupera path/URI comando richiesto (SE disponibile) senno default
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string GetCommand(string key)
        {
            // default ad implicito con IOB...
            string answ = $"{_baseUri}/{key}/";
            if (CurrSetup.ContainsKey(key))
            {
                answ = CurrSetup[key];
            }
            return answ;
        }

        public Dictionary<string, string> StdCommands()
        {
            CurrSetup = new Dictionary<string, string>();
            //CurrSetup.Add("alive", "IOB");
            CurrSetup.Add("alive", _baseUri);
            //CurrSetup.Add("Base", "IOB/input/");
            //CurrSetup.Add("BaseJson", "IOB/evListJson/");
            //CurrSetup.Add("RawTransfJson", "IOB/rawTransfJson/");
            //CurrSetup.Add("Enabled", "IOB/enabled/");
            //CurrSetup.Add("Flog", "IOB/flog/");
            //CurrSetup.Add("FlogJson", "IOB/flogJson/");
            //CurrSetup.Add("fixDailyDossier", "IOB/fixDailyDossier/");
            //CurrSetup.Add("fixDailyOdl", "IOB/fixDailyOdl/");
            //CurrSetup.Add("fixDailyOdlConfPzCount", "IOB/fixDailyOdlConfPzCount/");
            //CurrSetup.Add("forceCreatePOdl", "IOB/forceCreatePOdl/");
            //CurrSetup.Add("forceSplitOdlFull", "IOB/forceSplitOdlFull/");
            //CurrSetup.Add("getPOdlAct", "IOB/getPOdlAct/");
            //CurrSetup.Add("IdleTime", "IOB/getIdlePeriod/");
            //CurrSetup.Add("OdlStarted", "IOB/getCurrOdlStart/");
            //CurrSetup.Add("Reboot", "IOB/sendReboot.aspx?idxMacchina=");
            //CurrSetup.Add("savePzCountInc", "IOB/savePzCountInc/");
            //CurrSetup.Add("savePzCountIncAtDate", "IOB/savePzCountIncAtDate/");
            // riordino
            CurrSetup = CurrSetup.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value);
            return CurrSetup;
        }

        #endregion Public Methods

        #region Protected Properties

        protected string _baseUri { get; set; } = "IOB";
        protected Dictionary<string, string> CurrSetup { get; set; } = new Dictionary<string, string>();

        #endregion Protected Properties
    }
}