Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Developing Next Generation Smart Clients using .NET 2.0 working with Existing .NET 1.1 SOA-based XML Web Services

, 16 Aug 2005
Comprehensive guide to development of .NET 2.0 Smart Clients working with existing Service Oriented Architecture based XML web services, fully utilizing the Enterprise Library
smartclientsoa_src.zip
SmartClient
Client
SMI.App
Controls
Forms
Modules
Properties
app.manifest
Settings.settings
Resources
240.png
Bottom.png
BuilderDialog_delete.bmp
DarkBlue.bmp
download-xp.gif
Earth.png
fldropen.png
iSync.gif
Leonardo_da_Vinci_My_Computer.png
LightBlue.bmp
LoginBox.jpg
LoginButton.jpg
LoginButton1.jpg
LoginButton2.jpg
Logo1.png
LogoPic.jpg
Middle.png
Refresh.bmp
refresh.ico
refresh1.ico
RightArrow.bmp
SuccessComplete.bmp
Task.bmp
Tasks.png
Top.png
TurnOffButton.bmp
wi0062-32.ico
wi0063-32.ico
wi0064-16.ico
wi0064-32.ico
SmartInstitute.App.csproj.user
wi0064-32.ico
SMI.Automation
Commands
Course
Framework
Security
Students
UI
Controls
Documents
MiscDocuments
StudentDocuments
Factories
Forms
Helpers
Misc
Properties
Settings.settings
Resources
BuilderDialog_delete.bmp
LogoSmall.bmp
Misho.jpg
My Pic 7.jpg
table.ico
SmartInstitute.Automation.csproj.user
Web References
SmartInstituteServices.AccountService
Account.datasource
AccountService.disco
AccountService.wsdl
Reference.map
SmartInstituteServices.CourseService
Course.datasource
CourseService.disco
CourseService.wsdl
Reference.map
SmartInstituteServices.SecurityService
Reference.map
SecurityService.disco
SecurityService.wsdl
SmartInstituteServices.StudentService
Reference.map
Student.datasource
StudentService.disco
StudentService.wsdl
SMI.ObjectModel.Enhanced
Base
Models
Properties
Settings.settings
Settings
SmartInstitute.ObjectModel.csproj.user
UMS.ObjectModel.Enhanced.csproj.user
SMI.Objects
SmartInstitute.csproj.user
CodeSmith
Tier
BusinessLogicLayer
Entity.cst
EntityBase.cst
EntityCollection.cst
EntityCollectionBase.cst
Enum.cst
IEntity.cst
DataAccessLayer
App.config.cst
CommonSql.cst
Configuration.cst
DBConcurrencyException.cst
DBException.cst
Factories
EntityRepositoryFactory.cst
IEntityRepository.cst
SqlClient
CVS
Entries
Entries.Extra
Entries.Extra.Old
Entries.Old
Repository
Root
TortoiseCVS.Status
SqlEntityRepository.cst
SqlEntityRepositoryBase.cst
TransactionManager.cst
UnitTests
EntityRepositoryTest.cst
WebServiceClient
WsEntityRepository.cst
WsEntityRepositoryBase.cst
Main.cst
nant.cst
References
GotDotNet.ApplicationBlocks.Data.dll
Microsoft.ApplicationBlocks.Data.dll
nunit.framework.dll
StoredProcedures.cst
vsnet2003.project.cst
vsnet2003.solution.cst
vsnet2005.project.cst
vsnet2005.solution.cst
WebService
Web.config.cst
WebService.cst
Database
SmartInstitute.bak
Library
Microsoft.Practices.EnterpriseLibrary.Caching.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Configuration.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll
Microsoft.Practices.EnterpriseLibrary.Logging.dll
Microsoft.Practices.EnterpriseLibrary.Security.ActiveDirectory.dll
Microsoft.Practices.EnterpriseLibrary.Security.Cache.CachingStore.dll
Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.dll
Microsoft.Practices.EnterpriseLibrary.Security.Database.Authentication.dll
Microsoft.Practices.EnterpriseLibrary.Security.Database.dll
Microsoft.Practices.EnterpriseLibrary.Security.dll
nunit.core.dll
nunit.framework.dll
Server
BLL
SmartInstitute.csproj.user
DAL
Factories
SmartInstitute.DataAccessLayer.csproj.user
SqlClient
Utilities
GotDotNet.ApplicationBlocks.Data.dll
Microsoft.ApplicationBlocks.Data.dll
nunit.framework.dll
UnitTests
SmartInstitute.build
SmartInstitute.Facade
FacadeTest
SmartInstitute.Facade.csproj.user
SmartInstitute.Test
App.ico
SmartInstitute.Test.csproj.user
SmartInstituteServices
Global.asax
log
SmartInstituteServices.csproj.webinfo
SQL
Setup
SecurityDatabase
SecurityDatabaseConsole
App.ico
SecurityDatabaseConsole.exe.manifest
SR.strings
Tests
Tools.SecurityDatabaseConsole.csproj.user
#region Using directives

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.Threading;
using SmartInstitute.Automation.Commands.Framework;
using SmartInstitute.Client.Automation;
using SmartInstitute.Client.Automation.Commands.UI;
using SmartInstitute.ObjectModel;
using SmartInstitute.Automation.Commands.Course;
using SmartInstitute.Automation.Commands.UI;

#endregion

namespace SmartInstitute.Client.Modules
{
	public partial class ClassListPane : UserControl
	{
		public ClassListPane()
		{
			InitializeComponent();

			_Application.Courses.OnRefresh += new CollectionRefreshHandler(Courses_OnRefresh);
		}

		private void ClassListFile_Load(object sender, EventArgs e)
		{
			if( !base.DesignMode )
				this.LoadCourseList();	
		}

		#region Loading Course List

