Esempio n. 1
0
		public WorkFlowIfElseRule ()
		{
			IfElseActivity ifelse_activity = new IfElseActivity ();
			branch1 = new IfElseBranchActivity ();

			CodeActivity code_branch1 = new CodeActivity ();
			CodeActivity code_branch2 = new CodeActivity ();
			branch2 = new IfElseBranchActivity ();

			code_branch1.Name ="Code1";
			code_branch2.Name ="Code2";
			code_branch1.ExecuteCode += new EventHandler (ExecuteCode1);
			code_branch2.ExecuteCode += new EventHandler (ExecuteCode2);

			branch1.Activities.Add (code_branch1);
			branch2.Activities.Add (code_branch2);

			RuleConditionReference condition1 = new RuleConditionReference ();
			condition1.ConditionName = "Condition1";
			RuleExpressionCondition rc =  new RuleExpressionCondition ("Condition1",
				RulesBinaryOpTest.check_condition);

			definitions.Conditions.Add (rc);
			branch1.Condition = condition1;

			ifelse_activity.Activities.Add (branch1);
			ifelse_activity.Activities.Add (branch2);

			SetValue (RuleDefinitions.RuleDefinitionsProperty, definitions);
			Activities.Add (ifelse_activity);
		}
        public override RuleCondition Clone()
        {
            RuleExpressionCondition condition = (RuleExpressionCondition)base.MemberwiseClone();

            condition._runtimeInitialized = false;
            condition._expression         = RuleExpressionWalker.Clone(this._expression);
            return(condition);
        }
        public override bool Equals(object obj)
        {
            bool flag = false;
            RuleExpressionCondition condition = obj as RuleExpressionCondition;

            if (condition != null)
            {
                flag = (this.Name == condition.Name) && (((this._expression == null) && (condition.Expression == null)) || ((this._expression != null) && RuleExpressionWalker.Match(this._expression, condition.Expression)));
            }
            return(flag);
        }
 public RuleConditionDialog(System.Type activityType, ITypeProvider typeProvider, CodeExpression expression)
 {
     this.ruleExpressionCondition = new RuleExpressionCondition();
     if (activityType == null)
     {
         throw new ArgumentNullException("activityType");
     }
     this.InitializeComponent();
     RuleValidation validation = new RuleValidation(activityType, typeProvider);
     this.ruleParser = new Parser(validation);
     this.InitializeDialog(expression);
 }
Esempio n. 5
0
        public override bool Equals(object obj)
        {
            bool equals = false;
            RuleExpressionCondition declarativeConditionDefinition = obj as RuleExpressionCondition;

            if (declarativeConditionDefinition != null)
            {
                equals = ((this.Name == declarativeConditionDefinition.Name) &&
                          ((this._expression == null && declarativeConditionDefinition.Expression == null) ||
                           (this._expression != null && RuleExpressionWalker.Match(this._expression, declarativeConditionDefinition.Expression))));
            }

            return(equals);
        }
 protected override object OnNewInternal()
 {
     using (RuleConditionDialog dlg = new RuleConditionDialog(this.Activity, null))
     {
         if (DialogResult.OK == dlg.ShowDialog(this))
         {
             RuleExpressionCondition declarativeRuleDefinition = new RuleExpressionCondition();
             declarativeRuleDefinition.Expression = dlg.Expression;
             declarativeRuleDefinition.Name = this.CreateNewName();
             this.declarativeConditionCollection.Add(declarativeRuleDefinition);
             return declarativeRuleDefinition;
         }
     }
     return null;
 }
