private ExTimeZone ConvertTimeZone(TimeZoneDefinitionType remoteTimeZone) { ExTimeZone result = ExTimeZone.UtcTimeZone; if (remoteTimeZone != null) { try { Globals.ConsistencyChecksTracer.TraceDebug <CalendarItemConverter, string, string>((long)this.GetHashCode(), "{0}: Converting TimeZone - Id: {1}, Name: {2}", this, remoteTimeZone.Id, remoteTimeZone.Name); result = new TimeZoneDefinitionAdaptor(remoteTimeZone).ExTimeZone; } catch (TimeZoneException) { } } return(result); }
private void CopyCalendarProperties(CalendarItemBase localItem, CalendarItemType remoteItem) { ExTimeZone desiredTimeZone = ExTimeZone.UtcTimeZone; ExTimeZone desiredTimeZone2 = ExTimeZone.UtcTimeZone; if (remoteItem.StartTimeZone != null) { AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string, string>((long)this.GetHashCode(), "{0}: Converting StartTimeZone - Id: {1}, Name: {2}", this, remoteItem.StartTimeZone.Id, remoteItem.StartTimeZone.Name); desiredTimeZone = new TimeZoneDefinitionAdaptor(remoteItem.StartTimeZone).ExTimeZone; } if (remoteItem.EndTimeZone != null) { AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string, string>((long)this.GetHashCode(), "{0}: Converting EndTimeZone - Id: {1}, Name: {2}", this, remoteItem.EndTimeZone.Id, remoteItem.EndTimeZone.Name); desiredTimeZone2 = new TimeZoneDefinitionAdaptor(remoteItem.EndTimeZone).ExTimeZone; } AppointmentTranslator.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Copying Subject: {1}, Location: {2}, StartTime: {3}, EndTime: {4}", new object[] { this, remoteItem.Subject, remoteItem.Location, remoteItem.Start, remoteItem.End }); localItem.StartTime = new ExDateTime(desiredTimeZone, this.NormalizeDateToUtc(remoteItem.Start)); localItem.EndTime = new ExDateTime(desiredTimeZone2, this.NormalizeDateToUtc(remoteItem.End)); localItem.Sensitivity = this.Convert(remoteItem.Sensitivity); localItem.FreeBusyStatus = this.Convert(remoteItem.LegacyFreeBusyStatus); if (remoteItem.Location != null) { localItem.Location = remoteItem.Location; } else { localItem.Location = string.Empty; } if (localItem.Sensitivity != Sensitivity.Normal) { localItem.Subject = ClientStrings.PrivateAppointmentSubject.ToString(this.ClientCulture); } else if (remoteItem.Subject != null) { localItem.Subject = remoteItem.Subject; } else { localItem.Subject = this.ConvertFreeBusyToTitle(localItem.FreeBusyStatus); } localItem.Reminder.Disable(); string value = string.Empty; BodyFormat bodyFormat = BodyFormat.TextPlain; if (remoteItem.Body != null) { value = remoteItem.Body.Value; switch (remoteItem.Body.BodyType1) { case BodyTypeType.HTML: bodyFormat = BodyFormat.TextHtml; break; case BodyTypeType.Text: bodyFormat = BodyFormat.TextPlain; break; default: throw new InvalidAppointmentException(); } AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string>((long)this.GetHashCode(), "{0}: Copying body: {1}", this, remoteItem.Body.Value); } using (TextWriter textWriter = localItem.Body.OpenTextWriter(bodyFormat)) { textWriter.Write(value); } AppointmentTranslator.Tracer.TraceDebug <AppointmentTranslator, string>((long)this.GetHashCode(), "{0}: Copying Id: {1}", this, remoteItem.ItemId.Id); localItem[SharingSchema.ExternalSharingMasterId] = remoteItem.ItemId.Id; }