Click here to Skip to main content
11,492,385 members (63,312 online)
Click here to Skip to main content
Articles » Web Development » Ajax » Atlas » Downloads
Add your own
alternative version

Build a Google IG like AJAX Start Page in 7 days using ASP.NET AJAX and .NET 3.0

, 10 Mar 2010 CPOL 1.2M 7.6K 1.1K
Build a Start Page similar to Google IG in 7 nights using ASP.NET AJAX, .NET 3.0, LINQ, DLinq, and XLinq.
dashboard.zip
src
bin
AjaxControlToolkit.dll
CustomDragDrop
Dashboard
App_Code
App_Data
App_Themes
Default
google.gif
HeaderBack.PNG
Logo.png
max_blue.gif
max_blue_highlight.gif
min_blue.gif
min_blue_highlight.gif
x_blue.gif
x_blue_highlight.gif
Bin
AjaxControlToolkit.dll
CSharp3CodeDomProvider.dll
Global.asax
indicator.gif
vwd.webinfo
Widgets
FlickrIcon.gif
rss.gif
DashboardBusiness
Activities
CreateDeafultWidgetsOnPageActivity.rules
DashboardBusiness.csproj.user
NewUserSetupWorkflow.rules
Properties
UserVisitWorkflow.rules
DashboardData
Properties
Dashboard.bak
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Security;
using System.Transactions;
using System.Query;
using System.Data.DLinq;

using DashboardDataAccess;

namespace DashboardBusiness
{    
	public class DashboardFacade
	{
        private string _UserName; 

        public DashboardFacade( string userName )
        {
            this._UserName = userName;
        }

        public UserPageSetup NewUserVisit( )
        {
            using( new TimedLog(this._UserName, "New user visit") )
            {
                var properties = new Dictionary<string,object>();
                properties.Add("UserName", this._UserName);
                var userSetup = new UserPageSetup();
                properties.Add("UserPageSetup", userSetup);
                
                WorkflowHelper.ExecuteWorkflow( typeof( NewUserSetupWorkflow ), properties ); 

                return userSetup;
            }
        }

        public UserPageSetup LoadUserSetup( )
        {
            using( new TimedLog(this._UserName, "Total: Existing user visit") )
            {
                var properties = new Dictionary<string,object>();
                properties.Add("UserName", this._UserName);
                var userSetup = new UserPageSetup();
                properties.Add("UserPageSetup", userSetup);
                    
                WorkflowHelper.ExecuteWorkflow( typeof( UserVisitWorkflow ), properties ); 

                return userSetup;
            }
        }

        public void AddNewPage( )
        {
            using( new TimedLog(this._UserName, "Add New Page") )
            {
                var properties = new Dictionary<string,object>();
                properties.Add("UserName", this._UserName);
                    
                WorkflowHelper.ExecuteWorkflow( typeof( AddNewTabWorkflow ), properties ); 
            }
        }


        public void DeleteWidgetInstance( WidgetInstance instance )
        {
            using( new TimedLog(this._UserName, "Delete Widget:" + instance.Title) )
            {
                var properties = new Dictionary<string,object>();
                properties.Add("WidgetInstanceId", instance.Id);
                properties.Add("PageId", instance.PageId);
                properties.Add("ColumnNo", instance.ColumnNo);
                
                WorkflowHelper.ExecuteWorkflow( typeof( DeleteWidgetInstanceWorkflow ), properties );
            }
        }

        public void MoveWidgetInstance( int widgetInstanceId, int toColumn, int toRow )
        {
            using( new TimedLog(this._UserName, "Move Widget:" + widgetInstanceId) )
            {
                var properties = new Dictionary<string,object>();
                properties.Add("WidgetInstanceId", widgetInstanceId);
                properties.Add("ColumnNo", toColumn);
                properties.Add("RowNo", toRow);
                
                WorkflowHelper.ExecuteWorkflow( typeof( MoveWidgetInstanceWorkflow ), properties );
            }
        }

        public List<Widget> GetWidgetList()
        {
            return DatabaseHelper.GetDashboardData().Widgets.ToList();
        }

        public void AddWidget(int widgetId)
        {
            using( new TimedLog(this._UserName, "Add Widget" + widgetId) )
            {
                var properties = new Dictionary<string,object>();
                properties.Add("UserName", this._UserName);
                properties.Add("WidgetId", widgetId);
                
                WorkflowHelper.ExecuteWorkflow( typeof( AddWidgetWorkflow ), properties );
            }
        }

        public void RegisterAs(string email)
        {
            using( new TimedLog( this._UserName, "Register As: " + email) )
            {
                DashboardData db = DatabaseHelper.GetDashboardData();

                MembershipUser newUser = Membership.GetUser(email);
                
                // Get the User Id for the anonymous user from the aspnet_users table
                AspnetUser anonUser = db.AspnetUsers.Single( u => u.LoweredUserName == this._UserName && u.ApplicationId == DatabaseHelper.ApplicationGuid );

                Guid oldGuid = anonUser.UserId;
                Guid newGuid = (Guid)newUser.ProviderUserKey;

                // Move page ownership
                using( TransactionScope ts = new TransactionScope() )
                {
                    List<Page> pages = db.Pages.Where( p => p.UserId == oldGuid ).ToList();
                    foreach( Page page in pages )
                        page.UserId = newGuid;
                    
                    // Change setting ownership
                    UserSetting setting = db.UserSettings.Single( u => u.UserId == oldGuid );
                    db.UserSettings.Remove(setting);
                    
                    setting.UserId = newGuid;
                    db.UserSettings.Add(setting);
                    db.SubmitChanges();

                    ts.Complete();
                }
            }
        }

        public void ChangePageName(string newName)
        {
            using( new TimedLog(this._UserName, "Change Page Name") )
            {
                var properties = new Dictionary<string,object>();
                properties.Add("UserName", this._UserName);
                var userSetup = new UserPageSetup();
                properties.Add("PageName", newName);
                    
                WorkflowHelper.ExecuteWorkflow( typeof( ChangePageNameWorkflow ), properties ); 
            }
        }
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Omar Al Zabir
Architect BT, UK (ex British Telecom)
United Kingdom United Kingdom

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150520.1 | Last Updated 10 Mar 2010
Article Copyright 2007 by Omar Al Zabir
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid