AKZA#38400 Exchange import problemen omdat syncstate meer dan 8000 karakters

svn path=/Website/branches/v2016.2/; revision=31451
This commit is contained in:
Jos Groot Lipman
2016-11-14 10:28:10 +00:00
parent db282ebe50
commit a8f2d017cf
2 changed files with 66 additions and 59 deletions

View File

@@ -15,7 +15,7 @@
var fso = new ActiveXObject("Scripting.FileSystemObject");
var zaalemail = WScript.Arguments(0);
var zaalsync = WScript.Arguments(1); // Gebruik EXCHFULL voor alles in bepaalde periode
var import_app_key = WScript.Arguments(1); // Gebruik EXCHFULL voor alles in bepaalde periode
var inifile = ".\\exchange.config.js";
var f = fso.OpenTextFile(inifile, 1); // ForReading
@@ -41,60 +41,72 @@ if (!Date.prototype.toISOString) {
var oCrypto = new ActiveXObject("SLNKDWF.Crypto");
var sha = oCrypto.hex_sha1(zaalsync); // Gemakkelijker verschillen te zien
WScript.Echo("\n\n==== Room: " + zaalemail + "\nOld sync hash: " + sha);
if (zaalsync != "EXCHFULL")
if (import_app_key != "EXCHFULL")
{
var soapRequest = '<m:SyncFolderItems'
+ ' xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" '
+ ' xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">'
+ ' <m:ItemShape>'
+ ' <t:BaseShape>IdOnly</t:BaseShape>'
+ ' <t:AdditionalProperties>'
+ ' <t:FieldURI FieldURI="calendar:CalendarItemType" />'
+ ' <t:FieldURI FieldURI="calendar:Start" />'
+ ' </t:AdditionalProperties>'
+ ' </m:ItemShape>'
+ ' <m:SyncFolderId>'
+ ' <t:DistinguishedFolderId Id="calendar">'
+ ' <t:Mailbox>'
+ ' <t:EmailAddress>' + zaalemail + '</t:EmailAddress>'
+ ' </t:Mailbox>'
+ ' </t:DistinguishedFolderId>'
+ ' </m:SyncFolderId>'
+ ' <m:SyncState>' + zaalsync + '</m:SyncState>'
+ ' <m:MaxChangesReturned>' + config.maxchange + '</m:MaxChangesReturned>'
+ ' <m:SyncScope>NormalItems</m:SyncScope>'
+ '</m:SyncFolderItems>';
var udl = "../Oracle.udl";
var Oracle = new ActiveXObject("ADODB.Connection");
Oracle.Open('File Name='+udl);
var sql = "SELECT res_ruimte_syncstate"
+ " FROM res_ruimte"
+ " WHERE res_ruimte_verwijder IS NULL"
+ " AND res_ruimte_extern_id = '" + zaalemail + "'";
var oRs = Oracle.Execute(sql);
var zaalsync = oRs("res_ruimte_syncstate").Value||"";
oRs.Close();
var sha = oCrypto.hex_sha1(zaalsync); // Gemakkelijker verschillen te zien
WScript.Echo("\n\n==== Room: " + zaalemail + "\nOld sync hash: " + sha);
var soapRequest = '<m:SyncFolderItems'
+ ' xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" '
+ ' xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">'
+ ' <m:ItemShape>'
+ ' <t:BaseShape>IdOnly</t:BaseShape>'
+ ' <t:AdditionalProperties>'
+ ' <t:FieldURI FieldURI="calendar:CalendarItemType" />'
+ ' <t:FieldURI FieldURI="calendar:Start" />'
+ ' </t:AdditionalProperties>'
+ ' </m:ItemShape>'
+ ' <m:SyncFolderId>'
+ ' <t:DistinguishedFolderId Id="calendar">'
+ ' <t:Mailbox>'
+ ' <t:EmailAddress>' + zaalemail + '</t:EmailAddress>'
+ ' </t:Mailbox>'
+ ' </t:DistinguishedFolderId>'
+ ' </m:SyncFolderId>'
+ ' <m:SyncState>' + zaalsync + '</m:SyncState>'
+ ' <m:MaxChangesReturned>' + config.maxchange + '</m:MaxChangesReturned>'
+ ' <m:SyncScope>NormalItems</m:SyncScope>'
+ '</m:SyncFolderItems>';
}
else
{
var dtFrom = new Date();
dtFrom.setHours(0, 0, 0, 0);
var dtTo = new Date(dtFrom);
dtFrom.setDate(dtFrom.getDate() - config.fullpast);
dtTo.setDate(dtTo.getDate() + config.fullfuture);
WScript.Echo("Full syncing from " + dtFrom.toISOString() + " to " + dtTo.toISOString() + " (" + (config.fullfuture + config.fullpast) + " days)");
var soapRequest = '<m:FindItem Traversal="Shallow"'
+ ' xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" '
+ ' xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">'
+ ' <m:ItemShape>'
+ ' <t:BaseShape>IdOnly</t:BaseShape>'
+ ' <t:AdditionalProperties>'
+ ' <t:FieldURI FieldURI="calendar:CalendarItemType" />'
+ ' <t:FieldURI FieldURI="calendar:Start" />'
+ ' </t:AdditionalProperties>'
+ ' </m:ItemShape>'
//+ ' <m:CalendarView StartDate="2016-01-01T17:30:24.127Z" EndDate="2016-05-20T17:30:24.127Z" />'
+ ' <m:CalendarView StartDate="' + dtFrom.toISOString() + '" EndDate="' + dtTo.toISOString() + '" />'
+ ' <m:ParentFolderIds>'
+ ' <t:DistinguishedFolderId Id="calendar">'
+ ' <t:Mailbox>'
+ ' <t:EmailAddress>' + zaalemail + '</t:EmailAddress>'
+ ' </t:Mailbox>'
+ ' </t:DistinguishedFolderId>'
+ ' </m:ParentFolderIds>'
+ '</m:FindItem>';
var dtFrom = new Date();
dtFrom.setHours(0, 0, 0, 0);
var dtTo = new Date(dtFrom);
dtFrom.setDate(dtFrom.getDate() - config.fullpast);
dtTo.setDate(dtTo.getDate() + config.fullfuture);
WScript.Echo("Full syncing from " + dtFrom.toISOString() + " to " + dtTo.toISOString() + " (" + (config.fullfuture + config.fullpast) + " days)");
var soapRequest = '<m:FindItem Traversal="Shallow"'
+ ' xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" '
+ ' xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">'
+ ' <m:ItemShape>'
+ ' <t:BaseShape>IdOnly</t:BaseShape>'
+ ' <t:AdditionalProperties>'
+ ' <t:FieldURI FieldURI="calendar:CalendarItemType" />'
+ ' <t:FieldURI FieldURI="calendar:Start" />'
+ ' </t:AdditionalProperties>'
+ ' </m:ItemShape>'
//+ ' <m:CalendarView StartDate="2016-01-01T17:30:24.127Z" EndDate="2016-05-20T17:30:24.127Z" />'
+ ' <m:CalendarView StartDate="' + dtFrom.toISOString() + '" EndDate="' + dtTo.toISOString() + '" />'
+ ' <m:ParentFolderIds>'
+ ' <t:DistinguishedFolderId Id="calendar">'
+ ' <t:Mailbox>'
+ ' <t:EmailAddress>' + zaalemail + '</t:EmailAddress>'
+ ' </t:Mailbox>'
+ ' </t:DistinguishedFolderId>'
+ ' </m:ParentFolderIds>'
+ '</m:FindItem>';
}
var room_id = safefilename(zaalemail);
@@ -110,7 +122,7 @@ if (exch.response != 'NoError')
WScript.Quit(1);
}
if (zaalsync != "EXCHFULL")
if (import_app_key != "EXCHFULL")
{
var newsyncstate = xmlDoc.selectSingleNode("//m:SyncState");
var sha = oCrypto.hex_sha1(newsyncstate.text); // Gemakkelijker verschillen te zien

View File

@@ -40,8 +40,7 @@ var Oracle = new ActiveXObject("ADODB.Connection");
Oracle.Open('File Name='+udl);
var sql = "SELECT res_ruimte_key,"
+ " res_ruimte_extern_id,"
+ " res_ruimte_syncstate"
+ " res_ruimte_extern_id"
+ " FROM res_ruimte"
+ " WHERE res_ruimte_verwijder IS NULL"
+ " AND res_ruimte_extern_id IS NOT NULL";
@@ -57,12 +56,8 @@ var logfile = "Exchange_" + dt.getUTCFullYear() + '_' + pad(dt.getUTCMonth() + 1
var fbat = fso.CreateTextFile(batfile, true /* overwrite */);
while (!oRs.Eof)
{
var syncstate = oRs("res_ruimte_syncstate").Value||"";
if (import_app_key == 'EXCHFULL')
syncstate = import_app_key;
var line = 'CScript /NoLogo ..\\..\\..\\utils\\Exchange\\Exchange.js "'
+ oRs("res_ruimte_extern_id").Value + '" "' + syncstate + '"'
+ oRs("res_ruimte_extern_id").Value + '" "' + import_app_key + '"'
+ ' >>' + logfile + ' 2>>&1';
fbat.WriteLine(line);
if (import_app_key != "EXCHFULL") // De full calender heeft geen syncstate in zich