using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Vrh.Web.OneReport.ReportViewerForMvc
{
    /// <summary>
    /// Class for handled parameters in ReportViewerWebForm.aspx call
    /// </summary>
    public class ReportViewerWebFormParameterParser
    {
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="parameters">parameter collection</param>
        public ReportViewerWebFormParameterParser(NameValueCollection parameters)
        {
            _parameters = parameters;
        }

        /// <summary>
        /// Get AsyncPostBackTimeOut parameter from collection
        /// </summary>
        public int AsyncPostBackTimeOut
        {
            get
            {
                int value = 90;
                try
                {
                    string strValue = _parameters[ASYNCPOSTBACKTIMEOUT];
                    if (!String.IsNullOrEmpty(strValue))
                    {
                        Int32.TryParse(strValue, out value);
                    }
                }
                catch{ }
                return value;                
            }
        }

        /// <summary>
        /// parameter collection
        /// </summary>
        private NameValueCollection _parameters;

        /// <summary>
        /// Name of AsyncPostBackTimeOut parameter
        /// </summary>
        private const string ASYNCPOSTBACKTIMEOUT = "AsyncPostBackTimeOut"; 
    }
}
