Reservation: PageBox for .NET application with booking and search Reservation

for
Presentation Distributed Database Install Security Offer Booking Search Internals

Reservation internals

Design

Reservation is a .NET Web Application written in C#.

Reservation design conforms to a small set of rules:

  1. Due to its origin (evaluation of storyboarding) Reservation has a simple design where the logic of an .aspx is implemented in its peer .aspx.cs

  2. Reservation doesn’t use stored procedures: you can use any Database that can be accessed in OleDb

  3. The configuration analysis is implemented in Global.asax.cs that populates a set of static strings and objects

  4. Reservation uses a custom authentication. Page_Load methods (Event Handler called at the Page Load) check if the Session object already contains the user name. If it is not the case or if the user is not of a suitable type, then the method redirects to the Login.aspx page

Note:

Because the Page_Load mechanism is the same for all pages, it is described only once in the Login.aspx.cs section.

Reservation is divided in five subsets:

  1. Configuration

  2. User management

  3. Resource management

  4. Booking

  5. Search

When Reservation is not deployed using PageBox, the Search subset cannot be used.

Configuration

The configuration subset reads the Reservation configuration file, reservation.xml and the code lists:

Name

First Field

Second field

states.csv

State code (USA)

State name

provinces.csv

Province code (Canada)

Province name

countries.csv

Country code (Earth)

Country name

Global.asax.cs

Code URL

Application_BeginRequest

Application_BeginRequest is invoked at the beginning of each request (form or Web Service). It

  • Computes the physical path and the URL

  • Restores reservation.xml

  • Call restoreCsv to restore states.csv, provinces.csv and countries.csv.

restoreCsv

restoreCsv is called by Application_BeginRequest and restores a .csv file whose each line is made of two fields separated by a comma.

User management

The user management updates two tables:

  • users

  • resources-info

Users.aspx.cs

Page URL

Code URL

bind

bind is called by Page_Load, OnUpdate, dgUser_delete and OnRefresh to populate the Datagrid that lists the users.

To do that, bind makes a select of all non-deleted users in the users table and builds an ArrayList of UserEntry object.

The UserEntry class has four properties, id, type, name and mail.

OnUpdate

OnUpdate is invoked when the user clicks on the Update button.

When the user exists, OnUpdate updates the users table and if the user is an employee the resources_info table.

When it is a new user, OnUpdate inserts a new row in the users table and if the user is an employee a new row in the resource_info table.

dgUser_delete

dgUser_delete is the item command of the Datagrid that lists the users.

It is invoked either when the user clicks on a Del or Sel button of the Datagrid.

When the user has clicked on a Del button,

  • dgUser_delete checks if the user is an employee

  • If the user is an employee dgUser_delete

    • Selects the resources defined for this employee after the deletion date

    • Updates the total entries in the resources table for each date found: for each slot where the employee was defined, the slot value of the total entry is decremented

    • Updates the available entries in the resources table for each date found: for each slot where the employee was defined, the slot value of the available entry is decremented and can become negative

    • Marks the user as deleted (sets its deltime to the deletion date)

    • Deletes the resources defined for this employee after the deletion date

  • Otherwise dgUser_delete deletes the user entry in the users table

When the user has clicked on the Sel button, dgUser_delete retrieves the user definition from the users table and populates the form.

  • If the user is a customer, because employees are not allowed to update user accounts, dgUser_delete disables all fields

  • If the user is a proxied user, dgUser_delete enables all fields except the user identifier and the type, which cannot be changed in update mode and the information field, which cannot be set for a proxied user

  • If the user is an employee, dgUser_delete enables all fields except the user identifier and the type, which cannot be changed in update mode

When the user is a proxied user or an employee, dgUser_delete writes a UserUpdate Boolean on the Session object: When the page is invoked again, disabled fields remain disabled but if the user clicks on the Refresh button.

For the Sel handling, dgUser_delete uses two methods, setForm and enable.

A user deletion request is considered as imperative. When the user is deleted the slot value of some available entries can become negative, which means that for these slots there is not enough resources to serve all booked customers. It is up to the employees to take proper action, which can be:

  • To ask to an employee to be available at the slot

  • Or to send a mail/call the customer to ask for a reschedule

To cope with this situation, dgUser_delete call the checkLog method.

setDropDown

setDropDown is called by dgUser_delete and by setForm to select the correct entries on the state drop down list (ddState) and on the country drop down list (ddCountry).

checkLog_init

checkLog_init is used for the support of the checkLog methods.

checkLog_init is invoked by dgUser_delete when dgUser_delete must delete an employee account.

checkLog_init checks that the user_delete.html log file that reports the slots with missing resources doesn’t exist. If user_delete.html exists the employee must check and clean it before trying to delete another account.

checkLog_bind

checkLog_bind is used for the support of the checkLog methods.

checkLog_bind is invoked by bind.

checkLog_bind sets the log icon if user_delete.html exists.

If the log icon is enabled and set to CheckWarning.gif, the user must check the user_delete.html, take proper action to satisfy all customers and clear user_delete.html.

checkLog_term

checkLog_term is used for the support of the checkLog methods.

checkLog_term is invoked at the end of an employee deletion to close the user.delete.html file.

checkLog

checkLog is invoked by dgUser_delete for each slot that can become negative during an employee deletion.

When the slot is negative,

  • The first time checkLog creates the user_delete.html file

  • checkLog writes a line describing the slot to fix

OnRefresh

OnRefresh is invoked when the user clicks on the Refresh button.

It removes the UserUpdate Boolean from the Session object and enables all fields.

The idea is to allow using any account as a template for the creation of new accounts.

Login.aspx.cs

Login.aspx.cs processes authentication.

Users are redirected from the other pages to the Login.aspx page either because they didn’t authenticate or because their session expired.

Page URL

Code URL

Objects stored in the Session object

Name

Set by

Used by

Meaning

userid

Login.aspx.cs

All forms

User identifier (string)

password

Login.aspx.cs

Not used

User password (string)

type

Login.aspx.cs

All forms

User type (short): 0 customer, 1 proxy, 2 employee

UserUpdate

Users.aspx.cs

Users.aspx.cs

When UserUpdate is set the type and ID fields are disabled on the Users form

from

All forms

Login.aspx.cs

Once Login.aspx.cs has checked the user ID and password, it redirects to the URL stored in from

status

All forms

Login.aspx.cs

Login.aspx.cs displays the message stored in status

Page_Load implementation on other forms

Page_Load:

  • Checks if the user is logged (if userid is set) and if its type is correct

  • If the user is not logged or if the account type is incorrect, Page_Load sets the from and the status in the Session object and redirects to Login.aspx

  • If the user is logged and if the account type is correct, Page_Load performs the needed binding – typically by invoking a bind something method

Page_Load

Page_Load is invoked at the Login page load.

Page_Load retrieves userid and type from the Session object and populates the Login form.

OnLogin

OnLogin is invoked when the user clicks on the Login button.

OnLogin first checks if the user identifier is the configuration account ID.

If the user identifier is not the configuration account ID, OnLogin tries to find the user record in the users database and checks the password.

If the user and password are valid and if the new password is set, OnLogin updates the user record in the users database.

Then OnLogin writes the userid, password and type objects in the Session object.

If the from object was set in the Session Onlogin redirects to the from URL.

Register.aspx.cs

Customers use Register.aspx to query an account. They fill the form to ask for an account creation. Then they receive a mail with the account information.

Register.aspx.cs updates the users and the currentUserNo tables.

Page URL

Code URL

Page_Load

Page_Load is invoked at the Login page load.

Page_Load populates the form from the configuration of the Reservation instance.

OnClick

OnClick is invoked when the user clicks on the Register button.

To create a unique user ID, OnClick retrieves the current customer number from the currentUserNo table.

Then OnClick increments the current customer number and updates the currentUserNo table.

OnClick uses the current customer number to generate an ID and a password for the new account.

Then OnClick inserts the account in the users table.

Eventually OnClick builds and sends a mail with a text body to the user.

Retrieve.aspx.cs

Customers use Retrieve.aspx to retrieve an account from their mail address. Then they receive a mail with the account information.

