public override IList<IResult> Get()
        {
            var rtn = new List<IResult>();
            const string CheckpointFile = @"checkpoint.lpc";

            var logParser = new LogQueryClassClass();
            var w3Clog = new COMIISW3CInputContextClass
            {
                iCheckpoint = CheckpointFile
            };

            var records = logParser.Execute(this.Sql, w3Clog);
            while (!records.atEnd())
            {
                var record = records.getRecord();
                rtn.Add(this.Map(record));
                records.moveNext();
            }
            return rtn;
        }
Beispiel #2
0
        /// <summary>
        /// Returns the correct Input Context class for this type of query. It will also sanity check
        /// all relevant config params and throw exceptions where there are violations (required
        /// setting missing, badly formed etc)
        /// </summary>
        /// <returns></returns>
        /// <exception cref="ArgumentException">Thrown if a setting is missing</exception>
        /// <exception cref="FormatException">Thrown if a setting is badly formed</exception>
        protected override object GetInputContext()
        {
            var context = new COMIISW3CInputContextClass
            {
                iCodepage       = myConfig.Codepage.GetValueOrDefault(-2),
                recurse         = myConfig.Recurse.GetValueOrDefault(0),
                consolidateLogs = myConfig.ConsolidateLogs.GetValueOrDefault(false),
                dirTime         = myConfig.DirTime.GetValueOrDefault(false),
                dQuotes         = myConfig.DoubleQuotes.GetValueOrDefault(false)
            };

            if (!string.IsNullOrEmpty(myConfig.MinDateMod))
            {
                context.minDateMod = myConfig.MinDateMod;
            }
            if (!string.IsNullOrEmpty(myConfig.CheckpointFile))
            {
                context.iCheckpoint = myConfig.CheckpointFile;
            }

            return(context);
        }
 private static void Parse(string checkpointFile, string strSQL)
 {
     var logParser = new LogQueryClassClass();
     var w3Clog = new COMIISW3CInputContextClass
         {
             iCheckpoint = checkpointFile
         };
     var logRecordset = logParser.Execute(strSQL, w3Clog);
     while (!logRecordset.atEnd())
     {
         var logRecord = logRecordset.getRecord();
         //Console.WriteLine(logRecord.getValue(0).GetType());
         //Console.WriteLine(logRecord.getValue(1).GetType());
         //Console.WriteLine(string.Format("{0} {1}", logRecord.getValue(0), logRecord.getValue(1)));
         logRecordset.moveNext();
     }
 }
Beispiel #4
0
        /// <summary>
        /// Adds the current log file to the WebStats SQL database.
        /// </summary>
        /// <returns>Flag to indicate whether the log file was added to the WebStats SQL database successfully.</returns>
        private bool AddLogFileToWebStatsSqlDb()
        {
            bool result;

            /*  Reasoning for the input context:
             *
             *  1. Disable checkpoints because incremental parsing of log files does not apply when we are picking up the previous day's log files AFTER updates to them have stopped.
             *  2. Disable recursion (set to zero) because all log file paths are read from Whois and there should never be any subdirectories in those paths.
            */
            COMIISW3CInputContextClass inputContext = new COMIISW3CInputContextClass();
            inputContext.consolidateLogs = true;
            //inputContext.iCheckpoint = this._installDirectory + "\\WebStats.IISLogManager.lpc";
            inputContext.recurse = 0;

            COMSQLOutputContextClass outputContext = new COMSQLOutputContextClass();
            outputContext.clearTable = false;
            outputContext.createTable = false;
            outputContext.fixColNames = true;
            outputContext.ignoreIdCols = true;
            outputContext.ignoreMinWarns = false;
            outputContext.maxStrFieldLen = 8000;
            outputContext.transactionRowCount = 0;
            outputContext.oConnString = WebStatsODBCSqlDbConnectionString;

            LogQueryClass logQuery = new LogQueryClass();

            logQuery.ExecuteBatch(GetIISLogSql(), inputContext, outputContext);
            result = (logQuery.lastError == 0);

            if (result)
            {
                EventLog.WriteEntry(SourceName, "Logs added to WebStats database.\r\n\r\n" + GetLogFileInfo(), EventLogEntryType.Information, InfoEventID);
            }
            else
            {
                EventLog.WriteEntry(SourceName, "Failed to add logs to WebStats database.\r\n\r\n" + GetLogFileInfo(), EventLogEntryType.Information, InfoEventID);
            }

            return result;
        }