/// <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 COMTextLineInputContextClass { codepage = myConfig.CodePage ?? 0, recurse = myConfig.Recurse ?? 0, splitLongLines = myConfig.SplitLongLines ?? false }; if (!string.IsNullOrEmpty(myConfig.CheckpointFile)) { context.iCheckpoint = myConfig.CheckpointFile; } return(context); }
//Call references LogParser. Take sql string query and the Table name and execute into a logparser records set. Then, loop through the records //and save them into a dataTable private static DataTable parseLog(string query, string TableName) { LogQueryClass logParser = new LogQueryClass(); COMTextLineInputContextClass Log = new COMTextLineInputContextClass(); ILogRecordset rsLP = null; ILogRecord rowLP = null; rsLP = logParser.Execute(query, Log); DataTable tab = new DataTable(TableName); // copy schema for (int i = 0; i < rsLP.getColumnCount(); i++) { DataColumn col = new DataColumn(); col.ColumnName = rsLP.getColumnName(i); tab.Columns.Add(col); } // copy data while (!rsLP.atEnd()) { rowLP = rsLP.getRecord(); DataRow row = tab.NewRow(); for (int i = 0; i < rsLP.getColumnCount(); i++) { row[i] = Convert.ToString(rowLP.getValue(i)); } tab.Rows.Add(row); rsLP.moveNext(); } return tab; }