Reservation |
|
Presentation | Distributed | Database | Install | Security | Offer | Booking | Search | Internals |
Reservation internals
Reservation is a .NET Web Application written in C#.
Reservation design conforms to a small set of rules:
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
Reservation doesn’t use stored procedures: you can use any Database that can be accessed in OleDb
The configuration analysis is implemented in Global.asax.cs that populates a set of static strings and objects
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:
Configuration
User management
Resource management
Booking
Search
When Reservation is not deployed using PageBox, the Search subset cannot be used.
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 |
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 is called by Application_BeginRequest and restores a .csv file whose each line is made of two fields separated by a comma.
The user management updates two tables:
users
resources-info
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 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 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 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 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 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 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 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 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 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.
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:
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 is invoked at the Login page load.
Page_Load retrieves userid and type from the Session object and populates the Login form.
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.
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_Load is invoked at the Login page load.
Page_Load populates the form from the configuration of the Reservation instance.
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.
Customers use Retrieve.aspx to retrieve an account from their mail address. Then they receive a mail with the account information.
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 allows customers and proxied customers to check and update their account information.
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 is invoked when the user clicks on the Update button.
OnUpdate updates the user record in the users table from the form fields.
The resource management updates the resources table.
Only employees can use the resource management form, Offer.aspx.
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 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 is invoked when the user clicks on the Set button.
OnSet sets all slots to one.
OnZero is invoked when the user clicks on the Zero button.
OnZero sets all slots to zero.
validate is called by OnUpdate.
validate checks that the schedule is valid. If the schedule is not valid, it display an error message.
buildTotal is called by OnUpdate.
buildTotal has two functions:
It updates the total and available entries of the resources table
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 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 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 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.
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.
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 is invoked when the user selects a date on the calendar.
OnCalSelect calls bind and enables the Book and “Cancel booking” buttons.
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 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 is invoked by OnBook.
update
Inserts a booking record in the bookings table
Updates the available record of the resources table. update decrements the availability of the booked slot
Updates the booked record of the resource table. update increments the booking number of the booked slot
remove is invoked by OnBook.
remove calls delete if the booking record exists.
delete is invoked by remove and by dgBookings_cmds.
delete essentially makes the opposite of update.
delete
Deletes the booking record of the current user for the selected date and slot from the bookings table
Updates the available record of the resources table. delete increments the availability of the booked slot
Updates the booked record of the resource table. delete decrements the booking number of the booked slot
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
Updates the available record of the resources table. OnCancel increments the availability of the booked slot
Updates the booked record of the resource table. OnCancel decrements the booking number of the booked slot
Deletes the booking record of the current user for the selected date and slot from the bookings table
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
Deletes the booking record of the current user for the selected date and slot from the bookings table
Updates the available record of the resources table. delete increments the availability of the booked slot
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.
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.
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 is the proxy of the PageBox Query Web Service.
The Query class is used by Application.cs to retrieve the peer instance list.
Location.asmx.cs is the implementation of the Location Web service.
Location.asmx.cs has two Web service methods, Notify and Available.
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 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 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.
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.
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.
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
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.
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 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 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 is invoked when the user clicks on the “Clear schedule selection” button.
OnClear unchecks all slots of the schedule.
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 is called by OnList.
addSelected selects suitable Reservation instances in the applications table.
For each Reservation instance found addSelected
Checks if the Reservation instance is not already recorded in the Hashtable
Calls checkAvail to check if the Reservation instance has slots available
Builds a MapQuest request for the direction of the Reservation instance
Creates an ApplicationEntry object
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 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 is invoked when the user selects a date on the calendar.
OnCalSel enables the schedule slots.
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
Reads the query string
Retrieves the Reservation instance information from the applications table
Displays the Reservation instance information
Contact:support@pagebox.net
©2001-2004 Alexis Grandemange.
Last modified
.