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

FrameControl - Framework for creating web applications

Rate me:
Please Sign up or sign in to vote.
2.88/5 (8 votes)
25 Jul 20033 min read 83.5K   40  
FrameControl is a framework that contains the code common for most of the web applications.
  • framecontrol_demo.zip
    • doc
      • banner.htm
      • banner.jpg
      • CodeCommentReportError.htm
      • commentreport.css
      • darkcorner.jpg
      • FrameControl1
        • CWP0.HTM
        • CWP10.HTM
        • CWP100.HTM
        • CWP101.HTM
        • CWP102.HTM
        • CWP103.HTM
        • CWP104.HTM
        • CWP105.HTM
        • CWP106.HTM
        • CWP107.HTM
        • CWP108.HTM
        • CWP109.HTM
        • CWP11.HTM
        • CWP110.HTM
        • CWP111.HTM
        • CWP112.HTM
        • CWP113.HTM
        • CWP114.HTM
        • CWP115.HTM
        • CWP116.HTM
        • CWP117.HTM
        • CWP118.HTM
        • CWP119.HTM
        • CWP12.HTM
        • CWP120.HTM
        • CWP121.HTM
        • CWP122.HTM
        • CWP123.HTM
        • CWP124.HTM
        • CWP125.HTM
        • CWP126.HTM
        • CWP127.HTM
        • CWP128.HTM
        • CWP129.HTM
        • CWP13.HTM
        • CWP130.HTM
        • CWP131.HTM
        • CWP132.HTM
        • CWP133.HTM
        • CWP134.HTM
        • CWP135.HTM
        • CWP136.HTM
        • CWP137.HTM
        • CWP138.HTM
        • CWP139.HTM
        • CWP14.HTM
        • CWP140.HTM
        • CWP15.HTM
        • CWP16.HTM
        • CWP17.HTM
        • CWP18.HTM
        • CWP19.HTM
        • CWP2.HTM
        • CWP20.HTM
        • CWP21.HTM
        • CWP22.HTM
        • CWP23.HTM
        • CWP24.HTM
        • CWP25.HTM
        • CWP26.HTM
        • CWP27.HTM
        • CWP28.HTM
        • CWP29.HTM
        • CWP3.HTM
        • CWP30.HTM
        • CWP31.HTM
        • CWP32.HTM
        • CWP33.HTM
        • CWP34.HTM
        • CWP35.HTM
        • CWP36.HTM
        • CWP37.HTM
        • CWP38.HTM
        • CWP39.HTM
        • CWP4.HTM
        • CWP40.HTM
        • CWP41.HTM
        • CWP42.HTM
        • CWP43.HTM
        • CWP44.HTM
        • CWP45.HTM
        • CWP46.HTM
        • CWP47.HTM
        • CWP48.HTM
        • CWP49.HTM
        • CWP5.HTM
        • CWP50.HTM
        • CWP51.HTM
        • CWP52.HTM
        • CWP53.HTM
        • CWP54.HTM
        • CWP55.HTM
        • CWP56.HTM
        • CWP57.HTM
        • CWP58.HTM
        • CWP59.HTM
        • CWP6.HTM
        • CWP60.HTM
        • CWP61.HTM
        • CWP62.HTM
        • CWP63.HTM
        • CWP64.HTM
        • CWP65.HTM
        • CWP66.HTM
        • CWP67.HTM
        • CWP68.HTM
        • CWP69.HTM
        • CWP7.HTM
        • CWP70.HTM
        • CWP71.HTM
        • CWP72.HTM
        • CWP73.HTM
        • CWP74.HTM
        • CWP75.HTM
        • CWP76.HTM
        • CWP77.HTM
        • CWP78.HTM
        • CWP79.HTM
        • CWP8.HTM
        • CWP80.HTM
        • CWP81.HTM
        • CWP82.HTM
        • CWP83.HTM
        • CWP84.HTM
        • CWP85.HTM
        • CWP86.HTM
        • CWP87.HTM
        • CWP88.HTM
        • CWP89.HTM
        • CWP9.HTM
        • CWP90.HTM
        • CWP91.HTM
        • CWP92.HTM
        • CWP93.HTM
        • CWP94.HTM
        • CWP95.HTM
        • CWP96.HTM
        • CWP97.HTM
        • CWP98.HTM
        • CWP99.HTM
        • FrameControl1.HTM
      • gradleft.jpg
      • gradtop.jpg
      • graycorner.jpg
      • minus.jpg
      • plus.jpg
      • Solution_FrameControl1.HTM
      • titletile.jpg
      • vt.js
    • FrameControl1.dll
    • readme.txt
  • framecontrol_src.zip
    • ActionClass.cs
    • ActionClassContainer.cs
    • ApplicationTransit.cs
    • AssemblyInfo.cs
    • BaseControl.cs
    • CryptoDecrypt.cs
    • DispatchRequest.cs
    • DisplayCentral.cs
    • banner.htm
    • banner.jpg
    • CodeCommentReportError.htm
    • commentreport.css
    • darkcorner.jpg
    • CWP0.HTM
    • CWP10.HTM
    • CWP100.HTM
    • CWP101.HTM
    • CWP102.HTM
    • CWP103.HTM
    • CWP104.HTM
    • CWP105.HTM
    • CWP106.HTM
    • CWP107.HTM
    • CWP108.HTM
    • CWP109.HTM
    • CWP11.HTM
    • CWP110.HTM
    • CWP111.HTM
    • CWP112.HTM
    • CWP113.HTM
    • CWP114.HTM
    • CWP115.HTM
    • CWP116.HTM
    • CWP117.HTM
    • CWP118.HTM
    • CWP119.HTM
    • CWP12.HTM
    • CWP120.HTM
    • CWP121.HTM
    • CWP122.HTM
    • CWP123.HTM
    • CWP124.HTM
    • CWP125.HTM
    • CWP126.HTM
    • CWP127.HTM
    • CWP128.HTM
    • CWP129.HTM
    • CWP13.HTM
    • CWP130.HTM
    • CWP131.HTM
    • CWP132.HTM
    • CWP133.HTM
    • CWP134.HTM
    • CWP135.HTM
    • CWP136.HTM
    • CWP137.HTM
    • CWP138.HTM
    • CWP139.HTM
    • CWP14.HTM
    • CWP140.HTM
    • CWP141.HTM
    • CWP142.HTM
    • CWP143.HTM
    • CWP144.HTM
    • CWP145.HTM
    • CWP146.HTM
    • CWP147.HTM
    • CWP15.HTM
    • CWP16.HTM
    • CWP17.HTM
    • CWP18.HTM
    • CWP19.HTM
    • CWP2.HTM
    • CWP20.HTM
    • CWP21.HTM
    • CWP22.HTM
    • CWP23.HTM
    • CWP24.HTM
    • CWP25.HTM
    • CWP26.HTM
    • CWP27.HTM
    • CWP28.HTM
    • CWP29.HTM
    • CWP3.HTM
    • CWP30.HTM
    • CWP31.HTM
    • CWP32.HTM
    • CWP33.HTM
    • CWP34.HTM
    • CWP35.HTM
    • CWP36.HTM
    • CWP37.HTM
    • CWP38.HTM
    • CWP39.HTM
    • CWP4.HTM
    • CWP40.HTM
    • CWP41.HTM
    • CWP42.HTM
    • CWP43.HTM
    • CWP44.HTM
    • CWP45.HTM
    • CWP46.HTM
    • CWP47.HTM
    • CWP48.HTM
    • CWP49.HTM
    • CWP5.HTM
    • CWP50.HTM
    • CWP51.HTM
    • CWP52.HTM
    • CWP53.HTM
    • CWP54.HTM
    • CWP55.HTM
    • CWP56.HTM
    • CWP57.HTM
    • CWP58.HTM
    • CWP59.HTM
    • CWP6.HTM
    • CWP60.HTM
    • CWP61.HTM
    • CWP62.HTM
    • CWP63.HTM
    • CWP64.HTM
    • CWP65.HTM
    • CWP66.HTM
    • CWP67.HTM
    • CWP68.HTM
    • CWP69.HTM
    • CWP7.HTM
    • CWP70.HTM
    • CWP71.HTM
    • CWP72.HTM
    • CWP73.HTM
    • CWP74.HTM
    • CWP75.HTM
    • CWP76.HTM
    • CWP77.HTM
    • CWP78.HTM
    • CWP79.HTM
    • CWP8.HTM
    • CWP80.HTM
    • CWP81.HTM
    • CWP82.HTM
    • CWP83.HTM
    • CWP84.HTM
    • CWP85.HTM
    • CWP86.HTM
    • CWP87.HTM
    • CWP88.HTM
    • CWP89.HTM
    • CWP9.HTM
    • CWP90.HTM
    • CWP91.HTM
    • CWP92.HTM
    • CWP93.HTM
    • CWP94.HTM
    • CWP95.HTM
    • CWP96.HTM
    • CWP97.HTM
    • CWP98.HTM
    • CWP99.HTM
    • FrameControl1.HTM
    • gradleft.jpg
    • gradtop.jpg
    • graycorner.jpg
    • linestat.html
    • minus.jpg
    • plus.jpg
    • Solution_FrameControl1.HTM
    • titletile.jpg
    • vt.js
    • FrameControl_install.zip
    • FrameControl1.csproj
    • FrameControl1.csproj.user
    • FrameControl1.sln
    • Global.cs
    • JMTools.cs
    • obj
      • Debug
        • temp
        • TempPE
      • Release
        • FrameControl1.dll
        • FrameControl1.projdata
        • temp
        • TempPE
    • RewriteURL.cs
    • SessionTransit.cs
    • SPGenerator.cs
