FSN#34737 Putorders logging verbeteren

svn path=/Website/trunk/; revision=30250
This commit is contained in:
Jos Groot Lipman
2016-08-10 08:35:17 +00:00
parent 863ecc375c
commit 7b67d4392a
9 changed files with 92 additions and 37 deletions

View File

@@ -46,6 +46,12 @@ function generateHeader()
FcltMgr.setCaller({prs_key: prs_key, prs_naam: prs_naam});
}
<%
if (S("puo_loglevel") > 1 && user.has("WEB_FACTAB"))
{
%>
$(function () { $.toast({ text: "<%="Warning: puo_loglevel={0}".format(S("puo_loglevel"))%>", icon: "warning", position : 'top-left'}); });
<%
}
if (Application("otap_environment") == "O" || Session("logging") > 0)
{%>
function startLogging(silent)
@@ -97,7 +103,7 @@ function generateHeader()
if (user_key != -1) {
if (parseInt(schemaversion,10) < parseInt(FCLTMinDatabaseSchema,10))
{
if (user.checkAutorisation("WEB_FACTAB", true))
if (user.has("WEB_FACTAB"))
Response.Write("<div id='badschema' title='"+Oracle.RealConnection.Properties("User Name")+'@'+Oracle.RealConnection.Properties("Data source")+"'>BAD SCHEMA. Need DB"+FCLTMinDatabaseSchema+" have DB"+schemaversion+"</div>");
// else: gewone users niet direct lastigvallen.
// tijdens een (nieuw ingrijpende) hot-upgrade staan we het gewoon eventjes toe.

View File

@@ -32,7 +32,7 @@ function sendAllOrders()
}
sql = sql + " ORDER BY prs_bedrijf_key, xmlnode";
Log2File(2, sql);
Log2File(3, sql);
var oRs = Oracle.Execute(sql);
var RecTotal = 0;
@@ -89,7 +89,9 @@ function sendAllOrders()
function send1Order(Bedrijf_key, XMLnode, OpdrKey, ordernr, Sender, cust)
{
var result = false;
Log2File(1, "\n====== " + XMLnode + ": key: " + OpdrKey + " nr: " + ordernr + " (" + toDateTimeString(new Date()) + ")");
Log2File(1, "\n");
Log2File(2, "\n\n" + Fill(100, "="));
Log2File(1, "====== " + XMLnode + ": key: " + OpdrKey + " nr: " + ordernr + " (" + toDateTimeString(new Date()) + ")");
if ((S("puo_flags") & 2) != 2) // Voor in testomgevingen
{
@@ -123,7 +125,7 @@ function send1Order(Bedrijf_key, XMLnode, OpdrKey, ordernr, Sender, cust)
var sqlOT = "SELECT mld_typeopdr_key"
+ " FROM mld_opdr"
+ " WHERE mld_opdr_key = " + OpdrKey;
Log2File(2, sqlOT);
Log2File(3, sqlOT);
var oRsOT = Oracle.Execute(sqlOT);
if (!oRsOT.Eof)
{
@@ -154,7 +156,7 @@ function send1Order(Bedrijf_key, XMLnode, OpdrKey, ordernr, Sender, cust)
}
}
Log2File(2, sqlB);
Log2File(3, sqlB);
var oRsB = Oracle.Execute(sqlB);
if (oRsB.Eof)
{
@@ -256,6 +258,7 @@ function send1Order(Bedrijf_key, XMLnode, OpdrKey, ordernr, Sender, cust)
connect.disconnect()
} // if (connect.Connected)
}
Log2File(2, Fill(100, "=") + "\n\n");
return result;
}

View File

@@ -85,7 +85,7 @@ function sendNotification(ref_key, pcode)
+ strFilter
+ " ORDER BY fac_notificatie_datum"
+ " , fac_notificatie_key";
Log2File(2, sql);
Log2File(3, sql);
var oRs = Oracle.Execute(sql);
var notiMAILed = 0;
@@ -93,7 +93,9 @@ function sendNotification(ref_key, pcode)
var notiSYSed = 0;
while (!oRs.Eof)
{
Log2File(1, "\n== Notificatie: "
Log2File(1, "\n");
Log2File(2, "\n\n" + Fill(100, "="));
Log2File(1, "== Notificatie: "
+ oRs("fac_notificatie_key").value + " "
+ oRs("fac_srtnotificatie_code").value + ": "
+ oRs("fac_notificatie_refkey").value
@@ -111,6 +113,7 @@ function sendNotification(ref_key, pcode)
notiMAILed += notificationMail(oRs, NotificationXSL, puo_const);
notiSMSed += notificationSMS (oRs, NotificationXSL, puo_const);
notiSYSed += notificationSYS (oRs, puo_const);
Log2File(2, Fill(100, "=") + "\n\n");
oRs.MoveNext();
}
@@ -265,7 +268,7 @@ function notificationMail(rec, p_notificationXSL, params)
var sql = "UPDATE fac_notificatie"
+ " SET fac_notificatie_status = BITAND (fac_notificatie_status, " + controle + ")"
+ " WHERE fac_notificatie_key = " + rec("fac_notificatie_key").value;
Log2File(2, sql);
Log2File(3, sql);
Oracle.Execute(sql);
}
return noti_mailed;
@@ -337,7 +340,7 @@ function notificationSMS(rec, p_notificationXSL, params)
sql = "UPDATE fac_notificatie"
+ " SET fac_notificatie_status = BITAND (fac_notificatie_status, " + controle + ")"
+ " WHERE fac_notificatie_key = " + rec("fac_notificatie_key").value;
Log2File(2, sql);
Log2File(3, sql);
Oracle.Execute(sql);
}
@@ -446,7 +449,7 @@ function notificationSYS(rec, params)
sql = "UPDATE fac_notificatie"
+ " SET fac_notificatie_systeemadres = NULL "
+ " WHERE fac_notificatie_key = " + rec("fac_notificatie_key").value
Log2File(2, sql);
Log2File(3, sql);
Oracle.Execute(sql);
}
}

