private static int MergedFreeBusyWeight(char c, ExchangeVersionType requestSchemaVersion) { switch (c) { case '0': return(1); case '1': return(2); case '2': return(3); case '3': return(4); case '4': if (requestSchemaVersion < ExchangeVersionType.Exchange2012) { return(0); } return(1); default: return(0); } }
private ExchangeVersion GetEwsVersionFromHttpHeaders(Message request, HttpRequest httpRequest) { ExchangeVersion result = null; string headerValue = httpRequest.Headers["X-EWS-TargetVersion"]; ExchangeVersionHeader exchangeVersionHeader = new ExchangeVersionHeader(headerValue); if (!exchangeVersionHeader.IsMissing) { ExchangeVersionType version = exchangeVersionHeader.CheckAndGetRequestedVersion(); result = new ExchangeVersion(version); } return(result); }
public RequestServerVersion() { this.versionField = ExchangeVersionType.Exchange2016; }
public RequestServerVersion() { versionField = ExchangeVersionType.Exchange2007_SP1; }
public AttendeeData(MeetingAttendeeType attendeeType, string identity, bool excludeConflict, ExDateTime freeBusyStart, ExDateTime freeBusyEnd, string mergedFreeBusy, ExchangeVersionType requestSchemaVersion, AttendeeWorkHours workingHours) { if (identity == null) { throw new ArgumentNullException("identity"); } if (workingHours == null) { throw new ArgumentNullException("workingHours"); } if (freeBusyStart.TimeZone != freeBusyEnd.TimeZone) { throw new ArgumentException("freeBusyStart.TimeZone != freeBusyEnd.TimeZone"); } this.attendeeType = attendeeType; this.identity = identity; this.excludeConflict = excludeConflict; this.freeBusyStart = freeBusyStart; this.freeBusyEnd = freeBusyEnd; this.mergedFreeBusy = mergedFreeBusy; this.workingHours = workingHours; this.requestSchemaVersion = requestSchemaVersion; }
private ExchangeServiceBinding GetService(string adminUserName, string adminPassword, string userMail, string ewsUrl, ExchangeVersionType exVersion) { //Ignorar validação de certificado ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(OnValidationCallback); // Identify the service binding and the user. ExchangeServiceBinding service = new ExchangeServiceBinding(); service.RequestServerVersionValue = new RequestServerVersion(); service.RequestServerVersionValue.Version = exVersion; service.Credentials = new NetworkCredential(adminUserName, adminPassword); service.Url = ewsUrl; //Impersonating user context ExchangeImpersonationType exExchangeImpersonation = new ExchangeImpersonationType(); ConnectingSIDType csConnectingSid = new ConnectingSIDType(); csConnectingSid.Item = userMail; exExchangeImpersonation.ConnectingSID = csConnectingSid; service.ExchangeImpersonation = exExchangeImpersonation; return(service); }
internal static CalendarEvent CreateFromQueryData(EmailAddress mailbox, object[] properties, FreeBusyViewType allowedView, bool isCallerMailboxOwner, ExchangeVersionType exchangeVersion) { CalendarEvent calendarEvent = new CalendarEvent(); calendarEvent.viewType = allowedView; calendarEvent.globalObjectId = CalendarEvent.GetPropertyValue <byte[]>(properties, QueryPropertyIndexes.GlobalObjectId); calendarEvent.StartTime = DateTime.SpecifyKind((DateTime)CalendarEvent.GetPropertyValue <ExDateTime>(properties, QueryPropertyIndexes.StartTime, ExDateTime.MinValue), DateTimeKind.Unspecified); calendarEvent.EndTime = DateTime.SpecifyKind((DateTime)CalendarEvent.GetPropertyValue <ExDateTime>(properties, QueryPropertyIndexes.EndTime, ExDateTime.MinValue), DateTimeKind.Unspecified); BusyType busyType = CalendarEvent.GetPropertyValue <BusyType>(properties, QueryPropertyIndexes.BusyStatus, BusyType.Busy); if (busyType < BusyType.Free || busyType > BusyType.NoData) { CalendarEvent.CalendarViewTracer.TraceError((long)calendarEvent.GetHashCode(), "{0}: Calendar event with start time {1} and end time {2} in mailbox {3} has invalid busy type: {4}. This is being returned as BusyType.Tentative", new object[] { TraceContext.Get(), calendarEvent.StartTime, calendarEvent.EndTime, mailbox, busyType }); calendarEvent.BusyType = BusyType.Tentative; } else { if (exchangeVersion < ExchangeVersionType.Exchange2012 && busyType == BusyType.WorkingElsewhere) { busyType = BusyType.Free; } calendarEvent.BusyType = busyType; } Sensitivity propertyValue = CalendarEvent.GetPropertyValue <Sensitivity>(properties, QueryPropertyIndexes.Sensitivity, Sensitivity.Normal); if (propertyValue < Sensitivity.Normal || propertyValue > Sensitivity.CompanyConfidential) { CalendarEvent.CalendarViewTracer.TraceError((long)calendarEvent.GetHashCode(), "{0}: Calendar event with start time {1} and end time {2} in mailbox {3} has invalid sensitivity value: {4}.", new object[] { TraceContext.Get(), calendarEvent.StartTime, calendarEvent.EndTime, mailbox, propertyValue }); } VersionedId propertyValue2 = CalendarEvent.GetPropertyValue <VersionedId>(properties, QueryPropertyIndexes.EntryId); ByteArray byteArray = new ByteArray(propertyValue2.ObjectId.ProviderLevelItemId); if (allowedView != FreeBusyViewType.Detailed && allowedView != FreeBusyViewType.DetailedMerged) { return(calendarEvent); } calendarEvent.CalendarEventDetails = new CalendarEventDetails(); CalendarEventDetails calendarEventDetails = calendarEvent.CalendarEventDetails; calendarEventDetails.IsPrivate = (propertyValue != Sensitivity.Normal); if (calendarEventDetails.IsPrivate && !isCallerMailboxOwner) { CalendarEvent.CalendarViewTracer.TraceError((long)calendarEvent.GetHashCode(), "{0}: Calendar event with start time {1} and end time {2} in mailbox {3} is a private item. Detail data will not be included.", new object[] { TraceContext.Get(), calendarEvent.StartTime, calendarEvent.EndTime, mailbox }); return(calendarEvent); } calendarEventDetails.ID = byteArray.ToString(); calendarEventDetails.Subject = CalendarEvent.GetPropertyValue <string>(properties, QueryPropertyIndexes.Subject); calendarEventDetails.Location = CalendarEvent.GetPropertyValue <string>(properties, QueryPropertyIndexes.Location); calendarEventDetails.IsReminderSet = CalendarEvent.GetPropertyValue <bool>(properties, QueryPropertyIndexes.IsReminderSet, false); AppointmentStateFlags propertyValue3 = CalendarEvent.GetPropertyValue <AppointmentStateFlags>(properties, QueryPropertyIndexes.AppointmentState, AppointmentStateFlags.None); calendarEventDetails.IsMeeting = ((propertyValue3 & AppointmentStateFlags.Meeting) > AppointmentStateFlags.None); CalendarItemType propertyValue4 = CalendarEvent.GetPropertyValue <CalendarItemType>(properties, QueryPropertyIndexes.CalendarItemType, CalendarItemType.Single); if (propertyValue4 == CalendarItemType.Occurrence) { calendarEventDetails.IsRecurring = true; } if (propertyValue4 == CalendarItemType.Exception) { calendarEventDetails.IsException = true; calendarEventDetails.IsRecurring = true; } return(calendarEvent); }
// Token: 0x06000584 RID: 1412 RVA: 0x0002AFD8 File Offset: 0x000291D8 private void CallEws(Func <BaseResponseMessageType> delegateEwsCall, Func <ResponseMessageType, int, bool> responseMessageProcessor, Func <Exception, Exception> exceptionHandler, ExchangeVersionType requestServerVersion, string mailboxEmailAddress) { if (this.Connect()) { base.ServiceBinding.RequestServerVersionValue = new RequestServerVersion { Version = requestServerVersion }; base.ServiceCallingContext.SetServiceApiContext(base.ServiceBinding, mailboxEmailAddress); try { base.InternalCallService <BaseResponseMessageType>(delegateEwsCall, delegate(BaseResponseMessageType response) { List <ResponseMessageType> list = new List <ResponseMessageType>(response.ResponseMessages.Items); foreach (ResponseMessageType responseMessageType in from t in response.ResponseMessages.Items orderby(int) t.ResponseClass select t) { int arg = list.IndexOf(responseMessageType); if (responseMessageType.ResponseClass == ResponseClassType.Error) { ElcEwsClient.Tracer.TraceError <ResponseCodeType, string>(0L, "ElcEwsClient.CallEws: Message response error. ResponseCode:{0}; MessageText:'{1}'", responseMessageType.ResponseCode, responseMessageType.MessageText); if (responseMessageType.ResponseCode == ResponseCodeType.ErrorInternalServerTransientError || responseMessageType.ResponseCode == ResponseCodeType.ErrorMailboxStoreUnavailable || responseMessageType.ResponseCode == ResponseCodeType.ErrorServerBusy || responseMessageType.ResponseCode == ResponseCodeType.ErrorTimeoutExpired) { ElcEwsClient.Tracer.TraceError <ResponseCodeType>(0L, "ElcEwsClient.CallEws: Transient exception causing retry. ResponseCode: {0}.", responseMessageType.ResponseCode); throw new RetryException(new ExportException(ExportErrorType.ExchangeWebServiceCallFailed, responseMessageType.MessageText), false); } if (responseMessageProcessor == null) { ElcEwsClient.Tracer.TraceError(0L, "ElcEwsClient.CallEws: Error response message received and responseMessageProcessor is null."); throw new ExportException(ExportErrorType.ExchangeWebServiceCallFailed, responseMessageType.MessageText); } } try { if (responseMessageProcessor != null && !responseMessageProcessor(responseMessageType, arg)) { break; } } catch (RetryException ex) { if (ElcBaseServiceClient <ExchangeServiceBinding, IElcEwsClient> .IsTransientError(responseMessageType.ResponseCode)) { throw; } throw ex.InnerException; } } }, exceptionHandler, () => base.ServiceCallingContext.AuthorizeServiceBinding(base.ServiceBinding), delegate(Uri redirectedUrl) { base.ServiceCallingContext.SetServiceUrlAffinity(base.ServiceBinding, redirectedUrl); base.ServiceCallingContext.SetServiceUrl(base.ServiceBinding, redirectedUrl); }); return; } catch (ExportException) { ElcEwsClient.Tracer.TraceError <ServiceHttpContext>(0L, "ElcEwsClient.CallEws: {0}", base.ServiceBinding.HttpContext); throw; } } throw new ExportException(ExportErrorType.ExchangeWebServiceCallFailed, "Unable to connect to Exchange web service at: " + base.ServiceEndpoint.ToString()); }
private InternalClientContext(InternalClientContext clientContext, ClientSecurityContext clientSecurityContext, bool ownsClientSecurityContext, ExchangeVersionType requestSchemaVersion) : base(clientContext.Budget, clientContext.TimeZone, clientContext.ClientCulture, clientContext.MessageId) { this.clientSecurityContext = clientSecurityContext; this.ownsClientSecurityContext = ownsClientSecurityContext; this.adUser = clientContext.adUser; this.adUserInitialized = clientContext.adUserInitialized; this.organizationId = clientContext.OrganizationId; this.serializedSecurityContext = clientContext.serializedSecurityContext; this.identityForFilteredTracing = clientContext.identityForFilteredTracing; this.RequestSchemaVersion = requestSchemaVersion; }
internal static CalendarEvent[] GetCalendarEvents(EmailAddress emailAddress, CalendarFolder calendarFolder, ExDateTime windowStart, ExDateTime windowEnd, FreeBusyViewType accessAllowed, bool canActAsMailboxOwner, ExchangeVersionType exchangeVersion) { CalendarEvent[] array = null; int num = 0; object[][] calendarView = calendarFolder.GetCalendarView(windowStart, windowEnd, InternalCalendarQuery.CalendarQueryProperties); InternalCalendarQuery.CalendarViewTracer.TraceDebug(0L, "{0}: Query for {1} found {2} appointment entries between {3} and {4}", new object[] { TraceContext.Get(), emailAddress, calendarView.Length, windowStart, windowEnd }); num += calendarView.Length; if (num > Configuration.MaximumResultSetSize) { LocalizedException ex = new ResultSetTooBigException(Configuration.MaximumResultSetSize, num); InternalCalendarQuery.CalendarViewTracer.TraceError <object, EmailAddress, LocalizedException>(0L, "{0}: Query for {1} got exception getting Calendar Data. Exception: {2}", TraceContext.Get(), emailAddress, ex); throw ex; } int length = calendarView.GetLength(0); if (length > 0) { array = new CalendarEvent[length]; for (int i = 0; i < length; i++) { object[] properties = calendarView[i]; array[i] = CalendarEvent.CreateFromQueryData(emailAddress, properties, accessAllowed, canActAsMailboxOwner, exchangeVersion); } } return(array); }
public static string GenerateMergedFreeBusyString(ExTimeZone timeZone, int mergedFreeBusyInterval, ExDateTime windowStart, ExDateTime windowEnd, CalendarEvent[] calendarEventArray, bool exceptionOccurred, byte[] globalObjectId, ExchangeVersionType requestedSchemaVersion) { int numberOfFreeBusySlots = MergedFreeBusy.NumberOfSlots(windowStart, windowEnd, mergedFreeBusyInterval); return(MergedFreeBusy.BuildMergedFreeBusyString(timeZone, mergedFreeBusyInterval, windowStart, windowEnd, numberOfFreeBusySlots, calendarEventArray, exceptionOccurred, globalObjectId, requestedSchemaVersion)); }
private static string BuildMergedFreeBusyString(ExTimeZone timeZone, int mergedFreeBusyInterval, ExDateTime windowStart, ExDateTime windowEnd, int numberOfFreeBusySlots, CalendarEvent[] calendarEventArray, bool exceptionOccurred, byte[] globalObjectId, ExchangeVersionType requestedSchemaVersion) { char[] array = new char[numberOfFreeBusySlots]; char c; if (requestedSchemaVersion < ExchangeVersionType.Exchange2012) { c = (exceptionOccurred ? '4' : '0'); } else { c = (exceptionOccurred ? '5' : '0'); } for (int i = 0; i < numberOfFreeBusySlots; i++) { array[i] = c; } if (!exceptionOccurred && calendarEventArray != null) { int num = calendarEventArray.Length; int j = 0; while (j < num) { if (globalObjectId == null) { goto IL_72; } byte[] globalObjectId2 = calendarEventArray[j].GlobalObjectId; if (globalObjectId2 == null || !ArrayComparer <byte> .Comparer.Equals(globalObjectId2, globalObjectId)) { goto IL_72; } IL_B3: j++; continue; IL_72: ExDateTime startTime = new ExDateTime(timeZone, calendarEventArray[j].StartTime); ExDateTime endTime = new ExDateTime(timeZone, calendarEventArray[j].EndTime); BusyType busyType = calendarEventArray[j].BusyType; MergedFreeBusy.AddAppointmentToFreeBusyString(windowStart, windowEnd, startTime, endTime, busyType, mergedFreeBusyInterval, array, requestedSchemaVersion); goto IL_B3; } } return(new string(array)); }
private static void AddAppointmentToFreeBusyString(ExDateTime windowStart, ExDateTime windowEnd, ExDateTime startTime, ExDateTime endTime, BusyType busyType, int mergedFreeBusyInterval, char[] freeBusyValues, ExchangeVersionType requestedSchemaVersion) { TimeSpan timeSpan = startTime - windowStart; TimeSpan timeSpan2 = endTime - windowStart; int num = (int)timeSpan.TotalMinutes / mergedFreeBusyInterval; int num2 = (int)(timeSpan2.TotalMinutes / (double)mergedFreeBusyInterval) - 1; if (timeSpan2.TotalMinutes % (double)mergedFreeBusyInterval > 0.0) { num2++; } if (num < 0) { num = 0; } if (num2 >= freeBusyValues.Length) { num2 = freeBusyValues.Length - 1; } char c = (char)(busyType + 48); for (int i = num; i <= num2; i++) { if (MergedFreeBusy.MergedFreeBusyWeight(freeBusyValues[i], requestedSchemaVersion) < MergedFreeBusy.MergedFreeBusyWeight(c, requestedSchemaVersion)) { freeBusyValues[i] = c; } } }
public static FreeBusyQueryResult MergeGroupMemberResults(ExTimeZone timeZone, int mergedFreeBusyInterval, ExDateTime startTime, ExDateTime endTime, FreeBusyQuery[] freeBusyQueryMembers, ExchangeVersionType requestSchemaVersion) { int num = MergedFreeBusy.NumberOfSlots(startTime, endTime, mergedFreeBusyInterval); char[] array = new char[num]; char c = (requestSchemaVersion < ExchangeVersionType.Exchange2012) ? '4' : '5'; for (int i = 0; i < num; i++) { array[i] = c; } foreach (FreeBusyQuery freeBusyQuery in freeBusyQueryMembers) { if (freeBusyQuery.Result != null) { string text = freeBusyQuery.Result.MergedFreeBusy; if (text == null) { text = MergedFreeBusy.BuildMergedFreeBusyString(timeZone, mergedFreeBusyInterval, startTime, endTime, num, freeBusyQuery.Result.CalendarEventArray, freeBusyQuery.Result.ExceptionInfo != null, null, requestSchemaVersion); } for (int k = 0; k < array.Length; k++) { if (MergedFreeBusy.MergedFreeBusyWeight(array[k], requestSchemaVersion) < MergedFreeBusy.MergedFreeBusyWeight(text[k], requestSchemaVersion)) { array[k] = text[k]; } } } } return(new FreeBusyQueryResult(FreeBusyViewType.MergedOnly, null, new string(array), null)); }