Esempio n. 1
0
        public static StorageWorkingHours LoadFrom(MailboxSession session, StoreId folderId)
        {
            WorkHoursInCalendar fromCalendar = WorkHoursInCalendar.GetFromCalendar(session, folderId);

            if (fromCalendar == null || fromCalendar.WorkHoursVersion1 == null)
            {
                return(null);
            }
            if (fromCalendar.WorkHoursVersion1.TimeSlot == null)
            {
                throw new WorkingHoursXmlMalformedException(ServerStrings.NullWorkHours);
            }
            ExTimeZone exTimeZone = null;

            try
            {
                if (!string.IsNullOrEmpty(fromCalendar.WorkHoursVersion1.TimeZone.Name))
                {
                    if (ExTimeZoneEnumerator.Instance.TryGetTimeZoneByName(fromCalendar.WorkHoursVersion1.TimeZone.Name, out exTimeZone))
                    {
                        WorkHoursTimeZone workHoursTimeZone = fromCalendar.WorkHoursVersion1.TimeZone;
                        if (!workHoursTimeZone.IsSameTimeZoneInfo(TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(exTimeZone)))
                        {
                            exTimeZone = null;
                        }
                    }
                    else
                    {
                        exTimeZone = null;
                    }
                }
                if (exTimeZone == null)
                {
                    exTimeZone = TimeZoneHelper.CreateCustomExTimeZoneFromRegTimeZoneInfo(fromCalendar.WorkHoursVersion1.TimeZone.TimeZoneInfo, "tzone://Microsoft/Custom", "Customized Time Zone");
                }
            }
            catch (InvalidTimeZoneException ex)
            {
                throw new WorkingHoursXmlMalformedException(ServerStrings.MalformedTimeZoneWorkingHours(session.MailboxOwner.MailboxInfo.DisplayName, ex.ToString()), ex);
            }
            return(new StorageWorkingHours(exTimeZone, fromCalendar.WorkHoursVersion1.WorkDays, fromCalendar.WorkHoursVersion1.TimeSlot.StartTimeInMinutes, fromCalendar.WorkHoursVersion1.TimeSlot.EndTimeInMinutes));
        }
Esempio n. 2
0
 internal WorkHoursVersion1(WorkHoursTimeZone timeZone, TimeSlot timeSlot, DaysOfWeek workDays)
 {
     this.timeZone = timeZone;
     this.timeSlot = timeSlot;
     this.workDays = workDays;
 }