Home » Uncategorized » Co-op Highlights 15

Co-op Highlights 15

This week at my co-op, I was able to sit in on a meeting regarding Google Apps for Enterprise. It was a brainstorming meeting to discover what topics would be good to cover in a staff training early next year (2014). What I found particularly interesting was looking at Google Apps from an end user perspective and figuring out what staff needs to know about Gmail, Calendar, Drive, Documents, Chat, Hangouts, etc to help staff work effectively and efficiently, fully utlilizing the tools available to us with Google Apps for Enterprise. Some of the topics we identified were things that we know most staff people aren’t using, but also things that would make work more efficient. It’s also a cost-effective solution for our organization, with email addresses and 25GB available for Drive and Documents costing about half (50%) of the current Office licenses per person.

Although this topic does not include any coding, it does help to cement the fact that computer programmers and web developers really need to work with the end user in mind. Any program or website needs to be user-friendly, that is, intuitive and easy for the end user to use. Components in a website or web application should be clearly labeled and easy to see for users. One example that I’ve noticed with Googe Mail (for our organization) recently is that there is a little grid of squares in the upper right corner – this is not labeled at all. But, when you click on it, the window opens and you can see links for Calendar, Documents, Drive, and other options. Now that I know it’s there, I don’t need it labeled, but when it first appeared, it would have been nice to have a hover balloon pop up to let you know what the little grid of squares is. This is just an example of how web developers could enhance their web pages to provide a great experience for the end users.

I also wanted to provide some information here on how to add Dynamic Data to an existing web application. This topic was one that I had to research earlier this week and it proved very interesting. I’m not sure that it would be applicable to my organization, but the research provided me some good basic knowledge, so that I can provide input to my organization if the topics arises.

It seems that the easiest way to add dynamic data to an existing web application is to create a dummy Dynamic Data web application and then copy the critical folders and files over to your pre-existing web application. You would then make some changes in different files to be able to utilize the Dynamic Data scaffolding. I found similar explanations at different websites, but this MSDN Microsoft website (http://msdn.microsoft.com/en-us/library/ee923692(VS.100).aspx) was the main source of my information. This website, http://blogs.msdn.com/b/scothu/archive/2008/06/24/how-to-add-dynamic-data-to-an-existing-web-application.aspx?Redirected=true, also contained some helpful information, but was very similar to the first information source. Additionally, this website, http://msdn.microsoft.com/en-us/library/cc837197(v=vs.90).aspx, provided similar information, but focused on adding Dynamic Data to a website, rather than a web application.

For this scenario, we have our web application called MyWebsite. We’ll want to create a new web application using Dynamic Data in Visual Studio – we’ll call this the DDWebsite.

In the MyWebsite, you’ll want to make sure that you have added the Data Model. This would be the model that represents the database (in this scenario, AdventureWorks). In Solution Explorer, right-click the project name and click Add. Click the Add ASP.NET folder and then click App_Data. Then, right-click the newly created App_Data folder and click Add Existing Item. At that point, enter the location for the AdventureWorks database file (.mdf) and click Add.

The Data Model will contain the classes representing the database tables and will help the Dynamic Data to interact with the database. You can use either a LINQ-to-SQL model or a ADO.NET Entity Framework model. You must choose and cannot use parts of each model. This example will use LINQ-to-SQL. Right click the project in Solution Explorer and click Add ASP.NET folder and click App_Code. In the Installed Templates in the left-side pane, click Data. In the center pane, you would click LINQ-to-SQL Class. Then, in the Name box, enter the name AdventureWorksLT.dbml and click Add. The Object Relational Designer should now be displayed.

In the Object Relational Designer, click the Server Explorer link. Under Server Explorer and under Data Connections, expand the AdventureWorks.mdf node and expand the Tables node. Select all of the tables and drag them into the Object Relational Designer window. Then close the Server Explorer and click Save All in the File menu.

Additionally, you’ll want to register the data model context to enable Dynamic Date to access the information in the database. In Solution Explorer, right click to Add New Item and select Global Application Class (Global.asax file). If the MyWebsite already contains the Global.asax file, you would just add the following code to it:

<%@ Import Namespace=”System.ComponentModel.DataAnnotations” %>
<%@ Import Namespace=”System.Web.Routing” %>
<%@ Import Namespace=”System.Web.DynamicData” %>
And in the Application_Start method, add the following:

void Application_Start(object sender, EventArgs e)
{
// Create an instance of the data model.
MetaModel DefaultModel = new MetaModel();
// Register the data model.
DefaultModel.RegisterContext(typeof(
AdventureWorksLTDataContext),
new ContextConfiguration() { ScaffoldAllTables = false });
}

At this time, you’ll want to create the routes. Routes are URL patterns, rather than actual URLs (to specific pages). In the Application_Start method, add the following:

void Application_Start(object sender, EventArgs e)
{
// Register the data model.
DefaultModel.RegisterContext(typeof(
AdventureWorksLTDataContext),
new ContextConfiguration() { ScaffoldAllTables = false });

// Create the routes.
RouteTable.Routes.Add(new
DynamicDataRoute(“{table}/{action}.aspx”){
Constraints = new RouteValueDictionary(new {
action = “List|Details|Edit|Insert” }),
Model = DefaultModel});
}

At this point, you’ll want to close your project (MyWebsite) and create a new project, which will be the DDWebsite, the Dynamic Data website where you’ll get the Dynamic Data scaffolding files and folders to copy into your MyWebsite. To create this Dynamic Data website, click File, New, and Web Site. Under Installed Templates, select C# and Dynamic Data LINQ to SQL Web Site in the center pane and select the location where you’ll be saving the website and name it.

Additionally, you’ll want to add the scaffolding elements to your existing website (MyWebsite) to enable users to create, read, update, and delete (CRUD) items in the tables. In Windows Explorer, open your Dynamic Data website (DDWebsite), copy the DynamicData folder, then right click the project name (of the existing website, MyWebsite) in the Solution Explorer and Paste. You’ll want to do this for the Site.css and Site.master files also (copy those files from DDWebsite to MyWebsite).

Thoughts?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s