Click here to Skip to main content
15,896,915 members
Articles / Web Development / ASP.NET

Zeta Enterprise Library

Rate me:
Please Sign up or sign in to vote.
4.97/5 (14 votes)
16 Jan 2010CPOL3 min read 50.4K   2.3K   48  
A small set of general-purpose classes for using in .NET applications (2.0 or higher)
namespace Zeta.EnterpriseLibrary.Data.Common
{
	#region Using directives.
	// ----------------------------------------------------------------------

	using System.ComponentModel;
	using System.Data;

	// ----------------------------------------------------------------------
	#endregion

	/////////////////////////////////////////////////////////////////////////

	/// <summary>
	/// Class to pass additional information to an updater class.
	/// </summary>
	public class AdoNetUpdaterInformation
	{
		#region Public methods.
		// ------------------------------------------------------------------

		/// <summary>
		/// Initializes a new instance of the
		/// <see cref="AdoNetUpdaterInformation"/> class.
		/// </summary>
		public AdoNetUpdaterInformation()
		{
		}

		/// <summary>
		/// Initializes a new instance of the
		/// <see cref="AdoNetUpdaterInformation"/> class.
		/// </summary>
		/// <param name="continueUpdateOnError">if set to <c>true</c>
		/// [continue update on error].</param>
		public AdoNetUpdaterInformation(
			bool continueUpdateOnError )
		{
			_continueUpdateOnError = continueUpdateOnError;
		}

		/// <summary>
		/// Initializes a new instance of the
		/// <see cref="AdoNetUpdaterInformation"/> class.
		/// </summary>
		/// <param name="continueUpdateOnError">if set to <c>true</c>
		/// [continue update on error].</param>
		/// <param name="conflictOption">The conflict option.</param>
		public AdoNetUpdaterInformation(
			bool continueUpdateOnError,
			ConflictOption conflictOption )
		{
			_continueUpdateOnError = continueUpdateOnError;
			_conflictOption = conflictOption;
		}

		/// <summary>
		/// Notifies the error occured.
		/// </summary>
		/// <param name="sender">The sender.</param>
		/// <param name="args">The <see cref="UpdateErrorOccurredEventArgs"/> 
		/// instance containing the event data.</param>
		internal void NotifyErrorOccured(
			object sender,
			UpdateErrorOccurredEventArgs args )
		{
			if ( UpdateErrorOccured != null )
			{
				UpdateErrorOccured( sender, args );
			}
		}

		/// <summary>
		/// Notifies the row updated zero records affected.
		/// </summary>
		/// <param name="sender">The sender.</param>
		/// <param name="args">The <see cref="RowUpdatedErrorOccurredEventArgs"/> 
		/// instance containing the event data.</param>
		internal void NotifyRowUpdatedErrorOccured(
			object sender,
			RowUpdatedErrorOccurredEventArgs args )
		{
			if ( RowUpdatedErrorOccured != null )
			{
				RowUpdatedErrorOccured( sender, args );
			}
		}

		/// <summary>
		/// Notifies the row updating error occurs.
		/// </summary>
		/// <param name="sender">The sender.</param>
		/// <param name="args">The <see cref="RowUpdatingErrorOccursEventArgs"/> 
		/// instance containing the event data.</param>
		public void NotifyRowUpdatingErrorOccurs(
			object sender,
			RowUpdatingErrorOccursEventArgs args )
		{
			if ( RowUpdatingErrorOccurs != null )
			{
				RowUpdatingErrorOccurs( sender, args );
			}
		}

		// ------------------------------------------------------------------
		#endregion

		#region Public events.
		// ------------------------------------------------------------------

		/// <summary>
		/// Event to be called after an update error occured, to give
		/// callers a chance to handle.
		/// </summary>
		public event UpdateErrorOccurredEvent UpdateErrorOccured;

		/// <summary>
		/// Event to be called after an update affected zero records, to give
		/// callers a chance to handle.
		/// </summary>
		public event RowUpdatedErrorOccurredEvent RowUpdatedErrorOccured;

		/// <summary>
		/// Occurs when [row updating error occurs].
		/// </summary>
		public event RowUpdatingErrorOccursEvent RowUpdatingErrorOccurs;

		// ------------------------------------------------------------------
		#endregion

		#region Public properties.
		// ------------------------------------------------------------------

		/// <summary>
		/// Gets a value indicating whether [continue update on error].
		/// </summary>
		/// <value>
		/// 	<c>true</c> if [continue update on error]; otherwise, <c>false</c>.
		/// </value>
		[DefaultValue( false )]
		public bool ContinueUpdateOnError
		{
			get
			{
				return _continueUpdateOnError;
			}
		}

		/// <summary>
		/// Gets the conflict option.
		/// </summary>
		/// <value>The conflict option.</value>
		/// <remarks>
		/// Since I got lots of DBConcurrencyException inside the ZP8 project,
		/// I decided to make the default conflict option to "OverwriteChanges",
		/// meaning that only the primary key is compared and that the last one 
		/// (in a multithreaded environment) wins. For mose of MY scenarios, 
		/// this is sufficient.
		/// See http://entwickler-forum.de/showthread.php?t=39541
		/// </remarks>
		[DefaultValue( ConflictOption.OverwriteChanges )]
		public ConflictOption ConflictOption
		{
			get
			{
				return _conflictOption;
			}
		}

		// ------------------------------------------------------------------
		#endregion

		#region Private variables.
		// ------------------------------------------------------------------

		private readonly bool _continueUpdateOnError;
		private readonly ConflictOption _conflictOption =
			ConflictOption.OverwriteChanges;

		// ------------------------------------------------------------------
		#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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Zeta Software GmbH
Germany Germany
Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.

➡️ Give me a tip 🙂

In his free time, he does climbing, running and mountain biking. In 2012 he became a father of a cute boy and in 2014 of an awesome girl.

Some cool, free software from us:

Windows 10 Ereignisanzeige  
German Developer Community  
Free Test Management Software - Intuitive, competitive, Test Plans.  
Homepage erstellen - Intuitive, very easy to use.  
Offline-Homepage-Baukasten

Comments and Discussions