<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetResult.aspx.cs" Inherits="SampleCS.NotifyCallback" %>

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Text" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <%
        // 要使用各种Srv必须先使用LoadConf载入配置

        String strUrl, MerId, UserId, Pwd, PaySuc, ShoppingTime, BeginTime, EndTime, OrderNo, strBody;
        
        strUrl = "http://test.gnete.com:8888/bin/scripts/Openvendor/gnete/V34/GetPayResult.asp";
        MerId = "198";
        UserId = "198";
        Pwd = "a123456";
        PaySuc = "1";
        ShoppingTime = "";
        BeginTime = DateTime.Now.ToString("yyyy-MM-dd");
        BeginTime = BeginTime+" 00:00:00";
        EndTime = DateTime.Now.ToString("yyyy-MM-dd")+" 23:00:00";
        OrderNo = "";

        BeginTime = HttpUtility.UrlEncode(BeginTime);
        EndTime = HttpUtility.UrlEncode(EndTime);

        strBody = "Merid=" + MerId + "&userid=" + UserId + "&pwd=" + Pwd + "&paysuc=" + PaySuc + "&shoppingtime=" + ShoppingTime + "&BeginTime=" + BeginTime + "&endtime=" + EndTime + "&orderno=" + OrderNo;
       

        Stream responseStream;
        HttpWebRequest request = WebRequest.Create(strUrl) as HttpWebRequest;
        const string sContentType = "application/x-www-form-urlencoded";  
        // request.UserAgent = sUserAgent;
        request.ContentType = sContentType;
        request.Method = "POST";
        request.ContentLength = strBody.Length;
        Stream requestStream = request.GetRequestStream();
        requestStream.Write(Encoding.GetEncoding("UTF-8").GetBytes(strBody), 0, strBody.Length);
        requestStream.Close();
        try
        {
            responseStream = request.GetResponse().GetResponseStream();
        }
        catch (Exception exception)
        {
            Response.Write(exception.Message);
            throw exception;
        }
        string str = string.Empty;
        using (StreamReader reader = new StreamReader(responseStream, Encoding.GetEncoding("UTF-8")))
        {
            str = reader.ReadToEnd();
        }
        responseStream.Close();
        //打印返回字符串
        Response.Write(str);
        
         %>
    </div>
    </form>
</body>
</html>
