using qdr.fnd.core.pqueue.Exceptions;
using Quadarax.Foundation.Core.Data;
using Quadarax.Foundation.Core.Logging;

namespace qdr.fnd.core.pqueue.Process
{
    public class PsProcessProviderDummy : PsProcessProviderBase
    {

        #region *** Constants ***
        /// <summary>
        /// (Input) Argument name for the result code. Type is <see cref="string"/>
        /// </summary>
        public const string CS_ARG_INPUT_TEXT = "input-text";
        #endregion


        #region *** Constructors ***
        public PsProcessProviderDummy(ProcessDoneCallback processDoneCallback, ProcessStdOutputCallback processStdOutputCallback, string itemId, TypedArgument[] arguments, ILogger logger) : base(processDoneCallback, processStdOutputCallback, itemId, arguments, logger)
        {
        }
        #endregion

        #region *** Overrides ***
        public new static IEnumerable<TypedArgument> CreateArguments()
        {
            var list = new List<TypedArgument>(PsProcessProviderBase.CreateArguments());
            list.Add(new TypedArgument(CS_ARG_INPUT_TEXT, typeof(string), true));
            return list;    
        }

        protected override void OnValidate()
        {
            base.OnValidate();
            if (!ContainsArgument(CS_ARG_INPUT_TEXT) || !Arguments[CS_ARG_INPUT_TEXT].IsOutput)
                throw new PsProcessProviderException(PsProcessProviderException.ErrorCodes.ProcessProviderNotDefinedArgument, GetType().Name, ItemId, CS_ARG_INPUT_TEXT);
        }

        protected override Task OnProcess()
        {
            Arguments[CS_ARG_RESULT_CODE].Value = "0";
            Arguments[CS_ARG_RESULT_TEXT].Value = GetArgumentValue<string>(CS_ARG_INPUT_TEXT);
            return base.OnProcess();
        }
        #endregion
    }
}
