FSN#23537 Gen_Export en Putorders omschrijven naar JavaScript

svn path=/Website/trunk/; revision=20700
This commit is contained in:
Jos Groot Lipman
2014-02-19 11:11:38 +00:00
parent 5e2d682a2d
commit d4b4c42476
16 changed files with 177 additions and 106 deletions

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_allorders.js $Revision$
// * $Id$
// *
// * SendAllOrders()
// * getXslNode()
@@ -14,22 +14,22 @@ function sendAllOrders(CustomerId)
// De sortering is van belang voor de loops erna
var sql = "SELECT prs_bedrijf_key,"
+ " xmlnode,"
+ " key,"
+ " reference,"
+ " 0 cust,"
+ " COALESCE(sender,'-') sender "
+ " FROM fac_v_orderqueue";
+ " xmlnode,"
+ " key,"
+ " reference,"
+ " 0 cust,"
+ " COALESCE(sender,'-') sender "
+ " FROM fac_v_orderqueue";
if (S("puo_custorders"))
{
sql += " UNION"
+ " SELECT prs_bedrijf_key,"
+ " xmlnode,"
+ " key,"
+ " reference,"
+ " 1 cust,"
+ " COALESCE(sender,'-') sender"
+ " xmlnode,"
+ " key,"
+ " reference,"
+ " 1 cust,"
+ " COALESCE(sender,'-') sender"
+ " FROM " + CustomerId + "_v_orderqueue ";
}
sql = sql + " ORDER BY prs_bedrijf_key, xmlnode";
@@ -43,9 +43,10 @@ function sendAllOrders(CustomerId)
var CNTRecSaved = 0;
var CustRecSaved = 0;
__Log("Opening order query")
while (!oRs.Eof)
{
var Bedrijf = oRs("prs_bedrijf_key").value;
var Bedrijf_key = oRs("prs_bedrijf_key").value;
var XMLnode = oRs("xmlnode").value;
var OpdrKey = oRs("key").value;
var ordernr = oRs("reference").value;
@@ -59,15 +60,15 @@ function sendAllOrders(CustomerId)
connect.Connected = false;
// techparams 5.3.3 style
var sqlB = "SELECT prs_bedrijfadres_url, "
+ " NVL(prs_bedrijfadres_ordermode, 0) prs_bedrijfadres_ordermode, "
+ " prs_bedrijf_email, "
+ " NVL(prs_bedrijfadres_xsl, 'xsl/cust.xsl') prs_bedrijfadres_xsl, "
+ " NVL(prs_bedrijfadres_certificate, '-') prs_bedrijfadres_certificate, "
+ " ba.mld_typeopdr_key, "
+ " NVL(ba.prs_bedrijfadres_ext, '-') prs_bedrijfadres_ext "
+ " FROM prs_bedrijf b, prs_bedrijfadres ba "
+ " WHERE b.prs_bedrijf_key = " + Bedrijf
+ " AND b.prs_bedrijf_key = ba.prs_bedrijf_key(+)"
+ " NVL(prs_bedrijfadres_ordermode, 0) prs_bedrijfadres_ordermode, "
+ " prs_bedrijf_email, "
+ " NVL(prs_bedrijfadres_xsl, 'xsl/cust.xsl') prs_bedrijfadres_xsl, "
+ " NVL(prs_bedrijfadres_certificate, '-') prs_bedrijfadres_certificate, "
+ " ba.mld_typeopdr_key, "
+ " NVL(ba.prs_bedrijfadres_ext, '-') prs_bedrijfadres_ext "
+ " FROM prs_bedrijf b, prs_bedrijfadres ba "
+ " WHERE b.prs_bedrijf_key = " + Bedrijf_key
+ " AND b.prs_bedrijf_key = ba.prs_bedrijf_key(+)"
switch (XMLnode)
{
@@ -77,7 +78,7 @@ function sendAllOrders(CustomerId)
// Moet ik hier zelf nog het opdrachttype gaan opzoeken?? Ja.
var sqlOT = "SELECT mld_typeopdr_key"
+ " FROM mld_opdr"
+ " WHERE mld_opdr_key = " + Opdrkey;
+ " WHERE mld_opdr_key = " + OpdrKey;
Log2File(2, sqlOT);
var oRsOT = Oracle.Execute(sqlOT);
if (!oRsOT.Eof)
@@ -112,7 +113,7 @@ function sendAllOrders(CustomerId)
var oRsB = Oracle.Execute(sqlB);
if (oRsB.Eof)
{
Log2File(0, "Bedrijf is niet goed geconfigureerd: " + Bedrijf);
Log2File(0, "Bedrijf is niet goed geconfigureerd: " + Bedrijf_key);
}
else
{
@@ -138,7 +139,7 @@ function sendAllOrders(CustomerId)
var AttachPath = "" // (nog) niet voor bestellingen
if (XMLnode == "opdracht")
AttachPath = S("puo_flexfilesfolder") + "MLD/" + subfolderKey("O", toString(OpdrKey)) + "/";
AttachPath = S("puo_flexfilesfolder") + "MLD/" + subfolderKey("O", String(OpdrKey)) + "/";
if (Sender == "-")
Sender = "";
@@ -176,7 +177,7 @@ function sendAllOrders(CustomerId)
var sqlC = "BEGIN "
+ (cust == 0 ? "FAC" : CustomerId) + ".markorderassent(" + safe.quoted_sql(XMLnode)
+ ", " + Opdrkey
+ ", " + OpdrKey
+ ", " + SendOrderResult.sendorder
+ ", " + safe.quoted_sql(SendOrderResult.errtext)
+ ");"
@@ -187,7 +188,7 @@ function sendAllOrders(CustomerId)
if (SendOrderResult.sendorder == 0 || SendOrderResult.sendorder == 2)
{
Log2File(1, "File sent");
switch(oRs("xmlnode"))
switch(oRs("xmlnode").Value)
{
case "opdracht": MLDRecSaved += 1; break;
case "bestelopdr": BESRecSaved += 1; break;
@@ -211,12 +212,12 @@ function sendAllOrders(CustomerId)
{
// Als er minder opdrachten verstuurd zijn dan er te versturen waren, dan noemen we dat een error
var recSaved = BESRecSaved + MLDRecSaved + CNTRecSaved + CustRecSaved;
var errLevel = (RecSaved == RecTotal ? 1 : 0);
var recMsg = " CUST:" + toString(CustRecSaved)
+ " and BES:" + toString(BESRecSaved)
+ " and MLD:" + toString(MLDRecSaved)
+ " and CNT:" + toString(CNTRecSaved)
+ " of " + toString(RecTotal)
var errLevel = (recSaved == RecTotal ? 1 : 0);
var recMsg = " CUST:" + String(CustRecSaved)
+ " and BES:" + String(BESRecSaved)
+ " and MLD:" + String(MLDRecSaved)
+ " and CNT:" + String(CNTRecSaved)
+ " of " + String(RecTotal)
+ " orders put";
Log2File(errLevel, recMsg);
}
@@ -251,7 +252,7 @@ function getMailSubject(pXMLnode, pOpdrKey)
{
case "opdracht":
{
MailSubject = S("puo_subjectprefixmld");
MailSubject = S("puo_subjectprefixmld")||S("puo_subjectprefix");
sqlS = "SELECT mld.opdrsprintf(" + safe.quoted_sql(MailSubject) + "," + pOpdrKey + ") subj FROM DUAL";
break;
}
@@ -263,7 +264,7 @@ function getMailSubject(pXMLnode, pOpdrKey)
}
case "contract":
{
MailSubject = S("puo_subjectprefixcnt");
MailSubject = S("puo_subjectprefixcnt")||S("puo_subjectprefix");
sqlS = "SELECT cnt.sprintf(" + safe.quoted_sql(MailSubject) + "," + pOpdrKey + ") subj FROM DUAL";
break;
}

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_base64.js $Revision$
// * $Id$
// *
// * encode()
// * decode()

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_connector.js $Revision$
// * $Id$
// *
// * connect()
// * disconnect()
@@ -60,7 +60,7 @@ function ConnectorCls()
{
Log2File(1, "Creating connector...");
var about = new ActiveXObject("SLNKDWF.About");
Log2File(1, "Ge<47>nstalleerde SLNKDWF Versie: " + about.VersionString);
Log2File(2, "Ge<47>nstalleerde SLNKDWF Versie: " + about.VersionString);
Log2File(2, about.All);
//
return new ActiveXObject("SLNKDWF.FTP");
@@ -80,10 +80,10 @@ function ConnectorCls()
this.disconnect();
Log2File(1, "Connecting to " + url + "...");
if (!S("puo_forceorderaddress"))
if (S("puo_forceorderaddress"))
{
url = S("puo_forceorderaddress");
Log2File(1, "Using: " + url + "...");
Log2File(1, "effective: " + url + "...");
}
var URLAdres = url;
@@ -124,13 +124,13 @@ function ConnectorCls()
this.connection.Username = URLParts.user;
this.connection.Password = URLParts.password;
//
Log2File(1, "protocol: http");
Log2File(1, "protocol: https");
Log2File(1, "Login/Wachtwoord: " + URLParts.user + "/" + URLParts.password);
this.Connected = true;
break;
}
case "ftp":
{ // voorbeeld: "ftp://stravis:kloostertuin@ftp.sgfacilitor.nl/versies/"
{ // voorbeeld: "ftp://klaas:geheim@example.com/folder/"
this.ConnectionType = CONNECTION_FTP;
this.connection.Hostname = URLParts.host;
this.connection.Username = URLParts.user;
@@ -177,7 +177,7 @@ function ConnectorCls()
}
default:
{
if (URLAdres.substr(0,1) != "\\" )
if (!URLAdres.match(/\\\$/))
{
URLAdres = URLAdres + "\\";
}

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_crackurl.js $Revision$
// * $Id$
// *
// * parseUrl()
// *

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_notifications.js $Revision$
// * $Id$
// *
// * sendNotification()
// * Onderstaande functies worden alleen vanuit sendNotificatie aangeroepen:
@@ -28,24 +28,24 @@ function sendNotification(custId)
, CustId: custId
};
Log2File(1, "** START sendNotification (" + new Date() + ")");
Log2File(1, "** START sendNotification (" + toDateTimeString(new Date()) + ")");
var strDelay = (S("puo_notificationdelay") > 0 ? " AND (fac_notificatie_datum + " + S("puo_notificationdelay") + "/60/24) < SYSDATE" : "");
Log2File(3, "strDelay: " + strDelay);
var sql = "SELECT fac_notificatie_receiver_email"
+ ", fac_notificatie_receiver_phone"
+ ", fac_notificatie_oms"
+ ", fac_notificatie_status"
+ ", fac_notificatie_refkey"
+ ", fac_notificatie_key"
+ ", fac_srtnotificatie_xmlnode"
+ ", fac_srtnotificatie_code"
+ ", NVL(fac_notificatie_extrakey, -1) fac_notificatie_extrakey"
+ ", fac_notificatie_sender_email"
+ ", COALESCE(fac_notificatie_lang, 'NL') fac_notificatie_lang"
+ ", fac_notificatie_systeemadres"
+ " , fac_notificatie_receiver_phone"
+ " , fac_notificatie_oms"
+ " , fac_notificatie_status"
+ " , fac_notificatie_refkey"
+ " , fac_notificatie_key"
+ " , fac_srtnotificatie_xmlnode"
+ " , fac_srtnotificatie_code"
+ " , NVL(fac_notificatie_extrakey, -1) fac_notificatie_extrakey"
+ " , fac_notificatie_sender_email"
+ " , COALESCE(fac_notificatie_lang, 'NL') fac_notificatie_lang"
+ " , fac_notificatie_systeemadres"
+ " FROM fac_v_notifyqueue"
+ " WHERE ( BITAND (fac_notificatie_status, " + (puo_const.STATUS_EMAIL || puo_const.STATUS_SMS) + ") > 0"
+ " WHERE ( BITAND (fac_notificatie_status, " + (puo_const.STATUS_EMAIL | puo_const.STATUS_SMS) + ") > 0"
+ " OR fac_notificatie_systeemadres IS NOT NULL)"
+ strDelay
+ " ORDER BY fac_notificatie_datum DESC"
@@ -62,7 +62,7 @@ function sendNotification(custId)
+ oRs("fac_notificatie_key").value + " "
+ oRs("fac_srtnotificatie_code").value + ": "
+ oRs("fac_notificatie_refkey").value
+ " (" + new Date() + ")"
+ " (" + toDateTimeString(new Date()) + ")"
);
var XMLnode = oRs("fac_srtnotificatie_xmlnode").value || "";
var NotificationXSL = getXslName(XMLnode);
@@ -77,7 +77,7 @@ function sendNotification(custId)
Log2File(1, " " + notiMAILed + " email messages sent");
Log2File(1, " " + notiSMSed + " SMS messages sent");
Log2File(1, " " + notiSYSed + " systemadres messages sent");
Log2File(1, "** END sendNotification (" + new Date() + ")");
Log2File(1, "** END sendNotification (" + toDateTimeString(new Date()) + ")");
}
@@ -99,8 +99,8 @@ function notificationMail(rec, p_notificationXSL, params)
sendMail( sender_email
, receiver_email
, "", "", ""
, rec("fac_notificatie_oms")
, rec("fac_notificatie_oms")
, rec("fac_notificatie_oms").Value
, rec("fac_notificatie_oms").Value
, ""
, { CustId: params.CustId
, attachFileName: ""
@@ -133,7 +133,7 @@ function notificationMail(rec, p_notificationXSL, params)
, "email"
);
SubjectText = rec("fac_notificatie_oms").value;
if (rec("fac_notificatie_status").value && params.STATUS_SUMMARY_XSL)
if (rec("fac_notificatie_status").value & params.STATUS_SUMMARY_XSL)
{
// Via XSL
SubjectTextXSL = XML2HTML( xml_content
@@ -199,7 +199,7 @@ function notificationMail(rec, p_notificationXSL, params)
+ " SET fac_notificatie_status = BITAND (fac_notificatie_status, " + controle + ")"
+ " WHERE fac_notificatie_key = " + rec("fac_notificatie_key").value;
Log2File(2, sql);
// Oracle.Execute(sql);
Oracle.Execute(sql);
}
return noti_mailed;
}
@@ -271,13 +271,13 @@ function notificationSMS(rec, p_notificationXSL, params)
finally
{
// == DONE SMS ==
// Let op: bitwise AND en NOT con controle.
// Let op: bitwise AND en NOT controle.
var controle = (255 & ~params.STATUS_SMS & ~params.STATUS_SUMMARY_XSL);
sql = "UPDATE fac_notificatie"
+ " SET fac_notificatie_status = BITAND (fac_notificatie_status, " + controle + ")"
+ " SET fac_notificatie_status = BITAND (fac_notificatie_status, " + controle + ")"
+ " WHERE fac_notificatie_key = " + rec("fac_notificatie_key").value;
Log2File(2, sql);
// Oracle.Execute(sql);
Oracle.Execute(sql);
}
return noti_smsed;
@@ -290,6 +290,7 @@ function notificationSYS(rec, params)
// ======================== Systeemadres ========================
// Het systeemadres wordt niet aangemerkt als bitje in de status kolom
Log2File(1, "*> notificationSYS");
var SendOrderResult = { sendorder: 1 };
var noti_sysed = 0;
try
{
@@ -376,7 +377,7 @@ function notificationSYS(rec, params)
if (SendOrderResult.sendorder == 0)
{
sql = "UPDATE fac_notificatie"
+ " SET fac_notificatie_systeemadres = NULL "
+ " SET fac_notificatie_systeemadres = NULL "
+ " WHERE fac_notificatie_key = " + rec("fac_notificatie_key").value
Log2File(2, sql);
// Oracle.Execute(sql);

View File

@@ -1,6 +1,5 @@
<![CDATA[
/*
$Revision$
$Id$
File: put_orders.wsf
@@ -8,7 +7,8 @@
Parameters: 0: customerId
1:
Context: Scheduled task
Note:
Note: De code verondersteld (nog) dat de current folder een cust/xxxx/tasks folder is
Concreter: ../Oracle.udl wordt gebruikt
*/
]]>
@@ -30,8 +30,6 @@
<script language="JScript" src="./puo_notifications.js"/>
<script language="JScript">
__Log('$Workfile: put_orders.wsf $','$Revision$');
if (WScript.Arguments.length < 1)
{
__Log("Usage: CScript put_orders.wsf XXXX \n");
@@ -40,18 +38,18 @@
var customerId = WScript.Arguments(0);
var applicatieRun = new Date();
var Oracle = Connect2Oracle();
var Oracle = Connect2Oracle('puo_Putorders.wsf');
applyIni();
__Log("====================================================================");
__Log("PUTORDERS STARTED (" + applicatieRun + ")");
Log2File(0, "====================================================================");
Log2File(0, "PUTORDERS STARTED (" + toDateTimeString(applicatieRun) + ")");
clearDBLog();
settings.loadSet();
result = process();
__Log("PUTORDERS FINISHED (" + new Date() + ")");
Log2File(0, "PUTORDERS FINISHED (" + toDateTimeString(new Date()) + ")");
// FUNCTIES
@@ -74,7 +72,6 @@
var result = {message: "", success: false};
try
{
//settings.puo_proxyserveripaddress= "127.0.0.1:8888";
sendAllOrders(customerId);
sendNotification(customerId);
cleanPopup();
@@ -82,6 +79,7 @@
}
catch(e)
{
Log2File(0, "Error in process: " + e.description);
result.message = "Error in process: " + e.description;
}
return result;

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_sendfile.js $Revision$
// * $Id$
// *
// * sendOrder()
// *
@@ -51,7 +51,7 @@ function sendOrderCls()
Log2File(2, "extensionNode is defined");
Extension = extensionNode.text;
}
Log2File(1, "Extension: " + Extension);
Log2File(2, "Extension: " + Extension);
}
return Extension;
}
@@ -103,7 +103,7 @@ function sendOrderCls()
var HTTPresult = submitHTTP( p_connect
, p_textstream
, p_order_certificate);
if (HTTPresult >= "200" && HTTPresult <= "299")
if (HTTPresult >= 200 && HTTPresult <= 299)
{
SendOrder = 0;
}
@@ -226,7 +226,7 @@ function sendOrderCls()
var SendOrder = 0;
var errText = "";
if ( S("puo_fromaddress") != "null" && S("puo_fromaddress") != "nodefault")
if ( S("puo_fromaddress") && S("puo_fromaddress") != "null" && S("puo_fromaddress") != "nodefault")
{
// Compose mail
Log2File(2, "Before SendMail");

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_sendftp.js $Revision$
// * $Id$
// *
// * sendFTP()
// *

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_sendhttp.js $Revision$
// * $Id$
// *
// * submitHTTP()
// *

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_sendmail.js $Revision$
// * $Id$
// *
// * sendMail()
//*
@@ -108,7 +108,7 @@ function sendMail( p_mailfrom
try
{
var cdoBodyPart = objMail.BodyPart;
cdoBodyPart.Charset = S("puo_mailbodycharset"); // default "unicode-1-1-utf-7
cdoBodyPart.Charset = S("puo_mailbodycharset"); // default "unicode-1-1-utf-8
Log2File(2, "Before bodyHTML");
objMail.HtmlBody = p_bodyhtml;

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_snedsms.js $Revision$
// * $Id$
// *
// * sendSMS()
// *
@@ -42,13 +42,15 @@ function sendSMS( p_telnr
+ "&CONCAT=1"
+ "&INFO=1";
xmlHTTP.send(body);
if (xmlHTTP.status == 200)
if (xmlHTTP.status == 200 && xmlHTTP.responseText.substr(0,3) == '01=')
{
SMSsend = true;
}
else
{
Log2File(0, "xmlHTTP error " + xmlHTTP.status + ": (" + xmlHTTP.statusText + ")");
Log2File(0, "SMS xmlHTTP error "
+ xmlHTTP.status + "/ " + xmlHTTP.statusText
+ "/" + xmlHTTP.responseText);
}
}
else
@@ -67,7 +69,7 @@ function sendSMS( p_telnr
);
SMSsend = true;
}
Log2File(1, "SMS bericht: '" + escape(p_msg) + "' via " + S("puo_smsprotocol") + " verzonden naar: " + p_telnr);
Log2File(1, "SMS bericht: '" + p_msg + "' via " + S("puo_smsprotocol") + " verzonden naar: " + p_telnr);
Log2File(1, "*< sendSMS");
return SMSsend;

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_sendsoap.js $Revision$
// * $Id$
// *
// * submitDOMXSLSOAP()
// *

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_settings.js $Revision$
// * $Id$
// *
// * applyIni()
// * S()
@@ -28,11 +28,11 @@
{
// Als er nog een ini-bestand aanwezig is, kopieer dan deze instellingen naar de database.
//
fso = new ActiveXObject("Scripting.FileSystemObject");
var fso = new ActiveXObject("Scripting.FileSystemObject");
var puoini = "putorders.ini";
if (fso.FileExists(puoini))
{
__Log("Applying " + puoini);
Log2File(0, "Applying " + fso.GetAbsolutePathName(puoini));
var f = fso.OpenTextFile(puoini, 1); // 1=ForReading
var tekst = f.ReadAll();
f.Close();
@@ -48,6 +48,10 @@
for (var l in lines)
{
if (lines[l].substr(0,1) == ';')
continue;
if (lines[l].substr(0,2) == '//')
continue;
var sp = lines[l].split("=");
if (sp.length < 2)
continue;
@@ -77,7 +81,12 @@
oRs.Close();
}
} // for
// Verwijderen ini file ?
var jsDate = new Date;
var backupTime = String(jsDate.getFullYear()) + padout(jsDate.getMonth() + 1) + padout(jsDate.getDate()) + "_"
+ padout(jsDate.getHours()) + padout(jsDate.getMinutes())+ padout(jsDate.getSeconds());
var backupName = "putorders_" + backupTime + ".ini";
Log2File(0, "backupName " + backupName);
fso.MoveFile(puoini, backupName);
}
else
{
@@ -87,7 +96,10 @@
var settings = {
var settings = { // defaults voordat parameters gelezen zijn; fouten gaan nog alleen naar file (want geen db bekend)
puo_loglevel: { v: 1, t: "string" },
puo_logdestination: { v: 1, t: "string" },
loadSet : function()
{ // Laad alle settings voor put_orders uit de database
try
@@ -111,8 +123,13 @@ var settings = {
}
catch(err)
{
__Log("Error loading settings from database.");
__Log("Error loading settings from database: " + err.description);
}
// Optionele overrules in cust/custenv.wsc en cust/XXXX/custenv.inc
tryOverrule("../../custenv.wsc");
tryOverrule("../custenv.wsc");
tryOverrule("./custenv.wsc"); // deze is het sterkst sterker
},
get_setting : function (s, defval)
{
@@ -168,6 +185,14 @@ var settings = {
WScript.Quit();
}
}
},
overrule_setting : function (s, v)
{
if (settings[s.toLowerCase()])
{
Log2File(0, s + " overruled to: " + v);
settings[s.toLowerCase()].v = v;
}
}
}
@@ -175,3 +200,33 @@ function S(s, defval)
{
return settings.get_setting(s, defval)
}
function tryOverrule(path)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var hookfile = fso.GetAbsolutePathName(path);
if (fso.FileExists(hookfile))
{
Log2File(0, "Using overrule " + hookfile);
var hook = GetObject("script:"+hookfile);
// Deze mag de hookfile gebruiken
hook.Overrule =
{
SET: function (naam, waarde)
{
settings.overrule_setting(naam.toLowerCase(), waarde);
},
LCL: function (naam, waarde)
{
return; // doen we nog niets mee hier
//overrule_lcl[naam] = waarde;
},
APPLICATION: function (naam, waarde)
{
return; // doen we niets mee hier
}
}
hook.custenv();
hook = null; // zorg dat de GC het object kan opruimen.
}
}

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_shared.js $Revision$
// * $Id$
// *
// * Log2File()
// * cleanPopup()
@@ -8,16 +8,24 @@
// * http://www.webtoolkit.info/
// *
// ******************************************
var logfso = new ActiveXObject("Scripting.FileSystemObject");
function Log2File(level, str, fatal)
{
// uses: scr="../wsf_shared.js"
// src="./puo_settings.js"
//
var dtstr = toDateTimeString(new Date);
if (level <= 1)
WScript.Echo(dtstr + " " + str);
if( level <= S("puo_loglevel"))
{
if (S("puo_logdestination")== 1 || S("puo_logdestination")==3)
{
__Log(str);
{ // Aparte logfile per maand
var logfilename = "putorders_" + customerId + "_" + padout((new Date).getFullYear()) + "_" + padout((new Date).getMonth() + 1) + ".log";
var flog = logfso.OpenTextFile(logfilename, 8 /* ForAppending */, true /* create */);
flog.WriteLine(str);
flog.Close();
}
if (S("puo_logdestination")== 2 || S("puo_logdestination")==3 || fatal)
{
@@ -26,6 +34,9 @@ function Log2File(level, str, fatal)
if (level==1) dblevel = "I";
if (level==2) dblevel = "D";
if (fatal) dblevel = "F";
// Merk op: de trigger van imp_log zal voor fatal meldingen een notificatie naar
// WEB_PRSSYS leden sturen. Een eventuele e-mail wordt de *volgende* run
// van putorders pas verstuurd.
var sql = "INSERT INTO imp_log"
+ "( imp_log_applicatie"
+ ", imp_log_datum"
@@ -36,7 +47,7 @@ function Log2File(level, str, fatal)
+ "( '$PutOrders$'"
+ ", SYSDATE"
+ ", " + safe.quoted_sql(dblevel)
+ ", " + safe.quoted_sql(str(0, 990))
+ ", " + safe.quoted_sql(dtstr + " " + str.substr(0, 990))
+ ", ''"
+ ")";
Oracle.Execute(sql);
@@ -49,12 +60,12 @@ function cleanPopup()
{
// Wissen oude (gisteren) popups
// Met 4.80 wilden we dit eigenlijk via een FAC_JOB en package doen
Log2File(1, "** START cleanPopup (" + new Date() + ")");
Log2File(1, "** START cleanPopup (" + toDateTimeString(new Date) + ")");
var sql = "UPDATE fac_notificatie n"
+ " 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)"
__Log(sql);
Log2File(2, sql);
Oracle.Execute(sql);
}

View File

@@ -1,5 +1,5 @@
// ******************************************
// * puo_xmltools.js $Revision$
// * $Id$
// *
// * UserException()
// * RaiseAnError()
@@ -14,7 +14,6 @@
// * XML en XSL functies.
// *
// ******************************************
// XMLTools.js
//
function UserException(number, source, message)
{

View File

@@ -1,5 +1,4 @@
/*
$Revision$
$Id$
File: wsf_shared.js
@@ -45,11 +44,16 @@ function replaceAll(str, find, replace)
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
function Connect2Oracle()
function Connect2Oracle(modulename)
{
var udl = "../Oracle.udl";
var Oracle = new ActiveXObject("ADODB.Connection");
Oracle.Open('File Name='+udl);
if (modulename)
{ // Vind je terug in Toad/Session browser
var sql = "BEGIN DBMS_APPLICATION_INFO.SET_MODULE (" + safe.quoted_sql(modulename) + ", NULL); END;";
Oracle.Execute(sql);
}
sql = "BEGIN fac.initsession(NULL); END;"
Oracle.Execute(sql);
__Log("Session initiated: " + sql);