AAIT#35610 -- Uitbreiding koppeling COM4

svn path=/Website/branches/v2015.3/; revision=29234
This commit is contained in:
Arthur Egberink
2016-04-28 14:22:38 +00:00
parent 1cd8ae9473
commit 09c5a86d12
3 changed files with 186 additions and 47 deletions

View File

@@ -1,52 +1,68 @@
<?xml version="1.0" encoding="Windows-1252"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:output method="xml" encoding="Windows-1252"/>
<xsl:template name="escape_quote">
<xsl:param name="string"/>
<xsl:choose>
<xsl:when test="contains($string, '&quot;')">
<xsl:value-of select="substring-before($string, '&quot;')"/>&quot;&quot;<xsl:call-template name="escape_quote">
<xsl:with-param name="string" select="substring-after($string, '&quot;')"/></xsl:call-template></xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
<xsl:template match="/">
<facilitor>
<xsl:for-each select="//header">
<xsl:copy-of select="."/>
</xsl:for-each>
<xsl:for-each select="//opdracht">
<xsl:copy-of select="."/>
</xsl:for-each>
<xsl:for-each select="incident">
<xsl:variable name="opdrachtspatie">
<xsl:value-of select="substring-after(korte_omschrijving, 'Facilitor opdracht: Opdracht nr.')"/> x</xsl:variable>
<xsl:variable name="opdrachtnummer">
<xsl:value-of select="substring-before($opdrachtspatie, ' ')"/>
</xsl:variable>
<xsl:element name="opdracht">
<xsl:attribute name="type">
<xsl:choose>
<xsl:when test="$opdrachtnummer = ''">insert</xsl:when>
<xsl:otherwise>update</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="key">
<xsl:value-of select="$opdrachtnummer"/>
</xsl:attribute>
<xsl:element name="externnr">
<xsl:value-of select="incidentnummer"/>
</xsl:element>
<xsl:element name="kenmerk">
<xsl:attribute name="naam">Ref. Nr. Leverancier</xsl:attribute>
<xsl:value-of select="incidentnummer"/>
</xsl:element>
<voor>300</voor>
<stdmelding_key>2925</stdmelding_key>
<typeopdr_key>901</typeopdr_key>
<opmerking><xsl:value-of select="actie"/></opmerking>
<mut_datum><xsl:value-of select="concat(substring(Datum_tijd_van_wijziging,7,4), '-', substring(Datum_tijd_van_wijziging,4,2), '-', substring(Datum_tijd_van_wijziging,1,2), 'T', substring(Datum_tijd_van_wijziging,12,5))"/></mut_datum>
<xsl:element name="kenmerk">
<xsl:attribute name="naam">Classificatie uit import</xsl:attribute>
<xsl:value-of select="Soort_call"/>;<xsl:value-of select="Categorie"/>;<xsl:value-of select="Subcategorie"/>;<xsl:choose>
<xsl:when test="afgemeld='Ja' or afgemeld='Yes'">AFM</xsl:when>
<xsl:otherwise>UPD</xsl:otherwise>
</xsl:choose>;<xsl:value-of select="status"/>
</xsl:element>
<bedrijf_key>735</bedrijf_key>
<opdrachttekst>
<xsl:value-of select="korte_omschrijving"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="aanmelder"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="email_aanmelder"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="verzoek"/>
</opdrachttekst>
</xsl:element>
</xsl:for-each>
</facilitor>
</xsl:template>
<xsl:template match="/">MSG_TYPE;OPDRACHTNR;EXTERNNR;ACTIE;ACTIEDATUM;STATUS;SOORT_CALL;CATEGORIE;SUBCATEGORIE;
<xsl:for-each select="incident">
<xsl:variable name="opdrachtspatie"><xsl:value-of select="substring-after(korte_omschrijving, 'Facilitor opdracht: Opdracht nr.')"/> x</xsl:variable>
<xsl:variable name="opdrachtnummer"><xsl:value-of select="substring-before($opdrachtspatie, ' ')"/></xsl:variable>
<xsl:variable name="tekst_oms"><xsl:call-template name="StrReplace"><xsl:with-param name="string" select="actie"/><xsl:with-param name="str1" select="'&#13;&#10;'"/><xsl:with-param name="str2" select="'%%0A'"/></xsl:call-template></xsl:variable>
<xsl:variable name="tekst_800">&quot;<xsl:call-template name="escape_quote"><xsl:with-param name="string" select="substring($tekst_oms,1,800)"/></xsl:call-template>&quot;</xsl:variable>
<xsl:choose>
<xsl:when test="afgemeld='Ja' or afgemeld='Yes'">AFM;<xsl:value-of select="$opdrachtnummer"/>;<xsl:value-of select="incidentnummer"/>;<xsl:value-of select="$tekst_800"/>;<xsl:value-of select="datum_afgemeld"/>;<xsl:value-of select="status"/>;<xsl:value-of select="Soort_call"/>;<xsl:value-of select="Categorie"/>;<xsl:value-of select="Subcategorie"/>
</xsl:when>
<xsl:otherwise>UPD;<xsl:value-of select="$opdrachtnummer"/>;<xsl:value-of select="incidentnummer"/>;<xsl:value-of select="$tekst_800"/>;<xsl:value-of select="datum_aangemeld"/>;<xsl:value-of select="status"/>;<xsl:value-of select="Soort_call"/>;<xsl:value-of select="Categorie"/>;<xsl:value-of select="Subcategorie"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="StrReplace">
<xsl:param name="string"/>
<xsl:param name="str1"/>
<xsl:param name="str2"/>
<xsl:choose>
<xsl:when test="contains($string, $str1)">
<xsl:value-of select="substring-before($string, $str1)"/><xsl:value-of select="$str2"/>
<xsl:call-template name="StrReplace">
<xsl:with-param name="string" select="substring-after($string, $str1)"/>
<xsl:with-param name="str1" select="$str1"/>
<xsl:with-param name="str2" select="$str2"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
<!-- Stylesheet edited using Stylus Studio - (c) 2004-2007. Progress Software Corporation. All rights reserved. -->
<!-- Stylesheet edited using Stylus Studio - (c) 2004-2007. Progress Software Corporation. All rights reserved. -->
<!-- Stylesheet edited using Stylus Studio - (c) 2004-2007. Progress Software Corporation. All rights reserved. --><!-- Stylesheet edited using Stylus Studio - (c) 2004-2007. Progress Software Corporation. All rights reserved. --><!-- Stylesheet edited using Stylus Studio - (c) 2004-2007. Progress Software Corporation. All rights reserved. -->

View File

@@ -0,0 +1,115 @@
// GetStatus.js
// Haalt statuswijzigingen op van de FTP server.
//
// $Revision$
// $Id$
//
// Opzet in kader van PNBR#
function padout(number) { return (number < 10) ? "0" + number : number; }
function date2string(mydate) {
return padout(mydate.getFullYear()) + "-" + padout(mydate.getMonth() + 1) + "-" + padout(mydate.getDate())
+ " " + padout(mydate.getHours()) + "-" + padout(mydate.getMinutes() + 1) + "-" + padout(mydate.getSeconds());
}
var api = WScript.Arguments(0); // api
var folder = WScript.Arguments(1); // folder
var url = WScript.Arguments(2); // url
try {
var fh, lenght;
fso = new ActiveXObject("Scripting.FileSystemObject");
objRS = new ActiveXObject("ADODB.Recordset");
objRS.CursorLocation = 3 // useClient
objRS.Fields.Append ("Name", 200, 100) // adVarChar
objRS.Fields.Append ("created", 7 ) // adDate
objRS.Open();
try
{
var backdir_api = ".\\BACKUP"+(new Date).getFullYear()+"\\";
if (!fso.FolderExists(backdir_api))
fso.CreateFolder(backdir_api);
backdir_api += api + "\\";
if (!fso.FolderExists(backdir_api))
fso.CreateFolder(backdir_api);
}
catch (e)
{
WScript.Echo("Cannot create backup folder " + backDir + "\n" + e.description);
WScript.Quit();
}
// plaats de bestandsnamen en creatiedata in een resultset om deze vervolgens te kunnen filteren.
folder = folder.replace(/\//g,"\\");
//WScript.Echo("Folder: " + folder);
var f = fso.GetFolder(folder);
var fc = new Enumerator(f.files);
var filecount = 0;
for (; !fc.atEnd(); fc.moveNext())
{
filename = fc.item().name;
//WScript.Echo("File: " + filename);
var file = fso.GetFile(folder + filename);
var dt = new Date(file.DateCreated);
WScript.Echo("File: " + filename + " timestamp:" + date2string(dt));
if (fc.item().name.indexOf(".XML") != -1 && fc.item().name.indexOf("C4A") != -1) {
filecount++;
objRS.AddNew();
objRS("Name") = filename;
objRS("created") = file.DateCreated;
}
}
if (filecount > 0) {
objRS.Sort = "created ASC";
objRS.MoveFirst();
while (!objRS.EOF)
{
filename = objRS("Name").Value;
//WScript.Echo("File (sorted): " + filename);
objRS.MoveNext();
var fileStream = new ActiveXObject("ADODB.Stream");
fileStream.open();
fileStream.CharSet = "Windows-1252"; // het doel
fileStream.LoadFromFile(folder + filename);
//WScript.Echo("Filesize " + fileStream.Size);
fileStream.Position = 0;
//WScript.Echo("Request1: " + fileStream.ReadText);
XMLReq = fileStream.ReadText;
WScript.Echo("Request: " + XMLReq);
var objXMLHTTP = new ActiveXObject("MSXML2.ServerXMLHTTP.6.0");
objXMLHTTP.open("POST",
url
);
objXMLHTTP.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
objXMLHTTP.send(XMLReq);
//WScript.Echo("Status: " + objXMLHTTP.status);
//WScript.Echo("StatusText: " + objXMLHTTP.statusText);
WScript.Echo("Result: " + objXMLHTTP.responseText);
if (objXMLHTTP.status == 200) {
jsDate = new Date;
dateString = padout(jsDate.getFullYear()) + "-" + padout(jsDate.getMonth() + 1) + "-" + padout(jsDate.getDate());
timeString = padout(jsDate.getHours()) + "-" + padout(jsDate.getMinutes() + 1) + "-" + padout(jsDate.getSeconds());
backDir = backdir_api + dateString + "_" + api + "\\";
if (!fso.FolderExists(backDir))
fso.CreateFolder(backDir)
// deze file backuppen
//WScript.Echo("from:" + filename);
//WScript.Echo("to:" + backDir + timeString + "_" + filename);
fso.MoveFile(folder + filename, backDir + timeString + "_" + filename);
}
}
}
}
catch (e)
{
WScript.Echo("Serieuze fout in GetStatus.js: " + e.description)
WScript.Quit(1);
}

View File

@@ -15,4 +15,12 @@ REM
move D:\Apps\Facilitor\ftp_sites\LocalUser\COM4IT\*.xml .
cscript ..\..\..\utils\gen_import\gen_import.wsf AAIT OPDRSTATUS >>genimport.log 2>>&1
REM cscript ..\..\..\utils\gen_import\gen_import.wsf AAIT OPDRSTATUS >>genimport.log 2>>&1
if not exist "d:\Apps\Facilitor\AAFM\cust\AAIT\import\C4A*.xml" goto einde
cscript .\api_opdrsoap_com4.js COM4OPDR d:\Apps\Facilitor\AAFM\cust\AAIT\import\ "https://aait.facilitor.nl/default.asp?fac_id=AAIT&API=COM4OPDR&APIKEY=bWBdlwCfLoSXYCwBBGyesfcfaqHYDXTk" >>genimport.log 2>>&1
call ..\..\..\utils\gen_export\gen_export.bat STATUS_COM4
:einde