Page URL

Code URL

OnRetrieve

OnRetrieve is invoked when the user clicks on the Retrieve button.

OnRetrieve retrieves the user account from the users table.

Then OnRetrieve builds and sends a mail with a text body to the user.

Update.aspx.cs

Update.aspx allows customers and proxied customers to check and update their account information.

Page URL

Code URL

setDropDown

setDropDown is called by the Update.aspx.cs’ Page_Load, which populates the form from the user account information.

setDropDown select the correct entries on the state drop down list (ddState) and on the country drop down list (ddCountry).

OnUpdate

OnUpdate is invoked when the user clicks on the Update button.

OnUpdate updates the user record in the users table from the form fields.

Resource management

The resource management updates the resources table.

Only employees can use the resource management form, Offer.aspx.

Offer.aspx.cs

Page URL

Code URL

bindResources

bindResources is called by Page_Load.

bindResources retrieves the list of employees from the users table and stores their ID in an ArrayList.

bindResources adds three special entries, total, available and booked to the ArrayList. These entries maps to special entries of the resources: the user can display but not change these entries.

Then bindResources binds the ArrayList to the resources drop down list and set the selected entry to the current user.

bind

bind is called by OnUpdate and OnReset.

bind retrieves the schedule of the user selected on the drop down list, for the date selected on the calendar, from the resources table.

bind also computes the daily and the monthly total. For the monthly total it selects the records of the selected user between the beginning and the end of the month selected on the calendar.

OnSet

OnSet is invoked when the user clicks on the Set button.

OnSet sets all slots to one.

OnZero

OnZero is invoked when the user clicks on the Zero button.

OnZero sets all slots to zero.

validate

validate is called by OnUpdate.

validate checks that the schedule is valid. If the schedule is not valid, it display an error message.

buildTotal

buildTotal is called by OnUpdate.

buildTotal has two functions:

  1. It updates the total and available entries of the resources table

  2. It checks if the update is valid. If as a consequence of the schedule update, there would no more resources to serve all customers buildTotal returns an error

buildTotal first retrieves all employee accounts except the current user and the total, available and booked special entries and uses them to recomputed the resource total for the current date.

Then buildTotal retrieves the booked special entry for the current date.

Then buildTotal computes the availability schedule. For each slot it is total – booked. If a slot value becomes negative, buildTotal writes an error message and roll back.

Then buildTotal updates the total and available entries in the resources table.

OnUpdate

OnUpdate is invoked when the user clicks on the Update button.

The calendar of Offer.aspx allows selecting a date, a week or a month.

OnUpdate manages a current date, which is the first date of the range.

For each date of the range OnUpdate first updates the resources record for the selected user and then call buildTotal.

Then OnUpdate calls bind for the current date.

OnReset

OnReset is invoked when the user clicks on the Reset button.

OnReset restores the schedule from the resources record for the selected user and for the first date in the range selected on the calendar.

OnResSelect

OnResSelect is invoked when the user selects a different resource on the drop down list.

When the user has selected total, available or booked, which are special – non-updateable – entries OnResSelect disables the schedule and the buttons.

Then OnResetSelect calls OnReset to display the correct schedule.

Booking

The booking subset updates the resource table (booked and available entries) and the bookings table.

Only customers and proxied customers can use the booking form, Book.aspx.

Book.aspx.cs

Page URL

Code URL

dgBind

dgBind is called by Page_Load.

dgBind retrieves the coming bookings for the current user from the bookings table and populates an ArrayList of DgRow objects.

Then dgBind binds the ArrayList to the Current bookings Datagrid.

The DgRow class has a single property, datetime, which contains the date and time slot.

OnCalSelect

OnCalSelect is invoked when the user selects a date on the calendar.

OnCalSelect calls bind and enables the Book and “Cancel booking” buttons.

bind

bind is called by OnCalSelect, OnBook, OnCancel and dgBookings_cmds.

bind retrieves the available record from the resources table for the selected date.

bind enables the slots of the schedule when there are available resources (when the slot has at least one resource in the available record).

Then bind retrieves the user bookings for the selected date and checks a slot of the schedule when the user has already booked this slot.

