internal static void Log(this Exception ex, IDbConnectorLogger logger, bool isLoggingEnabled = true) { try { #if DEBUG Debug.WriteLine(ex.ToString()); #endif if (isLoggingEnabled) { if (logger != null) { logger.Log(ex); } else { OnError?.Invoke(ex); } } } catch (Exception e) { #if DEBUG Debug.WriteLine(e.ToString()); #endif } }
private static IDbResult <List <(List <IDbExecutedModel>, dynamic)> > TryExecuteAllHandled( IEnumerable <IDbJob> items, DbConnection connection = null, DbTransaction transaction = null, IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, bool isLoggingEnabled = true, IDbConnectorLogger logger = null, CancellationToken token = default) { IDbResult <List <(List <IDbExecutedModel>, dynamic)> > result = new DbResult <List <(List <IDbExecutedModel>, dynamic)> >(); List <(List <IDbExecutedModel>, dynamic)> data = null; try { ExecuteAllImplementation(ref data, ref logger, items, isolationLevel, token, connection, transaction); result.Data = data; } catch (Exception ex) { ex.Log(logger, isLoggingEnabled); if (items != null && data != null) { try { int index = 0; foreach (dynamic item in items) { if (item == null) { throw new NullReferenceException("IDbJob items cannot be null!"); } lock (item._executionLock) { if (item._onError != null) { var itemResult = data.ElementAtOrDefault(index); if (!itemResult.Equals(default))