示例#1
0
        public WonkaBreRule(int pnRuleId, RULE_TYPE peRuleType)
        {
            RuleId   = pnRuleId;
            RuleType = peRuleType;

            TargetAttribute = new WonkaRef.WonkaRefAttr();
            ParentRuleSetId = -1;

            NotOperator = false;
            IsPassive   = true;
        }
示例#2
0
        public WonkaBizRule(int pnRuleId, RULE_TYPE peRuleType)
        {
            RuleId   = pnRuleId;
            RuleType = peRuleType;

            TargetAttribute = new Wonka.MetaData.WonkaRefAttr();
            ParentRuleSetId = -1;

            NotOperator = false;
            IsPassive   = true;

            DescRuleId = string.Empty;

            RulesHostEngine = null;
        }
示例#3
0
        private DateTime CalNextTriggerDatetime(RULE_TYPE ruleType, int dayOfWeek, int ruleDay, DateTime d1, DateTime d2)
        {
            eventLog.WriteEntry("CalNextTriggerDatetime()", EventLogEntryType.Information, SLTConstants.EventID);

            int days = 0, hours = 0, minutes = 0, seconds = 0;

            DateTime retDateTime = DateTime.MinValue;

            switch (ruleType)
            {
            case RULE_TYPE.Daily:
                hours   = d1.Hour - d2.Hour;
                minutes = d1.Minute - d2.Minute;
                seconds = d1.Second - d2.Second;

                if ((hours < 0) || (hours == 0) && (minutes < 0) || (hours == 0) && (minutes == 0) && (seconds < 0))
                {
                    retDateTime = d2.AddDays(1);
                    retDateTime = retDateTime.AddHours(hours);
                }
                else
                {
                    retDateTime = d2.AddHours(hours);
                }

                retDateTime = retDateTime.AddMinutes(minutes);
                retDateTime = retDateTime.AddSeconds(seconds);
                retDateTime = retDateTime.AddMilliseconds(-d2.Millisecond);

                break;

            case RULE_TYPE.Weekly:
                int currentDayOfWeek = (int)d2.DayOfWeek;
                if (currentDayOfWeek == 0)     // 0 is Sunday in DateTime.DayOfWeek
                {
                    currentDayOfWeek = 7;      // 7 is Sunday in our world
                }
                days    = dayOfWeek - currentDayOfWeek;
                hours   = d1.Hour - d2.Hour;
                minutes = d1.Minute - d2.Minute;
                seconds = d1.Second - d2.Second;
                if (days < 0 || (days == 0) && (hours < 0) || (days == 0) && (hours == 0) && (minutes < 0) ||
                    (days == 0) && (hours == 0) && (minutes == 0) && (seconds < 0))
                {
                    retDateTime = d2.AddDays(7 + days);
                }
                else
                {
                    retDateTime = d2.AddDays(days);
                }

                retDateTime = retDateTime.AddHours(hours);
                retDateTime = retDateTime.AddMinutes(minutes);
                retDateTime = retDateTime.AddSeconds(seconds);
                retDateTime = retDateTime.AddMilliseconds(-d2.Millisecond);

                break;

            case RULE_TYPE.Monthly:
                days    = ruleDay - d2.Day;
                hours   = d1.Hour - d2.Hour;
                minutes = d1.Minute - d2.Minute;
                seconds = d1.Second - d2.Second;
                if (days < 0 || (days == 0) && (hours < 0) || (days == 0) && (hours == 0) && (minutes < 0) ||
                    (days == 0) && (hours == 0) && (minutes == 0) && (seconds < 0))
                {
                    retDateTime = d2.AddMonths(1);
                    retDateTime = retDateTime.AddDays(days);
                }
                else
                {
                    retDateTime = d2.AddDays(days);
                }

                retDateTime = retDateTime.AddHours(hours);
                retDateTime = retDateTime.AddMinutes(minutes);
                retDateTime = retDateTime.AddSeconds(seconds);
                retDateTime = retDateTime.AddMilliseconds(-d2.Millisecond);


                break;

            default:
                break;
            }

            return(retDateTime);
        }