Skip to content

Commit

Permalink
FindAppointment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamsi committed Apr 3, 2016
1 parent 4e30200 commit 447e582
Show file tree
Hide file tree
Showing 17 changed files with 601 additions and 232 deletions.
4 changes: 2 additions & 2 deletions src/js/ComplexProperties/FolderPermissionCollection.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -15,7 +15,7 @@ export class FolderPermissionCollection extends ComplexPropertyCollection<Folder
get UnknownEntries(): string[] { return this.unknownEntries; }// System.Collections.ObjectModel.Collection<string>;
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); }
Expand Down
29 changes: 16 additions & 13 deletions src/js/ComplexProperties/StringList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>, IJsonCollectionDeserializer
Expand All @@ -15,7 +15,7 @@ export class StringList extends ComplexProperty { // IEnumerable<string>, 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') {
Expand Down Expand Up @@ -88,24 +88,27 @@ export class StringList extends ComplexProperty { // IEnumerable<string>, 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);
writer.WriteValue(item, this.itemXmlElementName);
writer.WriteEndElement();
}
}


//IJsonCollectionDeserializer.CreateFromJsonCollection
CreateFromJsonCollection(jsonCollection: any[], service: ExchangeService): void {
for (var element of jsonCollection)
{
this.Add(<string>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(<string>item);
}
}
//IJsonCollectionDeserializer.UpdateFromJsonCollection
UpdateFromJsonCollection(jsonCollection: any[], service: ExchangeService): void {

UpdateFromXmlJsObjectCollection(jsObjectCollection: any[], service: ExchangeService): void {
throw new Error("StringList.ts - UpdateFromXmlJsObjectCollection : Not implemented.");
}
}
26 changes: 17 additions & 9 deletions src/js/Core/EwsServiceXmlWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand All @@ -255,7 +263,7 @@ export class EwsServiceXmlWriter {
WriteBase64ElementValue(buffer: any): void {
this.WriteValue(base64Helper.btoa(buffer), null);
}

/**
* Writes the element value.
*
Expand Down Expand Up @@ -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));
Expand Down
3 changes: 2 additions & 1 deletion src/js/Core/EwsUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit 447e582

Please sign in to comment.