Exemplo n.º 1
0
		// 11/22/2010   For a ListView, it makes sense to allow a column to be added in a Pre Event and the column to be set in the Post Event. 
		public static void ApplyGridViewRules(string sGRID_NAME, SplendidControl parent, string sPRE_LOAD_XOML_FIELD_NAME, string sPOST_LOAD_XOML_FIELD_NAME, DataTable dt)
		{
			try
			{
				string sMODULE_NAME = sGRID_NAME.Split('.')[0];
				DataTable dtFields = SplendidCache.GridViewRules(sGRID_NAME);
				if ( dtFields.Rows.Count > 0 )
				{
					string sXOML = Sql.ToString(dtFields.Rows[0][sPRE_LOAD_XOML_FIELD_NAME]);
					if ( !Sql.IsEmptyString(sXOML) )
					{
						RuleSet rules = RulesUtil.Deserialize(sXOML);
						RuleValidation validation = new RuleValidation(typeof(SplendidControlThis), null);
						// 11/11/2010   Validate so that we can get more information on a runtime error. 
						rules.Validate(validation);
						if ( validation.Errors.HasErrors )
						{
							throw(new Exception(RulesUtil.GetValidationErrors(validation)));
						}
						SplendidControlThis swThis = new SplendidControlThis(parent, sMODULE_NAME, dt);
						RuleExecution exec = new RuleExecution(validation, swThis);
						rules.Execute(exec);
					}
					sXOML = Sql.ToString(dtFields.Rows[0][sPOST_LOAD_XOML_FIELD_NAME]);
					if ( !Sql.IsEmptyString(sXOML) )
					{
						RuleSet rules = RulesUtil.Deserialize(sXOML);
						RuleValidation validation = new RuleValidation(typeof(SplendidControlThis), null);
						// 11/11/2010   Validate so that we can get more information on a runtime error. 
						rules.Validate(validation);
						if ( validation.Errors.HasErrors )
						{
							throw(new Exception(RulesUtil.GetValidationErrors(validation)));
						}
						foreach ( DataRow row in dt.Rows )
						{
							SplendidControlThis swThis = new SplendidControlThis(parent, sMODULE_NAME, row);
							RuleExecution exec = new RuleExecution(validation, swThis);
							rules.Execute(exec);
						}
					}
				}
			}
			catch(Exception ex)
			{
				SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
			}
		}
Exemplo n.º 2
0
		// 11/10/2010   Apply Business Rules. 
		public static void ApplyEditViewRules(string sEDIT_NAME, SplendidControl parent, string sXOML_FIELD_NAME, DataRow row)
		{
			try
			{
				string sMODULE_NAME = sEDIT_NAME.Split('.')[0];
				DataTable dtFields = SplendidCache.EditViewRules(sEDIT_NAME);
				if ( dtFields.Rows.Count > 0 )
				{
					string sXOML = Sql.ToString(dtFields.Rows[0][sXOML_FIELD_NAME]);
					if ( !Sql.IsEmptyString(sXOML) )
					{
						RuleSet rules = RulesUtil.Deserialize(sXOML);
						RuleValidation validation = new RuleValidation(typeof(SplendidControlThis), null);
						// 11/11/2010   Validate so that we can get more information on a runtime error. 
						rules.Validate(validation);
						if ( validation.Errors.HasErrors )
						{
							throw(new Exception(RulesUtil.GetValidationErrors(validation)));
						}
						SplendidControlThis swThis = new SplendidControlThis(parent, sMODULE_NAME, row);
						RuleExecution exec = new RuleExecution(validation, swThis);
						rules.Execute(exec);
					}
				}
			}
			catch(Exception ex)
			{
				//SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
				// 11/10/2010   Throwing an exception will be the preferred method of displaying an error. 
				// We want to skip the filler message "The following error was encountered while executing method Taoqi.SplendidControlThis.Throw". 
				if ( ex.InnerException != null )
					throw(new Exception(ex.InnerException.Message));
				else
					throw(new Exception(ex.Message));
			}
		}