Merge versie 5.4.1 Gold C patches

svn path=/Website/trunk/; revision=21333
This commit is contained in:
Jos Groot Lipman
2014-04-16 11:46:39 +00:00
parent 99521cc58d
commit b5cc6f5ec4
8 changed files with 138 additions and 56 deletions

View File

@@ -140,6 +140,7 @@ function ConnectorCls()
this.connection.Port = URLParts.port || 21; this.connection.Port = URLParts.port || 21;
this.connection.Proxyname = (S("puo_useproxy") ? S("puo_proxyserveripaddress") : ""); this.connection.Proxyname = (S("puo_useproxy") ? S("puo_proxyserveripaddress") : "");
this.Subfolder = URLParts.directory; this.Subfolder = URLParts.directory;
this.connection.Flags = S("puo_connectionflag")||0;
// //
Log2File(1, "protocol: ftp"); Log2File(1, "protocol: ftp");
Log2File(1, "FTPServer: " + this.connection.Hostname); Log2File(1, "FTPServer: " + this.connection.Hostname);
@@ -148,6 +149,7 @@ function ConnectorCls()
Log2File(1, "FTPPort: " + this.connection.Port); Log2File(1, "FTPPort: " + this.connection.Port);
Log2File(1, "FTPProxy: " + this.connection.Proxyname); Log2File(1, "FTPProxy: " + this.connection.Proxyname);
Log2File(1, "FTPDir: " + this.Subfolder); Log2File(1, "FTPDir: " + this.Subfolder);
Log2File(1, "Flags: " + this.connection.Flags);
// //
try try
{ {

View File

@@ -74,10 +74,7 @@ function sendOrderCls()
var filename = p_connect.CurrentAddress + p_filename; var filename = p_connect.CurrentAddress + p_filename;
Log2File(1, "Sending as: " + filename + "..."); Log2File(1, "Sending as: " + filename + "...");
var objFso = new ActiveXObject("Scripting.FileSystemObject"); p_textstream.SaveToFile(filename, 2); // adSaveCreateOverWrite
var objOtf = objFso.OpenTextFile(filename, fsoForWriting, true);
objOtf.Write(p_textstream);
objOtf.Close();
var SendOrder = 0; var SendOrder = 0;
var errText = ""; var errText = "";
@@ -101,7 +98,7 @@ function sendOrderCls()
Log2File(2, "IsHTTP>"); Log2File(2, "IsHTTP>");
Log2File(1, "Sending as: " + p_filename + "..."); Log2File(1, "Sending as: " + p_filename + "...");
var SendOrder = 1; var SendOrder = -1;
var errText = ""; var errText = "";
if (p_order_mode == 0) if (p_order_mode == 0)
@@ -172,11 +169,11 @@ function sendOrderCls()
objFso = new ActiveXObject("Scripting.FileSystemObject"); objFso = new ActiveXObject("Scripting.FileSystemObject");
// De opdracht: // De opdracht:
Log2File(2, "Sending data as file: " + p_filename + " (" + p_textstream.length + " bytes)"); Log2File(2, "Sending data as file: " + p_filename + " (" + p_textstream.Size + " bytes)");
var FTPresult = sendFTP(p_connect, p_filename, p_textstream); // send text data var FTPresult = sendFTP(p_connect, p_filename, p_textstream); // send text data
// //
// Stuur alle flexfiles (type M(ap) en F(file)) ook mee // Stuur alle flexfiles (type M(ap) en F(file)) ook mee
if (p_attachfolder) if (FTPresult && p_attachfolder)
{ {
if (objFso.FolderExists(p_attachfolder)) if (objFso.FolderExists(p_attachfolder))
{ {
@@ -198,7 +195,7 @@ function sendOrderCls()
} }
} }
var SendOrder = 0; var SendOrder = -1;
var errText = ""; var errText = "";
if (FTPresult) if (FTPresult)
{ {
@@ -230,7 +227,7 @@ function sendOrderCls()
Log2File(1, "*> connectMail"); Log2File(1, "*> connectMail");
Log2File(2, "IsMail>"); Log2File(2, "IsMail>");
Log2File(1, "Sending as: " + p_filename + "..."); Log2File(1, "Sending as: " + p_filename + "...");
var SendOrder = 0; var SendOrder = -1;
var errText = ""; var errText = "";
if ( S("puo_fromaddress") && S("puo_fromaddress") != "null" && S("puo_fromaddress") != "nodefault") if ( S("puo_fromaddress") && S("puo_fromaddress") != "null" && S("puo_fromaddress") != "nodefault")
@@ -285,7 +282,7 @@ function sendOrderCls()
, S("puo_bcc") , S("puo_bcc")
, S("puo_receiptto") , S("puo_receiptto")
, p_mailsubject , p_mailsubject
, p_textstream , stream2text(p_textstream)
, "" , ""
, params , params
); );
@@ -382,6 +379,10 @@ function sendOrderCls()
} }
if (extension != "") if (extension != "")
{ {
var streamResult = new ActiveXObject("ADODB.Stream");
streamResult.Type = 2; // adTypeText
streamResult.Charset = 'utf-8';
streamResult.Open();
if (extension == "xml") if (extension == "xml")
{ {
var XMLResult = new ActiveXObject("Msxml2.DOMDocument.4.0"); var XMLResult = new ActiveXObject("Msxml2.DOMDocument.4.0");
@@ -391,14 +392,13 @@ function sendOrderCls()
// Eventuele attachements inplakken // Eventuele attachements inplakken
//Log2File 2, "Order =" + XMLResult.xml //Log2File 2, "Order =" + XMLResult.xml
XMLResult = mergeXMLAttachments(XMLResult); XMLResult = mergeXMLAttachments(XMLResult);
var streamResult = XMLResult.xml; XMLResult.save(streamResult);
} }
else // Bijvoorbeeld csv else // Bijvoorbeeld csv
{ {
streamResult = xmlDoc.transformNode(xslDoc); xmlDoc.transformNodeToObject(xslDoc, streamResult);
} }
Log2File(4, "Order =" + stream2text(streamResult));
Log2File(4, "Order =" + streamResult);
// file naam mag geen / bevatten // file naam mag geen / bevatten
var filename = p_ordernr + "." + extension; var filename = p_ordernr + "." + extension;

View File

@@ -8,30 +8,37 @@
// ****************************************** // ******************************************
function sendFTP(p_connect, p_file, p_data, p_path) function sendFTP(p_connect, p_file, p_data, p_path)
{ {
var objFso = new ActiveXObject("Scripting.FileSystemObject");
Log2File(1, "*> sendFTP"); Log2File(1, "*> sendFTP");
var FTPsend = false; var FTPsend = false;
if (p_connect.Connected) if (p_connect.Connected)
{ {
try try
{ {
if (p_path) if (p_path)
{ {
objFso = new ActiveXObject("Scripting.FileSystemObject");
objFile = objFso.GetFile(p_path); objFile = objFso.GetFile(p_path);
Log2File(1, "Transfer file: " + p_file + " (size: " + objFile.Size + ")"); Log2File(1, "Transfer file: " + p_file + " (size: " + objFile.Size + ")");
p_connect.connection.PutFile(p_file, p_path); // Hiermee kunnen ook binary bestanden gekopieerd worden. p_connect.connection.PutFile(p_file, p_path); // Hiermee kunnen ook binary bestanden gekopieerd worden.
} }
else else
{ { // Forceer p_data altijd naar utf-8
Log2File(1, "Transfer file: " + p_file + " (size: " + p_data.length + ")"); var tempfile = "../../../temp/puo_" + objFso.GetTempName();
p_connect.connection.PutFileFromTextData(p_file, p_data); // Alleen een tekst-string schrijven. p_data.SaveToFile(tempfile);
Log2File(1, "Transfer data as file: " + p_file + " (size: " + p_data.Size + ")");
p_connect.connection.PutFile(p_file, tempfile); // Hiermee kunnen ook binary bestanden gekopieerd worden.
if (S("puo_loglevel") < 4)
objFso.DeleteFile(tempfile);
// schrijft geen utf-8
// p_connect.connection.PutFileFromTextData(p_file, p_data.ReadText()); // Alleen een tekst-string schrijven.
} }
FTPsend = true; FTPsend = true;
} }
catch(e) catch(e)
{ {
Log2File(0, "Error sending " + p_file + ": " + e.description); Log2File(0, "Error sending " + p_file + ": " + e.description);
FTPsend = false;
} }
} }
Log2File(1, "*< sendFTP"); Log2File(1, "*< sendFTP");

View File

@@ -37,7 +37,7 @@ function sendMail( p_mailfrom
var params = { attachFileName: p_params.attachFileName || "" var params = { attachFileName: p_params.attachFileName || ""
, attachFolder: p_params.attachFolder || "" , attachFolder: p_params.attachFolder || ""
, attachPassword: p_params.attachPassword || "" , attachPassword: p_params.attachPassword || ""
, attachStream: p_params.attachStream || "" , attachStream: p_params.attachStream
, CustId: p_params.CustId || "" , CustId: p_params.CustId || ""
}; };
objConf = new ActiveXObject("CDO.Configuration"); objConf = new ActiveXObject("CDO.Configuration");
@@ -93,7 +93,6 @@ function sendMail( p_mailfrom
cdoBodyPart.ContentMediaType = "text/html"; cdoBodyPart.ContentMediaType = "text/html";
cdoBodyPart.ContentTransferEncoding = "7bit"; cdoBodyPart.ContentTransferEncoding = "7bit";
objStrm = cdoBodyPart.GetDecodedContentStream(); objStrm = cdoBodyPart.GetDecodedContentStream();
objStrm.Charset = 'utf-8'; // In ieder geval beter dan de default iso-8859
objStrm.WriteText(p_bodyhtml); objStrm.WriteText(p_bodyhtml);
objStrm.Flush(); objStrm.Flush();
objStrm.Close(); objStrm.Close();
@@ -205,15 +204,15 @@ function sendMail( p_mailfrom
// //
if (params.attachStream) if (params.attachStream)
{ {
if (params.attachStream.length != 0) if (params.attachStream.Size != 0)
{ {
Log2File(2, "Before set addBodyPart"); Log2File(2, "Before set addBodyPart");
var cdoBodyPart = objMail.BodyPart.AddBodyPart(-1); var cdoBodyPart = objMail.BodyPart.AddBodyPart(-1);
cdoBodyPart.ContentMediaType = "text/html"; cdoBodyPart.ContentMediaType = "application/octet-stream";
cdoBodyPart.ContentTransferEncoding = "7bit"; cdoBodyPart.ContentTransferEncoding = "7bit";
objStrm = cdoBodyPart.GetDecodedContentStream(); objStrm = cdoBodyPart.GetDecodedContentStream();
objStrm.Charset = 'utf-8'; // In ieder geval beter dan de default iso-8859 params.attachStream.Position = 0;
objStrm.WriteText(params.attachStream); params.attachStream.copyTo(objStrm);
objStrm.Flush(); objStrm.Flush();
objStrm.Close(); objStrm.Close();
var objFlds = objMail.Configuration.Fields; var objFlds = objMail.Configuration.Fields;

View File

@@ -14,6 +14,12 @@ function sendSMS( p_telnr
, p_msg , p_msg
) )
{ {
if (!S("puo_uid") || !S("puo_pwd"))
{
Log2File(1, "SMS bericht: '" + p_msg + "' *niet* verzonden naar " + p_telnr + " want SMS niet geconfigureerd.");
return false;
}
Log2File(1, "*> sendSMS"); Log2File(1, "*> sendSMS");
var SXH_PROXY_SET_PROXY = 2; // contante in msxml2 var SXH_PROXY_SET_PROXY = 2; // contante in msxml2

View File

@@ -36,18 +36,18 @@ function submitDOMXSLSOAP( p_connect
{ {
if (p_order_mode & 8) if (p_order_mode & 8)
{ {
XMLpayloadDoc.loadXML(p_textstream); XMLpayloadDoc.load(p_textstream);
Log2File(3, "XMLpayloadDoc.documentElement = " + XMLpayloadDoc.documentElement.xml); Log2File(3, "XMLpayloadDoc.documentElement = " + XMLpayloadDoc.documentElement.xml);
XMLpayloadNode.appendChild(XMLpayloadDoc.documentElement); XMLpayloadNode.appendChild(XMLpayloadDoc.documentElement);
} }
else else
{ {
XMLpayloadNode.text = p_textstream; XMLpayloadNode.text = stream2text(p_textstream);
} }
} }
else else
{ {
XMLpayloadNode.text = Base64.encode(Base64.encode(p_textstream)); XMLpayloadNode.text = Base64.encode(Base64.encode(stream2text(p_textstream)));
} }
XMLenvelope.appendChild(XMLpayloadNode); XMLenvelope.appendChild(XMLpayloadNode);

View File

@@ -92,3 +92,11 @@ function LogResult(p_path, p_data)
fpt.Close(); fpt.Close();
} }
} }
function stream2text(stream)
{
stream.Position = 0;
var txt = stream.ReadText();
stream.Position = 0;
return txt;
}

View File

@@ -40,8 +40,8 @@
var customerId = oRs(0).Value; var customerId = oRs(0).Value;
oRs.Close(); oRs.Close();
convertIni(); convertIni();
app_key = getAppKey(export_app_id); app_key = getAppKey(export_app_id);
if (app_key == -1) if (app_key == -1)
WScript.Quit(); WScript.Quit();
@@ -52,43 +52,50 @@
ini.applrun = new Date; ini.applrun = new Date;
ini.custid = customerId.toUpperCase(); ini.custid = customerId.toUpperCase();
__Log("Start gen_import.wsf"); __Log("Start gen_export.wsf");
// if (taskScheduled(ini))
var streamParams = {streamwrite: 2};
var exportFile = getFileName(ini.prefix, ini.postfix, ini.applrun, ini.timestamp);
var expPath = checkDestination(ini.folder, exportFile, streamParams);
if (expPath.success)
{ {
preExport(ini); //
var streamData = exportToStream(ini, exportFile); var streamParams = {streamwrite: 2};
if (streamData) var exportFile = getFileName(ini.prefix, ini.postfix, ini.applrun, ini.timestamp);
{ var expPath = checkDestination(ini.folder, exportFile, streamParams);
if (expPath.success)
{
preExport(ini);
var streamData = exportToStream(ini, exportFile);
if (streamData)
{
if (ini.compress) if (ini.compress)
expPath.destination += '.zip'; expPath.destination += '.zip';
__Log("Writing: " + expPath.destination + " (" + streamData.Size + " bytes)"); __Log("Writing: " + expPath.destination + " (" + streamData.Size + " bytes)");
streamData.SaveToFile(expPath.destination, streamParams.streamwrite); streamData.SaveToFile(expPath.destination, streamParams.streamwrite);
streamData.Close(); streamData.Close();
} }
postExport(ini); postExport(ini);
} }
else else
{ {
__Log(expPath.message); __Log(expPath.message);
} }
//
// Nu de logfile schrijven // Nu de logfile schrijven
// //
var logFile = getFileName(ini.prefix, ini.logpostfix, ini.applrun, ini.timestamp); var logFile = getFileName(ini.prefix, ini.logpostfix, ini.applrun, ini.timestamp);
var logPath = checkDestination(ini.folder, logFile, streamParams); var logPath = checkDestination(ini.folder, logFile, streamParams);
if (logPath.success) if (logPath.success)
{ {
logErrors(logPath.destination, ini, {streamwrite: 2}); logErrors(logPath.destination, ini, {streamwrite: 2});
} }
else else
{ {
__Log(logPath.message); __Log(logPath.message);
}
//
// Datum in imp_schedule zetten
//
scheduledDone(ini);
} }
__Log("End gen_export.wsf"); __Log("End gen_export.wsf");
@@ -110,6 +117,7 @@
{ {
// Als er nog geen instellingen in de database zijn, kopieer dan de instellingen naar de database. // Als er nog geen instellingen in de database zijn, kopieer dan de instellingen naar de database.
// //
var sql = "SELECT * FROM fac_export_app"; var sql = "SELECT * FROM fac_export_app";
var oRs = Oracle.Execute(sql); var oRs = Oracle.Execute(sql);
if (!oRs.Eof) if (!oRs.Eof)
@@ -117,6 +125,13 @@
oRs.Close(); oRs.Close();
return; // al klaar return; // al klaar
} }
// Tijdelijke oplossing om de kolom fac_export_app_prefix 60 tekens lang te maken.
var sql = "ALTER TABLE fac_export_app MODIFY fac_export_app_prefix VARCHAR2(60)";
__Log("SQL: " + sql);
Oracle.Execute(sql);
//
var fso = new ActiveXObject("Scripting.FileSystemObject"); var fso = new ActiveXObject("Scripting.FileSystemObject");
var genini = "gen_export.ini"; var genini = "gen_export.ini";
if (fso.FileExists(genini)) if (fso.FileExists(genini))
@@ -141,6 +156,7 @@
var ExportStyleSheet = ""; var ExportStyleSheet = "";
var LogPostfix = ""; var LogPostfix = "";
var BackupTimestamp = ""; var BackupTimestamp = "";
var Manual = 0;
for (var l in lines) for (var l in lines)
{ {
@@ -174,7 +190,10 @@
LogPostfix = vl; LogPostfix = vl;
break; break;
case "backupfiletimestamp": case "backupfiletimestamp":
BackupTimestamp = vl; BackupTimestamp = vl.replace("hhmm", "HHMM");
break;
case "manual":
Manual = ((parseInt(vl) > 0) ? 2 : 0);
break; break;
} }
} }
@@ -194,6 +213,8 @@
if (!oRs.Eof) if (!oRs.Eof)
{ {
__Log("Reuse key " + oRs("fac_export_app_key").Value); __Log("Reuse key " + oRs("fac_export_app_key").Value);
var flags_old = oRs("fac_export_app_flags").Value;
var Zip = ((flags_old & 1) === 1 ? 1 : 0);
sql = "UPDATE fac_export_app" sql = "UPDATE fac_export_app"
+ " SET fac_export_app_charset = " + safe.quoted_sql(ExportCharset) + " SET fac_export_app_charset = " + safe.quoted_sql(ExportCharset)
+ " , fac_export_app_folder = " + safe.quoted_sql(ExportFolder) + " , fac_export_app_folder = " + safe.quoted_sql(ExportFolder)
@@ -202,6 +223,7 @@
+ " , fac_export_app_xsl = " + safe.quoted_sql(ExportStyleSheet) + " , fac_export_app_xsl = " + safe.quoted_sql(ExportStyleSheet)
+ " , fac_export_app_log_postfix = " + safe.quoted_sql(LogPostfix) + " , fac_export_app_log_postfix = " + safe.quoted_sql(LogPostfix)
+ " , fac_export_app_timestamp = " + safe.quoted_sql(BackupTimestamp) + " , fac_export_app_timestamp = " + safe.quoted_sql(BackupTimestamp)
+ " , fac_export_app_flags = " + (Manual | Zip)
+ " WHERE fac_export_app_key = " + oRs("fac_export_app_key").Value + " WHERE fac_export_app_key = " + oRs("fac_export_app_key").Value
//__Log(sql); //__Log(sql);
Oracle.Execute(sql); Oracle.Execute(sql);
@@ -220,6 +242,7 @@
+ ", fac_functie_key" + ", fac_functie_key"
+ ", fac_export_app_log_postfix" + ", fac_export_app_log_postfix"
+ ", fac_export_app_timestamp" + ", fac_export_app_timestamp"
+ ", fac_export_app_flags"
+ ") " + ") "
+ "SELECT " + safe.quoted_sql(sectienaam) + "SELECT " + safe.quoted_sql(sectienaam)
+ " , 'From gen_export.ini '||" + safe.quoted_sql(sectienaam) + " , 'From gen_export.ini '||" + safe.quoted_sql(sectienaam)
@@ -231,6 +254,7 @@
+ " , fac_functie_key" + " , fac_functie_key"
+ " , " + safe.quoted_sql(LogPostfix) + " , " + safe.quoted_sql(LogPostfix)
+ " , " + safe.quoted_sql(BackupTimestamp) + " , " + safe.quoted_sql(BackupTimestamp)
+ " , " + Manual
+ " FROM fac_functie" + " FROM fac_functie"
+ " WHERE fac_functie_code = 'WEB_PRSSYS'"; // veilig + " WHERE fac_functie_code = 'WEB_PRSSYS'"; // veilig
//__Log(sql); //__Log(sql);
@@ -347,5 +371,41 @@
return result; return result;
} }
function taskScheduled(params)
{
// Look if there is a task in the table IMP_SCHEDULE if Manual = 1
var result = true;
if (params.manual)
{
var sql = "SELECT imp_schedule_key FROM imp_schedule"
+ " WHERE imp_schedule_done IS NULL"
+ " AND imp_schedule_name = " + safe.quoted_sql(params.code);
__Log("SQL: " + sql);
var oRs = Oracle.Execute(sql);
if (oRs.eof)
{
__Log("Not scheduled. Skipping.");
result = false;
}
oRs.Close();
}
return result;
}
function scheduledDone(params)
{
if (params.manual)
{
var sql = "UPDATE imp_schedule"
+ " SET imp_schedule_done = SYSDATE"
+ " WHERE imp_schedule_done IS NULL"
+ " AND imp_schedule_name = " + safe.quoted_sql(params.code);
__Log("SQL: " + sql);
Oracle.Execute(sql);
}
}
</script> </script>
</job> </job>