using System;
using System.Collections;
using System.Reflection;
using System.Xml;

namespace JobMorning
{
	/// <summary>
	/// ActionClassContainer deals with the collection of objects of type ActionClass during the application 
	/// life. It is also a wrapper for all ActionClass functions that can call the methods of a specific 
	/// ActionClass using its page name reference.
	/// </summary>
	public class ActionClassContainer
	{
		// contains all instantiated children of the base class ActionClass.
		private Hashtable actionClassObjects;
		// contains the type of all ActionClass objects.
		private Hashtable actionClassTypes;

		// reference to the current Session Object
		private System.Web.SessionState.HttpSessionState sessionObject;
		
		public ActionClassContainer()
		{
			actionClassObjects = new Hashtable();
			actionClassTypes = new Hashtable();
		}
		
		/// <summary>
		/// Instatiate a class inheriting the base class ActionClass using the class name.
		/// Associates this new created class with an a page name.
		/// </summary>
		/// <param name="strActionClassName"></param>
		/// <returns>returns true if the class inheriting from ActionClass could be created successfully.</returns>
		public bool InstantiateActionClass(string strActionClassName, string strPage)
		{
			if (actionClassObjects[strPage]==null)
			{
				// object anActionClass;
				// anActionClass = Activator.CreateInstance(strActionClassName, "JobMorning.ActionClass");
			
				// Load the generated assembly into the ApplicationDomain 
				
					Object anActionClass;
					Type t = null;
					try
					{
						foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
						{
							t = asm.GetType(strActionClassName);
						
							if (t!=null)
							{
								anActionClass = Activator.CreateInstance(t);
								actionClassObjects.Add(strPage, anActionClass);
								actionClassTypes.Add(strPage, strActionClassName);
							} // if (t!=null)
						}
						return true;
					}
					catch (System.Reflection.TargetInvocationException e)
					{
						sessionObject["ERROR"]="The ActionClass "+strActionClassName+" could not be instantiated.";
						sessionObject["ERROR"]+="The constructor of the object class threw an exception. ";
						return false;
					}
					catch (System.ArgumentNullException)
					{
						sessionObject["ERROR"]="The type of "+strActionClassName+" could not be found in the ";
						sessionObject["ERROR"]+="running assembly. Make sure the type exists.";
						return false;
					}

				return false;
				/*
				// BindingFlags enumeration specifies flags that control binding and 
				// the way in which the search for members and types is conducted by reflection. 
				// The following specifies the Access Control of the bound type	
	
				BindingFlags bflags = BindingFlags.DeclaredOnly | BindingFlags.Public 
					| BindingFlags.NonPublic | BindingFlags.Instance;

				// Construct an instance of the type and invoke the member method	
				Object anActionClass = t.InvokeMember("doBeforeLoad", bflags | 
					BindingFlags.CreateInstance, null, null, null);
				*/
			
			}
			else
			{
				// ActionClass already instantiated.
				return false;
			}
		}

