using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Text;
using System.Reflection;
using System.Collections;
using System.Data.Common;
using System.Xml;
using System.Web.Script.Serialization;

namespace BeginScreen
{
    /// <summary>
    /// HandlerBase 的摘要说明
    /// </summary>
    public abstract class HandlerBase : IHttpHandler, System.Web.SessionState.IRequiresSessionState
    {
        public virtual void OnInit()
        {

        }

        #region 虚 方法
        public void ProcessRequest(HttpContext context)
        {
            OnInit();

            context.Response.ContentType = "text/plain";

            //context.Response.ContentType = "application/json";
            context.Response.Buffer = true;
            context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
            context.Response.AddHeader("pragma", "no-cache");
            context.Response.AddHeader("cache-control", "");
            context.Response.CacheControl = "no-cache";

            if (HttpContext.Current.Request["cmd"] != null)
            {
                string cmd = HttpContext.Current.Request["cmd"];
                var method = this.GetType().GetMethod(cmd);
                if (method != null)
                {
                    method.Invoke(this, new object[] { context });
                }
            }
        }
        #endregion

        #region 错误处理方法
        public class message
        {
            public message(bool success, string msg, string countPage, string workerCurrentPage)
            {
                this.msg = msg;
                this.success = success;
                this.countPage = countPage;
                this.workerCurrentPage = workerCurrentPage;
            }
            public bool success { get; set; }
            public string msg { get; set; }
            public string countPage { get; set; }
            public string workerCurrentPage { get; set; }
        }
        public class message1
        {
            public message1(bool success, string html, string msg, string systemType, string sendType, int messId, string countPage, string workerCurrentPage)
            {
                this.msg = msg;
                this.success = success;
                this.html = html;
                this.countPage = countPage;
                this.workerCurrentPage = workerCurrentPage;
                this.sendType = sendType;
                this.systemType = systemType;
                this.messId = messId;
            }
            public int messId { get; set; }
            public bool success { get; set; }
            public string html { get; set; }
            public string msg { get; set; }
            public string countPage { get; set; }
            public string workerCurrentPage { get; set; }
            public string sendType { get; set; }
            public string systemType { get; set; }
        }

        #endregion


        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}