AKZA#36054 Exchange fullsync savepoint
svn path=/Website/branches/v2016.1/; revision=29572
This commit is contained in:
3
CUST/AKZA/Exchange/ImportExchangeFull.bat
Normal file
3
CUST/AKZA/Exchange/ImportExchangeFull.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
IF EXIST tmp_Exchange_all.bat DEL tmp_Exchange_all.bat
|
||||
CScript ..\..\..\UTILS\Exchange\exchange_all.js AKZA EXCHFULL EXCHSYNC
|
||||
::CALL tmp_Exchange_all.bat
|
||||
@@ -4,6 +4,8 @@
|
||||
password : 'pass@word1', // Let op: dat werkt alleen als ServerXMLHTTP denkt op intranet te zitten
|
||||
maxchange : 25, // Maximaal 25 wijzigingen tegelijk. De rest komt de volgende keer wel
|
||||
maxrecurring: 100, // Maximaal 1e 100 occurences van een recurring afspraak
|
||||
fullpast : 0, // Tot 0 dagen in het verleden bij nachtelijke calendar-sync
|
||||
fullfuture : 90, // Tot 90 dagen in de toekomst bij nachtelijke calendar-sync
|
||||
xmlfolder : "./xml/", // Hier komen alle opgehaalde XML's geplaatst. Moet bestaan
|
||||
loglevel : 0
|
||||
}
|
||||
@@ -7,11 +7,15 @@
|
||||
Description: Exchange EWS koppeling
|
||||
Dit bestand maakt voor één ruimte-mailbox Arguments(0) de xml-bestanden
|
||||
met calenderitems aan sinds de laatste sync-actie, Arguments(1)
|
||||
|
||||
Parameters (0) e-mail adres van de zaal
|
||||
(1) - syncstate van de zaal of
|
||||
"EXCHFULL" alles (in de toekomst tot config.fullfuture)
|
||||
*/
|
||||
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
var zaalemail = WScript.Arguments(0);
|
||||
var zaalsync = WScript.Arguments(1);
|
||||
var zaalsync = WScript.Arguments(1); // Gebruik EXCHFULL voor alles in bepaalde periode
|
||||
|
||||
var inifile = ".\\exchange.config.js";
|
||||
var f = fso.OpenTextFile(inifile, 1); // ForReading
|
||||
@@ -23,10 +27,24 @@ WScript.Echo("Connecting to " + config.endpointurl)
|
||||
// ---
|
||||
// kunnen we niets mee doExchange(config.endpointurl, "<m:GetRoomLists />", "roomlist.xml");
|
||||
|
||||
if (!Date.prototype.toISOString) {
|
||||
Date.prototype.toISOString = function() {
|
||||
function pad(n) { return n < 10 ? '0' + n : n }
|
||||
return this.getUTCFullYear() + '-'
|
||||
+ pad(this.getUTCMonth() + 1) + '-'
|
||||
+ pad(this.getUTCDate()) + 'T'
|
||||
+ pad(this.getUTCHours()) + ':'
|
||||
+ pad(this.getUTCMinutes()) + ':'
|
||||
+ pad(this.getUTCSeconds()) + 'Z';
|
||||
};
|
||||
}
|
||||
|
||||
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")
|
||||
{
|
||||
var soapRequest = '<m:SyncFolderItems'
|
||||
+ ' xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" '
|
||||
+ ' xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">'
|
||||
@@ -35,11 +53,6 @@ var soapRequest = '<m:SyncFolderItems'
|
||||
+ ' <t:AdditionalProperties>'
|
||||
+ ' <t:FieldURI FieldURI="calendar:CalendarItemType" />'
|
||||
+ ' <t:FieldURI FieldURI="calendar:Start" />'
|
||||
// + ' <t:ExtendedFieldURI DistinguishedPropertySetId="Meeting" PropertyId="3" PropertyType="Binary" />' // 3=PidLidGlobalObjectId
|
||||
// + ' <t:ExtendedFieldURI DistinguishedPropertySetId="Meeting" PropertyId="35" PropertyType="Binary" />' // 35=PidLidCleanGlobalObjectId
|
||||
// + ' <t:ExtendedFieldURI DistinguishedPropertySetId="Meeting" PropertyId="40" PropertyType="Binary" />' // 40=PidLidOldLocation
|
||||
// + ' <t:ExtendedFieldURI DistinguishedPropertySetId="Meeting" PropertyId="98" PropertyType="Binary" />' // 98=PidTagOwnerAppointmentId
|
||||
// + ' <t:FieldURI FieldURI="calendar:Subject" />'
|
||||
+ ' </t:AdditionalProperties>'
|
||||
+ ' </m:ItemShape>'
|
||||
+ ' <m:SyncFolderId>'
|
||||
@@ -49,10 +62,40 @@ var soapRequest = '<m:SyncFolderItems'
|
||||
+ ' </t:Mailbox>'
|
||||
+ ' </t:DistinguishedFolderId>'
|
||||
+ ' </m:SyncFolderId>'
|
||||
+ ' <m:SyncState>' + zaalsync + '</m:SyncState> '
|
||||
+ ' <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 room_id = safefilename(zaalemail);
|
||||
var exch = doExchange(config.endpointurl, soapRequest, null);
|
||||
@@ -66,10 +109,14 @@ if (exch.response != 'NoError')
|
||||
WScript.Echo("Geen NoError responsecode in response: " + exch.response);
|
||||
WScript.Quit(1);
|
||||
}
|
||||
var newsyncstate = xmlDoc.selectSingleNode("//m:SyncState");
|
||||
var sha = oCrypto.hex_sha1(newsyncstate.text); // Gemakkelijker verschillen te zien
|
||||
|
||||
WScript.Echo("New syncstate: " + newsyncstate.text + "\nHash: " + sha + "\nlength: " + newsyncstate.text.length);
|
||||
if (zaalsync != "EXCHFULL")
|
||||
{
|
||||
var newsyncstate = xmlDoc.selectSingleNode("//m:SyncState");
|
||||
var sha = oCrypto.hex_sha1(newsyncstate.text); // Gemakkelijker verschillen te zien
|
||||
WScript.Echo("New syncstate: " + newsyncstate.text + "\nHash: " + sha + "\nlength: " + newsyncstate.text.length);
|
||||
}
|
||||
|
||||
var calItems = xmlDoc.selectNodes("//t:CalendarItem");
|
||||
if (calItems.length == 0)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
Parameters: (net als gen_import.wsf)
|
||||
0: customerId
|
||||
1: fac_import_app_key/code voor de EXCHANGE import
|
||||
1: fac_import_app_key/code voor de EXCHANGE import of de EXCHFULL import
|
||||
2: fac_import_app_key/code voor de EXCHSYNC import
|
||||
*/
|
||||
|
||||
@@ -48,21 +48,28 @@ var sql = "SELECT res_ruimte_key,"
|
||||
|
||||
var oRs = Oracle.Execute(sql);
|
||||
|
||||
|
||||
function pad(n) { return n < 10 ? '0' + n : n };
|
||||
var dt = new Date();
|
||||
var logfile = "Exchange_" + dt.getUTCFullYear() + '_' + pad(dt.getUTCMonth() + 1) + "_" + import_app_key + ".log";
|
||||
|
||||
|
||||
var fbat = fso.CreateTextFile(batfile, true /* overwrite */);
|
||||
while (!oRs.Eof)
|
||||
{
|
||||
var line = 'CScript /NoLogo ..\\..\\..\\utils\\Exchange\\Exchange.js "'
|
||||
+ oRs("res_ruimte_extern_id").Value + '" "' + (oRs("res_ruimte_syncstate").Value||"") + '"';
|
||||
+ oRs("res_ruimte_extern_id").Value + '" "' + (oRs("res_ruimte_syncstate").Value||"") + '"'
|
||||
+ ' >>' + logfile + ' 2>>&1';
|
||||
fbat.WriteLine(line);
|
||||
var line = 'Cscript /NoLogo ..\\..\\..\\utils\\gen_import\\gen_import.wsf '
|
||||
+ customerId + ' ' + sync_app_key + ' ' + oRs("res_ruimte_key").Value + '>>ExchangeAll.log 2>>&1';
|
||||
+ customerId + ' ' + sync_app_key + ' ' + oRs("res_ruimte_key").Value + ' >>' + logfile + ' 2>>&1';
|
||||
fbat.WriteLine(line);
|
||||
oRs.MoveNext();
|
||||
}
|
||||
|
||||
// E<>n import aan het eind; de room-id is toch uit de XML te halen
|
||||
var line = 'Cscript /NoLogo ..\\..\\..\\utils\\gen_import\\gen_import.wsf '
|
||||
+ customerId + ' ' + import_app_key + ' >>ExchangeAll.log 2>>&1';
|
||||
+ customerId + ' ' + import_app_key + ' >>' + logfile + ' 2>>&1';
|
||||
fbat.WriteLine(line);
|
||||
|
||||
fbat.Close();
|
||||
|
||||
Reference in New Issue
Block a user