		/// <summary>
		/// Loads class list from server
		/// </summary>
		private void LoadCourseList()
		{
			// 1. Show progress
			this.ShowProgress();

			// 2. Asynchronously load class list from server
			this.backgroundTask.RunWorkerAsync();
		}

		private void backgroundTask_DoWork(object sender, DoWorkEventArgs e)
		{
			// This method will run on a thread other than the UI thread.
			// Be sure not to manipulate any Windows Forms controls created
			// on the UI thread from this method.

			this.LoadCoursesBackground();
		}

		private void LoadCoursesBackground()
		{
			ICommand command = new LoadAllCourseCommand();
			command.Execute();
		}

		private void backgroundTask_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
		{
			if (e.Cancelled)
			{
				Exception x = (Exception)e.Result;
				MessageBox.Show(this, "Error occured while loading courses. Please try again later. " + x.Message,
					"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
			else
			{
				if (this.InvokeRequired)
					this.Invoke(new MethodInvoker(this.LoadComplete));
				else
					this.LoadComplete();
			}
		}

		private void LoadComplete()
		{
			// 1. Pause progress and show wait message 
			//this.lblProgress.Text = "Please wait...";
			//this.lblProgress.Refresh();
			this.pnlProgress.Visible = false;

			// 2. Populate the course tree
			this.courseTree.Load();

			// 3. Build the course search drop down cache
			this.BuildSearchList();

			// 4. Hide progress
			this.HideProgress();
		}

		#endregion

		#region Progress

		/// <summary>
		/// Show the progress screen and start the progress
		/// </summary>
		private void ShowProgress()
		{
			this.pnlProgress.Visible = true;
			//this.pnlProgress.BringToFront();
            this.progressPanel.Start();
        }

		private void HideProgress()
		{
            this.progressPanel.Stop();
            this.pnlProgress.Visible = false;
		}

		#endregion

		#region Seach Text Box routines - Search by class ID or title

		private MethodInvoker SearchInBackground = null;

		private void txtSearch_TextChanged(object sender, EventArgs e)
		{
			int classID;
			if (int.TryParse(txtSearch.Text, out classID))
			{
				// this is a class ID user is typing. So try to find match by
				// class ID
				if (null == this.SearchInBackground)
				{
					this.SearchInBackground = this.FindByClassID;
					this.BeginInvoke(this.SearchInBackground);
				}
			}
			else
			{
				// User is trying to search by title, find matches
				if (null == this.SearchInBackground)
				{
					this.SearchInBackground = this.FindByTitle;
					this.BeginInvoke(this.SearchInBackground);
				}
			}
		}

		/// <summary>
		/// Pupulate the search text box Auto Complete Source with all the course names
		/// </summary>
		private void BuildSearchList()
		{
			foreach (OfferedCourseTree.CourseNode courseNode in courseTree.Nodes)
			{
				this.txtSearch.AutoCompleteCustomSource.Add(courseNode.Course.Title);
			}
		}

		/// <summary>
		/// Delegate is used to select the matched tree node from background thread
		/// </summary>
		/// <param name="node"></param>
		private delegate void SelectNodeDelegate( TreeNode node );

		private void SelectNode( TreeNode node )
		{
			this.courseTree.SelectedNode = node;
		}

		/// <summary>
		/// Find the section in the tree which has the closed match to the class ID
		/// </summary>
		private void FindByClassID()
		{
			this.SearchInBackground = null;

			if (0 == this.txtSearch.Text.Length)
				return;

			// For each course, check each section and match the class ID
			foreach (OfferedCourseTree.CourseNode courseNode in courseTree.Nodes)
			{
				foreach (OfferedCourseTree.SectionNode sectionNode in courseNode.Nodes)
				{
					// Match the class ID from back. For ex, if user types 123, match
					// class ID = 00123
					if (sectionNode.Section.ClassID.EndsWith(txtSearch.Text, true, CultureInfo.CurrentCulture))
					{
						this.Invoke(new SelectNodeDelegate(SelectNode), new object[] { sectionNode } );
						return;
					}
				}
			}
		}

		/// <summary>
		/// Find the course that has the match
		/// </summary>
		private void FindByTitle()
		{
			this.SearchInBackground = null;

			if (0 == txtSearch.Text.Length)
				return;

			foreach (OfferedCourseTree.CourseNode courseNode in courseTree.Nodes)
			{
				if (courseNode.Course.Title.StartsWith(txtSearch.Text, true, CultureInfo.CurrentCulture))
				{
					this.Invoke(new SelectNodeDelegate(SelectNode), new object[] { courseNode });
					return;
				}
			}

		}

		#endregion

		private void btnRefresh_Click(object sender, EventArgs e)
		{
			this.LoadCourseList();
		}

		private void txtSearch_KeyUp(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Enter)
			{
				this.courseTree.Focus();
				e.Handled = true;
			}
		}

		void Courses_OnRefresh( CollectionBase collection )
		{
			this.LoadCourseList();
		}

		private void RegisterSelectedCourse()
		{
			if (null != courseTree.SelectedNode)
			{
				// Only section can be added
				if (courseTree.SelectedNode is OfferedCourseTree.SectionNode)
				{
					OfferedCourseTree.SectionNode sectionNode = courseTree.SelectedNode as OfferedCourseTree.SectionNode;

					ICommand command = new AddCourseCommand(sectionNode.Section, this);
					command.Execute();
				}
			}
		}

		private void courseTree_DoubleClick(object sender, EventArgs e)
		{
			this.RegisterSelectedCourse();
		}

		private void addToolStripMenuItem_Click(object sender, EventArgs e)
		{
			this.RegisterSelectedCourse();
		}
	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author


| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 17 Aug 2005
Article Copyright 2005 by Omar Al Zabir
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid