Final Report

advertisement
Technion – Israel Institute of Technology
The Faculty of Electrical Engineering - Softlab
Website for Traveling
By: Rabie Loulou & Hammad Abed
Supervisor: Viktor Kulikov
Spring 2009
Website for Traveling
By: Rabie Loulou & Hammad Abed
Contents
Abstract ......................................................................................................................................................... 3
Development Environment........................................................................................................................... 4
Microsoft Visual Studio 2008 ................................................................................................................ 4
Microsoft SQL Server 2005 ................................................................................................................... 4
Technologies ................................................................................................................................................. 5
ASP.NET ..................................................................................................................................................... 5
ADO.NET.................................................................................................................................................... 5
AJAX .......................................................................................................................................................... 5
Project Design ............................................................................................................................................... 6
Database Layer.......................................................................................................................................... 7
Data Structure Diagram ........................................................................................................................ 7
Data Access Layer ................................................................................................................................... 10
Data Set ............................................................................................................................................... 10
Business Logic Layer ................................................................................................................................ 11
Classes: ................................................................................................................................................ 12
Exception handling .............................................................................................................................. 20
User Interface Layer ................................................................................................................................ 21
Master Page ........................................................................................................................................ 21
Validation Controls.............................................................................................................................. 22
ToolTips ............................................................................................................................................... 23
Issues and Decisions: .................................................................................................................................. 24
Possible Improvements............................................................................................................................... 25
Supported Environments ............................................................................................................................ 26
Server side............................................................................................................................................... 26
Client Side ............................................................................................................................................... 26
Snapshots of the website ............................................................................................................................ 27
Summary ..................................................................................................................................................... 29
Bibliography ................................................................................................................................................ 30
2
Website for Traveling
By: Rabie Loulou & Hammad Abed
Abstract
Website For Traveling is an application which was designed and implemented to be a dynamic
resource for people to share traveling experiences. It gives them the ability to search, view and
share different places to visit, plan an amazing trip and see what others think of their own
vacation.
The main objective of this project is to get the experience of programming in a web based
environment which includes a database, using the most popular and common design pattern
for such software, the 3-tier design.
This project was developed using the most advanced programming tools, such as .Net 3.5
frameworks, ASP.Net, AJAX technology and more.
Through the development process, we learned databases, SQL queries, watched tutorials on
the internet and emphasized the working procedures and the project management.
We have set a clear timelines, defined the levels that we should go through, documented our
steps and like in real life projects, had team-work on the one hand, and single missions on the
other hand.
Having this project done, we thought of things that may improve our application, such as
passwords cashing mechanism for security issues, using AJAX on more components.
3
Website for Traveling
By: Rabie Loulou & Hammad Abed
Development Environment
Microsoft Visual Studio 2008
Microsoft Visual Studio is an Integrated Development Environment (IDE) from Microsoft. It can
be used to develop console and graphical user interface applications along with Windows
Forms applications, web sites, web applications, and web services in both native code together
with managed code for all platforms supported by Microsoft Windows, Windows Mobile,
Windows CE, .NET Framework, .NET Compact Framework and Microsoft Silver light.
Visual Studio includes a code editor supporting IntelliSense as well as code refactoring. The
integrated debugger works both as a source-level debugger and a machine-level debugger.
Other built-in tools include a forms designer for building GUI applications, web designer, class
designer, and database schema designer. It allows plug-ins to be added that enhance the
functionality at almost every level - including adding support for source control systems (like
Subversion and Visual SourceSafe) to adding new toolsets like editors and visual designers for
domain-specific languages or toolsets for other aspects of the software development lifecycle
(like the Team Foundation Server client: Team Explorer).
Microsoft SQL Server 2005
Microsoft SQL Server is a relational model database server produced by Microsoft. Its primary
query languages are T-SQL and ANSI SQL.
4
Website for Traveling
By: Rabie Loulou & Hammad Abed
Technologies
ASP.NET
ASP.NET is a web application framework developed and marketed by Microsoft to
allow programmers to build dynamic web sites, web applications and web services. It was first
released in January 2002 with version 1.0 of the .NET Framework, and is the successor to
Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language
Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET
language.
ADO.NET
ADO.NET is a set of computer software components that can be used by programmers to access
data and data services. It is a part of the base class library that is included with the Microsoft. It
is commonly used by programmers to access and modify data stored in relational database
systems, though it can also be used to access data in non-relational sources. ADO.NET is
sometimes considered an evolution of ActiveX Data Objects (ADO) technology, but was
changed so extensively that it can be considered an entirely new product.
AJAX
ASP.NET AJAX is a free framework for building a new generation of richer, more interactive,
highly personalized cross-browser web applications. This new web development technology
from Microsoft integrates cross-browser client script libraries with the ASP.NET 2.0 serverbased development framework. In addition, ASP.NET AJAX offers you the same type of
development platform for client-based web pages that ASP.NET offers for server-based pages.
And because ASP.NET AJAX is an extension of ASP.NET, it is fully integrated with server-based
services. ASP.NET AJAX makes it possible to easily take advantage of AJAX techniques on the
web and enables you to create ASP.NET pages with a rich, responsive UI and server
communication. However, AJAX isn't just for ASP.NET. You can take advantage of the rich client
framework to easily build client-centric web applications that integrate with any backend data
provider and run on most modern browsers.
5
Website for Traveling
By: Rabie Loulou & Hammad Abed
Project Design
In a database based web application, there are three tiers which allow programmers to write
code that is high in cohesion and low in coupling, promotes the reuse of code through the
application, and divides the program itself into different tiers (that’s the perfect name!) which
can be modified later independently.
Three-tier architecture has the following three tiers:
Presentation tier (User Interface):
This is the topmost level of the application. The presentation tier displays information which is
been valid in the application, and it helps using the system without knowing the inner content
of the code just by communicating with the other tiers as will be described later.
Application tier: (Business Logic tier)
The logic tier is plled out from the presentation tier and as it controls the application’s
functionality by performing detailed processing. In other words, it is the implementation of
functions and methods that programmers write in order to perform any action and making it
possible for the application to do what it should be doing.
Data tier:
This tier consists of database servers where information is stored and retrieved.
6
Website for Traveling
By: Rabie Loulou & Hammad Abed
Figure 1
Database Layer
Implemented in Microsoft SQL Server 2008, managed by data access layer with ADO.NET.
Figure 2
Data Structure Diagram
Tables design
Database tables can be divided into three main groups:
1. Users basic information and communication between users.
2. Article details and categories
3. Tables which connect previous groups together, which includes user actions on articles (Ratings
and Comments).
7
Website for Traveling
By: Rabie Loulou & Hammad Abed
First Group:
Users table
Field
UserId
Username
Password
JoinDate
GroupID
Comment
Key of this table
The user name
The user login password
Date of registration for the user
The ID of the group from the table “Groups”
Groups table include predefined group names that define users as per their activity in the application
itself as below:
GroupID 1 is saved for Administrators
GroupID 2 define Advanced users
GroupID 3 is for intermediate users
GroupID 4 is the default of registration, for Beginners.
When the user’s sharing activity is growing, the GroupID will be lowered from Beginner, passing through
Intermediate group after 30 articles, and reaching Advanced group by 60 articles and more.
UsersDetails
UserID
FirstName
LastName
Email
Birthday
CountryID
Key of this table, connecting each line here in one specific line in Users table
First Name of the User
Last Name of the User
Email address of the user
Birthdate of the user
CountryID of the country (from Coutries table)
Messages
Field
MessageID
Subject
Body
SentDate
FromUserID
ToUserID
HideFromSender
Comment
Key
Text describing the subject of the message
Text of the message itself
Date of sending the message (creating the message)
UserID of the sender
UserID of the receiver
Boolean cell which helps leaving the message in the database when deleting it
from one user’s inbox, in order to be able to view it at the other side
HideFromRecipient Same as previous cell
8
Website for Traveling
By: Rabie Loulou & Hammad Abed
Messages table include communication between users with all wanted information of the message
(Date of creation, sender and receiver, subject and body).
Regarding the two cells in the table HideFromSender and HideFromRecipient, the objective of these cells
are to help determine if the message should be deleted from database or not when a user deletes a
message from his inbox/outbox. If a line includes both hides, then the message should be deleted from
the DB.
Now will show the second group:
Tours
Field
TourID
UserID
CountryID
City
Title
SubText
Text
ImageURL
Rate
Tags
Active
DateAdded
Comment
Key
Userid – as mentioned before
CountryID – as mentioned before
The city which this article is about
Text describing the title of the article
Brief description of the article
The whole article
URL of an image on the internet to show in the article
Avarage of ratings been given to this TourID
Texts been added to describe this article which help in search
Boolean cell useful for Admins to show/hide a specific article
Date for creating the article
It can be seen obviously from this table that all relevant information is saved here.
Countries
Field
CountryID
CountryName
Comment
Key
Name of the county
This table will manually include all countries in the world to be used either in the tours, or for user
information.
Categories and ToursVsCategories tables are helper tables to indicate what possible categories can be
saved for quick-find in search results. Predefined categories are saved here in the table, such as High
cost / Low cost / Possible age ranges/ Religious and many more, while the connection table helps save
crossing between articles and categories.
9
Website for Traveling
By: Rabie Loulou & Hammad Abed
Third Group:
In this group we find 2 tables which are Ratings and Comments. Each rating and comment is from a
specific user to a specific article while a rate is a number between 1-5, and a comment is a text with the
date it was created.
Data Access Layer
A Data Access Layer (DAL) is a layer of a computer program which provides simplified access to
data stored in persistent storage of some kind, such as an entity-relational database.
This data access layer is used in turn by other program modules to access and manipulate the
data within the data store without having to deal with the complexities inherent in this access.
For example, the DAL might return a reference to an object (in terms of object-oriented
programming) complete with its attributes instead of a row of fields from a database table. This
allows the client (or user) modules to be created with a higher level of abstraction. This kind of
model could be implemented by creating a class of data access methods that directly reference
a corresponding set of database stored procedures. Another implementation could potentially
retrieve or write records to or from a file system. The DAL hides this complexity of the
underlying data store from the external world.
Also, business logic methods from an application can be mapped to the Data Access Layer. So,
for example, instead of making a query into a database to fetch all users from several tables the
application can call a single method from a DAL which abstracts those database calls.
Applications using a data access layer can be either database server dependent or independent.
If the data access layer supports multiple database types, the application becomes able to use
whatever databases the DAL can talk to. In either circumstance, having a data access layer
provides a centralized location for all calls into the database, and thus makes it easier to port
the application to other database systems (assuming that 100% of the database interaction is
done in the DAL for a given application).
Data Set
A DataSet contains a complete representation of data, including the table structure, the
relationships between tables, and the ordering of the data. DataSet classes are flexible enough
to store any kind of information from a database to an Extensible Markup Language (XML) file.
DataSet classes are stateless; that is, you can pass these classes from client to server without
tying up server connection resources
10
Website for Traveling
By: Rabie Loulou & Hammad Abed
Business Logic Layer
A Business logic layer (BLL) is a software engineering practice of compartmentalizing the rules
and calculations of a software application from its other design elements. It is also known as
the Domain layer.
This Business logic layer is usually one of the tiers in a multitier architecture, in our case, the 3tier design. It separates the business logic from other modules, such as the Data access layer
and User interface.
By doing this, the business logic of an application can often withstand modifications or
replacements of other tiers. For example, in an application with a properly separated Business
logic layer and Data access layer, the Data access layer could be rewritten to retrieve data from
a different database, without affecting any of the business logic. This practice allows software
application development to be more effectively split into teams, with each team working on a
different tier simultaneously.
Our design:
We used the 3 layers design pattern which is made of the following layers:
1) WUI – web user interface from asp.net pages
2) BLL – C# classes
3) DAL – ado .net objects. DATA SETS
Communications between the layers :
Each layer only knows about the existence of the lower layers, and doesn’t know about the
existence of the upper layers. For example the BLL layers, it knows that there exist a DAL
layer , and uses it , but doesn’t know that there exists WUI layer.
Each layer sends messages only to the below level and gets answers from that level. Our
design is like straight forward messages as the following example:
WUI  get users  BLL  get users  DAL  get users  DB
WUI  users list  BLL  users list  DAL  user list  DB
11
Website for Traveling
By: Rabie Loulou & Hammad Abed
We have no inheritance, no complicated object oriented design.
Why choosing such design when we can use store procedures and other DAL objects such as
SqlCommand?
Main reason for that is simplicity, second reason, there are many options or ways to design the
application, but you only choose one, we decided to use this one for more than one reason:
1) Simplicity: Microsoft has built the DATASETS objects especially for this need and for this reason,
so we can find it ready and easy to use object, and not build one from beginning.
2) Tutorials: most of the available tutorials, examples, videos, are made for this design, for the
DATASETS, and very easy to understand the example and from there to build your own objects.
3) Requirements: for this project and its requirements, we did not find a need to build complicated
design with inheritance, and support for thousands of users. It is simple project , with at most
100 users to use , so need to complicate stuff and instead we concentrate on our WUI and the
many features of .net
Classes:
- CategoriesBLL
Summary: this class is responsible for the different articles categories, like: religious, sea and
beach…
12
Website for Traveling
By: Rabie Loulou & Hammad Abed
-
CommentsBLL
Summary: this class is responsible for inserting and deleting comments on articles
-
CommentsVsUsersBLL
-
CountriesBLL
13
Website for Traveling
By: Rabie Loulou & Hammad Abed
-
DateList
-
GroupsBLL
Summary: this class is responsible for dividing the users into groups, newbie, moderate and
expert…
14
Website for Traveling
By: Rabie Loulou & Hammad Abed
-
MessagesBLL
Summary: this class is responsible for the messages system, can send new messages, delete old
ones and more…
-
RatingsBLL
Summary: this class is responsible for rating of articles, users can rate every article he read.
15
Website for Traveling
By: Rabie Loulou & Hammad Abed
-
ToursBLL
Summary: this class is responsible for managing the tours articles, insert new article, update it,
sort articles and more.
-
ToursVsCategoriesBLL
16
Website for Traveling
By: Rabie Loulou & Hammad Abed
-
ToursVsUsersVsGroupsViewBLL
-
UsersBLL
17
Website for Traveling
By: Rabie Loulou & Hammad Abed
-
UsersDetailsBLL
Summary: this class is responsible for the users details, it stores and fetches the details when
needed.
For each table in the database we have dataset , each dataset contains Table Adapter which
holds all the fields of the table in the database with the same entity types , for example the
table in the database contains the TourID field as GUID so also the table adapter contains a
GUID field with the same name TourID
.
As you can see, there is the Adapter property, it holds the dataset object in it, each time we
create new class from this BLL it immediately creates new DATASET and holds it in the adapter.
The main goal of the BLL classes in our design is to enforce the business rules. For example, it
ensures that the GUID is a legal value, or the quantity is a legal number, and the BLL returns a
well understandable error.
18
Website for Traveling
By: Rabie Loulou & Hammad Abed
Let's take a look on the TourInsertfunction:
public void ToursInsert(int UserID, string Title, int CountryID, string City,
string SubText, string Text, string ImageURL, string Tags, bool Active,
List<int> CategoriesIDs)
{
//************
Add Tour To Tours List
DateTime DateAdded = DateTime.Now;
int ERR;
try
{
ERR = Adapter.Insert(UserID, CountryID, City, Title, SubText,
Text, ImageURL, 0, Tags, Active, DateAdded);
}
catch (ArgumentNullException exp)
{
throw new Exception("Error In Adding Tour. Invalid " +
exp.ParamName);
}
finally
{
}
if (ERR < 1)
throw new Exception("Error In Adding Tour.");
//********** Add Tour To Categories
int TourID = (int)Adapter.GetLastTourID();
ToursVsCategoriesBLL TC = new ToursVsCategoriesBLL();
for (int i = 0; i < CategoriesIDs.Count; i++)
{
TC.ToursVsCategoriesInsert(TourID, CategoriesIDs[i]);
}
//********* Update User Group
UsersBLL Users = new UsersBLL();
Users.PutUserInTheRightGroup(UserID);
}
In this example we can see the rules enforce and see that it throws exception to indicate the error and
its meaning.
19
Website for Traveling
By: Rabie Loulou & Hammad Abed
Exception handling
Most of the exception handling in our application is placed in the business logic. Excepton that are
raised from the DAL or from the Database bubble to the BLL, and the BLL in its turn treat the exception.
The BLL may also raise some exceptions. Most of the functions in the BLL are wrapped with a try-catch
command.
Some exceptions are treated internally in the BLL and others alert the user in the GUI layer.
20
Website for Traveling
By: Rabie Loulou & Hammad Abed
User Interface Layer
Master Page
ASP.NET master pages allow you to create a consistent layout for the pages in your application.
A single master page defines the look and feel and standard behavior that you want for all of
the pages (or a group of pages) in your application. You can then create individual content
pages that contain the content you want to display. When users request the content pages,
they merge with the master page to produce output that combines the layout of the master
page with the content from the content page.
In our project, we used 1 main master pages, that divide the page into separate blocks and
handle the main graphics of the website, so in all the pages you visit you will see homogeneous
view.
For example the code to add master page:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site/MasterPage.master"…
21
Website for Traveling
By: Rabie Loulou & Hammad Abed
Validation Controls
An important aspect of creating ASP.NET Web pages for user input is to be able to check that
the information users enter is valid. ASP.NET provides a set of validation controls that provide
an easy-to-use but powerful way to check for errors and, if necessary, display messages to the
user. The topics in this section describe the validation controls and how to use them.
All of the validation controls inherit from the base class BaseValidator so they all have a series
of properties and methods that are common to all validation controls. They are:
ControlToValidate - This value is which control the validator is applied to.
ErrorMessage - This is the error message that will be displayed in the validation summary.
IsValid - Boolean value for whether or not the control is valid.
Validate - Method to validate the input control and update the IsValid property.
Display - This controls how the error message is shown. Here are the possible options:
None (The validation message is never displayed.)
Static (Space for the validation message is allocated in the page layout.)
Dynamic (Space for the validation message is dynamically added to the page if validation fails.)
Here is validator code which displays error message if the 2 passwords entered are not the
same:
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="*
Passwords Are Not The Same."
ControlToValidate="txtPassword2"
Display="Dynamic" ControlToCompare="txtPassword1"
Operator="Equal" Type="String"
ValidationGroup="RegisterGroup"></asp:CompareValidator>
22
Website for Traveling
By: Rabie Loulou & Hammad Abed
ToolTips
ToolTips are those small windows which display some text when the mouse is over a control
giving a hint about what should be done with that control. ToolTip is not a control but a
component which means that when we drag a ToolTip from the toolbox onto a form it will be
displayed on the component tray. Tooltip is an Extender provider component which means that
when you place an instance of a ToolTipProvider on a form, every control on that form receives
a new property.
For example, here is a code that hints the user that username is required:
<asp:RequiredFieldValidator ID="UserNameRequired"
runat="server" ControlToValidate="UserName"
ErrorMessage="User Name is required." ToolTip="User
Name is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
23
Website for Traveling
By: Rabie Loulou & Hammad Abed
Issues and Decisions:
Problems we encountered during the project or critical decisions we had to make:
One of the main problems and took a lot effort and time was what objects are we going to use in our
project, for example, are we going to use DataSets, Linq , general DAL… we had to read a lot of material
and search the web for examples , advantages and disadvantages of each object , what's recommended
and what is not recommended , problems in these objects , since it is all new objects, finally we decided
to use dataset because it was more appropriate for this project.
The graphics of the website was a very large stage of our development process, we had many problems
with it at the beginning, but after learning and reading materials about the cascading style sheets we
managed to solve all the view problems.
24
Website for Traveling
By: Rabie Loulou & Hammad Abed
Possible Improvements




