Skip to content

Commit 447e582

Browse files
committed
FindAppointment fixes
1 parent 4e30200 commit 447e582

File tree

17 files changed

+601
-232
lines changed

17 files changed

+601
-232
lines changed

src/js/ComplexProperties/FolderPermissionCollection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {XmlNamespace} from "../Enumerations/XmlNamespace";
22
import {Folder} from "../Core/ServiceObjects/Folders/Folder";
3-
//import CalendarFolder = require("../Core/ServiceObjects/Folders/Calendar____Folder");
3+
import {TypeContainer} from "../TypeContainer";
44
import {FolderPermission} from "./FolderPermission";
55
import {ComplexPropertyCollection} from "./ComplexPropertyCollection";
66
import {ExchangeService} from "../Core/ExchangeService";
@@ -15,7 +15,7 @@ export class FolderPermissionCollection extends ComplexPropertyCollection<Folder
1515
get UnknownEntries(): string[] { return this.unknownEntries; }// System.Collections.ObjectModel.Collection<string>;
1616
constructor(owner: Folder) {
1717
super();
18-
this.isCalendarFolder = owner._FolderType === XmlElementNames.CalendarFolder; //owner instanceof CalendarFolder;
18+
this.isCalendarFolder = owner instanceof TypeContainer.CalendarFolder;// owner instanceof CalendarFolder;
1919

2020
}
2121
Add(permission: FolderPermission): void { this.InternalAdd(permission); }

src/js/ComplexProperties/StringList.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Strings} from "../Strings";
33
import {ArgumentOutOfRangeException} from "../Exceptions/ArgumentException";
44
import {XmlNamespace} from "../Enumerations/XmlNamespace";
55
import {ExchangeService} from "../Core/ExchangeService";
6-
import {EwsServiceXmlReader} from "../Core/EwsServiceXmlReader";
6+
import {ArrayHelper} from "../ExtensionMethods";
77
import {EwsServiceXmlWriter} from "../Core/EwsServiceXmlWriter";
88
import {ComplexProperty} from "./ComplexProperty";
99
export class StringList extends ComplexProperty { // IEnumerable<string>, IJsonCollectionDeserializer
@@ -15,7 +15,7 @@ export class StringList extends ComplexProperty { // IEnumerable<string>, IJsonC
1515
constructor();
1616
constructor(itemXmlElementName: string);
1717
constructor(strings: string[]);
18-
constructor(stringOrItemXmlElementName?: string| string[]) {
18+
constructor(stringOrItemXmlElementName?: string | string[]) {
1919
super();
2020
if (typeof stringOrItemXmlElementName !== 'undefined') {
2121
if (typeof stringOrItemXmlElementName === 'string') {
@@ -88,24 +88,27 @@ export class StringList extends ComplexProperty { // IEnumerable<string>, IJsonC
8888
this.Changed();
8989
}
9090
ToString(): string { return this.items.join(","); }
91-
ReadElementsFromXmlJsObject(reader: EwsServiceXmlReader): boolean { debugger; throw new Error("StringList.ts - TryReadElementFromXmlJsObject : Not implemented."); return null; }
91+
//ReadElementsFromXmlJsObject(reader: any): boolean { debugger; throw new Error("StringList.ts - TryReadElementFromXmlJsObject : Not implemented."); return null; }
9292
WriteElementsToXml(writer: EwsServiceXmlWriter): void {
9393
for (var item of this.items) {
9494
writer.WriteStartElement(XmlNamespace.Types, this.itemXmlElementName);
9595
writer.WriteValue(item, this.itemXmlElementName);
9696
writer.WriteEndElement();
9797
}
9898
}
99-
100-
101-
//IJsonCollectionDeserializer.CreateFromJsonCollection
102-
CreateFromJsonCollection(jsonCollection: any[], service: ExchangeService): void {
103-
for (var element of jsonCollection)
104-
{
105-
this.Add(<string>element);
106-
}
99+
100+
CreateFromXmlJsObjectCollection(jsObjectCollection: any[], service: ExchangeService): void {
101+
var collection = jsObjectCollection[this.itemXmlElementName];
102+
if (!ArrayHelper.isArray(collection)) {
103+
collection = [collection];
104+
}
105+
106+
for (var item of collection) {
107+
this.Add(<string>item);
108+
}
107109
}
108-
//IJsonCollectionDeserializer.UpdateFromJsonCollection
109-
UpdateFromJsonCollection(jsonCollection: any[], service: ExchangeService): void {
110+
111+
UpdateFromXmlJsObjectCollection(jsObjectCollection: any[], service: ExchangeService): void {
112+
throw new Error("StringList.ts - UpdateFromXmlJsObjectCollection : Not implemented.");
110113
}
111114
}

src/js/Core/EwsServiceXmlWriter.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {ExchangeServiceBase} from "./ExchangeServiceBase";
44
import {EwsUtilities} from "./EwsUtilities";
55
import {XmlNamespace} from "../Enumerations/XmlNamespace";
66
import {StringHelper, base64Helper} from "../ExtensionMethods";
7+
import {DateTime} from "../DateTime";
78

89
/**
910
* XML writer
@@ -110,7 +111,8 @@ export class EwsServiceXmlWriter {
110111
var strValue: string = null;
111112

112113
if (value === null) return null;
113-
if (typeof (value) == "object" && !(value.GetSearchString /*ISearchStringProvider*/)) throw new Error("value can not be of type object");
114+
// // // // if (typeof (value) == "object" && !(value.GetSearchString /*ISearchStringProvider*/))
115+
// // // // throw new Error("value can not be of type object");
114116

115117
if (value != null) {
116118
switch (typeof (value)) {
@@ -125,12 +127,18 @@ export class EwsServiceXmlWriter {
125127
case "string":
126128
return value;
127129
default:
130+
if (value instanceof DateTime) {
131+
return this.service.ConvertDateTimeToUniversalDateTimeString(value as DateTime);
132+
//return EwsUtilities.DateTimeToXSDateTime(value as DateTime);
133+
}
128134
try {
129-
if (typeof value.GetSearchString !== 'undefined') // checking - ISearchStringProvider
130-
strValue = value.GetSearchString();
135+
if (typeof value.GetSearchString === 'function') // checking - ISearchStringProvider
136+
return value.GetSearchString();
137+
else
138+
throw new Error("value can not be of type object");
131139
}
132140
catch (e) {
133-
strValue = value;
141+
throw e;
134142
}
135143

136144
break;
@@ -219,8 +227,8 @@ export class EwsServiceXmlWriter {
219227
var value: any = valueToWrite;
220228
var alwaysWriteEmptyString: boolean = false;
221229
var namespacePrefix: string = null;
222-
var callWithNameSpacePrifix:boolean = false;
223-
230+
var callWithNameSpacePrifix: boolean = false;
231+
224232
if (argsLength === 2) {
225233
value = localNameOrAlwaysWriteEmptyStringOrValue;
226234
}
@@ -239,7 +247,7 @@ export class EwsServiceXmlWriter {
239247
var stringValue: string = this.ConvertObjectToString(value);
240248
if (!StringHelper.IsNullOrEmpty(stringValue) || alwaysWriteEmptyString) {
241249
this.WriteAttributeString(
242-
callWithNameSpacePrifix? namespacePrefix:"",
250+
callWithNameSpacePrifix ? namespacePrefix : "",
243251
localName,
244252
stringValue);
245253
}
@@ -255,7 +263,7 @@ export class EwsServiceXmlWriter {
255263
WriteBase64ElementValue(buffer: any): void {
256264
this.WriteValue(base64Helper.btoa(buffer), null);
257265
}
258-
266+
259267
/**
260268
* Writes the element value.
261269
*
@@ -295,7 +303,7 @@ export class EwsServiceXmlWriter {
295303
EwsLogging.Assert(stringValue !== 'undefined', 'WriteElementValue', StringHelper.Format(
296304
Strings.ElementValueCannotBeSerialized,
297305
typeof (value), localName));
298-
306+
299307
// throw new Error(StringHelper.Format(
300308
// Strings.ElementValueCannotBeSerialized,
301309
// typeof (value), localName));

src/js/Core/EwsUtilities.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ export class EwsUtilities {
500500
this.numPad(timeSpan.seconds(), 2));
501501
}
502502
static XSDurationToTimeSpan(xsDuration: string): TimeSpan {
503-
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?/;
503+
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?/;
504+
504505
if (xsDuration.match(regex) === null) {
505506
throw new ArgumentException(Strings.XsDurationCouldNotBeParsed);
506507
}

0 commit comments

Comments
 (0)