Esempio n. 7
0
        public override bool Equals(object obj)
        {
            RuleExpressionCondition target = (obj as RuleExpressionCondition);

            if (target == null)
            {
                return(false);
            }

            if (Name == target.Name && Expression == target.Expression)
            {
                return(true);
            }

            return(false);
        }
        protected override bool OnEditInternal(object currentRuleObject, out object updatedRuleObject)
        {
            RuleExpressionCondition declarativeRuleDefinition = currentRuleObject as RuleExpressionCondition;
            updatedRuleObject = null;

            using (RuleConditionDialog dlg = new RuleConditionDialog(this.Activity, declarativeRuleDefinition.Expression))
            {
                if (DialogResult.OK == dlg.ShowDialog(this))
                {
                    updatedRuleObject = new RuleExpressionCondition(declarativeRuleDefinition.Name, dlg.Expression);

                    this.declarativeConditionCollection.Remove(declarativeRuleDefinition.Name);
                    this.declarativeConditionCollection.Add(updatedRuleObject as RuleExpressionCondition);

                    return true;
                }
            }
            return false;
        }
Esempio n. 9
0
        private static object GetValue(RuleExecution execution, CodeExpression obj)
        {
            if (obj.GetType() == typeof(System.CodeDom.CodePrimitiveExpression))
            {
                return(((System.CodeDom.CodePrimitiveExpression)obj).Value);
            }

            if (obj.GetType() == typeof(CodeFieldReferenceExpression))
            {
                return(RuleExpressionCondition.CodeFieldReferenceValue(execution, obj));
            }

            if (obj.GetType() == typeof(CodePropertyReferenceExpression))
            {
                return(RuleExpressionCondition.CodePropertyReferenceValue(execution, obj));
            }

            return(null);
        }
 public RuleConditionDialog(Activity activity, CodeExpression expression)
 {
     ITypeProvider provider;
     this.ruleExpressionCondition = new RuleExpressionCondition();
     if (activity == null)
     {
         throw new ArgumentNullException("activity");
     }
     this.InitializeComponent();
     this.serviceProvider = activity.Site;
     if (this.serviceProvider != null)
     {
         IUIService service = this.serviceProvider.GetService(typeof(IUIService)) as IUIService;
         if (service != null)
         {
             this.Font = (Font) service.Styles["DialogFont"];
         }
         provider = (ITypeProvider) this.serviceProvider.GetService(typeof(ITypeProvider));
         if (provider == null)
         {
             throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.MissingService, new object[] { typeof(ITypeProvider).FullName }));
         }
         WorkflowDesignerLoader loader = this.serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
         if (loader != null)
         {
             loader.Flush();
         }
     }
     else
     {
         TypeProvider provider2 = new TypeProvider(null);
         foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
         {
             provider2.AddAssembly(assembly);
         }
         provider = provider2;
     }
     RuleValidation validation = new RuleValidation(activity, provider, false);
     this.ruleParser = new Parser(validation);
     this.InitializeDialog(expression);
 }
 public override void SetValue(object component, object value)
 {
     if (component == null)
     {
         throw new ArgumentNullException("component");
     }
     if (!(component is RuleConditionReference))
     {
         throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Messages.NotARuleConditionReference, new object[] { "component" }), "component");
     }
     string key = value as string;
     if ((key == null) || (key.TrimEnd(new char[0]).Length == 0))
     {
         key = string.Empty;
     }
     ISite serviceProvider = PropertyDescriptorUtils.GetSite(base.ServiceProvider, component);
     if (serviceProvider == null)
     {
         throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Messages.MissingService, new object[] { typeof(ISite).FullName }));
     }
     RuleConditionCollection conditions = null;
     RuleDefinitions definitions = ConditionHelper.Load_Rules_DT(serviceProvider, Helpers.GetRootActivity(serviceProvider.Component as Activity));
     if (definitions != null)
     {
         conditions = definitions.Conditions;
     }
     if (((conditions != null) && (key.Length != 0)) && !conditions.Contains(key))
     {
         RuleExpressionCondition item = new RuleExpressionCondition {
             Name = key
         };
         conditions.Add(item);
         ConditionHelper.Flush_Rules_DT(serviceProvider, Helpers.GetRootActivity(serviceProvider.Component as Activity));
     }
     PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(component)["ConditionName"];
     if (propertyDescriptor != null)
     {
         PropertyDescriptorUtils.SetPropertyValue(serviceProvider, propertyDescriptor, component, key);
     }
 }