View File

@@ -186,7 +186,7 @@ function connectFTP( p_connect
{
var attFile = allFiles.item();
Log2File(1, "Sending attachment: " + attFile.Path + " (" + attFile.Size + " bytes)");
var filename = replaceAll(attFile.Name, "/", "_");
var filename = safe.filename(attFile.Name, "/", "_");
FTPresult = sendFTP(p_connect, filename, "", attFile.Path);
}
@@ -390,6 +390,7 @@ function SendOrder( p_connect
var XMLResult = new ActiveXObject("Msxml2.DOMDocument.6.0");
XMLResult.async = false;
XMLResult.loadXML(result);
TestAndRaiseAnXMLError("Error in SendOrder XML2HTML result", XMLResult);
// Eventuele attachements inplakken
//Log2File(2, "Order: " + XMLResult.xml);
@@ -401,16 +402,12 @@ function SendOrder( p_connect
{
xmlDoc.transformNodeToObject(xslDoc, streamResult);
}
LogStream2File(2, "transformed", streamResult, p_bedrijfadres.extension);
streamResult.Position = 0;
if (S("puo_loglevel") > 7) // dure conversie voorkomen
{
// fout in logging niet aanzetten!!!!!!!!!!!!
// Log2File(4, "Order =" + stream2text(streamResult));
}
// file naam mag geen / bevatten
var filename = p_ordernr + "." + p_bedrijfadres.extension;
filename = replaceAll(filename, "/", "_");
filename = safe.filename(filename, "/", "_");
var connectResult = {};
if (p_connect.Connected)

View File

@@ -39,11 +39,13 @@ function submitHTTP( p_connect
oStream.Position = 0; //
params.data = stream2text(oStream); // Zonder de stream2text krijg ik een ongewenste BOM ervoor
// Ik snap niet waarom ik die bij p_textstream niet krijg
LogStream2File(2, "HTTPrequest", params.data);
}
else // Gewoon plain
{
params.headers["Content-Type"] = "text/xml; charset=utf-8";
params.data = p_textstream;
LogString2File(2, "HTTPrequest", params.data);
}
var XMLhttp = doHTTP(p_connect.CurrentAddress, params);
// Bij status buiten de 200 range is er al een exception geweest

View File

@@ -50,9 +50,10 @@ function submitDOMXSLSOAP( p_connect
}
XMLenvelope.appendChild(XMLpayloadNode);
Log2File(3, "Envelope = " + XMLenvelope.xml);
LogString2File(3, "Envelope", XMLresult.xml, "xml");
XMLenvelope.transformNodeToObject(p_xsldoc, XMLresult);
Log2File(2, "SOAP request = " + XMLresult.xml);
LogString2File(2, "SOAPrequest", XMLresult.xml, "xml");
//
// Verstuur de SOAP aanvraag
@@ -67,14 +68,14 @@ function submitDOMXSLSOAP( p_connect
var XMLhttp = doHTTP(p_connect.CurrentAddress, params);
// Bij status buiten de 200 range is er al een exception geweest
Log2File(3, "SOAP response = " + XMLhttp.responseText);
LogString2File(2, "SOAP response", XMLhttp.responseText, "xml");
//
// Open de envelope
XMLenvelope.loadXML(XMLhttp.responseText);
TestAndRaiseAnXMLError("Error loading SOAP response as XML", XMLenvelope);
XMLenvelope.transformNodeToObject(p_xsldoc, XMLresult);
Log2File(3, "Response payload = " + XMLresult.xml);
LogString2File(3, "Response payload", XMLresult.xml, "xml");
TestAndRaiseAnXMLError("Error finding xml tag in SOAP response", XMLresult);
if (p_bedrijfadres.ordermode & 4)

View File

@@ -82,6 +82,50 @@ function Log2File(level, str, fatal)
}
}
var logcounter = 0;
function LogString2File(level, postfix, data, ext, isStream)
{
if(level > S("puo_loglevel"))
return;
if (logcounter > 99)
{
Log2File(level, "Meer dan 100 logfiles in één run? Ik stop er mee");
return;
}
var fso = new ActiveXObject("Scripting.FileSystemObject");
var folder = custabspath + "/../../temp/" + customerId + "_files";
if (!fso.FolderExists(folder))
fso.CreateFolder(folder);
var jsDate = new Date();
var s = String(jsDate.getFullYear()) + padout(jsDate.getMonth() + 1) + padout(jsDate.getDate()) + "-"
+ padout(jsDate.getHours()) + padout(jsDate.getMinutes()) + padout(jsDate.getSeconds())
var log_file = "puo_" + s + "_" + padout(logcounter++);
log_file = log_file + "_" + postfix + "." + (ext || "txt");
try
{
if (isStream)
{
data.SaveToFile(folder + "/" + log_file);
}
else
{
var ts = fso.CreateTextFile(folder + "/" + log_file, true);
ts.WriteLine (data);
ts.Close();
}
Log2File(level, "{0} written to {1} ({2} bytes)".format(postfix, log_file, isStream?data.Size:String(data).length));
}
catch (e)
{
Log2File(level, "ERROR writing {0} to {1}: {2}".format(postfix, log_file, e.description));
}
}
function LogStream2File(level, postfix, stream, ext)
{
LogString2File(level, postfix, stream, ext, true);
}
function cleanPopup()
{
@@ -92,7 +136,7 @@ function cleanPopup()
+ " SET n.fac_notificatie_status = BITAND(n.fac_notificatie_status, 255 - 8)"
+ " WHERE BITAND (n.fac_notificatie_status, 8) = 8"
+ " AND TRUNC (n.fac_notificatie_datum) < TRUNC (SYSDATE)"
Log2File(2, sql);
Log2File(3, sql);
Oracle.Execute(sql);
}
@@ -182,18 +226,25 @@ function doHTTP(url, params) // params is sterk vergelijkbaar met p_bedrijfadres
for (var head in params.headers)
http_request.setRequestHeader(head, params.headers[head]);
//http_request.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
// let op: params.data kan een string of ADODB.Stream zijn. Daarom moet de aanroeper maar loggen
http_request.send(params.data);
if (http_request.status < 200 || http_request.status > 299)
{
Log2File(2, "response = " + http_request.responseText); // Level 2 omdat het soms dagen doorloopt en te groot is
Log2File(2, "response Status = " + http_request.status + ": " + http_request.statusText);
var ext = null;
var ctype = String(http_request.getResponseHeader("Content-Type"));
if (ctype.indexOf("xml") > 0)
ext = "xml"
else if (ctype.indexOf("html") > 0)
ext = "html";
else if (ctype.indexOf("json") > 0)
ext = "json";
Log2File(1, "response Status = " + http_request.status + ": " + http_request.statusText);
LogString2File(2, "HTTP response", http_request.responseText, ext); // Level 2 omdat het soms dagen doorloopt en te groot is
Log2File(3, "response Headers = " + http_request.getAllResponseHeaders);
RaiseAnError(http_request.status, "http_request error " + http_request.status + ": (" + http_request.statusText + ")");
}
else
{
// http_request.getResponseHeader("Content-Type") bijvoorbeeld "application/json; Charset=windows-1252"
Log2File(3, "response = " + http_request.responseText);
}
return http_request;

View File

@@ -107,7 +107,7 @@ function fetchXMLContent( node
var xrefkeystr = (xrefkey == -1 ? "NULL" : safe.quoted_sql(String(xrefkey)));
// we geven de gewenste taal mee aan de Oracle sessie, die dat verder zal gebruiken
var sql = "BEGIN lcl.setuserlanguage (" + safe.quoted_sql(userlang) + "); END;"
Log2File(2, sql);
Log2File(3, sql);
Oracle.Execute(sql);
//
var sql_params = safe.quoted_sql(node)
@@ -141,7 +141,7 @@ function fetchXMLContent( node
+ " FROM fac_xml"
+ " WHERE fac_session_id = '$PutOrdersSession$'"
+ " ORDER BY fac_xml_volgnr";
Log2File(2, sql);
Log2File(3, sql);
var xml_content_arr = [];
var oRXs = Oracle.Execute(sql);
while( !oRXs.Eof)
@@ -161,7 +161,7 @@ function fetchXMLContent( node
}
finally
{
Log2File(2, ">>" + xml_content);
LogString2File(2, "make_xml", xml_content, "xml");
}
return xml_content;
}

View File

@@ -35,14 +35,6 @@ function Fill(i, c)
{ // Maakt een string met i tekens 'char'.
return new Array(i + 1).join(c);
}
function replaceAll(str, find, replace)
{
function escapeRegExp(str)
{
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
function Connect2Oracle(modulename)
{