Vous êtes sur la page 1sur 5

protected void Btn_1B_New_Click(object sender, EventArgs e)

{
try
{
string tkt_GDS = "1A";
#region <dt> - Transaction Name List

DataTable dt = new DataTable();


dt.Reset();

dt.Columns.Add("TransactionName", typeof(string));
dt.Columns.Add("MessageHeaderID", typeof(string));
dt.Columns.Add("Version", typeof(string));
dt.Columns.Add("PartyIdType", typeof(string));
dt.Columns.Add("PartyIdToValue", typeof(string));
dt.Columns.Add("PartyIdFromValue", typeof(string));
dt.Columns.Add("CPAID", typeof(string));
dt.Columns.Add("ConversationId", typeof(string));
dt.Columns.Add("ServiceType", typeof(string));
dt.Columns.Add("ServiceValue", typeof(string));
dt.Columns.Add("Action", typeof(string));
dt.Columns.Add("PseudoCityCode", typeof(string));
dt.Columns.Add("RequestedID", typeof(string));
dt.Columns.Add("RequestType", typeof(string));
dt.Columns.Add("CompanyCode", typeof(string));
dt.Columns.Add("CompanyType", typeof(string));
dt.Columns.Add("MDRSubSetCode", typeof(string));
dt.Columns.Add("MaxResponse", typeof(string));

#region <dtsession>

DataRow dr = dt.NewRow();
dr["TransactionName"] = "SessionCreate";
dr["MessageHeaderID"] = "mid:20001209-133003-2333@clientURL";
dr["Version"] = "";
dr["PartyIdType"] = "NULLurn:x12.org:IO5:01";
dr["PartyIdToValue"] = "https://webservices.sabre.com/websvc";
dr["PartyIdFromValue"] = "URLofclient@client.com";
dr["CPAID"] = "IPCC";
dr["ConversationId"] = "ABC123@clientURL.com";
dr["ServiceType"] = "sabreXML";
dr["ServiceValue"] = "Session";
dr["Action"] = "SessionCreateRQ";
dr["PseudoCityCode"] = "D6ND";
dr["RequestedID"] = "";
dr["RequestType"] = "";
dr["CompanyCode"] = "";
dr["CompanyType"] = "";
dr["MDRSubsetCode"] = "";
dr["MaxResponse"] = "200";
dt.Rows.Add(dr);

#endregion

#region <dtTransaction>

DataRow dr1 = dt.NewRow();


dr1["MessageHeaderID"] = "mid:20001209-133003-2333@clientURL";
dr1["Version"] = "2.0.0";
dr1["PartyIdType"] = "NULLurn:x12.org:IO5:01";
dr1["PartyIdToValue"] = "5678";
dr1["PartyIdFromValue"] = "1234";
dr1["CPAID"] = "IPCC";
dr1["ConversationId"] = "ABC123@clientURL.com";
dr1["ServiceType"] = "AbacusXML";

if (tkt_GDS == "1B")
{
dr1["TransactionName"] = "eTicketCouponLLSRQ";
dr1["ServiceValue"] = "eTicketCouponLLSRQ";
dr1["Action"] = "eTicketCouponLLSRQ";
}
else
{
dr1["TransactionName"] = "SabreCommandLLSRQ";
dr1["ServiceValue"] = "SabreCommandLLSRQ";
dr1["Action"] = "SabreCommandLLSRQ";
}

dr1["PseudoCityCode"] = "D6ND";
dr1["RequestedID"] = "1";
dr1["RequestType"] = "1";
dr1["CompanyCode"] = "TN";
dr1["CompanyType"] = "TN";
dr1["MDRSubsetCode"] = "PN42";
dr1["MaxResponse"] = "200";
dt.Rows.Add(dr1);

#endregion

DataRow dr2 = dt.NewRow();


dr2["TransactionName"] = "SessionClose";
dr2["MessageHeaderID"] = "mid:20001209-133003-2333@clientURL";
dr2["Version"] = "";
dr2["PartyIdType"] = "NULLurn:x12.org:IO5:01";
dr2["PartyIdToValue"] = "OZ.com";
dr2["PartyIdFromValue"] = "www.Abacus.com";
dr2["CPAID"] = "IPCC";
dr2["ConversationId"] = "ABC123@clientURL.com";
dr2["ServiceType"] = "OTA";
dr2["ServiceValue"] = "SessionCloseRQ";
dr2["Action"] = "SessionCreateRQ";
dr2["PseudoCityCode"] = "D6ND";
dr2["RequestedID"] = "";
dr2["RequestType"] = "";

dr2["CompanyCode"] = "";
dr2["CompanyType"] = "";
dr2["MDRSubsetCode"] = "PN42";
dr2["MaxResponse"] = "200";

dt.Rows.Add(dr2);

#endregion
Dictionary<string, string> Xml1 = new Dictionary<string, string>();
//sabre
string ticketno = txtRecordLocator.Text.Trim();// 0985671909376;//
"0985672186906"; //"0985671909376";//"5895664247271";// //

int noofticket = int.Parse(txtLName.Text.Trim());


//amadeud
//string ticketno = "5895664247271";

string URL = "https://webservices.sabre.com/websvc";


string userid = "952813";
string password = "WS251739";
string orgCode = "D6ND";

//string userid = "9102";


//string password = "focus20";
//string orgCode = "2J5D";
//string orgCode = "D6ND";
string domain = "default";

DataSet dsSessionKey = new DataSet();


dsSessionKey.Reset();

dsSessionKey = getSessionKey("1B");
getpnrBookingDetail_1B objData = new getpnrBookingDetail_1B(userid,
password, domain, URL, orgCode, dt);

DataSet dsResult = new DataSet();


dsResult.Reset();
string signature = "";

if (dsSessionKey.Tables[0].Rows.Count > 0)
{
signature = dsSessionKey.Tables[0].Rows[0]
["session_key"].ToString();
}
else
{
signature = objData.createSessionGDS();

if (signature != "FAIL-TK")
{
int count = insertSessionKey(signature, "1B");
}
}

if (signature != "FAIL-TK")
{
dsResult = objData.getBookingFromTicketNo_1B(ticketno, noofticket,
tkt_GDS, out Xml1, signature.Trim());
}

if (dsSessionKey.Tables.Count > 1)
{
DataTable dtOldKey = dsSessionKey.Tables[1];
int l_out = objData.logoutOldSession(dtOldKey);
}

if (dsResult.Tables.Count > 0)
{
GridView1.DataMember = "Ticketing";
GridView1.DataSource = dsResult;
GridView1.DataBind();

GridView2.DataMember = "CouponData";
GridView2.DataSource = dsResult;
GridView2.DataBind();

GridView3.DataMember = "AirItineraryPricingInfo";
GridView3.DataSource = dsResult;
GridView3.DataBind();

GridView4.DataMember = "paymentInfo";
GridView4.DataSource = dsResult;
GridView4.DataBind();

GridView5.DataMember = "Passengers";
GridView5.DataSource = dsResult;
GridView5.DataBind();

GridView6.DataMember = "FlightSegments";
GridView6.DataSource = dsResult;
GridView6.DataBind();

GridView13.DataMember = "key";
GridView13.DataSource = dsResult;
GridView13.DataBind();

}
catch (Exception ex)
{

}
}

private DataSet getSessionKey(string provider)


{
string constr =
ConfigurationManager.ConnectionStrings["mytkt"].ConnectionString;

DataSet ds = new DataSet("key");


using (SqlConnection conn = new SqlConnection(constr))
{
SqlCommand sqlComm = new SqlCommand("getSessionKey", conn);
sqlComm.Parameters.AddWithValue("@provider", provider);

sqlComm.CommandType = CommandType.StoredProcedure;

SqlDataAdapter da = new SqlDataAdapter();


da.SelectCommand = sqlComm;
da.Fill(ds);
}

return ds;
}

private int insertSessionKey(string signature,string provider)


{
int k = 0;
string constr =
ConfigurationManager.ConnectionStrings["mytkt"].ConnectionString;
SqlConnection conn = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("insertKey", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("signature",signature);
cmd.Parameters.AddWithValue("provider", provider);
try
{
conn.Open();
k = cmd.ExecuteNonQuery();
}
catch (Exception exx)
{

}
finally
{
try
{
conn.Close();
}
catch (Exception er)
{

}
}
return k;
}