Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <c>Route</c> class.
        /// </summary>
        /// <param name="entity">Entity initialize datas.</param>
        internal Route(DataModel.Routes entity)
            : base(entity)
        {
            Debug.Assert(0 < entity.CreationTime); // NOTE: must be inited

            _InitTimeWindow(entity);
            _breaks = Breaks.CreateFromDBString(entity.Breaks);
            _days = Days.CreateFromDBString(entity.Days);

            // If collection is in schedule - remember it schedule.routes and
            // subscribe to collection changed event.
            if (this.Schedule != null)
            {
                this.Schedule.RoutesCollectionInitialized += _ScheduleRoutesCollectionInitialized;
            }

            _InitPropertiesEvents();
        }
Beispiel #2
0
 ///////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////
 internal static string AssemblyDBString(Days days)
 {
     // NOTE: format
     //  version\_weeklyPattern\_dates
     string result = string.Empty;
     result += VERSION_CURR;
     result += CommonHelpers.SEPARATOR_OF_PART + _AssemblyDaysDBString(days._enabledDays);
     result += CommonHelpers.SEPARATOR_OF_PART + _AssemblyDatesDBString(days._startDate, days._endDate);
     return result;
 }
Beispiel #3
0
        internal static Days CreateFromDBString(string value)
        {
            Days days = new Days();
            if (null != value)
            {
                string[] values = value.Split(new char[] { CommonHelpers.SEPARATOR_OF_PART }, StringSplitOptions.None);

                Debug.Assert(3 == values.Length);
                int version = (int)TypeDescriptor.GetConverter(typeof(int)).ConvertFrom(values[0]);
                    // NOTE: now not used

                days._enabledDays = _CreateDaysFromDBString(values[1]);

                // create dates
                string datesStting = values[2].Replace(CommonHelpers.SEPARATOR_OLD, CommonHelpers.SEPARATOR); // NOTE: for support old projects

                string[] valuesDates = datesStting.Split(new char[] { CommonHelpers.SEPARATOR }, StringSplitOptions.None);
                if (0 < valuesDates.Length)
                {
                    if (!string.IsNullOrEmpty(valuesDates[0]))
                        days._startDate = _CreateDateFromDBString(valuesDates[0]);

                    if (1 < valuesDates.Length)
                    {
                        Debug.Assert(2 == valuesDates.Length);
                        if (!string.IsNullOrEmpty(valuesDates[1]))
                            days._endDate = _CreateDateFromDBString(valuesDates[1]);
                    }
                }
            }

            return days;
        }
Beispiel #4
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Clones the Days object.
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            Days obj = new Days();

            // days of week
            obj._enabledDays = new List<DayOfWeek>();
            foreach (DayOfWeek day in this._enabledDays)
                obj._enabledDays.Add(day);

            obj.From = this.From;
            obj.To = this.To;

            return obj;
        }