Esempio n. 12
0
		private static Rule CreateMinTicketFareRule(TPromotionRule promotionRuleObj)
		{
			Rule minTktFareRule = new Rule("MinTicketFareRule");
			minTktFareRule.ReevaluationBehavior = RuleReevaluationBehavior.Never;
			minTktFareRule.Priority = 100;

			RuleStatementAction minTktFareThenAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"),"Message"),
																			new CodePrimitiveExpression("VALID"))
																		);
			RuleStatementAction minTktFareElseAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"),"Message"),
																			new CodePrimitiveExpression("INVALID. Fare should be greater than" + promotionRuleObj.MinTicketFare))
																		);

			RuleCondition minTktFareCondition = new RuleExpressionCondition(
																			new CodeBinaryOperatorExpression(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "InputObj"),"OrderValue"),
																			CodeBinaryOperatorType.GreaterThanOrEqual,
																			new CodePrimitiveExpression(promotionRuleObj.MinTicketFare))
																		);
			minTktFareRule.Condition = minTktFareCondition;
			minTktFareRule.ThenActions.Add(minTktFareThenAction);
			minTktFareRule.ElseActions.Add(minTktFareElseAction);
			minTktFareRule.ElseActions.Add(new RuleHaltAction());

			return minTktFareRule;
		}
Esempio n. 13
0
		private static Rule CreateOfferCodeRule(TPromotionRule promotionRuleObj)
		{
			Rule offerCodeRule = new Rule("OfferCodeRule");
			offerCodeRule.ReevaluationBehavior = RuleReevaluationBehavior.Never;
			offerCodeRule.Priority = 10;

			RuleStatementAction offerCodeThenAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"),"Message"),
																			new CodePrimitiveExpression("VALID"))
																		);
			RuleStatementAction offerCodeElseAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"),"Message"),
																			new CodePrimitiveExpression("INVALID. Invalid offer code."))
																		);

			RuleCondition offerCodeCondition = new RuleExpressionCondition(
																			new CodeBinaryOperatorExpression(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "InputObj"),"OfferCode"),
																			CodeBinaryOperatorType.ValueEquality,
																			new CodePrimitiveExpression(promotionRuleObj.OfferCode))
																		);
			offerCodeRule.Condition = offerCodeCondition;
			offerCodeRule.ThenActions.Add(offerCodeThenAction);
			offerCodeRule.ElseActions.Add(offerCodeElseAction);
			offerCodeRule.ElseActions.Add(new RuleHaltAction());

			return offerCodeRule;
		}
Esempio n. 14
0
		private static Rule CreateDiscountPercentRule(TPromotionRule promotionRuleObj)
		{
			Rule discountRule = new Rule("DiscountPercentRule");
			discountRule.ReevaluationBehavior = RuleReevaluationBehavior.Always;
			discountRule.Priority = 30;


			RuleStatementAction discountThenAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"),"Discount"),
																			new CodeBinaryOperatorExpression(
																			new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "InputObj"),"OrderValue"),
																			CodeBinaryOperatorType.Multiply,
																			new CodePrimitiveExpression(promotionRuleObj.DiscountPercent/100))
																		));


			RuleStatementAction discountElseAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"),"Discount"),
																			new CodePrimitiveExpression(0))
																		);

			RuleCondition discountCondition = new RuleExpressionCondition(
																			new CodeBinaryOperatorExpression(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"),"Message"),
																			CodeBinaryOperatorType.ValueEquality,
																			new CodePrimitiveExpression("VALID"))
																		);
			discountRule.Condition = discountCondition;
			discountRule.ThenActions.Add(discountThenAction);
			discountRule.ElseActions.Add(discountElseAction);

			return discountRule;
		}
