Ejemplo n.º 1
0
        private static Dictionary <REG_TIMEZONE_INFO, string> CollectTimeZones(IList <Item> items)
        {
            Dictionary <REG_TIMEZONE_INFO, string> dictionary = new Dictionary <REG_TIMEZONE_INFO, string>();

            foreach (Item item in items)
            {
                ExTimeZone        exTimeZoneFromItem = TimeZoneHelper.GetExTimeZoneFromItem(item);
                REG_TIMEZONE_INFO key  = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(exTimeZoneFromItem);
                string            text = CalendarUtil.RemoveDoubleQuotes(string.IsNullOrEmpty(exTimeZoneFromItem.AlternativeId) ? exTimeZoneFromItem.DisplayName : exTimeZoneFromItem.AlternativeId);
                if (!string.IsNullOrEmpty(text) && text.EndsWith("\r\n"))
                {
                    text = text.Substring(0, text.Length - 2);
                }
                string value = text;
                if (!dictionary.ContainsKey(key))
                {
                    int num = 0;
                    while (string.IsNullOrEmpty(value) || dictionary.ContainsValue(value))
                    {
                        value = string.Format("{0} {1}", text, ++num);
                    }
                    dictionary.Add(key, value);
                }
            }
            return(dictionary);
        }
Ejemplo n.º 2
0
 private bool IsMeetingChanged(GlobalObjectId goid, Item promotedItem, object[] matchedItem)
 {
     for (int i = 0; i < InternetCalendarSchema.ImportCompare.Length; i++)
     {
         PropertyDefinition propertyDefinition = InternetCalendarSchema.ImportCompare[i];
         object             obj  = matchedItem[i];
         object             obj2 = promotedItem.TryGetProperty(propertyDefinition);
         if (!Util.ValueEquals(obj, obj2))
         {
             if (!(obj is PropertyError) && !(obj2 is PropertyError))
             {
                 if (propertyDefinition == CalendarItemBaseSchema.AppointmentRecurrenceBlob)
                 {
                     InternalRecurrence internalRecurrence = InternalRecurrence.InternalParse((byte[])obj, (VersionedId)matchedItem[this.QueryIndexId], CalendarImporter.GetRecurringTimeZoneFromQueryItem(matchedItem), promotedItem.PropertyBag.ExTimeZone, CalendarItem.DefaultCodePage);
                     InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(promotedItem);
                     ExTraceGlobals.SharingTracer.TraceDebug <InternalRecurrence, InternalRecurrence, GlobalObjectId>((long)this.GetHashCode(), "CalendarImporter::IsMeetingChanged. Comparing property AppointmentRecurrenceBlob: old Recurrence is {0}; new Recurrence is {1}. GOID:{2}.", internalRecurrence, recurrenceFromItem, goid);
                     if (Util.ValueEquals(internalRecurrence, recurrenceFromItem) && Util.ValueEquals(internalRecurrence.GetDeletedOccurrences(false), recurrenceFromItem.GetDeletedOccurrences(false)))
                     {
                         goto IL_214;
                     }
                 }
                 if (true.Equals(promotedItem.TryGetProperty(CalendarItemBaseSchema.IsException)) && (propertyDefinition == ItemSchema.TimeZoneDefinitionStart || propertyDefinition == CalendarItemBaseSchema.TimeZoneDefinitionEnd))
                 {
                     ExTimeZone exTimeZone;
                     O12TimeZoneFormatter.TryParseTimeZoneBlob((byte[])obj, string.Empty, out exTimeZone);
                     ExTimeZone exTimeZone2;
                     O12TimeZoneFormatter.TryParseTimeZoneBlob((byte[])obj2, string.Empty, out exTimeZone2);
                     ExTraceGlobals.SharingTracer.TraceDebug((long)this.GetHashCode(), "CalendarImporter::IsMeetingChanged. Comparing property {0}: old TimeZone is {1}; new TimeZone is {2}. GOID:{3}.", new object[]
                     {
                         propertyDefinition.Name,
                         (exTimeZone != null) ? exTimeZone.AlternativeId : "null",
                         (exTimeZone2 != null) ? exTimeZone2.AlternativeId : "null",
                         goid
                     });
                     if (exTimeZone != null && exTimeZone2 != null)
                     {
                         REG_TIMEZONE_INFO reg_TIMEZONE_INFO  = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(exTimeZone, (ExDateTime)matchedItem[CalendarImporter.QueryIndexOfProperty(CalendarItemInstanceSchema.StartTime)]);
                         REG_TIMEZONE_INFO reg_TIMEZONE_INFO2 = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(exTimeZone2, (ExDateTime)promotedItem.TryGetProperty(CalendarItemInstanceSchema.StartTime));
                         if (Util.ValueEquals(reg_TIMEZONE_INFO, reg_TIMEZONE_INFO2))
                         {
                             goto IL_214;
                         }
                     }
                 }
             }
             ExTraceGlobals.SharingTracer.TraceDebug((long)this.GetHashCode(), "CalendarImporter::IsMeetingChanged. Change is detected on property {0}: old value is {1}; new value is {2}. GOID:{3}; Subject:{4}; StartTime:{5}.", new object[]
             {
                 propertyDefinition.Name,
                 obj,
                 obj2,
                 goid,
                 promotedItem.TryGetProperty(ItemSchema.Subject),
                 promotedItem.TryGetProperty(CalendarItemInstanceSchema.StartTime)
             });
             return(true);
         }
         IL_214 :;
     }
     return(false);
 }
Ejemplo n.º 3
0
        private static List <ExTimeZone> MatchCustomTimeZoneByEffectiveRule(ExTimeZone customTimeZone)
        {
            List <ExTimeZone> list = new List <ExTimeZone>();
            REG_TIMEZONE_INFO v    = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(customTimeZone);

            foreach (ExTimeZone exTimeZone in ExTimeZoneEnumerator.Instance)
            {
                if (v == TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(exTimeZone))
                {
                    list.Add(exTimeZone);
                }
            }
            return(list);
        }
Ejemplo n.º 4
0
        public static byte[] GetTimeZoneBlob(ExTimeZone timeZone)
        {
            if (timeZone == null)
            {
                throw new ArgumentNullException("timeZone");
            }
            if (timeZone == ExTimeZone.UnspecifiedTimeZone)
            {
                throw new ArgumentException("timeZone should not be UnspecifiedTimeZone");
            }
            REG_TIMEZONE_INFO timeZoneInfo = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(timeZone);

            return(O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.ToBytesFromRegistryFormat(timeZoneInfo));
        }
Ejemplo n.º 5
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));
        }
Ejemplo n.º 6
0
 private void DemoteVEvents(IList <Item> items)
 {
     foreach (Item item in items)
     {
         ExTimeZone exTimeZone = item.PropertyBag.ExTimeZone;
         try
         {
             REG_TIMEZONE_INFO reg_TIMEZONE_INFO = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(TimeZoneHelper.GetExTimeZoneFromItem(item));
             string            text = this.demotingTimeZones[reg_TIMEZONE_INFO];
             item.PropertyBag.ExTimeZone = TimeZoneHelper.CreateCustomExTimeZoneFromRegTimeZoneInfo(reg_TIMEZONE_INFO, text, text);
             VEvent vevent = new VEvent(this);
             vevent.Demote(item);
             if (!base.OutboundContext.SuppressExceptionAndAttachmentDemotion && (base.Context.Method == CalendarMethod.Request || base.Context.Method == CalendarMethod.Cancel || base.Context.Method == CalendarMethod.Publish))
             {
                 InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(item);
                 if (recurrenceFromItem != null)
                 {
                     IList <OccurrenceInfo> modifiedOccurrences = recurrenceFromItem.GetModifiedOccurrences();
                     foreach (OccurrenceInfo occurrenceInfo in modifiedOccurrences)
                     {
                         ExceptionInfo exceptionInfo = (ExceptionInfo)occurrenceInfo;
                         VEvent        vevent2       = new VEvent(this);
                         vevent2.DemoteException(exceptionInfo, vevent);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             ExTraceGlobals.ICalTracer.TraceError <Exception>((long)this.GetHashCode(), "VCalendar::DemoteVEvents. Skipping item due to {0}", ex);
             base.Context.AddError(ServerStrings.InvalidICalElement(ex.ToString()));
         }
         finally
         {
             item.PropertyBag.ExTimeZone = exTimeZone;
         }
     }
 }
Ejemplo n.º 7
0
 internal static REG_TIMEZONE_INFO RegTimeZoneInfoFromExTimeZone(ExTimeZone timeZone)
 {
     return(TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(timeZone));
 }
Ejemplo n.º 8
0
 public static REG_TIMEZONE_INFO RegTimeZoneInfoFromExTimeZone(ExTimeZone timeZone)
 {
     return(TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(timeZone, ExDateTime.Now));
 }
Ejemplo n.º 9
0
 internal WorkHoursTimeZone(ExTimeZone timeZone)
 {
     this.timeZoneInfo = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(timeZone);
     this.Name         = timeZone.Id;
 }