Click here to Skip to main content
15,892,059 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.4K   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.Text.RegularExpressions;
using System.Net;
using System.Security.Cryptography;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Mail;


namespace JobMorning
{
	/// <summary>
	/// Summary description for JMTools.
	/// </summary>
	public class JMTools
	{
		public JMTools()
		{
			//
			// TODO: Add constructor logic here
			//
		}
		
		public static bool CheckLocalIP(string strLicIP)
		{
			bool isLocalIPValid = false;
			// This function checks if the passed IP is in the list
			// of IP owned by the computer.
			string strHostName = "";
			string strIP = "";
			strHostName = Dns.GetHostName();
			// Then using host name, get the IP address list..
			IPHostEntry ipEntry = Dns.GetHostByName (strHostName);
			IPAddress [] addr = ipEntry.AddressList;
          
			for (int i = 0; i < addr.Length; i++)
			{
				strIP = addr[i].ToString();
				if (strIP.Equals(strLicIP))
				{
					isLocalIPValid = true;
				}
				// In any case, validate all local addresses
				// starting by either 192.168 or 127
				if (strIP.Substring(0,7)=="192.168")
				{
					isLocalIPValid = true;
				}
				if (strIP.Substring(0,3)=="127")
				{
					isLocalIPValid = true;
				}
			}
			return isLocalIPValid;
		}		


		public class EmailValidator
		{
			private bool   syntaxvalid = false;
			private string account, domain, inputemail;

			/// <summary>
			/// Determines if an email has valid syntax
			/// </summary>
			/// <param name="email">the email to test</param>
			/// <param name="domainExtensionRequired">indicates whether or not the 
			/// email must end with a known DomainExtension to be considered valid</param>
			/// <returns>boolean indicating if the email has valid syntax</returns>
			/// <remarks>
			/// Validates an email address specifying whether or not
			/// the email is required to have a DomainExtension that is valid.
			/// </remarks>
			public static bool Valid(string email, bool domainExtensionRequired)
			{
				EmailValidator v;
				bool                 valid;

				//call syntax validator
				v = new EmailValidator(email, domainExtensionRequired);

				//determine validity
				valid = v.IsValid;

				//cleanup
				v = null;

				//return indication of validity
				return valid;
			}

			/// <summary>
			/// Initializes a new instance of the EmailSyntaxValidator
			/// </summary>
			/// <param name="email">the email to test</param>
			/// <param name="domainExtensionRequired">indicates whether or not the 
			/// email must end with a known DomainExtension to be considered valid</param>
			/// <remarks>
			/// The initializer creates an instance of the EmailSyntaxValidator
			/// class to validate a single email. You can specify whether or not
			/// the DomainExtension is required and should be validated.
			/// </remarks>
			public EmailValidator(string email, bool domainExtensionRequired)
			{
				string tmpmail;

				//save email as validated
				this.inputemail = email;

				//remove <brackets> if found
				tmpmail = this.RemoveBrackets(email);

				//then trim
				tmpmail = this.Trim(tmpmail);
			
				//separate account from domain, quit if unable to separate
				if (! this.CrackEmail(tmpmail))
				{
					return;
				}

				//validate the domain, quit if domain is bad
				if (! this.DomainValid(domainExtensionRequired))
				{
					return;
				}

				//if the DomainExtension is required, validate the domain extension,
				//quit if the domain extension is bad
				if (domainExtensionRequired && ! this.DomainExtensionValid())
				{
					return;
				}

				//email syntax is valid
				this.syntaxvalid = true;
			}

			/// <summary>
			/// separates email account from domain
			/// </summary>
			/// <param name="email">the email to parse</param>
			/// <returns>boolean indicating success of separation</returns>
			private bool CrackEmail(string email)
			{
				Regex re;
				Match m;
				bool  ok = false;

				//pattern to separate email into account and domain.
				//note that we parse from right to left, thereby forcing
				//this pattern to match the last @ symbol in the email.
				re = new Regex(
					"^(.+?)\\@(.+?)$", 
					RegexOptions.Singleline | RegexOptions.RightToLeft
					);
				//determine if email matches pattern (email contains one
				//or more @'s)
				if (re.IsMatch(email))
				{
					//if matched, separate account and domain as noted
					//in our pattern with the () sections.
					m = re.Match(email);

					//first group is the account
					this.account = m.Groups[1].Value;
				
					//second group is the domain
					this.domain = m.Groups[2].Value;

					//cleanup
					m = null;

					//indicate success
					ok = true;
				} // if (re.IsMatch(email))

				//cleanup
				re = null;
				//return the indication of parse success or failure
				return ok;
			}

			/// <summary>
			/// removes outer brackets from an email address
			/// </summary>
			/// <param name="input">the email to parse</param>
			/// <returns>the email without brackets</returns>
			private string RemoveBrackets(string input)
			{
				string output = null;
				Regex  re;
		
				//pattern to match brackets or no brackets
				re = new Regex(
					"^\\<*|\\>*$", 
					RegexOptions.IgnoreCase | RegexOptions.Singleline
					);

				//if email matches (it will always match this pattern)
				if (re.IsMatch(input))
				{
					//replace them with nothing
					output = re.Replace(input, "");
				}

				//cleanup
				re = null;

				//return the email without brackets
				return output;
			}

			/// <summary>
			/// trims any leading and trailing white space from the email
			/// </summary>
			/// <param name="input">the email to parse</param>
			/// <returns>the email with no leading or trailing white space</returns>
			private string Trim(string input)
			{
				string output = null;
				Regex  re;
		
				//pattern to trim leading and trailing white space from string
				re = new Regex(
					"^\\s*|\\s*$", 
					RegexOptions.IgnoreCase | RegexOptions.Singleline
					);

				//if matches
				if (re.IsMatch(input))
				{
					//remove whitespace
					output = re.Replace(input, "");
				}

				//cleanup
				re = null;

				//return the email with no leading or trailing white space
				return output;
			}

			private bool DomainValid(bool domainExtensionRequired)
			{
				bool  valid;
				Regex re;
				string pattern, emaildomain;

				if (domainExtensionRequired)
				{
					//if the DomainExtension is required, the pattern contains
					//a basic DomainExtension length check at the end
					pattern = "^((([a-z0-9-]+)\\.)+)[a-z]{2,6}$";
					emaildomain=this.domain;
				}
				else
				{
					//when the DomainExtension is not required, the pattern is
					//the same except for the DomainExtension length check.
					//note the pattern ends with a . in the loop.
					//This means that we must append a . to the domain
					//temporarily to test the email.
					pattern = "^((([a-z0-9-]+)\\.)+)$";
					emaildomain=this.domain+".";
				}

				re = new Regex(
					pattern, 
					RegexOptions.IgnoreCase | RegexOptions.Singleline
					);

				//if the email matches, it's valid
				valid = re.IsMatch(emaildomain);

				//cleanup
				re = null;

				//return indication of validity
				return valid;
			}

			private bool DomainExtensionValid()
			{
				bool  valid;
				Regex re;
				string domainvalidatorpattern = "";

				//pattern to validate all known DomainExtension's
				domainvalidatorpattern+="\\.(";
				domainvalidatorpattern+="a[c-gil-oq-uwz]|";     //ac,ad,ae,af,ag,ai,al,am,an,ao,aq,ar,as,at,au,aw,az
				domainvalidatorpattern+="b[a-bd-jm-or-tvwyz]|"; //ba,bb,bd,be,bf,bg,bh,bi,bj,bm,bn,bo,br,bs,bt,bv,bw,by,bz
				domainvalidatorpattern+="c[acdf-ik-orsuvx-z]|"; //ca,cc,cd,cf,cg,ch,ci,ck,cl,cm,cn,co,cr,cs,cu,cv,cz,cy,cz
				domainvalidatorpattern+="d[ejkmoz]|";           //de,dj,dk,dm,do,dz
				domainvalidatorpattern+="e[ceghr-u]|";          //ec,ee,eg,eh,er,es,et,eu
				domainvalidatorpattern+="f[i-kmorx]|";          //fi,fj,fk,fm,fo,fr,fx
				domainvalidatorpattern+="g[abd-ilmnp-uwy]|";    //ga,gb,gd,ge,gf,gg,gh,gi,gl,gm,gn,gp,gq,gr,gs,gt,gu,gw,gy
				domainvalidatorpattern+="h[kmnrtu]|";           //hk,hm,hn,hr,ht,hu
				domainvalidatorpattern+="i[delm-oq-t]|";        //id,ie,il,im,in,io,iq,ir,is,it
				domainvalidatorpattern+="j[emop]|";             //je,jm,jo,jp
				domainvalidatorpattern+="k[eg-imnprwyz]|";      //ke,kg,kh,ki,km,kn,kp,kr,kw,ky,kz
				domainvalidatorpattern+="l[a-cikr-vy]|";        //la,lb,lc,li,lk,lr,ls,lt,lu,lv,ly
				domainvalidatorpattern+="m[acdghk-z]|";         //ma,mc,md,mg,mh,mk,ml,mm,mn,mo,mp,mq,mr,ms,mt,mu,mv,mw,mx,my,mz
				domainvalidatorpattern+="n[ace-giloprtuz]|";    //na,nc,ne,nf,ng,ni,nl,no,np,nr,nt,nu,nz
				domainvalidatorpattern+="om|";                  //om
				domainvalidatorpattern+="p[ae-hk-nrtwy]|";      //pa,pe,pf,pg,ph,pk,pl,pm,pn,pr,pt,pw,py
				domainvalidatorpattern+="qa|";                  //qa
				domainvalidatorpattern+="r[eouw]|";             //re,ro,ru,rw
				domainvalidatorpattern+="s[a-eg-ort-vyz]|";     //sa,sb,sc,sd,se,sg,sh,si,sj,sk,sl,sm,sn,so,sr,st,su,sv,sy,sz
				domainvalidatorpattern+="t[cdf-hjkm-prtvwz]|";  //tc,td,tf,tg,th,tj,tk,tm,tn,to,tp,tr,tt,tv,tx,tz
				domainvalidatorpattern+="u[agkmsyz]|";          //ua,ug,uk,um,us,uy,uz
				domainvalidatorpattern+="v[aceginu]|";          //va,vc,ve,vg,vy,vn,vu
				domainvalidatorpattern+="w[fs]|";               //wf,ws
				domainvalidatorpattern+="y[etu]|";              //ye,yt,yu
				domainvalidatorpattern+="z[admrw]|";            //za,zd,zm,zr,zw
				domainvalidatorpattern+="com|";                 //com
				domainvalidatorpattern+="edu|";                 //edu
				domainvalidatorpattern+="net|";                 //net
				domainvalidatorpattern+="org|";                 //org
				domainvalidatorpattern+="mil|";                 //mil
				domainvalidatorpattern+="gov|";                 //gov
				domainvalidatorpattern+="biz|";                 //biz
				domainvalidatorpattern+="pro|";                 //pro
				domainvalidatorpattern+="aero|";                //aero
				domainvalidatorpattern+="coop|";                //coop
				domainvalidatorpattern+="info|";                //info
				domainvalidatorpattern+="name|";                //name
				domainvalidatorpattern+="int|";                 //int
				domainvalidatorpattern+="museum";               //museum
				domainvalidatorpattern+=")$";
			
				re = new Regex(
					domainvalidatorpattern, 
					RegexOptions.IgnoreCase | RegexOptions.Singleline
					);

				//if domain matches pattern, it has a valid DomainExtension
				valid = re.IsMatch(this.domain);

				//cleanup
				re = null;

				//return an indication of DomainExtension validity
				return valid;
			}

			/// <summary>
			/// Gets a value indicating whether or not the email address 
			/// has valid syntax
			/// </summary>
			/// <remarks>
			/// This property returns a boolean indicating whether or not
			/// the email address has valid syntax as determined by the
			/// class.
			/// </remarks>
			/// <value>boolean indicating the validity of the email</value>
			public bool IsValid
			{
				get
				{
					return this.syntaxvalid;
				}
			}

			/// <summary>
			/// Get the domain part of the email address.
			/// </summary>
			/// <remarks>
			/// This property returns the domain part of the email
			/// address if and only if the email is considered valid
			/// by the class. Otherwise null is returned.
			/// </remarks>
			/// <value>string representing the domain of the email</value>
			public string Domain
			{
				get
				{
					return this.domain;
				}
			}

			/// <summary>
			/// Get the account part of the email address.
			/// </summary>
			/// <remarks>
			/// This property returns the account part of the email
			/// address if and only if the email is considered valid
			/// by the class. Otherwise null is returned.
			/// </remarks>
			/// <value>string representing the account of the email</value>
			public string Account
			{
				get
				{
					return this.account;
				}
			}

			/// <summary>
			/// Gets the email address as entered.
			/// </summary>
			/// <remarks>
			/// This property is filled regardless of the validity of the email.
			/// It contains the email as it was entered into the class.
			/// </remarks>
			/// <value>string representing the email address as entered</value>
			public string Address
			{
				get
				{
					return this.inputemail;
				}
			}
		}


		public class LicenceElements
		{
			private string strIP;
			private string NBPages;
			private string NBSessions;
			private string NBStoredProc;
			private string NBSavePoints;
			public string[] allDomains;
			private string strThisLicence;

			public string GetStrIP()
			{
				return strIP;
			}
			public string GetNBPages()
			{
				return NBPages;
			}
			public string GetNBSessions()
			{
				return NBSessions;
			}
			public string GetNBStoredProc()
			{
				return NBStoredProc;
			}
			public string GetNBSavePoints()
			{
				return NBSavePoints;
			}
			public LicenceElements(string strLicence)
			{
				strThisLicence = strLicence;
			}
			public string ExtractLicenceInfo()
			{
				string strReturn="";
				string strDecrypted = CryptoDecrypt.Decrypt(strThisLicence);
				try
				{
					string[] allLicenceItems = strDecrypted.Split(';');
					
					
					strIP = allLicenceItems[0];
					if (!JMTools.CheckLocalIP(strIP))
					{
						strReturn="<result>Licence is invalid</result>";
						// Set the licence to the minimal licence, because the IP is not valid.
						NBPages = "10";
						NBStoredProc = "2";
						NBSavePoints = "2";
						NBSessions = "2";
					} // if (!JMTools.CheckLocalIp(strIP))
					else
					{
						NBPages = allLicenceItems[1];
						NBStoredProc = allLicenceItems[2];
						NBSavePoints = allLicenceItems[3];
						NBSessions = allLicenceItems[4];
					}


					allDomains = new string[(allLicenceItems.Length-5)];
					for	(int k=5; k<allLicenceItems.Length;k++)
					{
						allDomains[(k-3)]= allLicenceItems[k];
					}
					strReturn="<result>Licence is valid</result>";
				}
				catch (System.IndexOutOfRangeException e)
				{
					strReturn="<result>Licence does not contain all the necessary elements</result>";
				}
				return strReturn;
			}
		}
	}
}

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