2014-04-01 25 views
0
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) { 
    } 
} 

我下面的步驟:
第一步:在本地主機
運行我的Visual Studio項目第二步:打開命令提示符
第三步:運行以下命令
C:\ Windows \ System32下>的Cscript.exe 「d:\項目\克朗\ CronScript.js」電子郵件的Cron問題與JScript和Cscript.exe將

我檢查的代碼在網上驗證JLint
enter image description here後R emoving整個if條件enter image description here

我仍然收到錯誤而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 ';' 

請指引我,我缺少我期待它的長和張貼在這裏那裏。

回答

0

我得到了問題的解決方案,它工作正常。

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. 

上面提到的相同的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. 

那麼我的Cron動機已經完成,但我仍然感到困惑,爲什麼它沒有爲我的項目,因爲它是在網站模板工作工作。 然後我安排了cscript.exe在Windows Task Scheduler中運行這個.js文件。

請評論和指導我們爲什麼它不工作,它在同一個項目中工作,但與另一個不同。