简体   繁体   English

电子邮件Cron问题与jscript和cscript.exe

[英]Email Cron issue with jscript and cscript.exe

var strURLs= new Array("http:// localhost: 51611/Cron/Email.aspx");
var webObj = WScript.CreateObject("MSXML2.ServerXMLHTTP");

var lResolve = 10 * 1000;
var lConnect = 10 * 1000;
var lSend = 60000 * 1000;
var lReceive = 60000 * 1000;

webObj.setTimeouts(lResolve, lConnect, lSend, lReceive);

for (var i = 0; i < strURLs.length; i++) {
    webObj.open("GET", strURLs[i], false);
    try {
        webObj.send();
        if (webObj.status != 200 || String(webObj.statusText).match(/Database is currently unavailable/gi) != null) {

        }
    }
    catch (e) {
    }
}

I am following the steps: 我正在执行以下步骤:
Step1: Run My visual studio project at localhost 步骤1:在本地主机上运行我的Visual Studio项目
Step2: Open the command prompt 步骤2:打开命令提示符
Step3: Run the following command 第三步:运行以下命令
C:\\Windows\\System32>cscript.exe "D:\\Projects\\Cron\\CronScript.js" C:\\ Windows \\ System32> cscript.exe“ D:\\ Projects \\ Cron \\ CronScript.js”

I checked the code at online validator JLint 我在在线验证器JLint上检查了代码
在此处输入图片说明 After removing the whole if condition 去除整个if条件后 在此处输入图片说明

I am still receiving an error while compling 编译时我仍然收到错误

Microsoft (R) Windows Script Host Version 5.8
Copyright (C) Microsoft Corporation. All rights reserved.

D:\Projects\Cron\CronScript.js(1, 8) Microsoft JScript compilation error: Expected ';' 

Please guide me where I am lacking I am looking it for long and posting here. 请指导我缺少的地方,我正在寻找它并在此处发布。

I got the solution for the issue and it is working fine properly. 我已找到问题的解决方案,并且工作正常。

Well I am using Visual Studio 2010 Project for my web application.   
So when I create any new page it contains 3 files Default.aspx, Default.aspx.cs,   
Default.aspx.designer.cs   
But when I choose New Website then I get only Default.aspx and Default.aspx.cs.

The same Cron code(javascript) mentioned above working fine for one of my colleague's and he is using Visual Studio 2010 Website. 上面提到的同一Cron代码(javascript)对于我的一位同事来说还可以,并且他正在使用Visual Studio 2010网站。

I copied the same file(without the designer.cs file) with the same code in-fact same letter,      
    and add in my project and it worked.

Well my Cron motive has been accomplished but I am still confused why it didn't work for me in Project as it is working in Website template. 好吧,我的Cron动机已经实现,但我仍然感到困惑,为什么它对Project无效,因为它在网站模板中有效。 Then I scheduled the cscript.exe to run this .js file in Windows Task Scheduler. 然后,我安排了cscript.exe在Windows Task Scheduler中运行此.js文件。

Please comment and guide us why it was not working and it worked in the same project but with a different. 请评论并指导我们为什么它不起作用,并且它在同一项目中起作用,但在另一个项目中却起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM