using ESoft.Script;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESToolkit;
using System.Data;
using ESToolkit.Helper;
using ESoft.Public.Struct;
using ESoft.Public.Enum;
using System.Collections.Specialized;
using System.IO;

namespace ESoft.Web
{
    public class wxbg : WebScript
    {
        public override void Run() {
            string str = File.ReadAllText(Toolkit.FilePath + "Web\\wxbg.htm");
			
			string appId=WeChatHelper.AppID;
			string timestamp=Toolkit.ToString(DateTimeHelper.DateTimeToTimeStamp(DateTime.Now));
			string nonceStr=Toolkit.GetRandomString(8);
			
			
			string signStr="jsapi_ticket="+WeChatHelper.GetJsapiTicket()+"&noncestr="+nonceStr+"&timestamp="+timestamp+"&url=http://192.168.103.116:8000/web/wxbg.cs";
			string signature=Toolkit.SHA1Encrypt(signStr);
			str=str.Replace("{appId}",appId).Replace("{timestamp}",timestamp).Replace("{nonceStr}",nonceStr).Replace("{signature}",signature);
            byte[] bs = Encoding.UTF8.GetBytes(nonceStr);
            ListenerContext.Response.OutputStream.Write(bs,0,bs.Length);

        }
    }
    
}
