Click here to Skip to main content
11,410,365 members (54,107 online)
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.Text;
using System.Xml;
using System.Xml.Serialization;
using SmartInstitute;

#endregion

namespace SmartInstitute.ObjectModel
{
	public delegate void ItemChangeHandler( ItemBase item, string changeType );

	public delegate void ItemDetachHandler( ItemBase item );

	public delegate void ItemSelectHandler( ItemBase item );

	public delegate void ItemShowHandler( ItemBase item );

	public delegate void ItemUndoStateHandler( ItemBase item );

	public delegate void ItemRedoStateHandler( ItemBase item );

	public delegate void ItemBeginUpdateHandler( ItemBase item, string name );
	
	public delegate void ItemEndUpdateHandler( ItemBase item );

	public delegate bool ItemQueryClose( ItemBase item );

	/// <summary>
	/// Base class for all item. This class provides support for
	/// observable items
	/// </summary>
	[Serializable]
	public abstract class ItemBase : IDisposable, IXml
	{
		#region Contants

		public const string NOTIFICATION_PROPERTY_CHANGE = "Property Change";

		#endregion

		#region Events

		public virtual event ItemBeginUpdateHandler OnBeginUpdate;
		public virtual event ItemEndUpdateHandler OnEndUpdate;

		public virtual event ItemUndoStateHandler OnUndoState;
		public virtual event ItemRedoStateHandler OnRedoState;

		public virtual event ItemSelectHandler OnSelect;
		public virtual event ItemQueryClose OnQueryClose;

		/// <summary>
		/// Event to notify that the item is changed
		/// </summary>
		public virtual event ItemChangeHandler OnChange;

		/// <summary>
		/// Event to notify observers to detach from the item
		/// </summary>
		public virtual event ItemDetachHandler OnDetach;

		/// <summary>
		/// Show the item in UI
		/// </summary>
		public virtual event ItemShowHandler OnShow;

		#endregion

		#region Properties

		private bool _Selected = false;

		private bool _IsDirty = false;

		[NonSerialized][XmlIgnore] private WeakReference _Parent = null;

		private bool _Visible = true;

		private bool _Enabled = true;

		/// <summary>
		/// Contains  a stack of state for the item. Whenever a state needs to be saved,
		/// push in the stack. 
		/// </summary>
		[NonSerialized] internal Stack<State> States = new Stack<State>();

		[XmlElement("v")]
		public bool Visible
		{
			get
			{
				return _Visible;
			}
			set
			{
				if( this._Visible != value )
				{
					_Visible = value;
					if( value == true )
						this.Show();
				}
			}
		}

		[XmlAttribute("e")]
		public bool Enabled
		{
			get
			{
				return _Enabled;
			}
			set
			{
				_Enabled = value;
			}
		}

		[XmlIgnore] 
		public object Parent
		{
			get
			{
				if( _Parent.IsAlive )
				{
					return _Parent.Target;
				}
				else
				{
					return null;
				}
			}
			set
			{
				_Parent = new WeakReference( value );
			}
		}

		[XmlAttribute("i")]
		public virtual bool IsDirty
		{
			get
			{
				return _IsDirty;
			}
			set
			{
				_IsDirty = value;
			}
		}

		[XmlAttribute("s")]
		public virtual bool Selected
		{
			get
			{
				return _Selected;
			}
			set
			{
				bool oldValue = _Selected;

				_Selected = value;

				// Fire notification event only when selection is changed
				if( _Selected != oldValue )
				{
					NotifySelect( );
				}
			}
		}

		#endregion

		#region Methods

		public virtual void Show( )
		{
			if( false == this._Visible )
				this._Visible = true;

			NotifyShow( this );
		}

		public virtual void Dispose( )
		{
			NotifyDetach( );
		}

		#endregion

		#region Notifications 

		protected virtual bool NotifyQueryClose(ItemBase item)
		{
			if (null != OnQueryClose)
				return OnQueryClose(item);
			else
				return true;
		}

		public virtual bool NotifyQueryClose()
		{
			return this.NotifyQueryClose(this);
		}

		protected virtual void NotifySelect( ItemBase item )
		{
			if( null != OnSelect )
			{
				OnSelect( item );
			}
		}

		public virtual void NotifySelect( )
		{
			this.NotifySelect( this );
		}

		public virtual void NotifyChange( string changeType )
		{
			this.NotifyChange( this, changeType );
		}

		protected virtual void NotifyChange( ItemBase item, string changeType )
		{
			if( null != OnChange )
			{
				OnChange( item, changeType );
			}
		}

		public virtual void NotifyDetach( )
		{
			this.NotifyDetach( this );
		}

		protected virtual void NotifyDetach( ItemBase item )
		{
			if( null != OnDetach )
			{
				OnDetach( item );
			}
		}

		protected virtual void NotifyShow( )
		{
			this.NotifyShow( this );
		}

		protected virtual void NotifyShow( ItemBase item )
		{
			if( null != OnShow )
			{
				OnShow( this );
			}
		}

		#endregion

		#region Child collection event handling

		// --------------------- Child Collection event handling -------------------------

		public event CollectionAddHandler OnCollectionAdd;
		public event CollectionRemoveHandler OnCollectionRemove;
		public event CollectionClearHandler OnCollectionClear;
		public event SelectionChangeHandler OnSelectionChanged;

