Example #1
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);
 }
Example #2
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);
        }
Example #3
0
 public static ExTimeZone CreateCustomExTimeZoneFromRegTimeZoneInfo(REG_TIMEZONE_INFO regInfo, string keyName, string displayName)
 {
     return(TimeZoneHelper.CreateCustomExTimeZoneFromRegRules(regInfo, keyName, displayName, new List <RegistryTimeZoneRule>(1)
     {
         new RegistryTimeZoneRule(DateTime.MinValue.Year, regInfo)
     }));
 }
        private static byte[] GenerateBlobFromRuleGroups(string keyName, IList <ExTimeZoneRuleGroup> groups)
        {
            O12TimeZoneFormatter.ExchangeTimeZoneHeader exchangeTimeZoneHeader = new O12TimeZoneFormatter.ExchangeTimeZoneHeader(keyName, (ushort)groups.Count);
            int size = exchangeTimeZoneHeader.GetSize();
            int num  = size + O12TimeZoneFormatter.ExchangeTimeZoneRule.Size * groups.Count;

            byte[] array = new byte[num];
            int    num2  = exchangeTimeZoneHeader.ToBytes(new ArraySegment <byte>(array, 0, size));

            foreach (ExTimeZoneRuleGroup exTimeZoneRuleGroup in groups)
            {
                O12TimeZoneFormatter.TzRuleFlags flag = O12TimeZoneFormatter.TzRuleFlags.None;
                if (groups.Count == 1 || (exTimeZoneRuleGroup.EffectiveUtcStart <= DateTime.UtcNow && exTimeZoneRuleGroup.EffectiveUtcEnd > DateTime.UtcNow))
                {
                    flag = O12TimeZoneFormatter.TzRuleFlags.EffectiveTimeZone;
                }
                int year;
                if (exTimeZoneRuleGroup.EffectiveUtcStart != DateTime.MinValue)
                {
                    ExTimeZoneRule ruleForUtcTime = exTimeZoneRuleGroup.GetRuleForUtcTime(exTimeZoneRuleGroup.EffectiveUtcStart);
                    year = ruleForUtcTime.FromUtc(exTimeZoneRuleGroup.EffectiveUtcStart).Year;
                }
                else
                {
                    year = exTimeZoneRuleGroup.EffectiveUtcStart.Year;
                }
                REG_TIMEZONE_INFO regInfo = TimeZoneHelper.RegTimeZoneInfoFromExTimeZoneRuleGroup(exTimeZoneRuleGroup);
                O12TimeZoneFormatter.ExchangeTimeZoneRule exchangeTimeZoneRule = new O12TimeZoneFormatter.ExchangeTimeZoneRule(flag, (ushort)year, regInfo);
                exchangeTimeZoneRule.ToBytes(new ArraySegment <byte>(array, num2, O12TimeZoneFormatter.ExchangeTimeZoneRule.Size));
                num2 += O12TimeZoneFormatter.ExchangeTimeZoneRule.Size;
            }
            return(array);
        }
Example #5
0
        private REG_TIMEZONE_INFO GetNativeTimeZoneRule(TimeZoneRule standard, TimeZoneRule daylight)
        {
            if (standard != null && daylight != null && standard.Offset == daylight.Offset)
            {
                daylight = null;
            }
            REG_TIMEZONE_INFO result = default(REG_TIMEZONE_INFO);

            if (standard == null)
            {
                result.Bias         = -daylight.Offset;
                result.DaylightBias = 0;
            }
            else
            {
                result.Bias         = -standard.Offset;
                result.StandardBias = 0;
                if (daylight != null)
                {
                    result.StandardDate = standard.TransitionDate;
                    result.DaylightDate = daylight.TransitionDate;
                    result.DaylightBias = standard.Offset - daylight.Offset;
                }
            }
            return(result);
        }
Example #6
0
        public static bool TryParseTimeZoneBlob(byte[] bytes, string displayName, out ExTimeZone timeZone)
        {
            timeZone = null;
            if (bytes == null || displayName == null)
            {
                ExTraceGlobals.StorageTracer.TraceError(0L, "O11TimeZoneParser, time zone blob or display name is null");
                return(false);
            }
            if (bytes.Length < O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.Size)
            {
                ExTraceGlobals.StorageTracer.TraceError <int>(0L, "O11TimeZoneParser, corrupted TimeZoneBlob. Length {0} less than standard blob", bytes.Length);
                return(false);
            }
            if (bytes.Length > O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.Size)
            {
                ExTraceGlobals.StorageTracer.TraceWarning <int>(0L, "O11TimeZoneParser, corrupted TimeZoneBlob Length {0}, going to trim extra bytes", bytes.Length);
            }
            REG_TIMEZONE_INFO regInfo = O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.ParseToRegistryFormat(bytes);

            try
            {
                timeZone = TimeZoneHelper.CreateCustomExTimeZoneFromRegTimeZoneInfo(regInfo, string.Empty, displayName);
            }
            catch (InvalidTimeZoneException ex)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>(0L, "O11TimeZoneParser, corrupted time zone, blob is not valid registry format. Inner message is {0}", ex.Message);
            }
            return(timeZone != null);
        }
Example #7
0
        protected override ConsistencyCheckResult DetectInconsistencies()
        {
            ConsistencyCheckResult consistencyCheckResult = ConsistencyCheckResult.CreateInstance(base.Type, base.Description);

            if (base.Context.OrganizerItem == null || base.Context.AttendeeItem == null)
            {
                consistencyCheckResult.Status      = CheckStatusType.CheckError;
                consistencyCheckResult.ErrorString = "Either organizer or attendee's calendar item is null";
            }
            else
            {
                ExTimeZone recurringTimeZoneFromPropertyBag = TimeZoneHelper.GetRecurringTimeZoneFromPropertyBag(base.Context.OrganizerItem.PropertyBag);
                if (recurringTimeZoneFromPropertyBag != null)
                {
                    ExTimeZone recurringTimeZoneFromPropertyBag2 = TimeZoneHelper.GetRecurringTimeZoneFromPropertyBag(base.Context.AttendeeItem.PropertyBag);
                    if (recurringTimeZoneFromPropertyBag2 == null)
                    {
                        this.FailCheck(consistencyCheckResult, this.GetLogValue(recurringTimeZoneFromPropertyBag, null), this.GetLogValue(recurringTimeZoneFromPropertyBag2, null));
                    }
                    else
                    {
                        REG_TIMEZONE_INFO value             = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(recurringTimeZoneFromPropertyBag);
                        REG_TIMEZONE_INFO reg_TIMEZONE_INFO = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(recurringTimeZoneFromPropertyBag2);
                        if (!value.Equals(reg_TIMEZONE_INFO))
                        {
                            this.FailCheck(consistencyCheckResult, this.GetLogValue(recurringTimeZoneFromPropertyBag, new REG_TIMEZONE_INFO?(value)), this.GetLogValue(recurringTimeZoneFromPropertyBag2, new REG_TIMEZONE_INFO?(reg_TIMEZONE_INFO)));
                        }
                    }
                }
            }
            return(consistencyCheckResult);
        }
Example #8
0
 public static byte[] ToBytesFromRegistryFormat(REG_TIMEZONE_INFO timeZoneInfo)
 {
     byte[] array = new byte[O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.Size];
     ExBitConverter.Write(timeZoneInfo.Bias, array, O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.BiasOffset);
     ExBitConverter.Write(timeZoneInfo.StandardBias, array, O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.StandardBiasOffset);
     ExBitConverter.Write(timeZoneInfo.DaylightBias, array, O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.DaylightBiasOffset);
     ExBitConverter.Write(0, array, O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.StandardYearOffset);
     timeZoneInfo.StandardDate.Write(new ArraySegment <byte>(array, O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.StandardDateOffset, NativeMethods.SystemTime.Size));
     ExBitConverter.Write(0, array, O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.DaylightYearOffset);
     timeZoneInfo.DaylightDate.Write(new ArraySegment <byte>(array, O11TimeZoneFormatter.OUTLOOK_TIMEZONE_INFO.DaylightDateOffset, NativeMethods.SystemTime.Size));
     return(array);
 }
Example #9
0
        // Token: 0x0600119B RID: 4507 RVA: 0x00060804 File Offset: 0x0005EA04
        public static bool IsClientTimeZoneEquivalentToServerTimeZoneRule(ExTimeZone clientTZ, ExTimeZone serverTZ, ExDateTime effectiveTime)
        {
            REG_TIMEZONE_INFO reg_TIMEZONE_INFO = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(clientTZ);
            REG_TIMEZONE_INFO v = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(serverTZ);

            if (reg_TIMEZONE_INFO.Equals(v))
            {
                return(true);
            }
            REG_TIMEZONE_INFO v2 = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(serverTZ, effectiveTime);

            return(reg_TIMEZONE_INFO.Equals(v2));
        }
Example #10
0
        internal static ExTimeZone CreateCustomExTimeZoneFromRegRules(REG_TIMEZONE_INFO regInfo, string keyName, string displayName, List <RegistryTimeZoneRule> regRules)
        {
            RegistryTimeZoneInformation registryTimeZoneInformation = new RegistryTimeZoneInformation(keyName, displayName, string.Empty, string.Empty, string.Empty, regInfo);

            foreach (RegistryTimeZoneRule item in regRules)
            {
                registryTimeZoneInformation.Rules.Add(item);
            }
            ExTimeZone timeZoneWithIdFromRegistryInfo = ExRegistryTimeZoneProvider.GetTimeZoneWithIdFromRegistryInfo("tzone://Microsoft/Custom", registryTimeZoneInformation);

            timeZoneWithIdFromRegistryInfo.TimeZoneInformation.AlternativeId = keyName;
            return(timeZoneWithIdFromRegistryInfo);
        }
Example #11
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));
        }
Example #12
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);
        }
 public static bool TryParse(ArraySegment <byte> source, out O12TimeZoneFormatter.ExchangeTimeZoneRule rule)
 {
     rule = default(O12TimeZoneFormatter.ExchangeTimeZoneRule);
     if (source.Count < O12TimeZoneFormatter.ExchangeTimeZoneRule.Size)
     {
         return(false);
     }
     rule.MajorVersion    = source.Array[source.Offset + O12TimeZoneFormatter.ExchangeTimeZoneRule.MajorVersionOffset];
     rule.MinVersion      = source.Array[source.Offset + O12TimeZoneFormatter.ExchangeTimeZoneRule.MinVersionOffset];
     rule.ruleSize        = BitConverter.ToUInt16(source.Array, source.Offset + O12TimeZoneFormatter.ExchangeTimeZoneRule.RuleSizeOffset);
     rule.Flags           = BitConverter.ToUInt16(source.Array, source.Offset + O12TimeZoneFormatter.ExchangeTimeZoneRule.FlagsOffset);
     rule.Start           = NativeMethods.SystemTime.Parse(new ArraySegment <byte>(source.Array, source.Offset + O12TimeZoneFormatter.ExchangeTimeZoneRule.StartOffset, NativeMethods.SystemTime.Size));
     rule.RegTimeZoneInfo = REG_TIMEZONE_INFO.Parse(new ArraySegment <byte>(source.Array, source.Offset + O12TimeZoneFormatter.ExchangeTimeZoneRule.RegTimeZoneInfoOffset, REG_TIMEZONE_INFO.Size));
     return(true);
 }
Example #14
0
        internal bool IsSameTimeZoneInfo(REG_TIMEZONE_INFO other)
        {
            if (other == this.timeZoneInfo)
            {
                return(true);
            }
            REG_TIMEZONE_INFO v = this.timeZoneInfo;

            v.StandardDate.Milliseconds = 0;
            v.DaylightDate.Milliseconds = 0;
            REG_TIMEZONE_INFO v2 = other;

            v2.StandardDate.Milliseconds = 0;
            v2.DaylightDate.Milliseconds = 0;
            return(v == v2);
        }
Example #15
0
        internal static REG_TIMEZONE_INFO RegTimeZoneInfoFromExTimeZoneRuleGroup(ExTimeZoneRuleGroup group)
        {
            REG_TIMEZONE_INFO result          = default(REG_TIMEZONE_INFO);
            ExTimeZoneRule    exTimeZoneRule  = group.Rules[0];
            ExTimeZoneRule    exTimeZoneRule2 = (group.Rules.Count > 1) ? group.Rules[1] : null;

            if (exTimeZoneRule2 != null && exTimeZoneRule.Bias > exTimeZoneRule2.Bias)
            {
                ExTimeZoneRule exTimeZoneRule3 = exTimeZoneRule;
                exTimeZoneRule  = exTimeZoneRule2;
                exTimeZoneRule2 = exTimeZoneRule3;
            }
            result.Bias         = (int)(-(int)exTimeZoneRule.Bias.TotalMinutes);
            result.StandardBias = 0;
            if (exTimeZoneRule2 != null)
            {
                result.DaylightBias = (int)(exTimeZoneRule.Bias.TotalMinutes - exTimeZoneRule2.Bias.TotalMinutes);
                result.StandardDate = TimeZoneHelper.Win32SystemTimeFromRecurringTime(exTimeZoneRule2.ObservanceEnd);
                result.DaylightDate = TimeZoneHelper.Win32SystemTimeFromRecurringTime(exTimeZoneRule.ObservanceEnd);
            }
            return(result);
        }
Example #16
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;
         }
     }
 }
Example #17
0
 internal VTimeZone(CalendarComponentBase root, REG_TIMEZONE_INFO tzInfo, string timeZoneId) : base(root)
 {
     this.timeZoneInfo = tzInfo;
     this.timeZoneId   = timeZoneId;
 }
 public ExchangeTimeZoneRule(O12TimeZoneFormatter.TzRuleFlags flag, ushort startYear, REG_TIMEZONE_INFO regInfo)
 {
     this.MajorVersion    = 2;
     this.MinVersion      = 1;
     this.ruleSize        = (ushort)(O12TimeZoneFormatter.ExchangeTimeZoneRule.Size - 4);
     this.Flags           = (ushort)flag;
     this.Start           = default(NativeMethods.SystemTime);
     this.Start.Year      = startYear;
     this.Start.Month     = 1;
     this.Start.Day       = 1;
     this.RegTimeZoneInfo = regInfo;
 }
Example #19
0
        public static ExTimeZone CreateExTimeZoneFromRegTimeZoneInfo(REG_TIMEZONE_INFO regInfo, string keyName)
        {
            ExTimeZone exTimeZone = TimeZoneHelper.CreateCustomExTimeZoneFromRegTimeZoneInfo(regInfo, keyName, keyName);

            return(TimeZoneHelper.PromoteCustomizedTimeZone(exTimeZone) ?? exTimeZone);
        }
Example #20
0
 private static extern void RtlMoveMemory(ref REG_TIMEZONE_INFO pDest, ref byte pSource, int ByteLen);
Example #21
0
        public static string ToTimeZoneString(ExTimeZone srcTimeZone)
        {
            if (srcTimeZone == null)
            {
                throw new EasSyncFailedPermanentException("Null source time zone");
            }
            byte[]            array             = new byte[172];
            int               num               = 0;
            REG_TIMEZONE_INFO reg_TIMEZONE_INFO = TimeZoneHelper.RegTimeZoneInfoFromExTimeZone(srcTimeZone);

            byte[] bytes = BitConverter.GetBytes(reg_TIMEZONE_INFO.Bias);
            bytes.CopyTo(array, num);
            num += Marshal.SizeOf(reg_TIMEZONE_INFO.Bias);
            char[] array2 = srcTimeZone.LocalizableDisplayName.ToString(CultureInfo.InvariantCulture).ToCharArray();
            int    num2   = Math.Min(array2.Length, 32);

            for (int i = 0; i < num2; i++)
            {
                BitConverter.GetBytes(array2[i]).CopyTo(array, num);
                num += 2;
            }
            for (int j = num2; j < 32; j++)
            {
                array[num++] = 0;
                array[num++] = 0;
            }
            BitConverter.GetBytes(reg_TIMEZONE_INFO.StandardDate.Year).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.StandardDate.Month).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.StandardDate.DayOfWeek).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.StandardDate.Day).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.StandardDate.Hour).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.StandardDate.Minute).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.StandardDate.Second).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.StandardDate.Milliseconds).CopyTo(array, num);
            num  += 2;
            bytes = BitConverter.GetBytes(reg_TIMEZONE_INFO.StandardBias);
            bytes.CopyTo(array, num);
            num   += Marshal.SizeOf(reg_TIMEZONE_INFO.StandardBias);
            array2 = srcTimeZone.LocalizableDisplayName.ToString(CultureInfo.InvariantCulture).ToCharArray();
            num2   = Math.Min(array2.Length, 32);
            for (int k = 0; k < num2; k++)
            {
                BitConverter.GetBytes(array2[k]).CopyTo(array, num);
                num += 2;
            }
            for (int l = num2; l < 32; l++)
            {
                array[num++] = 0;
                array[num++] = 0;
            }
            BitConverter.GetBytes(reg_TIMEZONE_INFO.DaylightDate.Year).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.DaylightDate.Month).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.DaylightDate.DayOfWeek).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.DaylightDate.Day).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.DaylightDate.Hour).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.DaylightDate.Minute).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.DaylightDate.Second).CopyTo(array, num);
            num += 2;
            BitConverter.GetBytes(reg_TIMEZONE_INFO.DaylightDate.Milliseconds).CopyTo(array, num);
            num  += 2;
            bytes = BitConverter.GetBytes(reg_TIMEZONE_INFO.DaylightBias);
            bytes.CopyTo(array, num);
            num += Marshal.SizeOf(reg_TIMEZONE_INFO.DaylightBias);
            if (num != 172)
            {
                throw new EasSyncFailedPermanentException("Failed to convert Timezone into bytes. Length=" + num);
            }
            return(Convert.ToBase64String(array));
        }