		/// <summary>
		/// Deletes an ActionClass associated to a page.
		/// </summary>
		/// <param name="strPage">The page name.</param>
		/// <returns></returns>
		public bool DisposeActionClass(string strPage)
		{
			bool rtnBool = true;
			rtnBool = actionClassObjects.Contains(strPage);
			actionClassObjects.Remove(strPage);
			return rtnBool;
		}
		
		/// <summary>
		/// Procedure called before the page mentionned in the XML file is loaded and displayed.
		/// </summary>
		public void DoBeforeDisplay(string strPage, string strXmlMCContext)
		{
			object anActionClass = actionClassObjects[strPage];
			string strType = (string)actionClassTypes[strPage];
			
			if (anActionClass!=null)
			{
				// Load the generated assembly into the ApplicationDomain 
				Type t;
				foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
				{
					t = asm.GetType(strType);
						
					if (t!=null)
					{
						// BindingFlags enumeration specifies flags that control binding and 
						// the way in which the search for members and types is conducted by reflection. 
						// The following specifies the Access Control of the bound type

						BindingFlags bflags = BindingFlags.DeclaredOnly | BindingFlags.Public 
							| BindingFlags.NonPublic | BindingFlags.Instance;
						string[] allParams = new string[1];
						allParams[0]=strXmlMCContext;
						// Call the method
						t.InvokeMember("DoBeforeDisplay", bflags | BindingFlags.InvokeMethod,
							null, anActionClass,allParams);
						break;
					} // if (t!=null)
				}
				
			}
		}
		
		
		/// <summary>
		/// doPageValidation validates the page input. 
		/// If the result is false, the page is displayed again with a PopUp message containing
		/// strErrorMessage. If no ActionClass is associated to the page, returns the value true.
		/// </summary>
		public bool ValidatePageBeforeSavePoints(string strPage,Hashtable pageInputs, out string strErrorMessage)
		{
			object anActionClass = actionClassObjects[strPage];
			string strType = (string)actionClassTypes[strPage];
			strErrorMessage = "";

			if (anActionClass!=null)
			{
				// Load the generated assembly into the ApplicationDomain 
				
				Type t;
				foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
				{
					t = asm.GetType(strType);
						
					if (t!=null)
					{

						// BindingFlags enumeration specifies flags that control binding and 
						// the way in which the search for members and types is conducted by reflection. 
						// The following specifies the Access Control of the bound type

						BindingFlags bflags = BindingFlags.DeclaredOnly | BindingFlags.Public 
							| BindingFlags.NonPublic | BindingFlags.Instance;
		
						object[] allParams = new object[2];
						allParams[0]=pageInputs;
						allParams[1]=strErrorMessage;
						// Call the method
						object boolRslt = t.InvokeMember("ValidatePageBeforeSavePoints", bflags | BindingFlags.InvokeMethod,
							null, anActionClass,allParams);
						strErrorMessage = (string)allParams[1];

						return ((bool)boolRslt);
					} // if (t!=null)
				} // foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
				return false;

				
			} // if (anActionClass!=null)
			else
			{
				return true;
			}
		}
		

