protected override void WriteBatch(IEnumerable<IEntry> records) { if (records.Count() == 0) return; NonSelectQuery query = new NonSelectQuery( "INSERT INTO T_INTEGRATION_STAT(POOL_ID, HOST_ID, APP_ID, THREADS, INPROCESS, INQUEUE, STATUS, PROCESSED, ERRORS, PROCESS_TIME, FOREIGN_TIME, PICK_TIME, PICKS_COUNT, PICKED, PICK_ERRORS, ENQUEUED, DTM) " + " VALUES (:POOL_ID, :HOST_ID, :APP_ID, :THREADS, :INPROCESS, :INQUEUE, :STATUS, :PROCESSED, :ERRORS, :PROCESS_TIME, :FOREIGN_TIME, :PICK_TIME, :PICKS_COUNT, :PICKED, :PICK_ERRORS, :ENQUEUED, :DTM)", false, new DbParam(":POOL_ID", DbParamType.Integer), new DbParam(":HOST_ID", DbParamType.Integer), new DbParam(":APP_ID", DbParamType.Integer), new DbParam(":THREADS", DbParamType.Integer), new DbParam(":INPROCESS", DbParamType.Integer), new DbParam(":INQUEUE", DbParamType.Integer), new DbParam(":STATUS", DbParamType.Byte), new DbParam(":PROCESSED", DbParamType.Integer), new DbParam(":ERRORS", DbParamType.Integer), new DbParam(":PROCESS_TIME", DbParamType.Integer), new DbParam(":FOREIGN_TIME", DbParamType.Integer), new DbParam(":PICK_TIME", DbParamType.Integer), new DbParam(":PICKS_COUNT", DbParamType.Integer), new DbParam(":PICKED", DbParamType.Integer), new DbParam(":PICK_ERRORS", DbParamType.Integer), new DbParam(":ENQUEUED", DbParamType.Integer), new DbParam(":DTM", DbParamType.DateTime) ); foreach (StatRecord record in records) { query.AddParamValues( record.Source.PoolId, this.hostIds[record.Source.Server], this.appIds[record.Source.AppPath], record.ThreadsCount, record.InProcessCount, record.InQueueCount, (byte)record.Status, record.ProcessedCount, record.ErrorsCount, record.ProcessTime, record.ForeignTime, record.PickTime, record.PicksCount, record.PickedCount, record.PickErrors, record.EnqueuedCount, record.Timestamp ); } DbContext.Execute(query); }
protected override void WriteBatch(IEnumerable<IEntry> records) { if (records.Count() == 0) return; /*DataTable tbl = new DataTable(); foreach (LogEntry entry in records) { object poolId = null; if (entry.Source.PoolId > 0) poolId = entry.Source.PoolId; // box/unbox object objectId = null; if (entry.object_code > 0) objectId = entry.object_code; // box/unbox insertQuery.AddParamValues( entry.Timestamp, entry.Msg, levelCodes[(int)entry.Level], entry.process_id, entry.thread_id, entry.Source.AppPathId, entry.Source.ServerId, poolId, objectId, entry.additional, entry.call_stack, entry.ex_stack ); } BulkInsert insertQuery = new BulkInsert("T_INTEGRATION_LOG", false, new DbParam("DTM_", DbParamType.Timestamp), new DbParam("MSG_", DbParamType.String), new DbParam("LVL_", DbParamType.Char), new DbParam("PROCESS_ID_", DbParamType.Integer), new DbParam("THREAD_ID_", DbParamType.Integer), new DbParam("APP_ID_", DbParamType.Integer), new DbParam("HOST_ID_", DbParamType.Integer), new DbParam("POOL_ID_", DbParamType.Integer), new DbParam("CODE_", DbParamType.Integer), new DbParam("ADDITIONAL_", DbParamType.String), new DbParam("CALL_STACK_", DbParamType.String), new DbParam("EX_STACK_", DbParamType.String)); DbContext.BulkInsert(insertQuery);*/ NonSelectQuery insertQuery = new NonSelectQuery( "INSERT INTO T_INTEGRATION_LOG(DTM, MSG, LVL, PROCESS_ID, THREAD_ID, APP_ID, HOST_ID, POOL_ID, CODE, ADDITIONAL, CALL_STACK, EX_STACK) VALUES " + " (:DTM_, :MSG_, :LVL_, :PROCESS_ID_, :THREAD_ID_, :APP_ID_, :HOST_ID_, :POOL_ID_, :CODE_, :ADDITIONAL_, :CALL_STACK_, :EX_STACK_)", false, new DbParam("DTM_", DbParamType.Timestamp), new DbParam("MSG_", DbParamType.String), new DbParam("LVL_", DbParamType.Char), new DbParam("PROCESS_ID_", DbParamType.Integer), new DbParam("THREAD_ID_", DbParamType.Integer), new DbParam("APP_ID_", DbParamType.Integer), new DbParam("HOST_ID_", DbParamType.Integer), new DbParam("POOL_ID_", DbParamType.Integer), new DbParam("CODE_", DbParamType.Integer), new DbParam("ADDITIONAL_", DbParamType.String), new DbParam("CALL_STACK_", DbParamType.String), new DbParam("EX_STACK_", DbParamType.String)); foreach (LogEntry entry in records) { object poolId = null; if (entry.Source.PoolId > 0) poolId = entry.Source.PoolId; // box/unbox object objectId = null; if (entry.object_code > 0) objectId = entry.object_code; // box/unbox insertQuery.AddParamValues( entry.Timestamp, entry.Msg, levelCodes[(int)entry.Level], entry.process_id, entry.thread_id, this.appIds[entry.Source.AppPath], this.hostIds[entry.Source.Server], poolId, objectId, entry.additional, entry.call_stack, entry.ex_stack ); } DbContext.Execute(insertQuery); }