Esempio n. 15
0
		private static Rule CreateMaxDiscountLimitRule(TPromotionRule promotionRuleObj)
		{
			Rule maxDiscountLimitRule = new Rule("MaxDiscountLimitRule");
			maxDiscountLimitRule.ReevaluationBehavior = RuleReevaluationBehavior.Never;
			maxDiscountLimitRule.Priority = 20;

			RuleStatementAction maxDiscountLimitThenAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"),"Discount"),
																			new CodePrimitiveExpression(promotionRuleObj.MaxDiscountAmount))
																		);

			RuleCondition maxDiscountLimitCondition = new RuleExpressionCondition(
																			new CodeBinaryOperatorExpression(
																				new CodeBinaryOperatorExpression(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																				new CodeThisReferenceExpression(), "OutputObj"),"Message"),
																				CodeBinaryOperatorType.ValueEquality,
																				new CodePrimitiveExpression("VALID")),
																			CodeBinaryOperatorType.BooleanAnd,
																				new CodeBinaryOperatorExpression(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																				new CodeThisReferenceExpression(), "OutputObj"),"Discount"),
																				CodeBinaryOperatorType.GreaterThanOrEqual,
																				new CodePrimitiveExpression(promotionRuleObj.MaxDiscountAmount)))
																		);
			maxDiscountLimitRule.Condition = maxDiscountLimitCondition;
			maxDiscountLimitRule.ThenActions.Add(maxDiscountLimitThenAction);

			return maxDiscountLimitRule;
		}
Esempio n. 16
0
		private static Rule CreateValidAdvanceBookingRule(TPromotionRule promotionRuleObj)
		{
			Rule validityAdvanceBookingRule = new Rule("ValidityAdvanceBookingRule");
			validityAdvanceBookingRule.ReevaluationBehavior = RuleReevaluationBehavior.Never;
			validityAdvanceBookingRule.Priority = 50;

			RuleStatementAction validityAdvanceBookingThenAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"), "Message"),
																			new CodePrimitiveExpression("VALID"))
																		);

			RuleStatementAction validityAdvanceBookingElseAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"), "Message"),
																			new CodePrimitiveExpression("INVALID"))
																		);

			RuleCondition validityAdvanceBookingCondition = new RuleExpressionCondition(
																			new CodeBinaryOperatorExpression(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "InputObj"), "NumOfAdvanceBookingDays"),
																			CodeBinaryOperatorType.GreaterThanOrEqual,
																			new CodePrimitiveExpression(promotionRuleObj.MinNumOfAdvanceBookingDays))
																		);

			validityAdvanceBookingRule.Condition = validityAdvanceBookingCondition;
			validityAdvanceBookingRule.ThenActions.Add(validityAdvanceBookingThenAction);
			validityAdvanceBookingRule.ElseActions.Add(validityAdvanceBookingElseAction);
			validityAdvanceBookingRule.ElseActions.Add(new RuleHaltAction());

			return validityAdvanceBookingRule;
		}
Esempio n. 17
0
		private static Rule CreateValidLastMinBookingRule(TPromotionRule promotionRuleObj)
		{
			Rule validityLastMinBookingRule = new Rule("ValidityLastMinBookingRule");
			validityLastMinBookingRule.ReevaluationBehavior = RuleReevaluationBehavior.Never;
			validityLastMinBookingRule.Priority = 45;

			RuleStatementAction validityLastMinBookingThenAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"), "Message"),
																			new CodePrimitiveExpression("VALID"))
																		);

			RuleStatementAction validityLastMinBookingElseAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"), "Message"),
																			new CodePrimitiveExpression("INVALID"))
																		);

			RuleCondition validityLastMinBookingCondition = new RuleExpressionCondition(
																			new CodeBinaryOperatorExpression(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "InputObj"), "MinuteCountBeforeDept"),
																			CodeBinaryOperatorType.LessThanOrEqual,
																			new CodePrimitiveExpression(promotionRuleObj.LastMinuteCountBeforeDept))
																		);

			validityLastMinBookingRule.Condition = validityLastMinBookingCondition;
			validityLastMinBookingRule.ThenActions.Add(validityLastMinBookingThenAction);
			validityLastMinBookingRule.ElseActions.Add(validityLastMinBookingElseAction);
			validityLastMinBookingRule.ElseActions.Add(new RuleHaltAction());

			return validityLastMinBookingRule;
		}