OnBook

OnBook is invoked when the user clicks on the Book button.

For each slot of the schedule, OnBook calls remove if the slot is no longer booked and update if the slot is now booked.

update

update is invoked by OnBook.

update

  1. Inserts a booking record in the bookings table

  2. Updates the available record of the resources table. update decrements the availability of the booked slot

  3. Updates the booked record of the resource table. update increments the booking number of the booked slot

remove

remove is invoked by OnBook.

remove calls delete if the booking record exists.

delete

delete is invoked by remove and by dgBookings_cmds.

delete essentially makes the opposite of update.

delete

  1. Deletes the booking record of the current user for the selected date and slot from the bookings table

  2. Updates the available record of the resources table. delete increments the availability of the booked slot

  3. Updates the booked record of the resource table. delete decrements the booking number of the booked slot

OnCancel

OnCancel is invoked when the user clicks on the “Cancel booking” button.

OnCancel retrieves the user bookings for the selected date from the bookings table.

For each found booking OnCancel essentially makes the same thing as delete. OnCancel

  1. Updates the available record of the resources table. OnCancel increments the availability of the booked slot

  2. Updates the booked record of the resource table. OnCancel decrements the booking number of the booked slot

  3. Deletes the booking record of the current user for the selected date and slot from the bookings table

dgBookings_cmds

dgBookings_cmds is the ItemCommand of the Datagrid.

dgBookings_cmds is invoked when the user clicks on a Cancel or Select button of the Datagrid.

When the user has clicked on a Cancel button, dgBookings_cmds retrieves the booking date and time and use them to call delete and

  1. Deletes the booking record of the current user for the selected date and slot from the bookings table

  2. Updates the available record of the resources table. delete increments the availability of the booked slot

  3. Updates the booked record of the resource table. delete decrements the booking number of the booked slot

When the user has clicked on a Select button, dbBookings_cmds selects the booking date on the calendar and calls bind to display the schedule of the booking date.

Search

The search subset updates the applications table.

Only customers and proxied customers can use the Search forms, Search.aspx and ApplicationDetails.aspx.

Search uses the Query proxy to query the Query Web service of the local PageBox for the list of peer Reservation instances.

Then Search uses the LocationProxy proxy to query the Location Web services of the peer reservation instances and get their location.

Step 1: Applications.cs gets the list of Reservation subscribers.Step 2: Applications.cs gets the location information about the Reservation subscribers and stores it in the applications table.Step 3: The user makes a request for Reservation instances close to an address and with suitable availabilities. Search.aspx.cs asks the closest Reservation instances for their availability

Search records the peer instance information in the Applications.

When a user makes a search, Search queries the Location Web service for the peer instance availability at the date selected by the user.

Query.cs

Query.cs is the proxy of the PageBox Query Web Service.

The Query class is used by Application.cs to retrieve the peer instance list.

Code URL

Location.asmx.cs

Location.asmx.cs is the implementation of the Location Web service.

Location.asmx.cs has two Web service methods, Notify and Available.

Code URL

Notify

Notify has a signature

Entry Notify(string url, string address, string city, string state, string zip,

string country, string region, string latitude, string longitude)

where Entry is a class

public class Entry

{

public string url;

public string address;

public string city;

public string state;

public string zip;

public string country;

public string region;

public string latitude;

public string longitude;

}

Notify receives the location information about a remote Reservation instance and returns the location information about this instance.

Notify calls populate to record the location information about the remote instance in the applications table.

Available

Available has a signature

public TimeEntry[] Available(DateTime dt)

where TimeEntry is a class

public class TimeEntry

{

public short hour;

public short minutes;

}

Available retrieves the available special record from the resources table for the date dt.

It uses a process method to create a TimeEntry object for each slot of the available record with a least one available resource.

populate

populate is a static method invoked by Notify and by the Refresh method of Application.cs.

populate creates or updates a record in the Application table that contains location information about a remote peer instance of Reservation.

LocationProxy.cs

Location.cs is the proxy of the Location Web Service.

The LocationProxy class is used by Application.cs to get the location of peer instances and by Search.aspx.cs to get the slot availability at the date specified by the user.