		/// <summary>
		/// ValidatePageAfterSavePoint validates the page input after a savePoint has been executed.
		/// The savePoint must be contained in the current path between the current page and its successor.
		/// </summary>
		public bool ValidatePageAfterSavePoint(string strPage, string strSavePointName, string strXmlMCContext, out string strErrorMessage)
		{
			strErrorMessage = "";
			object anActionClass = actionClassObjects[strPage];
			string strType = (string)actionClassTypes[strPage];
			
			if (anActionClass!=null)
			{
				
				Type t;
				foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
				{
					t = asm.GetType(strType);
						
					if (t!=null)
					{

						// BindingFlags enumeration specifies flags that control binding and 
						// the way in which the search for members and types is conducted by reflection. 
						// The following specifies the Access Control of the bound type

						BindingFlags bflags = BindingFlags.DeclaredOnly | BindingFlags.Public 
							| BindingFlags.NonPublic | BindingFlags.Instance;

						object[] allParams = new object[3];
						allParams[0]=strSavePointName;
						allParams[1]=strXmlMCContext;
						allParams[2]= strErrorMessage;

						// Call the method
						object boolRslt = t.InvokeMember("ValidatePageAfterSavePoint", bflags | BindingFlags.InvokeMethod,
							null, anActionClass,allParams);
						strErrorMessage = (string)allParams[2];

						return ((bool)boolRslt);
					} // if (t!=null)
				} // foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
				return false;
				
			} // if (anActionClass!=null)
			else
			{
				return true;
			}
		}
		

		/// <summary>
		/// Procedure called after the page has been posted and that all values have been saved
		/// into the context. This procedure is executed after ValidatePageBeforeSavePoints.
		/// </summary>
		public void DoAfterContextSave(string strPage, string strXmlMCContext)
		{
			object anActionClass = actionClassObjects[strPage];
			string strType = (string)actionClassTypes[strPage];
			
			if (anActionClass!=null)
			{
				// Load the generated assembly into the ApplicationDomain 
				
				Type t;
				foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
				{
					t = asm.GetType(strType);
						
					if (t!=null)
					{

						// BindingFlags enumeration specifies flags that control binding and 
						// the way in which the search for members and types is conducted by reflection. 
						// The following specifies the Access Control of the bound type

						BindingFlags bflags = BindingFlags.DeclaredOnly | BindingFlags.Public 
							| BindingFlags.NonPublic | BindingFlags.Instance;

						string[] allParams = new string[1];
						allParams[0]=strXmlMCContext;
						// Call the method
						t.InvokeMember("DoAfterContextSave", bflags | BindingFlags.InvokeMethod,
							null, anActionClass,allParams);
						break;
					} // if (t!=null)
				} // foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
			}
		}
	}
}

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


Written By
Japan Japan
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions