예제 #1
0
        /// <summary>
        /// Register new <see cref="HolidayCalendar"/> and optionally provide an initital set of dates to exclude.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="daysExcludedUtc"></param>
        public Guid AddHolidayCalendar(string name, string description, IList <DateTime> daysExcludedUtc = null)
        {
            var holidays = new HolidayCalendar {
                Description = description
            };

            if (null != daysExcludedUtc && daysExcludedUtc.Count > 0)
            {
                foreach (var dateTime in daysExcludedUtc)
                {
                    holidays.AddExcludedDate(dateTime);
                }
            }

            Guid id;

            using (var tran = new TransactionScope())
            {
                id = _persistanceStore.UpsertCalendarIdMap(name);
                _scheduler.AddCalendar(name, holidays, true, true);
                tran.Complete();
            }

            return(id);
        }