Esempio n. 18
0
		private static Rule CreateValidBulkBookingRule(TPromotionRule promotionRuleObj)
		{
			Rule validityBulkBookingRule = new Rule("ValidityBulkBookingRule");
			validityBulkBookingRule.ReevaluationBehavior = RuleReevaluationBehavior.Never;
			validityBulkBookingRule.Priority = 55;

			RuleStatementAction validityBulkBookingThenAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"), "Message"),
																			new CodePrimitiveExpression("VALID"))
																		);

			RuleStatementAction validityBulkBookingRouteElseAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"), "Message"),
																			new CodePrimitiveExpression("INVALID. This offer is only applicable for bulk booking."))
																		);

			RuleCondition validityBulkBookingRouteCondition = new RuleExpressionCondition(
																			new CodeBinaryOperatorExpression(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "InputObj"), "NumOfSeatsForBooking"),
																			CodeBinaryOperatorType.GreaterThanOrEqual,
																			new CodePrimitiveExpression(promotionRuleObj.MinNumOfSeats))
																		);

			validityBulkBookingRule.Condition = validityBulkBookingRouteCondition;
			validityBulkBookingRule.ThenActions.Add(validityBulkBookingThenAction);
			validityBulkBookingRule.ElseActions.Add(validityBulkBookingRouteElseAction);
			validityBulkBookingRule.ElseActions.Add(new RuleHaltAction());

			return validityBulkBookingRule;
		}
Esempio n. 19
0
		private static Rule CreateValidRouteRule(TPromotionRule promotionRuleObj)
		{
			Rule validityRouteRule = new Rule("ValidityRouteRule");
			validityRouteRule.ReevaluationBehavior = RuleReevaluationBehavior.Never;
			validityRouteRule.Priority = 60;

			RuleStatementAction validityRouteThenAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"),"Message"),
																			new CodePrimitiveExpression("VALID"))
																		);

			RuleStatementAction validityRouteElseAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"),"Message"),
																			new CodePrimitiveExpression("INVALID. This offer is not applicable for this route."))
																		);

			/*RuleCondition validityRouteCondition = new RuleExpressionCondition(
																			new CodeBinaryOperatorExpression(
																			new CodeMethodInvokeExpression(
																			new CodeThisReferenceExpression(),
																			"IsElementExistInArray",
																			new CodeExpression[] {new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "InputObj"),"RouteId"), 
																			new CodePrimitiveExpression(promotionRuleObj.RouteIDCSV)}),
																			CodeBinaryOperatorType.BooleanAnd,
																			new CodePrimitiveExpression(true))
																		);*/

			RuleCondition validityRouteCondition = new RuleExpressionCondition(
																				new CodeBinaryOperatorExpression(
																					new CodeMethodInvokeExpression(
																							new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(typeof(BusinessObjects.TPromotion)), "IsElementExistInArray")
																						, new CodeExpression[] {	new CodePropertyReferenceExpression(	new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "InputObj"),"RouteId")
																																						, 	new CodePrimitiveExpression(promotionRuleObj.RouteIDCSV)}
																					)
																					, CodeBinaryOperatorType.BooleanAnd
																					, new CodePrimitiveExpression(true)
																				)
																			);

			validityRouteRule.Condition = validityRouteCondition;
			validityRouteRule.ThenActions.Add(validityRouteThenAction);
			validityRouteRule.ElseActions.Add(validityRouteElseAction);
			validityRouteRule.ElseActions.Add(new RuleHaltAction());

			return validityRouteRule;
		}
