Hi there,
I've made a WinForms application that gets the traffic of a single site. This works perfectly, until I decided to make a WebForms application out of it instead. The exact same code (see below) now throws the following exception:
System.IO.FileNotFoundException: Error executing query: Cannot open : Cannot find any file matching "C:\inetpub\logs\LogFiles\W3SVC4\ex*.log"
The exception makes sence, since all log files are prefixed with 'u_ex' and not 'ex'. It's just strange that it does work when ran from a WinForms application.
Could anyone please help me with this?
Thanks!
Code:
private void UpdateByDateRange(DateTime dateFrom, DateTime dateTo)
{
string siteId = Request.ServerVariables["INSTANCE_ID"];
LogQueryClassClass logger = new LogQueryClassClass();COMIISW3CInputContextClass inputContext = new COMIISW3CInputContextClassClass();
string query = "SELECT SUM(TO_REAL(sc-bytes)) AS sentTotal, SUM(TO_REAL(cs-bytes)) AS receivedTotal FROM <" + siteId + "> WHERE TO_TIMESTAMP(date, time) >= TO_TIMESTAMP('" + dateFrom.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-MM-dd HH:mm:ss') AND TO_TIMESTAMP(date, time) <= TO_TIMESTAMP('" + dateTo.ToString("yyyy-MM-dd HH:mm:ss") + "', 'yyyy-MM-dd HH:mm:ss')";ILogRecord record = logger.Execute(query, inputContext).getRecord();
decimal trafficSent = decimal.Parse(record.getValue("sentTotal").ToString());decimal trafficReceived = decimal.Parse(record.getValue("receivedTotal").ToString());
// ...
}