Exemplo n.º 1
0
        public void LoadFromElement(XmlElement element)
        {
            sCallTime tmp = (sCallTime)element.InnerText;

            _year        = tmp.Year;
            _yearDay     = tmp.YearDay;
            _month       = tmp.Month;
            _monthDay    = tmp.MonthDay;
            _week        = tmp.Week;
            _monthWeek   = tmp.MonthWeek;
            _weekDay     = tmp.WeekDay;
            _hour        = tmp.Hour;
            _minute      = tmp.Minute;
            _minuteOfDay = tmp.MinuteOfDay;
        }
Exemplo n.º 2
0
 public sCallTimeOfDayCondition(sCallTime start, sCallTime?end, ICallAction[] actions, ICallAction[] antiActions, CallConditionBreakTypes?breakType) :
     this(start, end, null, null, actions, antiActions, breakType)
 {
 }
Exemplo n.º 3
0
 public sCallTimeOfDayCondition(sCallTime? start, sCallTime? end, sCallTimeOfDayRange? timeRange, sCallTimeDateRange? dateRange,
     ICallAction[] actions,ICallAction[] antiActions,CallConditionBreakTypes? breakType)
 {
     _start = start;
     _end = end;
     _timeRange = timeRange;
     _dateRange = dateRange;
     if (_end == null && _start == null && _timeRange == null && _dateRange == null)
         throw new Exception("You must specify at least one type of time condition");
     _actions = (actions == null ? new ICallAction[0] : actions);
     _antiActions = (antiActions == null ? new ICallAction[0] : antiActions);
     _break = breakType;
 }
Exemplo n.º 4
0
 public sCallTimeOfDayCondition(sCallTime start, sCallTime? end, ICallAction[] actions, ICallAction[] antiActions, CallConditionBreakTypes? breakType) :
     this(start, end, null, null, actions, antiActions, breakType) { }
Exemplo n.º 5
0
 internal bool IsInRange(DateTime date, sCallTime? end)
 {
     int dayOfWeek = 1;
     switch (date.DayOfWeek)
     {
         case DayOfWeek.Monday:
             dayOfWeek = 2;
             break;
         case DayOfWeek.Tuesday:
             dayOfWeek = 3;
             break;
         case DayOfWeek.Wednesday:
             dayOfWeek = 4;
             break;
         case DayOfWeek.Thursday:
             dayOfWeek = 5;
             break;
         case DayOfWeek.Friday:
             dayOfWeek = 6;
             break;
         case DayOfWeek.Saturday:
             dayOfWeek = 7;
             break;
     }
     int weekOfYear = GetWeekNumberOfYear(date);
     int minuteOfDay = (date.Hour * 60) + (date.Minute);
     int weekOfMonth = GetWeekNumberOfMonth(date);
     if (end.HasValue)
     {
         return (_year.HasValue ? _year.Value : date.Year) <= date.Year
             && (_yearDay.HasValue ? _yearDay.Value : date.DayOfYear) <= date.DayOfYear
             && (_month.HasValue ? _month.Value : date.Month) <= date.Month
             && (_monthDay.HasValue ? _monthDay.Value : date.Day) <= date.Day
             && (_week.HasValue ? _week.Value : weekOfYear) <= weekOfYear
             && (_monthWeek.HasValue ? _monthWeek.Value : weekOfMonth) <= weekOfMonth
             && (_weekDay.HasValue ? (int)_weekDay.Value : dayOfWeek) <= dayOfWeek
             && (_hour.HasValue ? _hour.Value : date.Hour) <= date.Hour
             && (_minute.HasValue ? _minute.Value : date.Minute) <= date.Minute
             && (_minuteOfDay.HasValue ? _minuteOfDay.Value : minuteOfDay) <= minuteOfDay
             && (end.Value._year.HasValue ? end.Value._year.Value : date.Year) >= date.Year
             && (end.Value._yearDay.HasValue ? end.Value._yearDay.Value : date.DayOfYear) >= date.DayOfYear
             && (end.Value._month.HasValue ? end.Value._month.Value : date.Month) >= date.Month
             && (end.Value._monthDay.HasValue ? end.Value._monthDay.Value : date.Day) >= date.Day
             && (end.Value.Week.HasValue ? end.Value.Week.Value : weekOfYear) >= weekOfYear
             && (end.Value._monthWeek.HasValue ? end.Value._monthWeek.Value : weekOfMonth) >= weekOfMonth
             && (end.Value._weekDay.HasValue ? (int)end.Value._weekDay.Value : dayOfWeek) >= dayOfWeek
             && (end.Value._hour.HasValue ? end.Value._hour.Value : date.Hour) >= date.Hour
             && (end.Value._minute.HasValue ? end.Value._minute.Value : date.Minute) >= date.Minute
             && (end.Value._minuteOfDay.HasValue ? end.Value._minuteOfDay.Value : minuteOfDay) >= minuteOfDay;
     }
     else
     {
         return (_year.HasValue ? _year.Value : date.Year) == date.Year
             && (_yearDay.HasValue ? _yearDay.Value : date.DayOfYear) == date.DayOfYear
             && (_month.HasValue ? _month.Value : date.Month) == date.Month
             && (_monthDay.HasValue ? _monthDay.Value : date.Day) == date.Day
             && (_week.HasValue ? _week.Value : weekOfYear) == weekOfYear
             && (_monthWeek.HasValue ? _monthWeek.Value : weekOfMonth) == weekOfMonth
             && (_weekDay.HasValue ? (int)_weekDay.Value : dayOfWeek) == dayOfWeek
             && (_hour.HasValue ? _hour.Value : date.Hour) == date.Hour
             && (_minute.HasValue ? _minute.Value : date.Minute) == date.Minute
             && (_minuteOfDay.HasValue ? _minuteOfDay.Value : minuteOfDay) == minuteOfDay;
     }
 }
 public void UpdateTimedRoute(string context,string originalName, string name, string condition, bool performOnFail, sCallTime start, sCallTime? end,
     sDomainExtensionPair extensionNumber)
 {
     lock (_lock)
     {
         Hashtable ht = StoredConfiguration;
         ArrayList cont = new ArrayList();
         if (ht.ContainsKey(context))
         {
             cont = (ArrayList)ht[context];
             ht.Remove(context);
         }
         for (int x = 0; x < cont.Count; x++)
         {
             Hashtable ext = (Hashtable)cont[x];
             if (ext[_NAME_FIELD_ID].ToString() == originalName)
             {
                 cont.RemoveAt(x);
                 break;
             }
         }
         Hashtable pln = new Hashtable();
         pln.Add(_NAME_FIELD_ID, name);
         pln.Add(_CONDITION_FIELD_ID,condition);
         pln.Add(_PERFORM_ON_FAIL_FIElD_ID, performOnFail);
         pln.Add(_START_FIELD_ID, start.ToString());
         if (end.HasValue)
             pln.Add(_END_FIELD_ID, end.Value.ToString());
         pln.Add(_TYPE_FIELD_ID, VacationRouteRedirectTypes.PhoneExtension);
         pln.Add(_EXTENSION_FIELD_ID, extensionNumber.ToString());
         cont.Add(pln);
         ht.Add(context, cont);
         StoredConfiguration = ht;
     }
 }
 public void AddTimedRoute(string context, string name, string condition, bool performOnFail, sCallTime start, sCallTime? end,
     sGatewayNumberPair gateway)
 {
     lock (_lock)
     {
         Hashtable ht = StoredConfiguration;
         ArrayList cont = new ArrayList();
         if (ht.ContainsKey(context))
         {
             cont = (ArrayList)ht[context];
             ht.Remove(context);
         }
         Hashtable pln = new Hashtable();
         pln.Add(_NAME_FIELD_ID, name);
         pln.Add(_CONDITION_FIELD_ID, condition);
         pln.Add(_PERFORM_ON_FAIL_FIElD_ID, performOnFail);
         pln.Add(_START_FIELD_ID, start.ToString());
         if (end.HasValue)
             pln.Add(_END_FIELD_ID, end.Value.ToString());
         pln.Add(_TYPE_FIELD_ID, VacationRouteRedirectTypes.OutGateway);
         pln.Add(_GATEWAY_NUMBER_FIELD_ID, gateway.ToString());
         cont.Add(pln);
         ht.Add(context, cont);
         StoredConfiguration = ht;
     }
 }
 public void AddTimedRoute(string context, string name, string condition, bool performOnFail, sCallTime start, sCallTime? end,
     sCallExtensionReference callExtension)
 {
     lock (_lock)
     {
         Hashtable ht = StoredConfiguration;
         ArrayList cont = new ArrayList();
         if (ht.ContainsKey(context))
         {
             cont = (ArrayList)ht[context];
             ht.Remove(context);
         }
         Hashtable pln = new Hashtable();
         pln.Add(_NAME_FIELD_ID, name);
         pln.Add(_CONDITION_FIELD_ID, condition);
         pln.Add(_PERFORM_ON_FAIL_FIElD_ID, performOnFail);
         pln.Add(_START_FIELD_ID, start.ToString());
         if (end.HasValue)
             pln.Add(_END_FIELD_ID, end.Value.ToString());
         pln.Add(_TYPE_FIELD_ID, VacationRouteRedirectTypes.TransferToExtension);
         pln.Add(_CALL_EXTENSION_FIELD_ID, callExtension.ToString());
         cont.Add(pln);
         ht.Add(context, cont);
         StoredConfiguration = ht;
     }
 }