Reservation |
|
Presentation | Distributed | Database | Install | Security | Offer | Booking | Search | Internals |
Reservation internalsDesignReservation is a .NET Web Application written in C#. Reservation design conforms to a small set of rules:
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:
When Reservation is not deployed using PageBox, the Search subset cannot be used. ConfigurationThe configuration subset reads the Reservation configuration file, reservation.xml and the code lists:
Global.asax.csApplication_BeginRequestApplication_BeginRequest is invoked at the beginning of each request (form or Web Service). It
restoreCsvrestoreCsv is called by Application_BeginRequest and restores a .csv file whose each line is made of two fields separated by a comma. User managementThe user management updates two tables:
Users.aspx.csbindbind 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. OnUpdateOnUpdate 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_deletedgUser_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,
When the user has clicked on the Sel button, dgUser_delete retrieves the user definition from the users table and populates the form.
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 cope with this situation, dgUser_delete call the checkLog method. setDropDownsetDropDown 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_initcheckLog_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_bindcheckLog_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_termcheckLog_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. checkLogcheckLog is invoked by dgUser_delete for each slot that can become negative during an employee deletion. When the slot is negative,
OnRefreshOnRefresh 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.csLogin.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. Objects stored in the Session object
Page_Load implementation on other formsPage_Load:
Page_LoadPage_Load is invoked at the Login page load. Page_Load retrieves userid and type from the Session object and populates the Login form. OnLoginOnLogin 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.csCustomers 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_LoadPage_Load is invoked at the Login page load. Page_Load populates the form from the configuration of the Reservation instance. OnClickOnClick 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.csCustomers use Retrieve.aspx to retrieve an account from their mail address. Then they receive a mail with the account information. OnRetrieveOnRetrieve 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.csUpdate.aspx allows customers and proxied customers to check and update their account information. setDropDownsetDropDown 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). OnUpdateOnUpdate is invoked when the user clicks on the Update button. OnUpdate updates the user record in the users table from the form fields. Resource managementThe resource management updates the resources table. Only employees can use the resource management form, Offer.aspx. Offer.aspx.csbindResourcesbindResources 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. bindbind 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. OnSetOnSet is invoked when the user clicks on the Set button. OnSet sets all slots to one. OnZeroOnZero is invoked when the user clicks on the Zero button. OnZero sets all slots to zero. validatevalidate is called by OnUpdate. validate checks that the schedule is valid. If the schedule is not valid, it display an error message. buildTotalbuildTotal is called by OnUpdate. buildTotal has two functions:
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. OnUpdateOnUpdate 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. OnResetOnReset 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. OnResSelectOnResSelect 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. BookingThe 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.csdgBinddgBind 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. OnCalSelectOnCalSelect is invoked when the user selects a date on the calendar. OnCalSelect calls bind and enables the Book and “Cancel booking” buttons. bindbind 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. OnBookOnBook 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. updateupdate is invoked by OnBook. update
removeremove is invoked by OnBook. remove calls delete if the booking record exists. deletedelete is invoked by remove and by dgBookings_cmds. delete essentially makes the opposite of update. delete
OnCancelOnCancel 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
dgBookings_cmdsdgBookings_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
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. SearchThe 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.csQuery.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.csLocation.asmx.cs is the implementation of the Location Web service. Location.asmx.cs has two Web service methods, Notify and Available. NotifyNotify has a signature
where Entry is a class
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. AvailableAvailable has a signature
where TimeEntry is a class
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. populatepopulate 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.csLocation.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. Application.csAn 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. RefreshRefresh first calls the GetSubscribers method of the PageBox Query Web service to get the list of the peer instances. Then for each instance Refresh
Then Refresh removes older records from the applications table computeUrlTechnically 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
If your conventions are different, you can change this method. Search.aspx.cssetCoordFromHostsetCoordFromHost is called by Page_Load and by OnNeighborChanged. setCoordFromHost sets the location information on the Search form from the configuration stored in Global. OnNeighborChangedOnNeighborChanged 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. setDropDownsetDropDown 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). OnClearOnClear is invoked when the user clicks on the “Clear schedule selection” button. OnClear unchecks all slots of the schedule. OnListOnList 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. addSelectedaddSelected is called by OnList. addSelected selects suitable Reservation instances in the applications table. For each Reservation instance found addSelected
The ApplicationEntry class has three properties:
checkAvailcheckAvail 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. OnCalSelOnCalSel is invoked when the user selects a date on the calendar. OnCalSel enables the schedule slots. ApplicationDetails.aspxWhen 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
Contact:support@pagebox.net |