public void PushError(EntityException ex) { lock (queueException) { queueException.Enqueue(ex); } }
/// <summary> /// Вставка ошибок /// </summary> /// <param name="exception"></param> public async void InsertException(EntityException exception) { var query = $@"INSERT INTO ExceptionTable VALUES ('{exception.Class}', '{exception.Method}', '{Normalize(exception.ExceptionMessage)}', '{exception.Date}' )"; await InsertCommand(query); }
protected override void Work() { while (true) { EntityMessage message = null; EntityException exception = null; lock (queueMessage) { if (queueMessage.Count > 0) { message = queueMessage.Dequeue(); } } if (message != null) { SendMessageToDb(message); } lock (queueException) { if (queueException.Count > 0) { exception = queueException.Dequeue(); } } if (exception != null) { SendExceptionToDb(exception); } if (_state.IsDoneReading && _state.IsDoneWorkers && queueMessage.Count == 0 && queueException.Count == 0) { _state.IsDoneWriting = true; break; } } }
private void SendExceptionToDb(EntityException ex) { ISqlInsert sqlInsert = new SqlInsert(_connectionString); sqlInsert.InsertException(ex); }