Exemple #1
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 COMCSVInputContextClass
            {
                headerRow   = myConfig.HeaderRow ?? true,
                fixedFields = myConfig.FixedFields ?? true,
                nFields     = myConfig.Fields ?? -1,
                dtLines     = myConfig.Lines ?? 10,
                iDQuotes    = myConfig.DoubleQuotes ?? "Auto",
                nSkipLines  = myConfig.SkipLines ?? 0,
                codepage    = myConfig.CodePage ?? 0
            };

            if (!string.IsNullOrEmpty(myConfig.TimestampFormat))
            {
                context.iTsFormat = myConfig.TimestampFormat;
            }
            if (!string.IsNullOrEmpty(myConfig.HeaderFile))
            {
                context.headerFile = myConfig.HeaderFile;
            }
            if (!string.IsNullOrEmpty(myConfig.Comment))
            {
                context.comment = myConfig.Comment;
            }
            if (!string.IsNullOrEmpty(myConfig.CheckpointFile))
            {
                context.iCheckpoint = myConfig.CheckpointFile;
            }

            return(context);
        }
Exemple #2
0
        public ILogRecordset executeCommand()
        {
            // prepare LogParser Recordset & Record objects
            ILogRecordset rsLP  = null;
            ILogRecord    rowLP = null;

            LogQueryClassClass      LogParser = null;
            COMCSVInputContextClass W3Clog    = null;


            LogParser = new LogQueryClassClass();

            W3Clog = new COMCSVInputContextClass();

            try
            {
                //W3C Logparsing SQL. Replace this SQL query with whatever
                //you want to retrieve. The example below
                //will sum up all the bandwidth
                //Usage of a specific folder with name
                //"userID". Download Log Parser 2.2
                //from Microsoft and see sample queries.

                foreach (string s in logList)
                {
                    cmd = Utils.ReplaceFirst(cmd, s, "'" + currentDir + "\\Logs\\" + s + "'");
                }

                Debug.WriteLine(cmd);

                // run the query against W3C log
                rsLP = LogParser.Execute(cmd, W3Clog);
            }
            catch
            {
                throw;
            }
            return(rsLP);
        }