Security: it’s important aspect that didn’t had our attention enough, the passwords shouldn’t
be stored in the database, but should be encrypted and then stored. Also anti-spam system that
prevent the website from being flooded with irrelevant materials and viruses should be
implemented.
Email Support: to complete the registration stage there have to be an email validation
mechanism. Also allow users to send each other messages to the email.
Advanced search: another good feature may be an advanced search system that allows search
according to multiple keys, like author, date, categories and more.
Facebook sharing: facebook today is one of the most successive advertisement platform, so
implementing a sharing system with the facebook will help spreading the website fast.
25
Website for Traveling
By: Rabie Loulou & Hammad Abed
Supported Environments
Server side
Operating System



Windows server 2003 and above.
.Net Framework 3.5
IIS 6 and above.
Client Side
Operating System:

All versions of Microsoft Windows later than windows XP.
Explorer:


Microsoft Internet Explorer 6 and above. (Internet Explorer 8 – compatibility mode).
Mozilla Firefox version 3 and above.
26
Website for Traveling
By: Rabie Loulou & Hammad Abed
Snapshots of the website
27
Website for Traveling
By: Rabie Loulou & Hammad Abed
28
Website for Traveling
By: Rabie Loulou & Hammad Abed
Summary
Developing this project was a great experience.
We have learned some vital information which made us better engineers. In the design stage,
we had to be well familiar with the theory of the 3-tier application design, then we had to get
to know Microsoft’s tools, like visual studio, MS-SQL server, DataSets, etc. and in the Web
Designing stage, we had to work with some state of the art technologies, like AJAX.
Finally, we hope you will enjoy using, checking and grading and maybe continue developing the
website.
29
Website for Traveling
By: Rabie Loulou & Hammad Abed
Bibliography








http://asp.net/
http://www.c-sharpcorner.com/
http://samples.gotdotnet.com/quickstart/aspplus/
http://www.csharphelp.com/
http://ajax.asp.net/
http://ajaxpatterns.org
tp://www.sql-tutorial.net/
http://msdn2.microsoft.com/en-us/library/ms203721(sql.90).aspx
30
Download