ASP.NET 2.0 Instant Results
.pdf3
Modifying the Wrox
Chat Ser ver
Some possible enhancements to the Wrox Chat Server could include:
Management Capabilities: The ability to see which chat sessions are used and how often they are used
Automated Responses: Automatic messages to respond to a user if no administrative personnel are available to enter their chat requests.
Chat Content Filters: The ability to track and alert administrative personnel when certain vulgarities or unacceptable terminology is used within chat sessions.
The following steps would be required to implement automated responses:
1.Open the Web.config file, and scroll down to the appSettings section. Add two entries for the hour in the morning that the site opens and the hour that it closes, (using military hours from 0 to 24). You also will need to add an entry to specify the administrator’s email address, and the message to send out to the chat user during off-hours. So if you want to open at 8am and close at 6pm, the following four entries would be added (using military time, 8am is the number 8, and 6pm is the number 18):
<configuration xmlns=”http://schemas.microsoft.com/.NetConfiguration/v2.0”> <appSettings>
<add key=”HourOpen” value=”8”/> <add key=”HourClose” value=”18”/>
<add key=”AdminEmail” value=”Admin@MyDomain.com”/>
<add key=”ClosedMessage” value=”We are sorry, but nobody is here to assist you right now. Please try again between 8 am and 6 pm PST. For online assistance, visit our Help page.”/>
2.Expand the ContentFiles folder, then open the ChatRoom.aspx.vb WebForm’s codebehind page to view its contents. Within this file is the RaiseCallbackEvent event, where you will add a conditional message based on the time of the chatted message. The text of this function is below:
4
Modifying the Wrox
Sur vey Engine
Although the Wrox Survey Engine is a great starter application for utilizing ASP.NET 2.0, it likely does not contain all the features you might want to see. Some possible enhancements to the Wrox Survey Engine could include:
Survey Reviews: Let users make comments on what they think about the survey.
Number Counts: The ability to view the number of responses to each of the surveys from the Administration section.
Charting: The ability to view a pie chart or a bar chart next to the percentages of the survey results pages.
Email Invitations: An e-mail message-generation tool for sending an e-mail invitation to take the survey.
Final Report: A request area to view final survey results once a specified number of responses are received.
Reporting: Some prepared reports about surveys, their responses, and percentages for each response.
If you want to implement number counts, the following steps would be required:
1.In Visual Web Developer or Visual Studio 2005, open the website from its extracted location at C:\inetpub\wwwroot\SurveyEngine. Open the Database Explorer by selecting the View Database Explorer menu selection. Find your database under the Database Connections node of the tree view. If your database is not listed, right click the Data Connections node in the tree view, select the Add Connection option, select the Microsoft SQL Server File option, and browse to the PhotoDB.mdf file in the App_Data folder of the site. This should bring up your connection within the Database Explorer window. Now that you have a valid database tree, expand it to see the Views node, and drill down to the viewResponseCountBySurvey view. Right click the view and select the Open View Definition option.
5
Modifying the Wrox CMS
This chapter has focused mainly on the database aspects of the CMS. That allowed you to focus on important concepts that are the basis of the CMS without being caught up with explaining loads of code that isn’t really important. So you surely noticed this is quite a bare-bones CMS without eye candy and cool features. However, you have a good foundation to build on, implementing those features that meet your own or you customer’s expectations. With the concepts and techniques you learned in this chapter, you should now able to expand this CMS with your own features. Some examples of possible extensions include:
1.Display extended information about the published content item. Instead of just showing the title and the body text, you could display information like the date the item was published and last updated, and the author that created the article.
2.Content rating. Let your visitors rate the item to show their opinion about it. You could collect the user’s rating with a simple user control and display the results (with a bar graph for example) with another user control.
3.User feedback. A common extension for a CMS-driven site like the one presented in this chapter is to allow visitors to respond on the content; this is a good way for you to get feedback from your visitors, while at the same time the contributions may add to the value of it, increasing the chance that others might read it.
Another important feature is a hit counter. It would be interesting to know how many people actually viewed your content item. This is interesting for you to find out how popular an article is. It can also be interesting to your visitors, as it might give an indication whether the content item is worth reading. The next walkthrough shows you how to implement the hit counter.
Design Considerations
There are a few ways to implement a hit counter for each content item in your site. In all cases, you need a way to store information about the ID of the content item and the number of times it has been viewed. Since the entire CMS is database-driven, it makes a lot of sense to store this information in the database as well. A simple table, called PageView, with a column that holds the content item’s ID and a counter that tracks the number of page views is more than enough.