Studyroom Reservation

Features:

  1. Login automatically
  2. Automatically select an available seat
  3. Send a text message to your cellular phone via SMSGO API

In order to login to the reservation system, I use HTTP Analyzer to analyze HTTP/HTTPS traffic:

login.aspx?type=1&__EVENTTARGET=LinkButton1&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUJNjY4NzU5MzE0ZGTZg4txRnBH%2Bs%2B84oIQlb%2Bz%2BJlJLQ%3D%3D&__EVENTVALIDATION=%2FwEWBQKoi57rDgLr%2F4HeAgK%2Bmv37AgLM9PumDwKxi96RBUBQxiaTFm%2FOXRelnZ%2BE%2FRkGRcDS&UserId=UserId;PassWd=PassWd

Then, I can use the above parameters to login to the system.

Also, there are two parameters used to select a seat: seatID and date.

Main Screen:

studyroom_reservation

Available/Unavailable Seats:

seats

 

Partial code:

if(iURLPos == 1)//iURLPos :current webpage (0: home; 1: login page; 2: select seat page; 3: reservation result)
{
    Timer_Login->Enabled = false;
    Variant doc = CppWebBrowser_Main->ControlInterface->Document;
    if (((IDispatch *)doc) != NULL)
    {
        Variant body = doc.OlePropertyGet("Body");
        Variant html = body.OlePropertyGet("InnerHTML");
        AnsiString tmp_body = html;
        if(tmp_body.Pos("logout")>0)
        {
            Timer_Login->Enabled = false;
            Btn_Seat->OnClick(Sender);
        }
        else
            Timer_Login->Enabled = true;

    }
}
else if(iURLPos == 2)
{
    Timer_Refresh->Enabled = false;
    Variant doc = CppWebBrowser_Main->ControlInterface->Document;
    if (((IDispatch *)doc) != NULL)
    {
        Variant body = doc.OlePropertyGet("Body");
        Variant html = body.OlePropertyGet("InnerHTML");
        AnsiString tmp_body = html;
        if(tmp_body.Pos("2013/2")>0 || tmp_body.Pos("2013/3")>0 || tmp_body.Pos("2013/4")>0 || tmp_body.Pos("2013/5")>0 || tmp_body.Pos("2013/6")>0 || tmp_body.Pos("2013/7")>0 || tmp_body.Pos("2013/8")>0)
        {
            Timer_Refresh->Enabled = false;

            Variant disp,alllinks,eachlink;
            int linkcount;

            disp = CppWebBrowser_Main->Document;
            alllinks = disp.OlePropertyGet("links"); //get all links
            linkcount = alllinks.OlePropertyGet("length"); //get link numbers

            for (int i=0;i <linkcount;i++)
            {
                eachlink = alllinks.OleFunction("item",i); 
                if( i == 0)
                {
                    eachlink.OleFunction("click");
                    Timer_FindWin->Enabled = true;
                    iURLPos = 3;
                    break;
                }
            }
        }
        else
        {
            if(pMode == 0)
                CppWebBrowser_Main->Navigate(Variant(Edit_URL1->Text));
            else
            {

                Application->ProcessMessages();
                Delay(pMode);
                CppWebBrowser_Main->Navigate(Variant(Edit_URL1->Text));
            }
        }

    }
}
else if(iURLPos == 3)
{
    Variant doc = CppWebBrowser_Main->ControlInterface->Document;
    if (((IDispatch *)doc) != NULL)
    {
        Variant body = doc.OlePropertyGet("Body");
        Variant html = body.OlePropertyGet("InnerHTML");
        AnsiString tmp_body = html;
        if(tmp_body.Pos("successful")>0)
        {
            isChoose = true;
            //reservation is successful; send a text message to your cell phone
            AnsiString SMSBody = "Reservation is Successful" + ChooseDate+"("+SeatID+")";
            SMSURL="http://www.smsgo.com.tw/sms_gw/sendsms.asp?username=xxx&password=xxx&dstaddr=phone_number&smbody="+SMSBody;//SMSGO API
            iURLPos = -1;
            CppWebBrowser_SMS->Navigate(Variant(SMSURL));
        }
        else
        {
            Timer_FindWin->Enabled = true;
            Btn_NextSeat->OnClick(Sender);
        }
    }
}

 

 

 

 

 

Leave a Reply