Code URL

Application.cs

An Application object is instantiated by the Page_Load method of Search.aspx.cs at its first invocation.

Then the Page_Load method of Search.aspx.cs calls the Refresh method of Application.

Code URL

Refresh

Refresh first calls the GetSubscribers method of the PageBox Query Web service to get the list of the peer instances.

Then for each instance Refresh

  • Calls computeUrl to compute the Location Web service URL from the URL of the PageBox peer instance

  • Calls the Notify method of the Location Web service. Refresh set the Notify parameters from the configuration stored in Global

  • Calls the populate method of Location to record the location information about the remote instance in the application table

Then Refresh removes older records from the applications table

computeUrl

Technically the PageBox URL is the URL of the deploy.asmx Web service.

In our implementation, we assume that Reservation is deflated in a directory archBase under the PageBox directory.

archBase is the Reservation archive name without extension.

If the Reservation was deployed within an archive reservation.zip, then archBase is reservation.

Therefore we can compute the Location Web service with

PageBox_Dir + archBase + "/Location.asmx"

If your conventions are different, you can change this method.

Search.aspx.cs

Page URL

Code URL

setCoordFromHost

setCoordFromHost is called by Page_Load and by OnNeighborChanged.

setCoordFromHost sets the location information on the Search form from the configuration stored in Global.

OnNeighborChanged

OnNeighborChanged is invoked when the user changes the selection on the Neighbours Dropdown list.

Page_Load populates the Neighbour dropdown list with three values “the address below”, “this host” and “my address”.

If the user has selected “the address below”, it is up to her or him to set the address on the form and OnNeighborChanged doesn’t do anything.

If the user has selected “this host”, OnNeighborChanged calls setCoordFromHost to set the form from the configuration.

If the user has selected “my address”, OnNeighborChanged retrieves the location information about the current user from the users table to set the form.

setDropDown

setDropDown is called by OnNeighborChanged when the user has selected “my address”.

setDropDown select the correct entries on the state drop down list (ddState) and on the country drop down list (ddCountry).

OnClear

OnClear is invoked when the user clicks on the “Clear schedule selection” button.

OnClear unchecks all slots of the schedule.

OnList

OnList is invoked when the user clicks on the List button.

OnList populates a Hashtable whose values are ApplicationEntry objects and then binds the values oth this Hashtable to the Reservation instance Datagrid.

OnList first calls addSelected to find Reservation instances in the same city, state and country as on the form.

If it finds less than five Reservation instances, OnList calls addSelected to find Reservation instances with the same zip prefix and country as on the form.

If it still has found less than five Reservation instances, OnList calls addSelected to find Reservation instances with the same state and country as on the form.

addSelected

addSelected is called by OnList.

addSelected selects suitable Reservation instances in the applications table.

For each Reservation instance found addSelected

  1. Checks if the Reservation instance is not already recorded in the Hashtable

  2. Calls checkAvail to check if the Reservation instance has slots available

  3. Builds a MapQuest request for the direction of the Reservation instance

  4. Creates an ApplicationEntry object

  5. Adds the ApplicationEntry object to the Hashtable

The ApplicationEntry class has three properties:

  • The URL of the Reservation instance Location.asmx

  • The URL of the Reservation instance Book.aspx

  • The MapQuest URL

checkAvail

checkAvail is called by addSelected.

If the user has selected slots on the schedule, checkAvail calls the Available method of the remote Reservation instance for the date selected on the calendar.

Then checkAvail checks if there is match between the schedule returned by the Available method and the user preference.

OnCalSel

OnCalSel is invoked when the user selects a date on the calendar.

OnCalSel enables the schedule slots.

ApplicationDetails.aspx

When the user clicks on the Details link on the Search.aspx page, she or he links to the ApplicationDetails.aspx page with the URL of the Reservation instance Location.asmx as query string.

Page_Load

  1. Reads the query string

  2. Retrieves the Reservation instance information from the applications table

  3. Displays the Reservation instance information

Page URL

Code URL

Contact:support@pagebox.net
©2001-2004 Alexis Grandemange. Last modified .