我已经在技术支持团队中担任新角色,并负责解决我们的夜间数据提取失败的持续和间歇性问题。
提取过程每晚发送一个数据文件,其中包含当天完成的交易记录。计划任务每晚运行,如果第一次失败则运行第二次,然后根据状态发送电子邮件通知。
计划任务打开一个CMD文件,然后运行JS脚本命令以在SQL数据库上执行自定义存储过程。 每天晚上,文件将替换为新文件,此逻辑将状态写入文件。
以下是输出日志信息,表示无效的呼叫错误:
Custom_Extract_Second_Run.js于2016年1月19日星期二晚上8:15:00开始 C:\ DataExtract \ Custom_Extract_Second_Run.js(341,4)Microsoft JScript运行时错误:无效的过程调用或参数
Custom_Extract.js于2016年1月20日星期三下午8:03:00开始 脚本导致异常。 例外号码:0x5007 说明:' objRs.EOF'是null还是不是对象 任务于2016年1月20日星期三晚上8:08:13结束。发送的总消息数:0
Custom_Extract_Second_Run.js于2016年1月20日星期三晚上8:15:00开始 任务于2016年1月20日星期三下午8:20:00结束。发送的总消息数:1
Custom_Extract.js于2016年1月21日星期四下午8:03:01开始 脚本导致异常。 例外号码:0x5007 说明:' objRs.EOF'是null还是不是对象 任务于2016年1月21日星期四下午8:07:56结束。发送的总消息数:0
Custom_Extract_Second_Run.js于2016年1月21日星期四晚上8:15:00开始 脚本导致异常。 例外号码:0x3704 描述:关闭对象时不允许操作。 任务于2016年1月21日星期四晚上8:19:49结束。发送的总消息数:0
Custom_Extract.js于2016年1月22日星期五晚上8:03:00开始 C:\ DataExtract \ Custom_Extract.js(318,4)Microsoft JScript运行时错误:无效的过程调用或参数
Custom_Extract_Second_Run.js于2016年1月22日星期五晚上8:15:00开始 C:\ DataExtract \ Custom_Extract_Second_Run.js(341,4)Microsoft JScript运行时错误:无效的过程调用或参数
我们不得不对用于计算其实际行为方式的脚本进行反向工程,但不能在自信的水平上进行更改。提取逻辑是很久以前开发的(10到12年前),因此可能是非常陈旧和过时的逻辑。
以下是摘录中使用的javascript逻辑。
var QUERY_NAME_1 = "Custom_Extract";
var QUERY_NAME_2 = "Custom_Extract_UpdateDate";
var LOG_FILE_NAME = "DataExtract_error.log";
var EXTRACT_FILE_NAME = "Extract";
var DB_SERVER_NAME = "sql6";
var DB_DATABASE_NAME = "database_name";
var DB_DATABASE_USER_NAME = "username";
var DB_DATABASE_PASSWORD = "password";
var DateTimeNow = new Date();
var DATE_VALUE = DateTimeNow.getDate() + "/" + (DateTimeNow.getMonth() + 1) + "/" + DateTimeNow.getFullYear();
var EMAIL_SUBJECT_HEADER = "Email Extract Header - Extract Date - " + DATE_VALUE;
var EMAIL_SUBJECT = EMAIL_SUBJECT_HEADER + " Successful";
var EMAIL_SUBJECT_ERROR = "Unsuccessful - " + EMAIL_SUBJECT_HEADER;
var EmailCount = 0;
var DELIMITER = "|";
var STRING_SQL_FAILED = "SQL Failed";
var strScript = "";
var strMsg = "";
var ARG_REPORT_PATH = "";
var ARG_MAIL_SERVER = "";
var ARG_KEEP_BACKUP_COPIES = 0;
var ARG_EMAIL_FROM = "";
var ARG_EMAIL_TO = "";
function ParseCommandLineParams() {
var cmdArgs = WScript.Arguments;
for (i = 0; i < cmdArgs.length; i++) {
// Get next argument
arg = cmdArgs(i);
// Each argument is in the form a=b. Split the two components
j = arg.search(/=/);
if (j == -1) {
WScript.Echo("Invalid arguments arg = " + arg);
return false;
}
argName = arg.substring(0, j);
argValue = arg.substring(j + 1, arg.length);
switch (argName) {
case "/reportPath":
ARG_REPORT_PATH = argValue;
break;
case "/mailServer":
ARG_MAIL_SERVER = argValue;
break;
case "/keepBackupCopies":
ARG_KEEP_BACKUP_COPIES = parseInt(argValue);
break;
case "/from":
ARG_EMAIL_FROM = argValue;
break;
case "/to":
ARG_EMAIL_TO = argValue;
break;
default:
WScript.Echo("Invalid arguments. Name = '" + argName + "' Value = '" + argValue + "'");
return false;
}
}
return true;
}
function DisplayUsage() {
WScript.Echo("Usage: cscript DataExtract.js");
WScript.Echo(" [/m=<Report path directory where it creates file>]");
WScript.Echo(" [/from=<from-line in email>] [/to=<to-line in email>]");
WScript.Echo(" [/machinename=<Email Server name>] [/databaseConfig=<Database Config Setting file>]");
WScript.Echo(" ");
WScript.Echo(" /m - unc path to mail directory (default: ..\\reports\\)");
WScript.Echo(" /from - from-line in email (default: Tejas Magia <>");
WScript.Echo(" /to - to-line in email (default: Tejas Magia <>");
WScript.Echo(" /machinename - email server name (default: EXCHANGE2 ");
WScript.Echo(" /databaseConfig - DataBase Setup Config (default: ..\\..\\..\\..\\config\\config.txt ");
return;
}
function DisplayParameters() {
WScript.Echo("Parameters:");
WScript.Echo(" ARG_REPORT_PATH=[" + ARG_REPORT_PATH + "]");
WScript.Echo(" ARG_EMAIL_FROM=[" + ARG_EMAIL_FROM + "]");
WScript.Echo(" ARG_EMAIL_TO=[" + ARG_EMAIL_TO + "]");
WScript.Echo(" ARG_MAIL_SERVER=[" + ARG_MAIL_SERVER + "]");
WScript.Echo(" DB_SERVER_NAME=[" + DB_SERVER_NAME + "]");
WScript.Echo(" DB_DATABASE_NAME=[" + DB_DATABASE_NAME + "]");
return;
}
function GetConfigCDO() {
var objConf = WScript.CreateObject("CDO.Configuration");
objFields = objConf.Fields;
objFields.Item("http://schemas.Microsoft.com/cdo/configuration/sendusing") = 2;
objFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ARG_MAIL_SERVER;
objFields.Item("http://schemas.Microsoft.com/cdo/configuration/smtpserverport") = 25;
objFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30;
objFields.Update();
return objConf;
}
function GetDatabaseConnection() {
// SQLOLEDB is very sensitive to noise between client & server, and always mistaken certain
// noise as returned result set; ODBC is better way to go for now
var objCon = WScript.CreateObject("ADODB.Connection");
objCon.Open(
"Driver={Sql Server};APP=" + strScript +
";Server=" + DB_SERVER_NAME +
";Database=" + DB_DATABASE_NAME +
";user id=" + DB_DATABASE_USER_NAME +
";password=" + DB_DATABASE_PASSWORD +
";OLE DB Services=0"
);
return objCon;
}
//
// BEGIN MAIN PROGRAM
//
strMsg = "**************************************************";
WScript.Echo(strMsg);
WScript.StdErr.WriteLine(strMsg);
strScript = String(WScript.ScriptName);
DateTimeNow = new Date();
strMsg = strScript + " started at " + DateTimeNow.toLocaleString();
WScript.Echo(strMsg);
WScript.StdErr.WriteLine(strMsg);
if (!ParseCommandLineParams()) {
DisplayUsage();
WScript.Quit(0);
}
DisplayParameters();
try {
var objCon = GetDatabaseConnection();
var objCmd = WScript.CreateObject("ADODB.Command");
objCmd.ActiveConnection = objCon;
objCmd.CommandText = QUERY_NAME_1;
objCmd.CommandType = 4; // adCmdStoredProc
objCmd.CommandTimeout = 1800;
var objParam = objCmd.CreateParameter("Return", 3, 4); // adInteger, adParamReturnValue
objCmd.Parameters.Append(objParam);
WScript.Echo("Before execution");
if (ARG_KEEP_BACKUP_COPIES == 1) {
var objFSO = WScript.CreateObject("Scripting.FileSystemObject");
if (objFSO.FileExists(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "3.txt")) {
var File3 = objFSO.GetFile(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "3.txt");
File3.Delete();
}
if (objFSO.FileExists(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "2.txt")) {
var File2 = objFSO.GetFile(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "2.txt");
File2.Move(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "3.txt");
}
if (objFSO.FileExists(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "1.txt")) {
var File1 = objFSO.GetFile(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "1.txt");
File1.Move(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "2.txt");
}
if (objFSO.FileExists(ARG_REPORT_PATH + EXTRACT_FILE_NAME + ".txt")) {
var File0 = objFSO.GetFile(ARG_REPORT_PATH + EXTRACT_FILE_NAME + ".txt");
File0.Move(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "1.txt");
}
}
var objRs = null;
try {
objRs = objCmd.Execute();
} catch (er) {
try {
objRs = objCmd.Execute();
} catch (er2) {
try {
objRs.Close();
} catch (er3) {
WScript.Echo("Error found even after 2nd run attempt!");
}
var strError = "First run failed";
// Send error email
var objConf = GetConfigCDO();
var objMsg = WScript.CreateObject("CDO.Message");
objMsg.Configuration = objConf;
// objMsg.To = ARG_EMAIL_TO;
objMsg.To = "support@sumtotal.com.au";
objMsg.From = ARG_EMAIL_FROM;
objMsg.Subject = EMAIL_SUBJECT_ERROR;
objMsg.TextBody = strError;
objMsg.send();
// Log error in output file
var objTStreamLE = objFSO.CreateTextFile(ARG_REPORT_PATH + EXTRACT_FILE_NAME + ".txt", true);
objTStreamLE.WriteLine(strError);
objTStreamLE.Close();
}
}
if (objRs.EOF) {
objRs.Close();
// check return code after closing the record set
var rc = objCmd(0);
if (rc == 100010) {
WScript.Echo("Another instance is running. Bail out");
} else if (rc == 0) {
WScript.Echo("Found no records for users");
} else {
var objError = new Error(rc, STRING_SQL_FAILED);
throw objError;
}
} else {
// Update Last Update Date
objCmd.ActiveConnection = objCon;
objCmd.CommandText = QUERY_NAME_2;
objCmd.CommandType = 4; // adCmdStoredProc
objCmd.CommandTimeout = 1800;
objCmd.Execute();
var objTStreamLE = objFSO.CreateTextFile(ARG_REPORT_PATH + EXTRACT_FILE_NAME + ".txt", true);
while (true) {
if (objRs.EOF) {
// we have to send the last mail
strContentType = "";
} else {
var strApplicantID = new String(objRs("EmpID"));
var strCourse_Code = new String(objRs("Event_Code"));
var strCourse_Name = new String(objRs("Course_Name"));
var strCompletion_Date = new String(objRs("Completion_Date"));
var strGrade_Name = new String(objRs("Grade_Name"));
var strBodyInfo = strApplicantID + DELIMITER +
strCourse_Code + DELIMITER +
strCourse_Name + DELIMITER +
strCompletion_Date + DELIMITER +
strGrade_Name;
WScript.Echo(strBodyInfo);
objTStreamLE.WriteLine(strBodyInfo);
}
if (objRs.EOF) {
break;
}
objRs.MoveNext;
}
objTStreamLE.Close();
objRs.Close();
}
var objConf = GetConfigCDO();
var objMsg = WScript.CreateObject("CDO.Message");
objMsg.Configuration = objConf;
objMsg.To = ARG_EMAIL_TO;
objMsg.From = ARG_EMAIL_FROM;
objMsg.Subject = EMAIL_SUBJECT;
objMsg.TextBody = EMAIL_SUBJECT;
objMsg.send();
EmailCount++; // How many email sent. it will be always one email in this case.
objCon.Close();
} catch (e) {
var objFSO = WScript.CreateObject("Scripting.FileSystemObject");
var objTStreamErrorLog = objFSO.CreateTextFile(errorFile, true);
objTStreamErrorLog.WriteLine(strMsg);
if (e.description == STRING_SQL_FAILED) {
strMsg = "Failed to execute " + QUERY_NAME_1 + ".\nReturn code:" + String(e.number);
} else {
strMsg = "Script causes an exception.\nException number: 0x" + String(e.number & 0xFFFF) + "\nDescription:" + e.description;
}
objTStreamErrorLog.WriteLine(strMsg);
objTStreamErrorLog.close();
var errorFile = ARG_REPORT_PATH + LOG_FILE_NAME;
var theFile_1_Abs = objFSO.GetAbsolutePathName(errorFile);
var objConf = GetConfigCDO();
var objMsg = WScript.CreateObject("CDO.Message");
objMsg.Configuration = objConf;
objMsg.To = ARG_EMAIL_TO + ";" + ARG_EMAIL_FROM;
objMsg.From = ARG_EMAIL_FROM;
objMsg.Subject = EMAIL_SUBJECT_ERROR;
objMsg.TextBody = "The attached file contains a error log file of any issues that arose during the DataExtract process";
objMsg.AddAttachment(theFile_1_Abs);
objMsg.send();
WScript.StdErr.WriteLine(strMsg);
WScript.Echo(strMsg);
objFSO.DeleteFile(errorFile); // delete log file generated.
var objShell = WScript.CreateObject("WScript.Shell");
if (!objShell.LogEvent(1, "iX Learning Server Task(" + strScript + "): " + strMsg)) {
WScript.StdErr.WriteLine("Failed to log an event");
}
}
DateTimeNow = new Date();
strMsg = "Task ended at " + DateTimeNow.toLocaleString() + ". Total Messages Sent: " + EmailCount.toString();
WScript.Echo(strMsg);
WScript.StdErr.WriteLine(strMsg);
//
// END MAIN PROGRAM
//
&#13;
第二轮
var QUERY_NAME_1 = "Custom_Extract_Second_Run";
var QUERY_NAME_2 = "Custom_Extract_UpdateDate";
var QUERY_NAME_3 = "Custom_Extract_GetRunStatus";
var LOG_FILE_NAME = "DataExtract_error.log";
var EXTRACT_FILE_NAME = "Extract";
var DB_SERVER_NAME = "sql6";
var DB_DATABASE_NAME = "database_name";
var DB_DATABASE_USER_NAME = "username";
var DB_DATABASE_PASSWORD = "password";
var DateTimeNow = new Date();
var DATE_VALUE = DateTimeNow.getDate() + "/" + (DateTimeNow.getMonth()+1) + "/" + DateTimeNow.getFullYear();
var EMAIL_SUBJECT_HEADER = "Email Extract Header - Extract Date - " + DATE_VALUE;
var EMAIL_SUBJECT = EMAIL_SUBJECT_HEADER + " Successful";
var EMAIL_SUBJECT_ERROR = "Unsuccessful - " + EMAIL_SUBJECT_HEADER;
var EmailCount = 0;
var DELIMITER = "|";
var STRING_SQL_FAILED = "SQL Failed";
var strScript = "";
var strMsg = "";
var ARG_REPORT_PATH = "";
var ARG_MAIL_SERVER = "";
var ARG_KEEP_BACKUP_COPIES = 0;
var ARG_EMAIL_FROM = "";
var ARG_EMAIL_TO = "";
function ParseCommandLineParams()
{
var cmdArgs = WScript.Arguments;
for(i = 0; i < cmdArgs.length; i++)
{
// Get next argument
arg = cmdArgs(i);
// Each argument is in the form a=b. Split the two components
j = arg.search(/=/);
if(j == -1)
{
WScript.Echo("Invalid arguments arg = " + arg);
return false;
}
argName = arg.substring(0, j);
argValue = arg.substring(j+1, arg.length);
switch(argName)
{
case "/reportPath":
ARG_REPORT_PATH = argValue;
break;
case "/mailServer":
ARG_MAIL_SERVER = argValue;
break;
case "/keepBackupCopies":
ARG_KEEP_BACKUP_COPIES = parseInt(argValue);
break;
case "/from":
ARG_EMAIL_FROM = argValue;
break;
case "/to":
ARG_EMAIL_TO = argValue;
break;
default:
WScript.Echo("Invalid arguments. Name = '" + argName + "' Value = '" + argValue + "'");
return false;
}
}
return true;
}
function DisplayUsage()
{
WScript.Echo("Usage: cscript DataExtract.js");
WScript.Echo(" [/m=<Report path directory where it creates file>]");
WScript.Echo(" [/from=<from-line in email>] [/to=<to-line in email>]");
WScript.Echo(" [/machinename=<Email Server name>] [/databaseConfig=<Database Config Setting file>]");
WScript.Echo(" ");
WScript.Echo(" /m - unc path to mail directory (default: ..\\reports\\)");
WScript.Echo(" /from - from-line in email (default: Tejas Magia <>");
WScript.Echo(" /to - to-line in email (default: Tejas Magia <>");
WScript.Echo(" /machinename - email server name (default: EXCHANGE2 ");
WScript.Echo(" /databaseConfig - DataBase Setup Config (default: ..\\..\\..\\..\\config\\config.txt ");
return;
}
function DisplayParameters()
{
WScript.Echo("Parameters:");
WScript.Echo(" ARG_REPORT_PATH=[" + ARG_REPORT_PATH + "]");
WScript.Echo(" ARG_EMAIL_FROM=[" + ARG_EMAIL_FROM + "]");
WScript.Echo(" ARG_EMAIL_TO=[" + ARG_EMAIL_TO +"]");
WScript.Echo(" ARG_MAIL_SERVER=["+ ARG_MAIL_SERVER +"]");
WScript.Echo(" DB_SERVER_NAME=[" + DB_SERVER_NAME + "]");
WScript.Echo(" DB_DATABASE_NAME=[" + DB_DATABASE_NAME+ "]");
return;
}
function GetConfigCDO()
{
var objConf = WScript.CreateObject("CDO.Configuration");
objFields = objConf.Fields;
objFields.Item("http://schemas.Microsoft.com/cdo/configuration/sendusing") = 2;
objFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = ARG_MAIL_SERVER;
objFields.Item("http://schemas.Microsoft.com/cdo/configuration/smtpserverport") = 25;
objFields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30;
objFields.Update();
return objConf;
}
function GetDatabaseConnection()
{
// SQLOLEDB is very sensitive to noise between client & server, and always mistaken certain
// noise as returned result set; ODBC is better way to go for now
var objCon = WScript.CreateObject("ADODB.Connection");
objCon.Open(
"Driver={Sql Server};APP=" + strScript +
";Server=" + DB_SERVER_NAME +
";Database=" + DB_DATABASE_NAME +
";user id=" + DB_DATABASE_USER_NAME +
";password=" + DB_DATABASE_PASSWORD +
";OLE DB Services=0"
);
return objCon;
}
//
// BEGIN MAIN PROGRAM
//
strMsg = "**************************************************";
WScript.Echo(strMsg);
WScript.StdErr.WriteLine(strMsg);
strScript = String(WScript.ScriptName);
DateTimeNow = new Date();
strMsg = strScript + " started at " + DateTimeNow.toLocaleString();
WScript.Echo(strMsg);
WScript.StdErr.WriteLine(strMsg);
if (!ParseCommandLineParams())
{
DisplayUsage();
WScript.Quit(0);
}
DisplayParameters();
try
{
var objCon = GetDatabaseConnection();
var objCmd = WScript.CreateObject("ADODB.Command");
var objRs = null;
var runStatus = 0;
try
{
// Get Run Status
objCmd.ActiveConnection = objCon;
objCmd.CommandText = QUERY_NAME_3;
objCmd.CommandType = 4; // adCmdStoredProc
objCmd.CommandTimeout = 1800;
objRs = objCmd.Execute();
runStatus = objRs("Status");
}
catch (er5)
{
}
if (runStatus < 1)
{
objCmd.ActiveConnection = objCon;
objCmd.CommandText = QUERY_NAME_1;
objCmd.CommandType = 4; // adCmdStoredProc
objCmd.CommandTimeout = 1800;
var objParam = objCmd.CreateParameter("Return", 3, 4); // adInteger, adParamReturnValue
objCmd.Parameters.Append(objParam);
WScript.Echo("Before execution");
if (ARG_KEEP_BACKUP_COPIES == 1)
{
var objFSO = WScript.CreateObject("Scripting.FileSystemObject");
if (objFSO.FileExists(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "3.txt"))
{
var File3 = objFSO.GetFile(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "3.txt");
File3.Delete();
}
if (objFSO.FileExists(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "2.txt"))
{
var File2 = objFSO.GetFile(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "2.txt");
File2.Move(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "3.txt");
}
if (objFSO.FileExists(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "1.txt"))
{
var File1 = objFSO.GetFile(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "1.txt");
File1.Move(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "2.txt");
}
if (objFSO.FileExists(ARG_REPORT_PATH + EXTRACT_FILE_NAME + ".txt"))
{
var File0 = objFSO.GetFile(ARG_REPORT_PATH + EXTRACT_FILE_NAME + ".txt");
File0.Move(ARG_REPORT_PATH + EXTRACT_FILE_NAME + "1.txt");
}
}
try
{
objRs = objCmd.Execute();
}
catch (er)
{
try
{
objRs = objCmd.Execute();
}
catch (er2)
{
try
{
objRs.Close();
}
catch (er3)
{
WScript.Echo("Error found even after 2nd run attempt!");
}
var strError = "An unexpected error has occured during the run of this routine. " +
"and send through a manual extract. If you do not hear back from us by 1pm, please do not hesitate to call " +
".";
// Send error email
var objConf = GetConfigCDO();
var objMsg = WScript.CreateObject("CDO.Message");
objMsg.Configuration = objConf;
objMsg.To = ARG_EMAIL_TO + ";email@email.com.au";
// objMsg.To = ARG_EMAIL_TO;
objMsg.From = ARG_EMAIL_FROM;
objMsg.Subject = EMAIL_SUBJECT_ERROR;
objMsg.TextBody = strError;
objMsg.send();
// Log error in output file
var objTStreamLE = objFSO.CreateTextFile(ARG_REPORT_PATH + EXTRACT_FILE_NAME + ".txt", true);
objTStreamLE.WriteLine(strError);
objTStreamLE.Close();
}
}
if (objRs.EOF)
{
objRs.Close();
// check return code after closing the record set
var rc = objCmd(0);
if (rc == 100010)
{
WScript.Echo("Another instance is running. Bail out");
}
else if (rc == 0)
{
WScript.Echo("Found no records for users");
}
else
{
var objError = new Error(rc, STRING_SQL_FAILED);
throw objError;
}
}
else
{
// Update Last Update Date
objCmd.ActiveConnection = objCon;
objCmd.CommandText = QUERY_NAME_2;
objCmd.CommandType = 4; // adCmdStoredProc
objCmd.CommandTimeout = 1800;
objCmd.Execute();
var objTStreamLE = objFSO.CreateTextFile(ARG_REPORT_PATH + EXTRACT_FILE_NAME + ".txt", true);
while (true)
{
if (objRs.EOF)
{
// we have to send the last mail
strContentType = "";
}
else
{
var strApplicantID = new String(objRs("EmpID"));
var strCourse_Code = new String(objRs("Event_Code"));
var strCourse_Name = new String(objRs("Course_Name"));
var strCompletion_Date = new String(objRs("Completion_Date"));
var strGrade_Name = new String(objRs("Grade_Name"));
var strBodyInfo = strApplicantID + DELIMITER +
strCourse_Code + DELIMITER +
strCourse_Name + DELIMITER +
strCompletion_Date + DELIMITER +
strGrade_Name;
WScript.Echo(strBodyInfo);
objTStreamLE.WriteLine(strBodyInfo);
}
if (objRs.EOF)
{
break;
}
objRs.MoveNext;
}
objTStreamLE.Close();
objRs.Close();
}
var objConf = GetConfigCDO();
var objMsg = WScript.CreateObject("CDO.Message");
objMsg.Configuration = objConf;
objMsg.To = ARG_EMAIL_TO;
objMsg.From = ARG_EMAIL_FROM;
objMsg.Subject = EMAIL_SUBJECT;
objMsg.TextBody = EMAIL_SUBJECT;
objMsg.send();
EmailCount++; // How many email sent. it will be always one email in this case.
}
objCon.Close();
}
catch (e)
&#13;
经过大量的测试和分析,我们无法查明根本原因,因为两个工作似乎间歇性地失败,有些夜晚提取产生数据,其他夜晚根本没有数据。 以下是基于通过cmd手动运行的测试结果,以及通过任务产生间歇性失败和成功结果,没有特定模式。
测试结果:
通过命令提示符执行第一次运行 第一轮 - 失败 第二轮 - 失败 第3次运行 - 成功 第四轮 - 成功 第五轮 - 成功
执行预定任务 - &#39;首先运行&#39;
第一轮 - 成功 第二轮 - 成功 第3次运行 - 成功 第四次运行 - 失败 - 调度程序失败 第5次运行 - 失败 - 调度程序失败执行计划任务 - 顺序优先,然后是第二次运行
第一次运行 - 首次运行成功,第二次运行成功但没有生成文件 第二次运行 - 第一次运行失败,第二次运行 - 成功 第三次运行 - 首次运行成功,第二次运行成功但没有生成文件 第四次运行 - 首次运行失败,第二次运行 - 成功
可能的原因可能是由于超时;但是,每次运行都需要相同的时间才能完成(大约3分钟),无论是失败还是成功。
我们最近将环境从Windows Server 2005升级到Windows Server 2008,并注意到在实施后开始出现问题。没有对逻辑或SQL过程进行任何更改。 Server 2008会以这种方式处理逻辑以打破常规吗?