		protected void ListenCollection( CollectionBase collection )
		{
			collection.OnItemCollectionAdd += new CollectionAddHandler( collection_OnAdd );
			collection.OnItemChange += new ItemChangeHandler( collection_OnChange );
			collection.OnItemCollectionClear += new CollectionClearHandler( collection_OnClear );
			collection.OnItemDetach += new ItemDetachHandler( collection_OnDetach );
			collection.OnItemCollectionRemove += new CollectionRemoveHandler( collection_OnRemove );
			collection.OnItemShow += new ItemShowHandler( collection_OnShow );
			collection.OnItemCollectionSelectionChanged += new SelectionChangeHandler(collection_OnSelectionChanged);
		}

		protected void ListenCollection( SelectableCollection<ItemBase> collection )
		{
			ListenCollection( (CollectionBase) collection );
			collection.OnSelectionChanged += new SelectionChangeHandler( collection_OnSelectionChanged );
		}

		private void collection_OnAdd( CollectionBase collection, ItemBase item )
		{
			if( null != OnCollectionAdd )
			{
				OnCollectionAdd( collection, item );
			}
		}

		private void collection_OnChange( ItemBase item, string changeType )
		{
			if( null != OnChange )
			{
				OnChange( item, changeType );
			}
		}

		private void collection_OnClear( CollectionBase collection )
		{
			if( null != OnCollectionClear )
			{
				OnCollectionClear( collection );
			}
		}

		private void collection_OnDetach( ItemBase item )
		{
			if( null != OnDetach )
			{
				OnDetach( item );
			}
		}

		private void collection_OnRemove( CollectionBase collection, ItemBase item )
		{
			if( null != OnCollectionRemove )
			{
				OnCollectionRemove( collection, item );
			}
		}

		private void collection_OnShow( ItemBase item )
		{
			if( null != OnShow )
			{
				OnShow( item );
			}
		}


		private void collection_OnSelectionChanged( CollectionBase collection, ItemBase item )
		{
			if( null != OnSelectionChanged )
			{
				OnSelectionChanged( collection, item );
			}
		}

		#endregion

		#region Child Item event handling

		// ----------------------- Child Item event handling --------------------

		protected void ListenChildItem( ItemBase item )
		{
			item.OnChange += new ItemChangeHandler( item_OnChange );
			item.OnDetach += new ItemDetachHandler( item_OnDetach );
			item.OnSelect += new ItemSelectHandler( item_OnSelect );
			item.OnShow += new ItemShowHandler( item_OnShow );

			item.OnUndoState += new ItemUndoStateHandler(item_OnUndoState);
			item.OnRedoState += new ItemRedoStateHandler(item_OnRedoState);
			item.OnBeginUpdate += new ItemBeginUpdateHandler(item_OnRecordState);
			item.OnEndUpdate += new ItemEndUpdateHandler(item_OnEndUpdate);

			item.OnCollectionAdd += new CollectionAddHandler( collection_OnAdd );
			item.OnCollectionClear += new CollectionClearHandler( collection_OnClear );
			item.OnCollectionRemove += new CollectionRemoveHandler( collection_OnRemove );
			item.OnSelectionChanged += new SelectionChangeHandler( collection_OnSelectionChanged );
		}

		private void item_OnChange( ItemBase item, string changeType )
		{
			NotifyChange( item, changeType );
		}

		private void item_OnDetach( ItemBase item )
		{
			NotifyDetach( item );
		}

		private void item_OnSelect( ItemBase item )
		{
			NotifySelect( item );
		}

		private void item_OnShow( ItemBase item )
		{
			NotifyShow( item );
		}

		#endregion

		protected ItemBase( object parent )
		{
			this.Parent = parent;
		}

		#region IXml Members

		public virtual bool ToXml( XmlElement element )
		{
			return true ;
		}

		public virtual bool FromXml(XmlElement element)
		{
			return true;
		}

		#endregion

		#region State Management

		public virtual void Undo()
		{
			if( null != OnUndoState )
				OnUndoState( this );
		}

		public virtual void Redo()
		{
			if( null != OnRedoState )
				OnRedoState( this );
		}

		public virtual void BeginUpdate( string name )
		{
			if( null != OnBeginUpdate )
				OnBeginUpdate( this, name );
		}

		public virtual void EndUpdate()
		{
			if( null != OnEndUpdate )
				OnEndUpdate( this );
		}

		public virtual State StoreState( string name, int id )
		{
			State state = new State( name, id );
			this.States.Push( state );
			return state;
		}

		public virtual State RestoreState()
		{
			State state = States.Pop() as State;
			return state;
		}

		public virtual State LastState()
		{
			return States.Peek() as State;
		}

		#endregion

		#region Undo Redo

		private void item_OnUndoState(ItemBase item)
		{
			if( null != OnUndoState )
				OnUndoState( item );
		}

		private void item_OnRedoState(ItemBase item)
		{
			if( null != OnRedoState )
				OnRedoState( item );
		}

		private void item_OnRecordState(ItemBase item, string name)
		{
			if( null != OnBeginUpdate )
				OnBeginUpdate( item, name );
		}

		private void item_OnEndUpdate(ItemBase item)
		{
			if( null != OnEndUpdate )
				OnEndUpdate( item );
		}
 
		#endregion	
	}
}

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

Share

About the Author

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150414.5 | Last Updated 17 Aug 2005
Article Copyright 2005 by Omar Al Zabir
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid