using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class test_SendRequest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //string Do = "D5620509499F1C240C7FBBDDA4D4C1C22EB36C2C5C3D74B0AC919C18AD3A13EEBC1A968F9DC8EEB45F16BC59D256D02AB8A323CB9258F48023D4021D3FA41DB3E834686D1A1FAB3C18D63C36932515089BB107133CA183DA2B8E476395D4091E0DA4E1BEC6A6F46E03E67D64329775948B5D9B38A35C5FB132E9B8BFE29DE1EB3A4C8083DB59BD78C432B3BAC850DD2C6F21402551159A4A8EA13FB97B689F1A";
        string Po = "D5620509499F1C240C7FBBDDA4D4C1C22EB36C2C5C3D74B0AC919C18AD3A13EEBC1A968F9DC8EEB45F16BC59D256D02AB3C80BE7317B439FC5DEA5CF102A2C8836D62C3BE32BB523B4629D56B75752F2F737C3F89FB8F720F812347396722BBB26CCFC6C98A5C10D3EF3372D04B65A69AF6ECF29DE3D192D47C76699BEC371B3D95E64DFD59EC4C9203E9D8E143E54E2B3D6090ACA5C40E01B23B4FDA8C82B6D2BA2AC5C0A78F8C48495D6E48E4F9D1AEB7FC37194F7B68AE2A1238E86C9CDE52479118B2745C67382CCCA72B4B3CB15291F706FF154322397A4BF197A2BE535BBAB05161B1118397CE1D01D3760AFD09BFEB135D51B99348B3AFAD8A09A201EBB7359AB6433CFD05F53B51E0EE30F3A";
       // PostData("http://venusrecharge.in/TrainService/PaymentRequest.aspx", Po);
        //PostData("http://localhost:1045/venusrecharge.in/TrainService/DoubleVerification.aspx", Do);

        string FormName = "form1";
        string Method = "post";
        string V3URL = "http://venusrecharge.in/TrainService/PaymentRequest.aspx";
        Response.Clear();
        Response.Write("<html><head>");
        Response.Write("<META HTTP-EQUIV=\"CACHE-CONTROL\" CONTENT=\"no-store, no-cache, must-revalidate\" />");
        Response.Write("<META HTTP-EQUIV=\"PRAGMA\" CONTENT=\"no-store, no-cache, must-revalidate\" />");
        Response.Write(string.Format("</head><body onload=\"document.{0}.submit()\">", FormName));
        Response.Write(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >", FormName, Method, V3URL));

        //foreach (KeyValuePair<string, string> param in postparamslist)
        //{
        //    Response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\" />", param.Key, param.Value));
        //}
        // Response.Write("<input type=\"hidden\" name=\"response\" value=" + md5HashData + " />");
        Response.Write("<input type=\"hidden\" name=\"encdata\" value=" + Po + " />");
        Response.Write("</form>");
        Response.Write("</body></html>");
        Response.End();
    }
    public void PostData(string Url, string PostData)
    {
        string strUrl = Url + "?encdata=" + PostData;
        InsertLog("SendRequest", strUrl);
        WebRequest request = HttpWebRequest.Create(strUrl);
        request.Method = "POST";
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream s = (Stream)response.GetResponseStream();
        StreamReader readStream = new StreamReader(s);
        string dataString = readStream.ReadToEnd();
        response.Close();
        s.Close();
        readStream.Close();
    }


    public void InsertLog(string ServiceName, string Log)
    {
        SqlParameter[] warlock = new SqlParameter[]
        {
            new SqlParameter("@ServiceName",ServiceName),
            new SqlParameter("@LogData",Log)
        };
        int a = SqlHelper.ExecuteNonQuery(SqlHelper.mainConnectionString, CommandType.StoredProcedure, "Insert_Train_Log", warlock);
    }
}