Esempio n. 20
0
        private ConditionObject RuleObjectCondition(RuleExpressionCondition condition)
        {
            ConditionObject conditionObj = new ConditionObject();

            CodeBinaryOperatorExpression operatorExpression = (CodeBinaryOperatorExpression)condition.Expression;

            CodeFieldReferenceExpression leftExpression = (CodeFieldReferenceExpression)operatorExpression.Left;
            conditionObj.field = leftExpression.FieldName;

            CodePrimitiveExpression rightExpression = (CodePrimitiveExpression)operatorExpression.Right;
            conditionObj.value = rightExpression.Value.ToString();

            return conditionObj;
        }
Esempio n. 21
0
        private RuleExpressionCondition SetRuleCondition(RuleExpressionCondition condition, ConditionObject conditionObj)
        {
            CodeBinaryOperatorExpression operatorExpression = (CodeBinaryOperatorExpression)condition.Expression;

            CodePropertyReferenceExpression leftExpression = (CodePropertyReferenceExpression)operatorExpression.Left;
            leftExpression.PropertyName = conditionObj.field;

            CodePrimitiveExpression rightExpression = (CodePrimitiveExpression)operatorExpression.Right;
            rightExpression.Value = conditionObj.value;

            return condition;
        }
 protected override void UpdatePreview(TextBox previewBox, object ruleObject)
 {
     RuleExpressionCondition declarativeRuleDefinition = ruleObject as RuleExpressionCondition;
     if (declarativeRuleDefinition != null && declarativeRuleDefinition.Expression != null)
     {
         RuleExpressionCondition ruleExpressionCondition = new RuleExpressionCondition(declarativeRuleDefinition.Expression);
         NativeMethods.SendMessage(previewBox.Handle, NativeMethods.WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero);
         previewBox.Lines = ruleExpressionCondition.ToString().Split('\n');
         NativeMethods.SendMessage(previewBox.Handle, NativeMethods.WM_SETREDRAW, new IntPtr(1), IntPtr.Zero);
         previewBox.Invalidate();
     }
     else
     {
         previewBox.Text = string.Empty;
     }
 }
 private void conditionTextBox_Validating(object sender, CancelEventArgs e)
 {
     try
     {
         this.ruleExpressionCondition = this.ruleParser.ParseCondition(this.conditionTextBox.Text);
         if (!string.IsNullOrEmpty(this.conditionTextBox.Text))
         {
             this.conditionTextBox.Text = this.ruleExpressionCondition.ToString().Replace("\n", "\r\n");
         }
         this.conditionErrorProvider.SetError(this.conditionTextBox, string.Empty);
         this.syntaxException = null;
     }
     catch (Exception exception)
     {
         this.syntaxException = exception;
         this.conditionErrorProvider.SetError(this.conditionTextBox, exception.Message);
     }
 }
Esempio n. 24
0
		private static Rule CreateValidityEndDateRule(TPromotionRule promotionRuleObj)
		{
			Rule validityEndDateRule = new Rule("ValidityEndDateRule");
			validityEndDateRule.ReevaluationBehavior = RuleReevaluationBehavior.Never;
			validityEndDateRule.Priority = 80;

			RuleStatementAction validityEndDateThenAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"),"Message"),
																			new CodePrimitiveExpression("VALID"))
																		);

			RuleStatementAction validityEndDateElseAction = new RuleStatementAction(
																			new CodeAssignStatement(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "OutputObj"),"Message"),
																			new CodePrimitiveExpression("INVALID"))
																		);

			RuleCondition validityEndDateCondition = new RuleExpressionCondition(
																			new CodeBinaryOperatorExpression(new CodePropertyReferenceExpression(new CodePropertyReferenceExpression(
																			new CodeThisReferenceExpression(), "InputObj"),"DOJ"),
																			CodeBinaryOperatorType.LessThan,
																			new CodePrimitiveExpression(promotionRuleObj.ValidityEndDate))
																		);
			validityEndDateRule.Condition = validityEndDateCondition;
			validityEndDateRule.ThenActions.Add(validityEndDateThenAction);
			validityEndDateRule.ElseActions.Add(validityEndDateElseAction);
			validityEndDateRule.ElseActions.Add(new RuleHaltAction());

			return validityEndDateRule;
		}