diff --git a/src/js/ComplexProperties/FolderPermissionCollection.ts b/src/js/ComplexProperties/FolderPermissionCollection.ts index e4352b0d..e2ef4cf5 100644 --- a/src/js/ComplexProperties/FolderPermissionCollection.ts +++ b/src/js/ComplexProperties/FolderPermissionCollection.ts @@ -1,6 +1,6 @@ import {XmlNamespace} from "../Enumerations/XmlNamespace"; import {Folder} from "../Core/ServiceObjects/Folders/Folder"; -//import CalendarFolder = require("../Core/ServiceObjects/Folders/Calendar____Folder"); +import {TypeContainer} from "../TypeContainer"; import {FolderPermission} from "./FolderPermission"; import {ComplexPropertyCollection} from "./ComplexPropertyCollection"; import {ExchangeService} from "../Core/ExchangeService"; @@ -15,7 +15,7 @@ export class FolderPermissionCollection extends ComplexPropertyCollection; constructor(owner: Folder) { super(); - this.isCalendarFolder = owner._FolderType === XmlElementNames.CalendarFolder; //owner instanceof CalendarFolder; + this.isCalendarFolder = owner instanceof TypeContainer.CalendarFolder;// owner instanceof CalendarFolder; } Add(permission: FolderPermission): void { this.InternalAdd(permission); } diff --git a/src/js/ComplexProperties/StringList.ts b/src/js/ComplexProperties/StringList.ts index 5e84491e..2c10ba4d 100644 --- a/src/js/ComplexProperties/StringList.ts +++ b/src/js/ComplexProperties/StringList.ts @@ -3,7 +3,7 @@ import {Strings} from "../Strings"; import {ArgumentOutOfRangeException} from "../Exceptions/ArgumentException"; import {XmlNamespace} from "../Enumerations/XmlNamespace"; import {ExchangeService} from "../Core/ExchangeService"; -import {EwsServiceXmlReader} from "../Core/EwsServiceXmlReader"; +import {ArrayHelper} from "../ExtensionMethods"; import {EwsServiceXmlWriter} from "../Core/EwsServiceXmlWriter"; import {ComplexProperty} from "./ComplexProperty"; export class StringList extends ComplexProperty { // IEnumerable, IJsonCollectionDeserializer @@ -15,7 +15,7 @@ export class StringList extends ComplexProperty { // IEnumerable, IJsonC constructor(); constructor(itemXmlElementName: string); constructor(strings: string[]); - constructor(stringOrItemXmlElementName?: string| string[]) { + constructor(stringOrItemXmlElementName?: string | string[]) { super(); if (typeof stringOrItemXmlElementName !== 'undefined') { if (typeof stringOrItemXmlElementName === 'string') { @@ -88,7 +88,7 @@ export class StringList extends ComplexProperty { // IEnumerable, IJsonC this.Changed(); } ToString(): string { return this.items.join(","); } - ReadElementsFromXmlJsObject(reader: EwsServiceXmlReader): boolean { debugger; throw new Error("StringList.ts - TryReadElementFromXmlJsObject : Not implemented."); return null; } + //ReadElementsFromXmlJsObject(reader: any): boolean { debugger; throw new Error("StringList.ts - TryReadElementFromXmlJsObject : Not implemented."); return null; } WriteElementsToXml(writer: EwsServiceXmlWriter): void { for (var item of this.items) { writer.WriteStartElement(XmlNamespace.Types, this.itemXmlElementName); @@ -96,16 +96,19 @@ export class StringList extends ComplexProperty { // IEnumerable, IJsonC writer.WriteEndElement(); } } - - - //IJsonCollectionDeserializer.CreateFromJsonCollection - CreateFromJsonCollection(jsonCollection: any[], service: ExchangeService): void { - for (var element of jsonCollection) - { - this.Add(element); - } + + CreateFromXmlJsObjectCollection(jsObjectCollection: any[], service: ExchangeService): void { + var collection = jsObjectCollection[this.itemXmlElementName]; + if (!ArrayHelper.isArray(collection)) { + collection = [collection]; + } + + for (var item of collection) { + this.Add(item); + } } - //IJsonCollectionDeserializer.UpdateFromJsonCollection - UpdateFromJsonCollection(jsonCollection: any[], service: ExchangeService): void { + + UpdateFromXmlJsObjectCollection(jsObjectCollection: any[], service: ExchangeService): void { + throw new Error("StringList.ts - UpdateFromXmlJsObjectCollection : Not implemented."); } } \ No newline at end of file diff --git a/src/js/Core/EwsServiceXmlWriter.ts b/src/js/Core/EwsServiceXmlWriter.ts index 8ab6d9a0..5173c24e 100644 --- a/src/js/Core/EwsServiceXmlWriter.ts +++ b/src/js/Core/EwsServiceXmlWriter.ts @@ -4,6 +4,7 @@ import {ExchangeServiceBase} from "./ExchangeServiceBase"; import {EwsUtilities} from "./EwsUtilities"; import {XmlNamespace} from "../Enumerations/XmlNamespace"; import {StringHelper, base64Helper} from "../ExtensionMethods"; +import {DateTime} from "../DateTime"; /** * XML writer @@ -110,7 +111,8 @@ export class EwsServiceXmlWriter { var strValue: string = null; if (value === null) return null; - if (typeof (value) == "object" && !(value.GetSearchString /*ISearchStringProvider*/)) throw new Error("value can not be of type object"); + // // // // if (typeof (value) == "object" && !(value.GetSearchString /*ISearchStringProvider*/)) + // // // // throw new Error("value can not be of type object"); if (value != null) { switch (typeof (value)) { @@ -125,12 +127,18 @@ export class EwsServiceXmlWriter { case "string": return value; default: + if (value instanceof DateTime) { + return this.service.ConvertDateTimeToUniversalDateTimeString(value as DateTime); + //return EwsUtilities.DateTimeToXSDateTime(value as DateTime); + } try { - if (typeof value.GetSearchString !== 'undefined') // checking - ISearchStringProvider - strValue = value.GetSearchString(); + if (typeof value.GetSearchString === 'function') // checking - ISearchStringProvider + return value.GetSearchString(); + else + throw new Error("value can not be of type object"); } catch (e) { - strValue = value; + throw e; } break; @@ -219,8 +227,8 @@ export class EwsServiceXmlWriter { var value: any = valueToWrite; var alwaysWriteEmptyString: boolean = false; var namespacePrefix: string = null; - var callWithNameSpacePrifix:boolean = false; - + var callWithNameSpacePrifix: boolean = false; + if (argsLength === 2) { value = localNameOrAlwaysWriteEmptyStringOrValue; } @@ -239,7 +247,7 @@ export class EwsServiceXmlWriter { var stringValue: string = this.ConvertObjectToString(value); if (!StringHelper.IsNullOrEmpty(stringValue) || alwaysWriteEmptyString) { this.WriteAttributeString( - callWithNameSpacePrifix? namespacePrefix:"", + callWithNameSpacePrifix ? namespacePrefix : "", localName, stringValue); } @@ -255,7 +263,7 @@ export class EwsServiceXmlWriter { WriteBase64ElementValue(buffer: any): void { this.WriteValue(base64Helper.btoa(buffer), null); } - + /** * Writes the element value. * @@ -295,7 +303,7 @@ export class EwsServiceXmlWriter { EwsLogging.Assert(stringValue !== 'undefined', 'WriteElementValue', StringHelper.Format( Strings.ElementValueCannotBeSerialized, typeof (value), localName)); - + // throw new Error(StringHelper.Format( // Strings.ElementValueCannotBeSerialized, // typeof (value), localName)); diff --git a/src/js/Core/EwsUtilities.ts b/src/js/Core/EwsUtilities.ts index 311f4c88..582d2be6 100644 --- a/src/js/Core/EwsUtilities.ts +++ b/src/js/Core/EwsUtilities.ts @@ -500,7 +500,8 @@ export class EwsUtilities { this.numPad(timeSpan.seconds(), 2)); } static XSDurationToTimeSpan(xsDuration: string): TimeSpan { - var regex: RegExp = /(-)?P([0-9]+)Y?([0-9]+)M?([0-9]+)D?T([0-9]+)H?([0-9]+)M?([0-9]+\.[0-9]+)?S?/; + var regex: RegExp = /(-)?P(([0-9]+)Y)?(([0-9]+)M)?(([0-9]+)D)?(T(([0-9]+)H)?(([0-9]+)M)?(([0-9]+)(\.([0-9]+))?S)?)?/; //ref: info: not using \\, may be a bug in EWS managed api. does not match "-P2Y6M5DT12H35M30.4S" with \\ //old /(-)?P([0-9]+)Y?([0-9]+)M?([0-9]+)D?T([0-9]+)H?([0-9]+)M?([0-9]+\.[0-9]+)?S?/; + if (xsDuration.match(regex) === null) { throw new ArgumentException(Strings.XsDurationCouldNotBeParsed); } diff --git a/src/js/Core/ExchangeService.ts b/src/js/Core/ExchangeService.ts index ef484b78..b8455b0f 100644 --- a/src/js/Core/ExchangeService.ts +++ b/src/js/Core/ExchangeService.ts @@ -117,12 +117,12 @@ import {ExchangeServiceBase} from "./ExchangeServiceBase"; * */ export class ExchangeService extends ExchangeServiceBase { - + /* #region Constants */ private static TargetServerVersionHeaderName: string = "X-EWS-TargetVersion"; /* #endregion Constants */ - - + + /* #region Fields */ private url: Uri = null; //private preferredCulture: any = null;// System.Globalization.CultureInfo; @@ -138,8 +138,8 @@ export class ExchangeService extends ExchangeServiceBase { private targetServerVersion: string = null; //private exchange2007CompatibilityMode: boolean = false; /* #endregion Fields */ - - + + /* #region Properties */ Url: Uri; ImpersonatedUserId: ImpersonatedUserId = null; @@ -169,9 +169,9 @@ export class ExchangeService extends ExchangeServiceBase { this.targetServerVersion = value; } /* #region Properties */ - - - + + + /* #region Response object operations */ /** * @internal Create response object. @@ -191,25 +191,9 @@ export class ExchangeService extends ExchangeServiceBase { }); } /* #endregion Response object operations */ - - - /* #region Folder operations */ - //todo: delete soon; BindToFolderAs(folderId: FolderId, propertySet: PropertySet): IPromise { - // // debugger; - // return this.BindToFolder(folderId, propertySet); - // // if (result instanceof ServiceObject) //todo: implement instanceOf TFolder - // // { - // // return result;// - // // } - // // else { - // // //throw new ServiceLocalException( - // // // string.Format( - // // // Strings.FolderTypeNotCompatible, - // // // result.GetType().Name, - // // // typeof (TFolder).Name)); - // // } - // } + + /* #region Folder operations */ /** * @internal Binds to folder. @@ -282,7 +266,7 @@ export class ExchangeService extends ExchangeServiceBase { return null; }); } - + /** * @internal Deletes a folder. Calling this method results in a call to EWS. * @@ -363,7 +347,7 @@ export class ExchangeService extends ExchangeServiceBase { if (argsLength < 2 && argsLength > 3) { throw new Error("ExchangeService.ts - FindFolders - invalid number of arguments, check documentation and try again."); } - + //position 1 - parentFolderIdOrName var parentFolderIds: FolderId[] = [] if (typeof parentFolderIdOrName === 'number') { @@ -378,7 +362,7 @@ export class ExchangeService extends ExchangeServiceBase { var searchFilter: SearchFilter = null; var view: FolderView = null; - + //position 2 - viewOrSearchFilter if (viewOrSearchFilter instanceof SearchFilter) { if (!(folderView instanceof FolderView)) { @@ -490,10 +474,10 @@ export class ExchangeService extends ExchangeServiceBase { }); } /* #endregion Folder operations */ - - + + /* #region Item operations */ - + /** * Archives multiple items in a single call to EWS. * @@ -901,8 +885,10 @@ export class ExchangeService extends ExchangeServiceBase { * @param {ServiceErrorHandling} errorHandlingMode Indicates the type of error handling should be done. * @return {IPromise>>} Service response collection :Promise. */ - FindItems(parentFolderIds: FolderId[], searchFilter: SearchFilter, queryString: string, view: ViewBase, groupBy: Grouping, errorHandlingMode: ServiceErrorHandling): IPromise>>; - //skipped: not needed, no calls coming in to this internal function in ews managed api, future use possible until them keep it muted - FindItems(parentFolderId: FolderId, searchFilter: SearchFilter, view: ViewBase, groupBy: Grouping ): IPromise>>; + FindItems(parentFolderIds: FolderId[], searchFilter: SearchFilter, queryString: string, view: ViewBase, groupBy: Grouping, errorHandlingMode: ServiceErrorHandling): IPromise>>; + //skipped: not needed, no calls coming in to this internal function in ews managed api, future use possible until them keep it muted - + //FindItems(parentFolderId: FolderId, searchFilter: SearchFilter, view: ViewBase, groupBy: Grouping): IPromise>>; + FindItems( nameIdOrIds: WellKnownFolderName | FolderId | FolderId[], viewQueryStringOrSearchFilter: ViewBase | string | SearchFilter, @@ -911,7 +897,7 @@ export class ExchangeService extends ExchangeServiceBase { groupBy?: Grouping, errorHandlingMode: ServiceErrorHandling = ServiceErrorHandling.ThrowOnError ): IPromise | GroupedFindItemsResults | ServiceResponseCollection>> { - + //todo: better argument check with ewsutilities //EwsUtilities.ValidateParamAllowNull(searchFilter, "searchFilter"); @@ -928,7 +914,7 @@ export class ExchangeService extends ExchangeServiceBase { if (argsLength < 2 && argsLength > 6) { throw new Error("ExchangeService.ts - FindItems - invalid number of arguments, check documentation and try again."); } - + //position 1 - nameIdOrIds var parentIds: FolderId[] = [] if (typeof nameIdOrIds === 'number') { @@ -944,25 +930,26 @@ export class ExchangeService extends ExchangeServiceBase { var queryString: string = null; var searchFilter: SearchFilter = null; var view: ViewBase = null; - + //position 2 - viewQueryStringOrSearchFilter - if (typeof viewQueryStringOrSearchFilter === 'string') { - queryString = viewQueryStringOrSearchFilter; - } - else if (viewQueryStringOrSearchFilter instanceof SearchFilter) { - searchFilter = viewQueryStringOrSearchFilter; - } - else if (viewQueryStringOrSearchFilter instanceof ViewBase) { - view = viewQueryStringOrSearchFilter; - } - else { - throw new Error("ExchangeService.ts - FindItems - incorrect uses of parameters at 2nd position, must be string, ViewBase or SearchFilter"); - } + if (argsLength == 2) + if (typeof viewQueryStringOrSearchFilter === 'string') { + queryString = viewQueryStringOrSearchFilter; + } + else if (viewQueryStringOrSearchFilter instanceof SearchFilter) { + searchFilter = viewQueryStringOrSearchFilter; + } + else if (viewQueryStringOrSearchFilter instanceof ViewBase) { + view = viewQueryStringOrSearchFilter; + } + else if (viewQueryStringOrSearchFilter) { //error if not null + throw new Error("ExchangeService.ts - FindItems - incorrect uses of parameters at 2nd position, must be string, ViewBase or SearchFilter"); + } var groupResultBy: Grouping = null; var returnHighlightTerms: boolean = false; var isGroupped: boolean = false; // to resturn GroupedFindItemsResults - + //position 3 - groupByViewRHTOrQueryString if (argsLength >= 3) { if (groupByViewRHTOrQueryString instanceof Grouping) { @@ -982,11 +969,11 @@ export class ExchangeService extends ExchangeServiceBase { returnHighlightTerms = groupByViewRHTOrQueryString; EwsUtilities.ValidateMethodVersion(this, ExchangeVersion.Exchange2013, "FindItems"); } - else { + else if (groupByViewRHTOrQueryString) {//error if not null throw new Error("ExchangeService.ts - FindItems with " + argsLength + " parameters - incorrect uses of parameter at 3rd position, must be string, boolean, ViewBase or Grouping"); } } - + //position 4 - groupByOrView if (argsLength >= 4) { if (groupByOrView instanceof Grouping) { @@ -999,14 +986,14 @@ export class ExchangeService extends ExchangeServiceBase { else if (groupByOrView instanceof ViewBase) { view = groupByOrView; } - else { + else if (groupByOrView) {//error if not null throw new Error("ExchangeService.ts - FindItems with " + argsLength + " parameters - incorrect uses of parameter at 4th position, must be ViewBase or Grouping"); } } - + //position 5 - groupBy if (argsLength >= 5) { - if (!(groupByOrView instanceof ViewBase)) { + if (groupByOrView && !(groupByOrView instanceof ViewBase)) {//error if not null throw new Error("ExchangeService.ts - FindItems with " + argsLength + " parameters - incorrect uses of parameter at 4th position, it must be ViewBase when using Grouping at 5th place"); } groupResultBy = groupBy; @@ -1348,10 +1335,10 @@ export class ExchangeService extends ExchangeServiceBase { suppressReadReceipts); } /* #endregion Item operations 47*/ - - + + /* #region Attachment operations */ - + /** * @internal Creates attachments. * @@ -1381,7 +1368,7 @@ export class ExchangeService extends ExchangeServiceBase { return request.Execute(); } - + /** * @internal Gets an attachment. * @@ -1457,10 +1444,10 @@ export class ExchangeService extends ExchangeServiceBase { } return request.Execute(); } - + /* #endregion Attachment operations */ - - + + /* #region AD related operations */ /** @@ -1597,12 +1584,12 @@ export class ExchangeService extends ExchangeServiceBase { if (argsLength < 1 && argsLength > 5) { throw new Error("ExchangeService.ts - ResolveName - invalid number of arguments, check documentation and try again."); } - + //position 1 - nameToResolve - no change, same for all overload - + var searchScope: ResolveNameSearchLocation = null; var parentFolderIds: FolderId[] = null; - + //position 2 - parentFolderIdsOrSearchScope if (argsLength >= 2) { if (typeof parentFolderIdsOrSearchScope === 'number') { @@ -1618,7 +1605,7 @@ export class ExchangeService extends ExchangeServiceBase { } var returnContactDetails: boolean = false; - + //position 3 - searchScopeOrReturnContactDetails if (argsLength >= 3) { if (typeof searchScopeOrReturnContactDetails === 'boolean') { @@ -1637,7 +1624,7 @@ export class ExchangeService extends ExchangeServiceBase { throw new Error("ExchangeService.ts - ResolveName with " + argsLength + " parameters - incorrect uses of parameter at 3rd position, must be boolean, or ResolveNameSearchLocation"); } } - + //position 4 - returnContactDetailsOrContactDataPropertySet if (argsLength >= 4) { if (returnContactDetailsOrContactDataPropertySet instanceof PropertySet) { @@ -1656,7 +1643,7 @@ export class ExchangeService extends ExchangeServiceBase { throw new Error("ExchangeService.ts - ResolveName with " + argsLength + " parameters - incorrect uses of parameter at 4th position, must be PropertySet or boolean"); } } - + //position 5 - contactDataPropertySet if (argsLength >= 5) { if (typeof returnContactDetailsOrContactDataPropertySet !== 'boolean') { @@ -1676,12 +1663,12 @@ export class ExchangeService extends ExchangeServiceBase { return response.__thisIndexer(0).Resolutions; }); } - + /* #endregion AD related operations */ - - + + /* #region Notification operations */ - + // BeginGetEvents(callback: Function /*System.AsyncCallback*/, state: any, subscriptionId: string, watermark: string): Function /*System.IAsyncResult*/ { throw new Error("ExchangeService.ts - BeginGetEvents : Not implemented."); } // BeginSubscribeToPullNotifications(callback: Function /*System.AsyncCallback*/, state: any, folderIds: any[] /*System.Collections.Generic.IEnumerable*/, timeout: number, watermark: string, eventTypes: any): Function /*System.IAsyncResult*/ { throw new Error("ExchangeService.ts - BeginSubscribeToPullNotifications : Not implemented."); } // BeginSubscribeToPullNotificationsOnAllFolders(callback: Function /*System.AsyncCallback*/, state: any, timeout: number, watermark: string, eventTypes: any): Function /*System.IAsyncResult*/ { throw new Error("ExchangeService.ts - BeginSubscribeToPullNotificationsOnAllFolders : Not implemented."); } @@ -1715,17 +1702,17 @@ export class ExchangeService extends ExchangeServiceBase { //UnpinTeamMailbox(emailAddress: EmailAddress): any { throw new Error("ExchangeService.ts - UnpinTeamMailbox : Not implemented."); } //Unsubscribe(subscriptionId: string): any { throw new Error("ExchangeService.ts - Unsubscribe : Not implemented."); } /* #endregion Notification operations */ - - + + /* #region Synchronization operations */ - + // BeginSyncFolderItems(callback: Function /*System.AsyncCallback*/, state: any, syncFolderId: FolderId, propertySet: PropertySet, ignoredItemIds: any[] /*System.Collections.Generic.IEnumerable*/, maxChangesReturned: number, syncScope: SyncFolderItemsScope, syncState: string): Function /*System.IAsyncResult*/ { throw new Error("ExchangeService.ts - BeginSyncFolderItems : Not implemented."); } // BeginSyncFolderItems(callback: Function /*System.AsyncCallback*/, state: any, syncFolderId: FolderId, propertySet: PropertySet, ignoredItemIds: any[] /*System.Collections.Generic.IEnumerable*/, maxChangesReturned: number, numberOfDays: number, syncScope: SyncFolderItemsScope, syncState: string): Function /*System.IAsyncResult*/ { throw new Error("ExchangeService.ts - BeginSyncFolderItems : Not implemented."); } //BuildSyncFolderItemsRequest(syncFolderId: FolderId, propertySet: PropertySet, ignoredItemIds: any[] /*System.Collections.Generic.IEnumerable*/, maxChangesReturned: number, syncScope: SyncFolderItemsScope, syncState: string): SyncFolderItemsRequest { throw new Error("ExchangeService.ts - BuildSyncFolderItemsRequest : Not implemented."); } //EndSyncFolderItems(asyncResult: Function /*System.IAsyncResult*/): ChangeCollection { throw new Error("ExchangeService.ts - EndSyncFolderItems : Not implemented."); } //SyncFolderItems(syncFolderId: FolderId, propertySet: PropertySet, ignoredItemIds: any[] /*System.Collections.Generic.IEnumerable*/, maxChangesReturned: number, syncScope: SyncFolderItemsScope, syncState: string): ChangeCollection { throw new Error("ExchangeService.ts - SyncFolderItems : Not implemented."); } //SyncFolderItems(syncFolderId: FolderId, propertySet: PropertySet, ignoredItemIds: any[] /*System.Collections.Generic.IEnumerable*/, maxChangesReturned: number, numberOfDays: number, syncScope: SyncFolderItemsScope, syncState: string): ChangeCollection { throw new Error("ExchangeService.ts - SyncFolderItems : Not implemented."); } - + // BeginSyncFolderHierarchy(callback: Function /*System.AsyncCallback*/, state: any, propertySet: PropertySet, syncState: string): Function /*System.IAsyncResult*/ { throw new Error("ExchangeService.ts - BeginSyncFolderHierarchy : Not implemented."); } // //BeginSyncFolderHierarchy(callback: Function /*System.AsyncCallback*/, state: any, syncFolderId: FolderId, propertySet: PropertySet, syncState: string): Function /*System.IAsyncResult*/ { throw new Error("ExchangeService.ts - BeginSyncFolderHierarchy : Not implemented."); } //BuildSyncFolderHierarchyRequest(syncFolderId: FolderId, propertySet: PropertySet, syncState: string): SyncFolderHierarchyRequest { throw new Error("ExchangeService.ts - BuildSyncFolderHierarchyRequest : Not implemented."); } @@ -1733,10 +1720,10 @@ export class ExchangeService extends ExchangeServiceBase { ////SyncFolderHierarchy(syncFolderId: FolderId, propertySet: PropertySet, syncState: string): ChangeCollection { throw new Error("ExchangeService.ts - SyncFolderHierarchy : Not implemented."); } //SyncFolderHierarchy(propertySet: PropertySet, syncState: string): ChangeCollection { throw new Error("ExchangeService.ts - SyncFolderHierarchy : Not implemented."); } /* #endregion Synchronization operations */ - - + + /* #region Availability operations */ - + //GetRoomLists(): EmailAddressCollection { throw new Error("ExchangeService.ts - GetRoomLists : Not implemented."); } //GetRooms(emailAddress: EmailAddress): System.Collections.ObjectModel.Collection { throw new Error("ExchangeService.ts - GetRooms : Not implemented."); } /** @@ -1777,11 +1764,11 @@ export class ExchangeService extends ExchangeServiceBase { //GetUserOofSettings(smtpAddress: string): OofSettings { throw new Error("ExchangeService.ts - GetUserOofSettings : Not implemented."); } //SetUserOofSettings(smtpAddress: string, oofSettings: OofSettings): any { throw new Error("ExchangeService.ts - SetUserOofSettings : Not implemented."); } /* #endregion Availability operations */ - - + + /* #region Conversation */ - - + + // ApplyConversationAction(actionType: ConversationActionType, conversationIds: any[] /*System.Collections.Generic.IEnumerable*/, processRightAway: boolean, categories: StringList, enableAlwaysDelete: boolean, destinationFolderId: FolderId, errorHandlingMode: ServiceErrorHandling): ServiceResponseCollection { throw new Error("ExchangeService.ts - ApplyConversationAction : Not implemented."); } // ApplyConversationOneTimeAction(actionType: ConversationActionType, idTimePairs: any[] /*System.Collections.Generic.IEnumerable*/, contextFolderId: FolderId, destinationFolderId: FolderId, deleteType: DeleteMode, isRead: boolean, retentionPolicyType: RetentionType, retentionPolicyTagId: any /*System.Guid*/, flag: Flag, suppressReadReceipts: boolean, errorHandlingMode: ServiceErrorHandling): ServiceResponseCollection { throw new Error("ExchangeService.ts - ApplyConversationOneTimeAction : Not implemented."); } //DisableAlwaysCategorizeItemsInConversations(conversationId: any[] /*System.Collections.Generic.IEnumerable*/, processSynchronously: boolean): ServiceResponseCollection { throw new Error("ExchangeService.ts - DisableAlwaysCategorizeItemsInConversations : Not implemented."); } @@ -1798,7 +1785,7 @@ export class ExchangeService extends ExchangeServiceBase { ////GetConversationItems(conversationId: ConversationId, propertySet: PropertySet, syncState: string, foldersToIgnore: any[] /*System.Collections.Generic.IEnumerable*/, sortOrder: ConversationSortOrder): ConversationResponse { throw new Error("ExchangeService.ts - GetConversationItems : Not implemented."); } ////GetConversationItems(conversations: any[] /*System.Collections.Generic.IEnumerable*/, propertySet: PropertySet, foldersToIgnore: any[] /*System.Collections.Generic.IEnumerable*/, sortOrder: ConversationSortOrder, mailboxScope: MailboxSearchLocation): ServiceResponseCollection { throw new Error("ExchangeService.ts - GetConversationItems : Not implemented."); } //InternalGetConversationItems(conversations: any[] /*System.Collections.Generic.IEnumerable*/, propertySet: PropertySet, foldersToIgnore: any[] /*System.Collections.Generic.IEnumerable*/, sortOrder: ConversationSortOrder, mailboxScope: MailboxSearchLocation, maxItemsToReturn: number, errorHandling: ServiceErrorHandling): ServiceResponseCollection { throw new Error("ExchangeService.ts - InternalGetConversationItems : Not implemented."); } - + //CopyItemsInConversations(idLastSyncTimePairs: any[] /*System.Collections.Generic.IEnumerable*/, contextFolderId: FolderId, destinationFolderId: FolderId): ServiceResponseCollection { throw new Error("ExchangeService.ts - CopyItemsInConversations : Not implemented."); } //DeleteItemsInConversations(idLastSyncTimePairs: any[] /*System.Collections.Generic.IEnumerable*/, contextFolderId: FolderId, deleteMode: DeleteMode): ServiceResponseCollection { throw new Error("ExchangeService.ts - DeleteItemsInConversations : Not implemented."); } //MoveItemsInConversations(idLastSyncTimePairs: any[] /*System.Collections.Generic.IEnumerable*/, contextFolderId: FolderId, destinationFolderId: FolderId): ServiceResponseCollection { throw new Error("ExchangeService.ts - MoveItemsInConversations : Not implemented."); } @@ -1807,18 +1794,18 @@ export class ExchangeService extends ExchangeServiceBase { ////SetReadStateForItemsInConversations(idLastSyncTimePairs: any[] /*System.Collections.Generic.IEnumerable*/, contextFolderId: FolderId, isRead: boolean): ServiceResponseCollection { throw new Error("ExchangeService.ts - SetReadStateForItemsInConversations : Not implemented."); } //SetRetentionPolicyForItemsInConversations(idLastSyncTimePairs: any[] /*System.Collections.Generic.IEnumerable*/, contextFolderId: FolderId, retentionPolicyType: RetentionType, retentionPolicyTagId: any /*System.Guid*/): ServiceResponseCollection { throw new Error("ExchangeService.ts - SetRetentionPolicyForItemsInConversations : Not implemented."); } /* #end region Conversation */ - - + + /** #region Id conversion operations */ - + //ConvertId(id: AlternateIdBase, destinationFormat: IdFormat): AlternateIdBase { throw new Error("ExchangeService.ts - ConvertId : Not implemented."); } //ConvertIds(ids: any[] /*System.Collections.Generic.IEnumerable*/, destinationFormat: IdFormat): ServiceResponseCollection { throw new Error("ExchangeService.ts - ConvertIds : Not implemented."); } //InternalConvertIds(ids: any[] /*System.Collections.Generic.IEnumerable*/, destinationFormat: IdFormat, errorHandling: ServiceErrorHandling): ServiceResponseCollection { throw new Error("ExchangeService.ts - InternalConvertIds : Not implemented."); } /* #endregion Id conversion operations */ - - + + /* #region Delegate management operations */ - + // AddDelegates(mailbox: Mailbox, meetingRequestsDeliveryScope: MeetingRequestsDeliveryScope, delegateUsers: any[] /*System.Collections.Generic.IEnumerable*/): DelegateUserResponse[]/*System.Collections.ObjectModel.Collection*/ { throw new Error("ExchangeService.ts - AddDelegates : Not implemented."); } // //AddDelegates(mailbox: Mailbox, meetingRequestsDeliveryScope: MeetingRequestsDeliveryScope, delegateUsers: any): System.Collections.ObjectModel.Collection { throw new Error("ExchangeService.ts - AddDelegates : Not implemented."); } //GetDelegates(mailbox: Mailbox, includePermissions: boolean, userIds: any[] /*System.Collections.Generic.IEnumerable*/): DelegateInformation { throw new Error("ExchangeService.ts - GetDelegates : Not implemented."); } @@ -1828,29 +1815,29 @@ export class ExchangeService extends ExchangeServiceBase { //UpdateDelegates(mailbox: Mailbox, meetingRequestsDeliveryScope: MeetingRequestsDeliveryScope, delegateUsers: any): System.Collections.ObjectModel.Collection { throw new Error("ExchangeService.ts - UpdateDelegates : Not implemented."); } ////UpdateDelegates(mailbox: Mailbox, meetingRequestsDeliveryScope: MeetingRequestsDeliveryScope, delegateUsers: any[] /*System.Collections.Generic.IEnumerable*/): System.Collections.ObjectModel.Collection { throw new Error("ExchangeService.ts - UpdateDelegates : Not implemented."); } /* #endregion Delegate management operations */ - - + + /* #region UserConfiguration operations */ - + //CreateUserConfiguration(userConfiguration: UserConfiguration): any { throw new Error("ExchangeService.ts - CreateUserConfiguration : Not implemented."); } //DeleteUserConfiguration(name: string, parentFolderId: FolderId): any { throw new Error("ExchangeService.ts - DeleteUserConfiguration : Not implemented."); } //GetUserConfiguration(name: string, parentFolderId: FolderId, properties: UserConfigurationProperties): UserConfiguration { throw new Error("ExchangeService.ts - GetUserConfiguration : Not implemented."); } //LoadPropertiesForUserConfiguration(userConfiguration: UserConfiguration, properties: UserConfigurationProperties): any { throw new Error("ExchangeService.ts - LoadPropertiesForUserConfiguration : Not implemented."); } //UpdateUserConfiguration(userConfiguration: UserConfiguration): any { throw new Error("ExchangeService.ts - UpdateUserConfiguration : Not implemented."); } /* #endregion UserConfiguration operations */ - - + + /* #region InboxRule operations */ - + //GetInboxRules(): RuleCollection { throw new Error("ExchangeService.ts - GetInboxRules : Not implemented."); } ////GetInboxRules(mailboxSmtpAddress: string): RuleCollection { throw new Error("ExchangeService.ts - GetInboxRules : Not implemented."); } //UpdateInboxRules(operations: System.Collections.Generic.IEnumerable, removeOutlookRuleBlob: boolean, mailboxSmtpAddress: string): any { throw new Error("ExchangeService.ts - UpdateInboxRules : Not implemented."); } ////UpdateInboxRules(operations: System.Collections.Generic.IEnumerable, removeOutlookRuleBlob: boolean): any { throw new Error("ExchangeService.ts - UpdateInboxRules : Not implemented."); } /* #endregion InboxRule operations */ - - + + /* #region eDiscovery/Compliance operations */ - + // BeginGetNonIndexableItemDetails(callback: Function /*System.AsyncCallback*/, state: any, parameters: GetNonIndexableItemDetailsParameters): Function /*System.IAsyncResult*/ { throw new Error("ExchangeService.ts - BeginGetNonIndexableItemDetails : Not implemented."); } // BeginGetNonIndexableItemStatistics(callback: Function /*System.AsyncCallback*/, state: any, parameters: GetNonIndexableItemStatisticsParameters): Function /*System.IAsyncResult*/ { throw new Error("ExchangeService.ts - BeginGetNonIndexableItemStatistics : Not implemented."); } // BeginSearchMailboxes(callback: Function /*System.AsyncCallback*/, state: any, searchParameters: SearchMailboxesParameters): Function /*System.IAsyncResult*/ { throw new Error("ExchangeService.ts - BeginSearchMailboxes : Not implemented."); } @@ -1876,16 +1863,16 @@ export class ExchangeService extends ExchangeServiceBase { //GetNonIndexableItemStatistics(parameters: GetNonIndexableItemStatisticsParameters): GetNonIndexableItemStatisticsResponse { throw new Error("ExchangeService.ts - GetNonIndexableItemStatistics : Not implemented."); } ////GetNonIndexableItemStatistics(mailboxes: System.String[]): GetNonIndexableItemStatisticsResponse { throw new Error("ExchangeService.ts - GetNonIndexableItemStatistics : Not implemented."); } /* #endregion eDiscovery/Compliance operations */ - - + + /* #region MRM operations */ - + //GetUserRetentionPolicyTags(): GetUserRetentionPolicyTagsResponse { throw new Error("ExchangeService.ts - GetUserRetentionPolicyTags : Not implemented."); } /* #endregion MRM operations */ - - + + /* #region Autodiscover */ - + /** * Adjusts the service URI based on the current type of credentials. * @@ -2043,15 +2030,15 @@ export class ExchangeService extends ExchangeServiceBase { throw new AutodiscoverLocalException(Strings.AutodiscoverDidNotReturnEwsUrl); } /* #endregion Autodiscover */ - - + + /* #region ClientAccessTokens */ - + //GetClientAccessToken(tokenRequests: ClientAccessTokenRequest[]): ServiceResponseCollection { throw new Error("ExchangeService.ts - GetClientAccessToken : Not implemented."); } ////GetClientAccessToken(idAndTypes: any[] /*System.Collections.Generic.IEnumerable*/): ServiceResponseCollection { throw new Error("ExchangeService.ts - GetClientAccessToken : Not implemented."); } /* #end region ClientAccessTokens */ - - + + /* #region Client Extensibility */ //GetAppManifests(apiVersionSupported: string, schemaVersionSupported: string): System.Collections.ObjectModel.Collection { throw new Error("ExchangeService.ts - GetAppManifests : Not implemented."); } ////GetAppManifests(): System.Collections.ObjectModel.Collection { throw new Error("ExchangeService.ts - GetAppManifests : Not implemented."); } @@ -2065,14 +2052,14 @@ export class ExchangeService extends ExchangeServiceBase { //GetEncryptionConfiguration(): GetEncryptionConfigurationResponse { throw new Error("ExchangeService.ts - GetEncryptionConfiguration : Not implemented."); } //SetEncryptionConfiguration(imageBase64: string, emailText: string, portalText: string, disclaimerText: string): any { throw new Error("ExchangeService.ts - SetEncryptionConfiguration : Not implemented."); } /* #endregion Client Extensibility */ - - + + /* #region Diagnostic Method -- Only used by test */ - + //ExecuteDiagnosticMethod(verb: string, parameter: System.Xml.XmlNode): System.Xml.XmlDocument { throw new Error("ExchangeService.ts - ExecuteDiagnosticMethod : Not implemented."); } /* #endregion Diagnostic Method -- Only used by test */ - - + + /* #region Validation */ static IsMajorMinor(versionPart: string): boolean { @@ -2161,10 +2148,10 @@ export class ExchangeService extends ExchangeServiceBase { } } /* #endregion Validation */ - - + + /* #region Utilities */ - + /** * @internal Creates an IXHROptions instance and initializes it with the appropriate parameters, based on the configuration of this service object. * @@ -2195,9 +2182,9 @@ export class ExchangeService extends ExchangeServiceBase { return request; } - + ProcessHttpErrorResponse(httpWebResponse: XMLHttpRequest /*IEwsHttpWebResponse*/, webException: any): void { } - + /** * Sets the type of the content. * @@ -2215,7 +2202,7 @@ export class ExchangeService extends ExchangeServiceBase { else { super.SetContentType(request); } - } + } /* #endregion Utilities */ diff --git a/src/js/Core/Requests/FindItemRequest.ts b/src/js/Core/Requests/FindItemRequest.ts index e7bda21a..f65b27e0 100644 --- a/src/js/Core/Requests/FindItemRequest.ts +++ b/src/js/Core/Requests/FindItemRequest.ts @@ -1,17 +1,84 @@ -import {XmlElementNames} from "../XmlElementNames"; +import {ExchangeService} from "../ExchangeService"; +import {ExchangeVersion} from "../../Enumerations/ExchangeVersion"; +import {FindItemResponse} from "../Responses/FindItemResponse"; +import {Grouping} from "../../Search/Grouping"; import {Item} from "../ServiceObjects/Items/Item"; +import {ServiceErrorHandling} from "../../Enumerations/ServiceErrorHandling"; +import {XmlElementNames} from "../XmlElementNames"; + import {FindRequest} from "./FindRequest"; -import {Grouping} from "../../Search/Grouping"; -import {ExchangeService} from "../ExchangeService"; -import {FindItemResponse} from "../Responses/FindItemResponse"; -import {ExchangeVersion} from "../../Enumerations/ExchangeVersion"; +/** + * @internal Represents a **FindItem** request. + * + * @type Item type. + */ export class FindItemRequest extends FindRequest> { - GroupBy: Grouping; - //private groupBy: Grouping; - auto property is ok - CreateServiceResponse(service: ExchangeService, responseIndex: number): FindItemResponse { return new FindItemResponse(this.GroupBy != null, this.View.GetPropertySetOrDefault());} + + private groupBy: Grouping = null; + + /** + * Gets or sets the group by. + * + * @value The group by. + */ + get GroupBy(): Grouping { + return this.groupBy; + } + set GroupBy(value: Grouping) { + this.groupBy = value; + } + + /** + * @internal Initializes a new instance of the **FindItemRequest** class. + * + * @param {ExchangeService} service The service. + * @param {ServiceErrorHandling} errorHandlingMode Indicates how errors should be handled. + */ + constructor(service: ExchangeService, errorHandlingMode: ServiceErrorHandling) { + super(service, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param {ExchangeService} service The service. + * @param {number} responseIndex Index of the response. + * @return {FindItemResponse} Service response. + */ + CreateServiceResponse(service: ExchangeService, responseIndex: number): FindItemResponse { return new FindItemResponse(this.GroupBy != null, this.View.GetPropertySetOrDefault()); } + + /** + * @internal Gets the group by clause. + * + * @return {Grouping} The group by clause, null if the request does not have or support grouping. + */ GetGroupBy(): Grouping { return this.GroupBy; } + + /** + * @internal Gets the request version. + * + * @return {ExchangeVersion} Earliest Exchange version in which this request is supported. + */ GetMinimumRequiredServerVersion(): ExchangeVersion { return ExchangeVersion.Exchange2007_SP1; } + + /** + * @internal Gets the name of the response message XML element. + * + * @return {string} XML element name. + */ GetResponseMessageXmlElementName(): string { return XmlElementNames.FindItemResponseMessage; } + + /** + * @internal Gets the name of the response XML element. + * + * @return {string} XML element name. + */ GetResponseXmlElementName(): string { return XmlElementNames.FindItemResponse; } + + /** + * @internal Gets the name of the XML element. + * + * @return {string} XML element name. + */ GetXmlElementName(): string { return XmlElementNames.FindItem; } } \ No newline at end of file diff --git a/src/js/Core/ServiceObjects/Folders/CalendarFolder.ts b/src/js/Core/ServiceObjects/Folders/CalendarFolder.ts index 0491b949..0e88e29b 100644 --- a/src/js/Core/ServiceObjects/Folders/CalendarFolder.ts +++ b/src/js/Core/ServiceObjects/Folders/CalendarFolder.ts @@ -1,25 +1,112 @@ -import {WellKnownFolderName} from "../../../Enumerations/WellKnownFolderName"; +import {Appointment} from "../Items/Appointment"; +import {CalendarView} from "../../../Search/CalendarView"; +import {EwsLogging} from "../../EwsLogging"; +import {EwsUtilities} from "../../EwsUtilities"; +import {ExchangeService} from "../../ExchangeService"; import {ExchangeVersion} from "../../../Enumerations/ExchangeVersion"; +import {FindItemResponse} from "../../Responses/FindItemResponse"; +import {FindItemsResults} from "../../../Search/FindItemsResults"; +import {FolderId} from "../../../ComplexProperties/FolderId"; +import {IPromise} from "../../../Interfaces"; +import {Item} from "../Items/Item"; +import {PropertySet} from "../../PropertySet"; +import {SearchFilter} from "../../../Search/Filters/SearchFilter"; +import {ServiceResponseCollection} from "../../Responses/ServiceResponseCollection"; +import {TypeContainer} from "../../../TypeContainer"; +import {WellKnownFolderName} from "../../../Enumerations/WellKnownFolderName"; import {XmlElementNames} from "../../XmlElementNames"; - -import {ExchangeService} from "../../ExchangeService"; import {Folder} from "./Folder"; /** - * ## *Not Implemented* + * Represents a folder containing appointments. */ export class CalendarFolder extends Folder { + /** - * _FolderTYpe -> type of folder, use to avoid folder type detection using instanceof. some cases it has circular loop in nodejs/requirejs + * Initializes an unsaved local instance of **CalendarFolder**. To bind to an existing calendar folder, use CalendarFolder.Bind() instead. + * + * @param {ExchangeService} service The ExchangeService object to which the calendar folder will be bound. */ - get _FolderType(): string { return XmlElementNames.CalendarFolder; } constructor(service: ExchangeService) { super(service); } - ////////Bind(service: ExchangeService, id: FolderId, propertySet: PropertySet): CalendarFolder { throw new Error("CalendarFolder.ts - Bind : Not implemented."); } - ////////Bind(service: ExchangeService, id: FolderId): CalendarFolder { throw new Error("CalendarFolder.ts - Bind : Not implemented."); } - ////////Bind(service: ExchangeService, name: WellKnownFolderName, propertySet: PropertySet): CalendarFolder { throw new Error("CalendarFolder.ts - Bind : Not implemented."); } - //////Bind(service: ExchangeService, name: WellKnownFolderName): CalendarFolder { throw new Error("CalendarFolder.ts - Bind : Not implemented."); } - //////FindAppointments(view: CalendarView): FindItemsResults { throw new Error("CalendarFolder.ts - FindAppointments : Not implemented."); } - //////GetMinimumRequiredServerVersion(): ExchangeVersion { throw new Error("CalendarFolder.ts - GetMinimumRequiredServerVersion : Not implemented."); } + + /** + * Binds to an existing folder, whatever its actual type is, and loads the specified set of properties. + * Calling this method results in a call to EWS. + * + * @param {ExchangeService} service The service to use to bind to the calendar folder. + * @param {FolderId} id The Id of the calendar folder to bind to. + * @return {IPromise} A CalendarFolder instance representing the folder corresponding to the specified Id :Promise. + */ + static Bind(service: ExchangeService, id: FolderId): IPromise; + /** + * Binds to an existing folder, whatever its actual type is, and loads the specified set of properties. + * Calling this method results in a call to EWS. + * + * @param {ExchangeService} service The service to use to bind to the calendar folder. + * @param {WellKnownFolderName} name The name of the calendar folder to bind to. + * @return {IPromise} A CalendarFolder instance representing the folder corresponding to the specified name :Promise. + */ + static Bind(service: ExchangeService, name: WellKnownFolderName): IPromise; + /** + * Binds to an existing folder, whatever its actual type is, and loads the specified set of properties. + * Calling this method results in a call to EWS. + * + * @param {ExchangeService} service The service to use to bind to the calendar folder. + * @param {FolderId} id The Id of the calendar folder to bind to. + * @param {PropertySet} propertySet The set of properties to load. + * @return {IPromise} A CalendarFolder instance representing the folder corresponding to the specified Id :Promise. + */ + static Bind(service: ExchangeService, id: FolderId, propertySet: PropertySet): IPromise; + /** + * Binds to an existing folder, whatever its actual type is, and loads the specified set of properties. + * Calling this method results in a call to EWS. + * + * @param {ExchangeService} service The service to use to bind to the folder. + * @param {WellKnownFolderName} name The name of the folder to bind to. + * @param {PropertySet} propertySet The set of properties to load. + * @return {IPromise} A CalendarFolder instance representing the folder corresponding to the specified name :Promise. + */ + static Bind(service: ExchangeService, name: WellKnownFolderName, propertySet: PropertySet): IPromise; + static Bind(service: ExchangeService, idOrName: FolderId | WellKnownFolderName, propertySet: PropertySet = PropertySet.FirstClassProperties): IPromise { + if (idOrName instanceof FolderId) { + return service.BindToFolder(idOrName, propertySet, TypeContainer.CalendarFolder); + } + else if (typeof idOrName === 'number') { + return service.BindToFolder(new FolderId(idOrName), propertySet, TypeContainer.CalendarFolder); + } + EwsLogging.Assert(false, "CalendarFolder.Bind", "unknown paramete type"); + throw new Error("unknow parameter type. this should not be reached"); + } + + /** + * Obtains a list of appointments by searching the contents of this folder and performing recurrence expansion for recurring appointments. Calling this method results in a call to EWS. + * + * @param {CalendarView} view The view controlling the range of appointments returned. + * @return {FindItemsResults} An object representing the results of the search operation. + */ + FindAppointments(view: CalendarView): IPromise> { + EwsUtilities.ValidateParam(view, "view"); + return this.InternalFindItems( + null, + view, + null /* groupBy */ + ).then((responses) => { + return responses.__thisIndexer(0).Results + }); + } + + /** + * @internal Gets the minimum required server version. + * + * @return {ExchangeVersion} Earliest Exchange version in which this service object type is supported. + */ + GetMinimumRequiredServerVersion(): ExchangeVersion { return ExchangeVersion.Exchange2007_SP1; } + + /** + * @internal Gets the element name of item in XML + * + * @return {string} name of elelment + */ GetXmlElementName(): string { return XmlElementNames.CalendarFolder; } } \ No newline at end of file diff --git a/src/js/Core/ServiceObjects/Folders/ContactsFolder.ts b/src/js/Core/ServiceObjects/Folders/ContactsFolder.ts index a731efe7..27979bd3 100644 --- a/src/js/Core/ServiceObjects/Folders/ContactsFolder.ts +++ b/src/js/Core/ServiceObjects/Folders/ContactsFolder.ts @@ -7,7 +7,7 @@ export class ContactsFolder extends Folder { /** * _FolderTYpe -> type of folder, use to avoid folder type detection using instanceof. some cases it has circular loop in nodejs/requirejs */ - get _FolderType(): string { return XmlElementNames.ContactsFolder; } + //get _FolderType(): string { return XmlElementNames.ContactsFolder; } ////////Bind(service: ExchangeService, id: FolderId, propertySet: PropertySet): ContactsFolder { throw new Error("ContactsFolder.ts - Bind : Not implemented."); } ////////Bind(service: ExchangeService, id: FolderId): ContactsFolder { throw new Error("ContactsFolder.ts - Bind : Not implemented."); } diff --git a/src/js/Core/ServiceObjects/Folders/Folder.ts b/src/js/Core/ServiceObjects/Folders/Folder.ts index 6beb485f..b1f42bd4 100644 --- a/src/js/Core/ServiceObjects/Folders/Folder.ts +++ b/src/js/Core/ServiceObjects/Folders/Folder.ts @@ -1,36 +1,36 @@ -import {ServiceErrorHandling} from "../../../Enumerations/ServiceErrorHandling"; -import {FindItemsResults} from "../../../Search/FindItemsResults"; -import {PolicyTag} from "../../../ComplexProperties/PolicyTag"; +import {AffectedTaskOccurrence} from "../../../Enumerations/AffectedTaskOccurrence"; import {ArchiveTag} from "../../../ComplexProperties/ArchiveTag"; -import {ManagedFolderInformation} from "../../../ComplexProperties/ManagedFolderInformation"; +import {DeleteMode} from "../../../Enumerations/DeleteMode"; +import {EffectiveRights} from "../../../Enumerations/EffectiveRights"; +import {EwsLogging} from "../../EwsLogging"; +import {ExchangeService} from "../../ExchangeService"; +import {ExchangeVersion} from "../../../Enumerations/ExchangeVersion"; +import {ExtendedPropertyCollection} from "../../../ComplexProperties/ExtendedPropertyCollection"; +import {ExtendedPropertyDefinition} from "../../../PropertyDefinitions/ExtendedPropertyDefinition"; +import {FindFoldersResults} from "../../../Search/FindFoldersResults"; +import {FindItemResponse} from "../../Responses/FindItemResponse"; +import {FindItemsResults} from "../../../Search/FindItemsResults"; +import {FolderId} from "../../../ComplexProperties/FolderId"; import {FolderPermissionCollection} from "../../../ComplexProperties/FolderPermissionCollection"; -import {SearchFilter} from "../../../Search/Filters/SearchFilter"; +import {FolderView} from "../../../Search/FolderView"; import {GroupedFindItemsResults} from "../../../Search/GroupedFindItemsResults"; +import {Grouping} from "../../../Search/Grouping"; +import {IPromise} from "../../../Interfaces"; import {ItemView} from "../../../Search/ItemView"; import {Item} from "../Items/Item"; -import {ServiceResponseCollection} from "../../Responses/ServiceResponseCollection"; -import {FindItemResponse} from "../../Responses/FindItemResponse"; -import {Grouping} from "../../../Search/Grouping"; -import {AffectedTaskOccurrence} from "../../../Enumerations/AffectedTaskOccurrence"; -import {ViewBase} from "../../../Search/ViewBase"; -import {ExtendedPropertyDefinition} from "../../../PropertyDefinitions/ExtendedPropertyDefinition"; +import {ManagedFolderInformation} from "../../../ComplexProperties/ManagedFolderInformation"; +import {PolicyTag} from "../../../ComplexProperties/PolicyTag"; import {PropertyDefinition} from "../../../PropertyDefinitions/PropertyDefinition"; +import {PropertySet} from "../../PropertySet"; +import {Schemas} from "../Schemas/Schemas"; +import {SearchFilter} from "../../../Search/Filters/SearchFilter"; +import {SendCancellationsMode} from "../../../Enumerations/SendCancellationsMode"; +import {ServiceErrorHandling} from "../../../Enumerations/ServiceErrorHandling"; import {ServiceObjectSchema} from "../Schemas/ServiceObjectSchema"; +import {ServiceResponseCollection} from "../../Responses/ServiceResponseCollection"; import {ServiceResponse} from "../../Responses/ServiceResponse"; -import {SendCancellationsMode} from "../../../Enumerations/SendCancellationsMode"; -import {ExchangeVersion} from "../../../Enumerations/ExchangeVersion"; -import {PropertySet} from "../../PropertySet"; -import {FindFoldersResults} from "../../../Search/FindFoldersResults"; -import {FolderView} from "../../../Search/FolderView"; -import {DeleteMode} from "../../../Enumerations/DeleteMode"; -import {ExchangeService} from "../../ExchangeService"; +import {ViewBase} from "../../../Search/ViewBase"; import {WellKnownFolderName} from "../../../Enumerations/WellKnownFolderName"; -import {EffectiveRights} from "../../../Enumerations/EffectiveRights"; -import {ExtendedPropertyCollection} from "../../../ComplexProperties/ExtendedPropertyCollection"; -import {FolderId} from "../../../ComplexProperties/FolderId"; -import {Schemas} from "../Schemas/Schemas"; -import {EwsLogging} from "../../EwsLogging"; -import {IPromise} from "../../../Interfaces"; import {XmlElementNames} from "../../XmlElementNames"; import {ServiceObject} from "../ServiceObject"; @@ -135,11 +135,11 @@ export class Folder extends ServiceObject { /** * _FolderTYpe -> type of folder, use to avoid folder type detection using instanceof. some cases it has circular loop in nodejs/requirejs */ - get _FolderType(): string { return XmlElementNames.Folder; } + //get _FolderType(): string { return XmlElementNames.Folder; } /** - * Initializes an unsaved local instance of . To bind to an existing folder, use Folder.Bind() instead. + * Initializes an unsaved local instance of **Folder**. To bind to an existing folder, use Folder.Bind() instead. * * @param {ExchangeService} service EWS service to which this object belongs. */ diff --git a/src/js/Core/ServiceObjects/Folders/SearchFolder.ts b/src/js/Core/ServiceObjects/Folders/SearchFolder.ts index a4366d5c..547fb00b 100644 --- a/src/js/Core/ServiceObjects/Folders/SearchFolder.ts +++ b/src/js/Core/ServiceObjects/Folders/SearchFolder.ts @@ -7,7 +7,7 @@ export class SearchFolder extends Folder { /** * _FolderTYpe -> type of folder, use to avoid folder type detection using instanceof. some cases it has circular loop in nodejs/requirejs */ - get _FolderType(): string { return XmlElementNames.SearchFolder; } + //get _FolderType(): string { return XmlElementNames.SearchFolder; } //////SearchParameters: SearchFolderParameters; ////////Bind(service: ExchangeService, id: FolderId, propertySet: PropertySet): SearchFolder { throw new Error("SearchFolder.ts - Bind : Not implemented."); } diff --git a/src/js/Core/ServiceObjects/Folders/TasksFolder.ts b/src/js/Core/ServiceObjects/Folders/TasksFolder.ts index 45f75e1f..d52532b2 100644 --- a/src/js/Core/ServiceObjects/Folders/TasksFolder.ts +++ b/src/js/Core/ServiceObjects/Folders/TasksFolder.ts @@ -7,7 +7,7 @@ export class TasksFolder extends Folder { /** * _FolderTYpe -> type of folder, use to avoid folder type detection using instanceof. some cases it has circular loop in nodejs/requirejs */ - get _FolderType(): string { return XmlElementNames.TasksFolder; } + //get _FolderType(): string { return XmlElementNames.TasksFolder; } ////////Bind(service: ExchangeService, id: FolderId, propertySet: PropertySet): TasksFolder { throw new Error("TasksFolder.ts - Bind : Not implemented."); } ////////Bind(service: ExchangeService, id: FolderId): TasksFolder { throw new Error("TasksFolder.ts - Bind : Not implemented."); } diff --git a/src/js/ExchangeWebService.ts b/src/js/ExchangeWebService.ts index 1b0b545b..7ef5f2e8 100644 --- a/src/js/ExchangeWebService.ts +++ b/src/js/ExchangeWebService.ts @@ -117,6 +117,7 @@ TypeContainer.ServiceObjectSchema = ServiceObjectSchema; import {ServiceObject} from "./Core/ServiceObjects/ServiceObject"; import {Folder} from "./Core/ServiceObjects/Folders/Folder"; +import {CalendarFolder} from "./Core/ServiceObjects/Folders/CalendarFolder"; import {Appointment} from "./Core/ServiceObjects/Items/Appointment"; import {Item} from "./Core/ServiceObjects/Items/Item"; import {ItemAttachment} from "./ComplexProperties/ItemAttachment"; @@ -132,6 +133,7 @@ import {ExtendedPropertyDefinition} from "./PropertyDefinitions/ExtendedProperty TypeContainer.ServiceObject = ServiceObject; TypeContainer.Folder = Folder; +TypeContainer.CalendarFolder = CalendarFolder; TypeContainer.Item = Item; TypeContainer.Appointment = Appointment; TypeContainer.MeetingRequest = MeetingRequest; @@ -145,7 +147,7 @@ TypeContainer.IndexedPropertyDefinition = IndexedPropertyDefinition; TypeContainer.ExtendedPropertyDefinition = ExtendedPropertyDefinition; -export {ServiceObject, Folder, Appointment, ExchangeService, Item, ItemAttachment, ItemAttachmentOf, MeetingCancellation, MeetingRequest, MeetingResponse, IndexedPropertyDefinition, ExtendedPropertyDefinition} +export {ServiceObject, Folder, CalendarFolder, Appointment, ExchangeService, Item, ItemAttachment, ItemAttachmentOf, MeetingCancellation, MeetingRequest, MeetingResponse, IndexedPropertyDefinition, ExtendedPropertyDefinition} /**#endregion BootStrap code */ @@ -212,7 +214,6 @@ export {CalendarActionResults} from "./Misc/CalendarActionResults"; export {CalendarEvent} from "./ComplexProperties/Availability/CalendarEvent"; export {CalendarEventDetails} from "./ComplexProperties/Availability/CalendarEventDetails"; -export {CalendarFolder} from "./Core/ServiceObjects/Folders/CalendarFolder"; export {CalendarResponseMessage} from "./Core/ServiceObjects/ResponseObjects/CalendarResponseMessage"; export {CalendarResponseMessageBase} from "./Core/ServiceObjects/ResponseObjects/CalendarResponseMessageBase"; export {CalendarView} from "./Search/CalendarView"; diff --git a/src/js/Search/CalendarView.ts b/src/js/Search/CalendarView.ts index 021f743d..271fa74d 100644 --- a/src/js/Search/CalendarView.ts +++ b/src/js/Search/CalendarView.ts @@ -1,38 +1,156 @@ -import {ViewBase} from "./ViewBase"; -import {ItemTraversal} from "../Enumerations/ItemTraversal"; -import {JsonObject} from "../Core/JsonObject"; +import {ArgumentException} from "../Exceptions/ArgumentException"; +import {DateTime} from "../DateTime"; +import {EwsServiceXmlWriter} from "../Core/EwsServiceXmlWriter"; import {ExchangeService} from "../Core/ExchangeService"; +import {Grouping} from "./Grouping"; +import {ItemTraversal} from "../Enumerations/ItemTraversal"; import {ServiceObjectType} from "../Enumerations/ServiceObjectType"; import {ServiceRequestBase} from "../Core/Requests/ServiceRequestBase"; -import {EwsServiceXmlWriter} from "../Core/EwsServiceXmlWriter"; -import {Grouping} from "./Grouping"; +import {ServiceValidationException} from "../Exceptions/ServiceValidationException"; +import {Strings} from "../Strings"; +import {XmlAttributeNames} from "../Core/XmlAttributeNames"; +import {XmlElementNames} from "../Core/XmlElementNames"; + +import {ViewBase} from "./ViewBase"; +/** + * Represents a date range view of appointments in calendar folder search operations. + */ export class CalendarView extends ViewBase { - StartDate: Date; - EndDate: Date; - MaxItemsReturned: number; - Traversal: ItemTraversal; - private traversal: ItemTraversal; - private maxItemsReturned: number; - private startDate: Date; - private endDate: Date; - AddJsonProperties(jsonRequest: JsonObject, service: ExchangeService): void{ throw new Error("CalendarView.ts - AddJsonProperties : Not implemented.");} - GetMaxEntriesReturned(): number{ throw new Error("CalendarView.ts - GetMaxEntriesReturned : Not implemented.");} - GetServiceObjectType(): ServiceObjectType{ throw new Error("CalendarView.ts - GetServiceObjectType : Not implemented.");} - GetViewJsonTypeName(): string{ throw new Error("CalendarView.ts - GetViewJsonTypeName : Not implemented.");} - GetViewXmlElementName(): string{ throw new Error("CalendarView.ts - GetViewXmlElementName : Not implemented.");} - InternalValidate(request: ServiceRequestBase): void{ throw new Error("CalendarView.ts - InternalValidate : Not implemented.");} - InternalWritePagingToJson(jsonView: JsonObject, service: ExchangeService): void{ throw new Error("CalendarView.ts - InternalWritePagingToJson : Not implemented.");} - InternalWriteSearchSettingsToXml(writer: EwsServiceXmlWriter, groupBy: Grouping): void{ throw new Error("CalendarView.ts - InternalWriteSearchSettingsToXml : Not implemented.");} - InternalWriteViewToXml(writer: EwsServiceXmlWriter): void{ throw new Error("CalendarView.ts - InternalWriteViewToXml : Not implemented.");} - WriteAttributesToXml(writer: EwsServiceXmlWriter): void{ throw new Error("CalendarView.ts - WriteAttributesToXml : Not implemented.");} - WriteGroupingToJson(service: ExchangeService, groupBy: Grouping): any{ throw new Error("CalendarView.ts - WriteGroupingToJson : Not implemented.");} - WriteOrderByToXml(writer: EwsServiceXmlWriter): void{ throw new Error("CalendarView.ts - WriteOrderByToXml : Not implemented.");} -} + private traversal: ItemTraversal = ItemTraversal.Shallow; + private maxItemsReturned: number = null; + private startDate: DateTime = null; + private endDate: DateTime = null; + + /** + * Gets or sets the start date. + */ + get StartDate(): DateTime { + return this.startDate; + } + set StartDate(value: DateTime) { + this.startDate = value; + } + + /** + * Gets or sets the end date. + */ + get EndDate(): DateTime { + return this.endDate; + } + set EndDate(value: DateTime) { + this.endDate = value; + } + + /** + * The maximum number of items the search operation should return. + */ + get MaxItemsReturned(): number { + return this.maxItemsReturned; + } + set MaxItemsReturned(value: number) { + if (value !== null && value <= 0) { + throw new ArgumentException(Strings.ValueMustBeGreaterThanZero); + } + this.maxItemsReturned = value; + } + + /** + * Gets or sets the search traversal mode. Defaults to ItemTraversal.Shallow. + */ + get Traversal(): ItemTraversal { + return this.traversal; + } + set Traversal(value: ItemTraversal) { + this.traversal = value; + } + + /** + * Initializes a new instance of CalendarView. + * + * @param {DateTime} startDate The start date. + * @param {DateTime} endDate The end date. + */ + constructor(startDate: DateTime, endDate: DateTime); + /** + * Initializes a new instance of CalendarView. + * + * @param {DateTime} startDate The start date. + * @param {DateTime} endDate The end date. + * @param {number} maxItemsReturned The maximum number of items the search operation should return. + */ + constructor(startDate: DateTime, endDate: DateTime, maxItemsReturned: number); + constructor(startDate: DateTime, endDate: DateTime, maxItemsReturned: number = null) { + super(); + this.startDate = startDate; + this.endDate = endDate; + this.MaxItemsReturned = maxItemsReturned; + } + + /** + * @internal Gets the maximum number of items or folders the search operation should return. + * + * @return {number} The maximum number of items the search operation should return. + */ + GetMaxEntriesReturned(): number { return this.MaxItemsReturned; } + + /** + * @internal Gets the type of service object this view applies to. + * + * @return {ServiceObjectType} A ServiceObjectType value. + */ + GetServiceObjectType(): ServiceObjectType { return ServiceObjectType.Item; } + + /** + * @internal Gets the name of the view XML element. + * + * @return {string} XML element name. + */ + GetViewXmlElementName(): string { return XmlElementNames.CalendarView; } + /** + * @internal Validate instance. + * + * @param {ServiceRequestBase} request The request using this view. + */ + InternalValidate(request: ServiceRequestBase): void { + super.InternalValidate(request); + if (this.endDate < this.StartDate) { + throw new ServiceValidationException(Strings.EndDateMustBeGreaterThanStartDate); + } + } + /** + * @internal Writes the search settings to XML. + * + * @param {EwsServiceXmlWriter} writer The writer. + * @param {Grouping} groupBy The group by clause. + */ + InternalWriteSearchSettingsToXml(writer: EwsServiceXmlWriter, groupBy: Grouping): void { /* No search settings for calendar views. */ } + /** + * @internal Write to XML. + * + * @param {EwsServiceXmlWriter} writer The writer. + */ + InternalWriteViewToXml(writer: EwsServiceXmlWriter): void { + super.InternalWriteViewToXml(writer); + writer.WriteAttributeValue(XmlAttributeNames.StartDate, this.StartDate); + writer.WriteAttributeValue(XmlAttributeNames.EndDate, this.EndDate); + } - + /** + * @internal Writes the attributes to XML. + * + * @param {EwsServiceXmlWriter} writer The writer. + */ + WriteAttributesToXml(writer: EwsServiceXmlWriter): void { writer.WriteAttributeValue(XmlAttributeNames.Traversal, ItemTraversal[this.Traversal]); } + /** + * @internal Writes OrderBy property to XML. + * + * @param {EwsServiceXmlWriter} writer The writer + */ + WriteOrderByToXml(writer: EwsServiceXmlWriter): void { /* No OrderBy for calendar views. */ } +} \ No newline at end of file diff --git a/src/js/TypeContainer.ts b/src/js/TypeContainer.ts index e5fd9224..12434575 100644 --- a/src/js/TypeContainer.ts +++ b/src/js/TypeContainer.ts @@ -13,9 +13,13 @@ export class TypeContainer { */ public static ServiceObject: any; /** - * Type object of ExchangeService (not instance) + * Type object of Folder (not instance) */ public static Folder: any; + /** + * Type object of CalendarFolder (not instance) + */ + public static CalendarFolder: any; /** * Type object of ServiceObjectSchema (not instance) */ diff --git a/test/ManualLiveTesting/app.ts b/test/ManualLiveTesting/app.ts index 7ee40dc2..1078cbac 100644 --- a/test/ManualLiveTesting/app.ts +++ b/test/ManualLiveTesting/app.ts @@ -1,7 +1,8 @@ import {useCustomPromise, useCustomXhr, Uri, AttendeeInfo, TimeZoneDefinition, TimeWindow, DateTime, TimeSpan, DateTimeKind, TimeZoneInfo, AvailabilityData, EmailMessageSchema, ItemSchema, AggregateType, SortDirection, AutodiscoverService, ExchangeVersion, ExchangeCredentials, ExchangeService, UserSettingName, DomainSettingName, BasePropertySet, PropertySet, EnumHelper, FolderId, WellKnownFolderName, DOMParser, ItemView, Grouping, EmailMessage, EwsLogging, AppointmentSchema, CalendarActionResults, EwsUtilities, MeetingCancellation, MeetingRequest, MeetingResponse, Appointment, Item, StringHelper, - ResolveNameSearchLocation, ExtendedPropertyDefinition, MapiPropertyType, ConflictResolutionMode, Guid, DefaultExtendedPropertySet, SendInvitationsMode, MessageBody} from "../../src/js/ExchangeWebService"; + ResolveNameSearchLocation, ExtendedPropertyDefinition, MapiPropertyType, ConflictResolutionMode, Guid, DefaultExtendedPropertySet, SendInvitationsMode, MessageBody, + CalendarView} from "../../src/js/ExchangeWebService"; import {MockXHRApi} from "../MockXHRApi"; import {MockXHRData} from "../MockXHRData"; @@ -27,8 +28,23 @@ export class Greeter { var exch = new ExchangeService(ExchangeVersion.Exchange2013); exch.Credentials = new ExchangeCredentials(credentials.userName, credentials.password); exch.Url = new Uri("https://outlook.office365.com/Ews/Exchange.asmx"); - EwsLogging.DebugLogEnabled = false; - + EwsLogging.DebugLogEnabled = true; + + var mockXhr = new MockXHRApi(); + //exch.XHRApi = mockXhr; + mockXhr.requestXml.push(MockXHRData.Operations.CalendarOperations.FindAppointmentRequest); + mockXhr.responseXml.push(MockXHRData.Operations.CalendarOperations.FindAppointmentRequestResponseWith3results); + exch.FindAppointments(WellKnownFolderName.Calendar,new CalendarView(DateTime.Now.Add(-7,"days"), DateTime.Now)).then((resp)=>{ + EwsLogging.Log(resp,true, true); + console.log("------------"); + }, (ei) => { + EwsLogging.Log(ei, true, true); + console.log(ei.stack, ei.stack.split("\n")); + console.log("------------"); + }); + + + return; var msgattach = new EmailMessage(exch); msgattach.Subject = "Dentist Appointment"; msgattach.Body = new MessageBody("The appointment is with Dr. Smith."); diff --git a/test/MockXHRData.ts b/test/MockXHRData.ts index e3674556..af7d6bbf 100644 --- a/test/MockXHRData.ts +++ b/test/MockXHRData.ts @@ -109,7 +109,7 @@ X-MS-Exchange-Transport-EndToEndLatency: 00:00:03.2068487 \ export var FindItemWithTentativelyAcceptedMeetingResponseRequestResponse = 'NoErrorIPM.Schedule.Meeting.Resp.TentTentative:test acceptNormal2016-03-11T23:21:22Z15305Normalfalsefalsefalsefalsetrue2016-03-11T23:21:20Z2016-03-11T23:21:22Z2016-03-11T23:30:00Z2016-03-11T23:15:00ZGroup Managerfalseen-USfalsefalsefalsetruetruetruetrueroom12016-03-11T23:21:22Zfalsehttps://outlook.office365.com/owa/?ItemID=AAMkADQwYjI2NmQzLWRjOGItNDcyMC1iMWE2LWZiMWQxZTk0NDA5YwBGAAAAAAD7THPLlZw5QIg6OXUk7V98BwBW56ZK5wEvSplui1kQQWjKAAAAAAEMAABW56ZK5wEvSplui1kQQWjKAAAINEdWAAA%3D&exvsurl=1&viewmodel=ReadMessageItemNotFlaggedAQAAAAAAAQwBAAAACDRHVgAAAAA=room1room@contoso.comSMTPOneOfffalseAdF77LWcwiURniNH80u1fga4f3b8zgAAAQKstest acceptroom1room@contoso.comSMTPOneOff<SN1PR02MB1376ABA36C5A363829996FBB86B50@SN1PR02MB1376.namprd02.prod.outlook.com>falseGroup ManagerEXOneOffGroup Manager/O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=A568D36B45D44774BB8A67210FCCFA63-GROUPTESTEXOneOfftrueTentative040000008200E00074C5B7101A82E00800000000D9D198B5EC7BD1010000000000000000100000002A3066F01681AC4089EA4E4EFDEC89FA2016-03-11T23:21:20Z2016-03-11T23:30:00Z2016-03-12T00:30:00Zroom1Single'; export var GetItemWithTentativelyAcceptedMeetingResponseRequest = 'AllProperties'; - + export var GetItemWithTentativelyAcceptedMeetingResponseRequestResponse = 'NoErrorIPM.Schedule.Meeting.Resp.TentTentative:test acceptNormal<html> \ <head> \ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> \ @@ -130,6 +130,12 @@ X-MS-Exchange-Transport-EndToEndLatency: 00:00:03.2068487 \ export var CreateAppointmentRequest = 'Dentist AppointmentThe appointment is with Dr. Smith.2016-04-01T05:30:00.000+00:002016-04-01T05:30:00.000+00:00'; export var CreateAppointmentRequestResponse = 'NoError'; + + export var FindAppointmentRequest = 'AllProperties'; + + export var FindAppointmentRequestResponseWith0results = 'NoError'; + + export var FindAppointmentRequestResponseWith3results = 'NoErrorIPM.Appointmentsome appointmentNormal2016-04-02T23:24:19Z4639Green categoryNormalfalsefalsefalsefalsefalse2016-04-02T23:24:19Z2016-04-02T23:24:19Z2016-03-31T02:30:00Ztrue2016-03-31T02:00:00Z30falseen-USfalsefalsefalsetruetruetruetrueGroup Manager2016-04-03T01:10:31Zfalsehttps://outlook.office365.com/owa/?ItemID=AAMkADQwYjI2NmQzLWRjOGItNDcyMC1iMWE2LWZiMWQxZTk0NDA5YwBGAAAAAAD7THPLlZw5QIg6OXUk7V98BwBW56ZK5wEvSplui1kQQWjKAAAAAAENAABW56ZK5wEvSplui1kQQWjKAAAXHr1nAAA%3D&exvsurl=1&viewmodel=ICalendarItemDetailsViewModelFactoryhttps://outlook.office365.com/owa/?ItemID=AAMkADQwYjI2NmQzLWRjOGItNDcyMC1iMWE2LWZiMWQxZTk0NDA5YwBGAAAAAAD7THPLlZw5QIg6OXUk7V98BwBW56ZK5wEvSplui1kQQWjKAAAAAAENAABW56ZK5wEvSplui1kQQWjKAAAXHr1nAAA%3D&exvsurl=1&viewmodel=ComposeCalendarItemViewModelFactoryNotFlaggedAQAAAAAAAQ0BAAAAFx69ZwAAAAA=040000008200E00074C5B7101A82E00800000000A209D6C7368DD10100000000000000001000000014EA8CAA5F1E494A8448989E6916859C2016-04-03T01:10:31Z2016-03-31T02:30:00Z2016-03-31T03:00:00ZfalseBusyfalsefalsefalsefalsetrueSingleOrganizerGroup Manager/O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=A568D36B45D44774BB8A67210FCCFA63-GROUPTESTEXOneOffPT30M(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi00false2016-03-31T08:00:00+05:302016-03-31T08:30:00+05:30India Standard TimeIndia Standard TimeNoDatatrueIPM.Appointmentsome appointment3 Normal2016-04-02T23:25:07Z11344Purple categoryOrange categoryNormalfalsefalsefalsefalsefalse2016-04-02T23:25:07Z2016-04-02T23:25:07Z2016-03-31T05:00:00Ztrue2016-03-31T04:30:00Z30test8falseen-USfalsefalsefalsetruetruetruetrueGroup Manager2016-04-03T01:10:16Zfalsehttps://outlook.office365.com/owa/?ItemID=AAMkADQwYjI2NmQzLWRjOGItNDcyMC1iMWE2LWZiMWQxZTk0NDA5YwBGAAAAAAD7THPLlZw5QIg6OXUk7V98BwBW56ZK5wEvSplui1kQQWjKAAAAAAENAABW56ZK5wEvSplui1kQQWjKAAAXHr1pAAA%3D&exvsurl=1&viewmodel=ICalendarItemDetailsViewModelFactoryhttps://outlook.office365.com/owa/?ItemID=AAMkADQwYjI2NmQzLWRjOGItNDcyMC1iMWE2LWZiMWQxZTk0NDA5YwBGAAAAAAD7THPLlZw5QIg6OXUk7V98BwBW56ZK5wEvSplui1kQQWjKAAAAAAENAABW56ZK5wEvSplui1kQQWjKAAAXHr1pAAA%3D&exvsurl=1&viewmodel=ComposeCalendarItemViewModelFactoryNotFlaggedAQAAAAAAAQ0BAAAAFx69aQAAAAA=040000008200E00074C5B7101A82E008000000007C5796E4368DD1010000000000000000100000006C6986DFEA45CD418E474354B809861E2016-04-03T01:10:16Z2016-03-31T05:00:00Z2016-03-31T08:00:00ZfalseBusyOnline meetingtruefalsefalsetruetrueSingleOrganizerGroup Manager/O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=A568D36B45D44774BB8A67210FCCFA63-GROUPTESTEXOneOffPT3H(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi11true2016-03-31T10:30:00+05:302016-03-31T13:30:00+05:30India Standard TimeIndia Standard TimeNoDatahttps://meet.lync.com/mysupportin-mysupport/grouptest/TR6YUEG8trueIPM.Appointmentsome appointment2Normal2016-04-03T01:12:02Z5972Normalfalsefalsefalsefalsefalse2016-04-03T01:12:02Z2016-04-03T01:12:01Z2016-03-31T18:30:00Zfalse2016-04-02T18:30:00Z30falseen-USfalsefalsefalsetruetruetruetrueGroup Manager2016-04-03T01:12:02Zfalsehttps://outlook.office365.com/owa/?ItemID=AAMkADQwYjI2NmQzLWRjOGItNDcyMC1iMWE2LWZiMWQxZTk0NDA5YwBGAAAAAAD7THPLlZw5QIg6OXUk7V98BwBW56ZK5wEvSplui1kQQWjKAAAAAAENAABW56ZK5wEvSplui1kQQWjKAAAXw8SAAAA%3D&exvsurl=1&viewmodel=ICalendarItemDetailsViewModelFactoryhttps://outlook.office365.com/owa/?ItemID=AAMkADQwYjI2NmQzLWRjOGItNDcyMC1iMWE2LWZiMWQxZTk0NDA5YwBGAAAAAAD7THPLlZw5QIg6OXUk7V98BwBW56ZK5wEvSplui1kQQWjKAAAAAAENAABW56ZK5wEvSplui1kQQWjKAAAXw8SAAAA%3D&exvsurl=1&viewmodel=ComposeCalendarItemViewModelFactoryNotFlaggedAQAAAAAAAQ0BAAAAF8PEgAAAAAA=040000008200E00074C5B7101A82E008000000008E9207D4458DD101000000000000000010000000D1F0142310C554479F5418E52A749A062016-04-03T01:12:02Z2016-03-31T18:30:00Z2016-04-01T18:30:00ZtrueFreefalsefalsefalsefalsetrueSingleOrganizerGroup Manager/O=EXCHANGELABS/OU=EXCHANGE ADMINISTRATIVE GROUP (FYDIBOHF23SPDLT)/CN=RECIPIENTS/CN=A568D36B45D44774BB8A67210FCCFA63-GROUPTESTEXOneOffP1D(UTC+05:30) Chennai, Kolkata, Mumbai, New Delhi00false2016-04-01T00:00:00+05:302016-04-02T00:00:00+05:30India Standard TimeIndia Standard TimeNoDatatrue'; } export module AttachmentOperations { @@ -202,11 +208,11 @@ msg<br> \ export var GetItemAttachmentRequest = ''; export var GetItemAttachmentRequestResponse = 'NoErrorMessage with Attachmentsapplication/octet-streamIPM.NoteMessage with AttachmentsNormal<meta http-equiv="Content-Type" content="text/html; charset=utf-8">This message contains four file attachments.fiddler - ews javascript api.JPG1338122016-02-28T10:08:49falsefalse2016-02-28T10:08:52Z148830Normalfalsefalsefalsefalsetruefrom CY1PR02MB1754.namprd02.prod.outlook.com (10.162.165.148) by CY1PR02MB1754.namprd02.prod.outlook.com (10.162.165.148) with Microsoft SMTP Server (TLS) id 15.1.409.15 via Mailbox Transport; Sun, 28 Feb 2016 10:08:52 +0000from CY1PR02MB1754.namprd02.prod.outlook.com (10.162.165.148) by CY1PR02MB1754.namprd02.prod.outlook.com (10.162.165.148) with Microsoft SMTP Server (TLS) id 15.1.409.15; Sun, 28 Feb 2016 10:08:50 +0000from CY1PR02MB1754.namprd02.prod.outlook.com ([10.162.165.148]) by CY1PR02MB1754.namprd02.prod.outlook.com ([10.162.165.148]) with mapi id 15.01.0409.024; Sun, 28 Feb 2016 10:08:50 +0000contoso.com; dkim=none (message not signed) header.d=none;contoso.com; dmarc=none action=none header.from=contoso.com;application/ms-tnefbinaryMessage with AttachmentsMessage with AttachmentsAQHRchAE0n7aj5CyakiPiTnUlsBxyg==Sun, 28 Feb 2016 10:08:50 +0000<CY1PR02MB1754E6E9626F4FEADAF0C630C1B90@CY1PR02MB1754.namprd02.prod.outlook.com>en-USen-USyes-1<CY1PR02MB1754E6E9626F4FEADAF0C630C1B90@CY1PR02MB1754.namprd02.prod.outlook.com>1.0OriginatingCY1PR02MB1754.namprd02.prod.outlook.comInternal04[27.34.245.251]2101b3c6-6235-44bf-53de-08d3402727ca1.0SFV:SKI;SCL:-1SFV:SKI;SCL:-1SFV:SKI;SFS:;DIR:INB;SFP:;SCL:-1;SRVR:CY1PR02MB1754;H:CY1PR02MB1754.namprd02.prod.outlook.com;FPR:;SPF:None;LANG:en;user@contoso.comUriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR02MB1754;2101b3c6-6235-44bf-53de-08d3402727caUriScan:;BCL:0;PCL:0;RULEID:(102415293)(102615271)(601004)(2401047)(8121501046)(10201501046)(3002001);SRVR:CY1PR02MB1754;BCL:0;PCL:0;RULEID:;SRVR:CY1PR02MB1754;1:028 Feb 2016 10:08:50.4376 (UTC)Hosted459dde7d-be02-4767-933d-76263442fb00CY1PR02MB175400:00:01.98452951;CY1PR02MB1754;2:yCOPpRuOOs957DT58TOwcXUsZ8S1tzRgxTCvVCRU5Cwb9PRdiYr/pv1wlK2SurlyFaG3MLUyIp0bi979fj9gwqLw4L8HCebsFghHB0GAyLhgSvBB8HMg9uCo92DGrnhvwyY9hVrI5XdCvCPu9GZQmA==;3:oJ0XWCydV2NV1dpP1Fp5JUu3XZNxf3zE3ccfVsT5hFb8svsbBFy6FCpbhvJi61xgKYIzAPE2SlPazN0vEhAabhuli7v/B1BVTOqlO/JO6WATUhouskuCPw5A+l6sosPT;25:gmyD71XuSuh52PpfgU8XbrHjDVMdFBxpTBUjWat9/VRohDEzW4KVskjiUMKDocu9WpwaPgaLZdAPxB54n/dmNnM1zAbcblt9OvAxcJkT+gkUGlKEGotAET7Y9zZZE0pVoCwrUUBiHDdZVLLKb8fyt8PRoD5HhuZie0vTzovzvMyJvDX2miu91juO3Bn5TgUqk78ff184OAIMpCkW4QXBEGu3xhetF0vO+BPGjhd2GQRG+1PUiBNn4K2WAUuU1OaQFDa0gkUodP6ca9XzldzN19R+F2vJKxxg3h4FG0gpD3TSXbUrnL9f8bWg2Lr0K7tnmA2i07QW92VxIPF8HVpGLQ==1;CY1PR02MB1754;4:Fiv1WGB9SAjPfAq+XXb4YhuFkXXjyL6jexcNCPcQb5bWQSgEUPiR9s9+mHNvl82VXgp6M414hjFi7cEVhuMCXzm6oxp0CvW7LFPVAMFSZ8GPUmGw+LfJ6BzTmo7g0yMQS7vnQ33jSHQ2ctfV7AWVwcRae+Qs4IjTxuqjAc2P1Hvqp3bE8o+DP5UvW2lDoYvD/9qI2qPu9HuNcZSIvJvu9h2jNh7AMUIJMunC8g1pf8u6drXcMys41J+ROrY3JiDIGo12lIClcMvVR8POiSObNhjesQ3m2/qMq5zMipMJLhihp6VMmhsXx9nYKfhUEn7XjWzB+0/fofcNkVwJ1D5+731vGiRtuxA+DQOpMjpXdQKWU2nsc+z8JmDqa6Gv5WWAF5bN2SBsJydF3g7Qglt8TA==;23:mNm/7objdwQxqN2UtwGUyOD17r6fbQjkxEvCCXtqK0MNSqU/M1n8opFxfqqu54gpSPf3mNLo+zeX+vXv8LpDKfKp0SMbrbV4K6azF0wphHO/HOJ5PnzVEJ7G+LaRj+jYEEwpeLUT+MxmF4XO0i6ws7XIwxsEDdBbnP7BueMT2PihxsFtTe+TbGDbz5teewqh;5:f3eZhHQswYeFhtp32gyaoPqT4wP67bMEYT7IaKbwzrPwKjF0OB98kwPY6sLFnSwE/5zMd0B8fzAYZ1+KgbH518flixRJwEQpnJQI4y3asgCPtMxZ/TBa87js9Wg1cFlYyfclZGZ24j0gAodLNJC+Sw==;24:5/RrlpEzxTuMzWpEQH1lwQAWgeUinbIhAmuZCSnbTVUXJAcTZwM/Uqo3mxJpkjZoh0rq9JbRUzJkKJPlgfw8ykpxTcMy8tADkMln4JXUp78=1;CY1PR02MB1754;9:CN5wdbTTnSFqtWCaFTxW9983ncuVuaqW10l3X0TwA9r9pPGYZ7HAXJEpGCkoJ0cH+n0tjo+J3K9XVvNKyxieTDMGNWH5JI7PPo4ODvVNDB9X5s7zPKxCdE6FauANXX6QKD2khayCypEdjQl9SBA0Bg==2016-02-28T10:08:50Z2016-02-28T20:18:15ZGroup Managertrueen-USfalsefalsefalsetruetruetruetrueGroup Manager2016-02-28T20:18:06Zfalsehttps://outlook.office365.com/owa/?ItemID=AAMkADQwYjI2NmQzLWRjOGItNDcyMC1iMWE2LWZiMWQxZTk0NDA5YwAAAA%3D%3D&exvsurl=1&viewmodel=ReadMessageItemNotFlaggedGroup Manageruser@contoso.comSMTPMailboxGroup Manageruser@contoso.comSMTPMailboxfalsefalseAQHRchAE0n7aj5CyakiPiTnUlsBxyg==Message with AttachmentsGroup Manageruser@contoso.comSMTPMailbox<CY1PR02MB1754E6E9626F4FEADAF0C630C1B90@CY1PR02MB1754.namprd02.prod.outlook.com>falseGroup Manageruser@contoso.comSMTPMailboxGroup Manageruser@contoso.comSMTPMailbox'; - + export var GetAttachmentWith3AttachmentRequest = ''; - + export var GetAttachmentWith3AttachmentRequestResponse = 'NoErrortextFile.txttext/plainc29tZSB0ZXh0NoErrortextFile.txttext/plainc29tZSB0ZXh0NoErrorAttachemnt name 1application/octet-streamIPM.Note880falsetruefalsefalsefalse2016-03-06T22:35:47ZfalseenfalsefalsefalsetruetruetruetrueGroup Manager2016-03-06T22:35:48Zfalsehttps://outlook.office365.com/owa/?ItemID=AAMkADQwYjI2NmQzLWRjOGItNDcyMC1iMWE2LWZiMWQxZTk0NDA5YwAAAA%3D%3D&exvsurl=1&viewmodel=ReadMessageItemNotFlaggedfalseAQHRd/iH/slE3J+2t0uL/VOsw0aP+A==true'; - + } } diff --git a/test/mocha/Operations/CalendarOperationsTests.ts b/test/mocha/Operations/CalendarOperationsTests.ts new file mode 100644 index 00000000..1eaafbbe --- /dev/null +++ b/test/mocha/Operations/CalendarOperationsTests.ts @@ -0,0 +1,71 @@ +/// +/// +/// +import {AutodiscoverService, useCustomXhr, ExchangeCredentials, ExchangeService, ConflictResolutionMode, Guid, ExtendedPropertyDefinition, MapiPropertyType, PropertySet, ExchangeVersion, ItemView, UserSettingName, EwsLogging, Uri, DateTime, WellKnownFolderName, DefaultExtendedPropertySet, BasePropertySet} from "../../../src/js/ExchangeWebService"; +import {MockXHRApi} from "../../MockXHRApi"; +import {MockXHRData} from "../../MockXHRData"; + +import chaiAsPromised = require('chai-as-promised'); +import chai = require('chai'); +chai.use(chaiAsPromised); +var expect = chai.expect; +chai.should(); +describe.skip("Calendar Operation tests", () => { + var MyPropertySetId: Guid = new Guid("{C11FF724-AA03-4555-9952-8FA248A11C3E}"); + var exch = new ExchangeService(ExchangeVersion.Exchange2013); + exch.Url = new Uri("https://fake"); + exch.Credentials = new ExchangeCredentials("username", "password"); + var mockXhr = new MockXHRApi(); + it.skip("find appointments and load extended property ", (done) => { + mockXhr.requestXml = [MockXHRData.Operations.ItemOperations.FindItemRequest1ItemView]; + mockXhr.responseXml = [MockXHRData.Operations.ItemOperations.FindItemRequest1ItemViewResponse]; + var PR_TRANSPORT_MESSAGE_HEADERS = new ExtendedPropertyDefinition(MapiPropertyType.String, 0x007D); + var psPropSet = new PropertySet(BasePropertySet.IdOnly, [PR_TRANSPORT_MESSAGE_HEADERS]); + exch.XHRApi = mockXhr; + EwsLogging.DebugLogEnabled = false; + exch.FindItems(WellKnownFolderName.Inbox, new ItemView(1)) + .then((response) => { + for (var item of response.Items) { + mockXhr.requestXml = [MockXHRData.Operations.ItemOperations.GetItemRequestWithIDandExtendedPropertyHeader]; + mockXhr.responseXml = [MockXHRData.Operations.ItemOperations.GetItemRequestWithIDandExtendedPropertyHeaderResponse]; + item.Load(psPropSet) + .then((loadResp) => { + var outval = { outValue: null }; + if (item.TryGetExtendedProperty(PR_TRANSPORT_MESSAGE_HEADERS, outval)) { + chai.assert((outval.outValue).indexOf("from BN3PR09MB0564.namprd09.prod.outlook.com") >= 0); + done(); + } + }); + } + }); + }); + + it("Create extended property ", (done) => { + mockXhr.requestXml = [MockXHRData.Operations.ItemOperations.FindItemRequest1ItemView]; + mockXhr.responseXml = [MockXHRData.Operations.ItemOperations.FindItemRequest1ItemViewResponse]; + var PR_TRANSPORT_MESSAGE_HEADERS = new ExtendedPropertyDefinition(MapiPropertyType.String, 0x007D); + var psPropSet = new PropertySet(BasePropertySet.IdOnly, [PR_TRANSPORT_MESSAGE_HEADERS]); + exch.XHRApi = mockXhr; + EwsLogging.DebugLogEnabled = true; + exch.FindItems(WellKnownFolderName.Inbox, new ItemView(1)) + .then((response) => { + for (var item of response.Items) { + mockXhr.requestXml = [MockXHRData.Operations.ItemOperations.GetItemRequestWithIDandExtendedPropertyHeader]; + mockXhr.responseXml = [MockXHRData.Operations.ItemOperations.GetItemRequestWithIDandExtendedPropertyHeaderResponse]; + var extendedPropertyDefinition: ExtendedPropertyDefinition = new ExtendedPropertyDefinition(MyPropertySetId, "Expiration Date", MapiPropertyType.String); + + item.SetExtendedProperty(extendedPropertyDefinition, DateTime.Now.Add(2, "days").ToISOString()); + item.Update(ConflictResolutionMode.AutoResolve) + //item.Load(psPropSet) + .then((loadResp) => { + var outval = { outValue: null }; + if (item.TryGetExtendedProperty(PR_TRANSPORT_MESSAGE_HEADERS, outval)) { + chai.assert((outval.outValue).indexOf("from BN3PR09MB0564.namprd09.prod.outlook.com") >= 0); + done(); + } + }); + } + }); + }); + +}); \ No newline at end of file