예제 #1
0
        /// <inheritdoc/>
        public void Dispose()
        {
            lock (disposeGuard) {
                if (isDisposed)
                {
                    return;
                }
                isDisposed = true;

                OrmLog.Debug(Strings.LogDomainIsDisposing);

                NotifyDisposing();
                Services.Dispose();

                if (SingleConnection == null)
                {
                    return;
                }

                lock (singleConnectionGuard) {
                    if (singleConnectionOwner == null)
                    {
                        var driver = Handlers.StorageDriver;
                        driver.CloseConnection(null, SingleConnection);
                        driver.DisposeConnection(null, SingleConnection);
                    }
                    else
                    {
                        OrmLog.Warning(
                            Strings.LogUnableToCloseSingleAvailableConnectionItIsStillUsedBySessionX,
                            singleConnectionOwner);
                    }
                }
            }
        }
예제 #2
0
 private void RollbackWithSuppression(Transaction transaction)
 {
     try {
         Rollback(transaction);
     }
     catch (Exception e) {
         OrmLog.Warning(e);
     }
 }
예제 #3
0
        public async ValueTask InnerDispose(bool isAsync)
        {
            lock (disposeGuard) {
                if (isDisposed)
                {
                    return;
                }

                isDisposed = true;
            }

            if (isDebugEventLoggingEnabled)
            {
                OrmLog.Debug(Strings.LogDomainIsDisposing);
            }

            NotifyDisposing();
            Services.Dispose();

            if (SingleConnection == null)
            {
                return;
            }

            SqlConnection singleConnectionLocal;

            lock (singleConnectionGuard) {
                if (singleConnectionOwner != null)
                {
                    OrmLog.Warning(
                        Strings.LogUnableToCloseSingleAvailableConnectionItIsStillUsedBySessionX,
                        singleConnectionOwner);
                    return;
                }
                else
                {
                    singleConnectionLocal = SingleConnection;
                    SingleConnection      = null;
                }
            }

            var driver = Handlers.StorageDriver;

            if (isAsync)
            {
                await driver.CloseConnectionAsync(null, singleConnectionLocal).ConfigureAwait(false);

                await driver.DisposeConnectionAsync(null, singleConnectionLocal).ConfigureAwait(false);
            }
            else
            {
                driver.CloseConnection(null, singleConnectionLocal);
                driver.DisposeConnection(null, singleConnectionLocal);
            }
        }
예제 #4
0
        public void OrmLogTest()
        {
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            OrmLog.Debug("Test message", null);
            OrmLog.Debug("Test message with parameter {0}", new object[] { 1 });
            _ = OrmLog.Debug(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
            OrmLog.Debug("Test message", new object[] { 1 });
            OrmLog.Debug("Test message {0}", null);
            _ = OrmLog.Debug(new Exception("Some exeption"));
            OrmLog.Debug(null, new object[] { 1 });

            OrmLog.Info("Test message", null);
            OrmLog.Info("Test message with parameter {0}", new object[] { 1 });
            _ = OrmLog.Info(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
            OrmLog.Info("Test message", new object[] { 1 });
            OrmLog.Info("Test message {0}", null);
            _ = OrmLog.Info(new Exception("Some exeption"));
            OrmLog.Info(null, new object[] { 1 });

            OrmLog.Warning("Test message", null);
            OrmLog.Warning("Test message with parameter {0}", new object[] { 1 });
            _ = OrmLog.Warning(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
            OrmLog.Warning("Test message", new object[] { 1 });
            OrmLog.Warning("Test message {0}", null);
            _ = OrmLog.Warning(new Exception("Some exeption"));
            OrmLog.Warning(null, new object[] { 1 });

            OrmLog.Error("Test message", null);
            OrmLog.Error("Test message with parameter {0}", new object[] { 1 });
            _ = OrmLog.Error(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
            OrmLog.Error("Test message", new object[] { 1 });
            OrmLog.Error("Test message {0}", null);
            _ = OrmLog.Error(new Exception("Some exeption"));
            OrmLog.Error(null, new object[] { 1 });

            OrmLog.FatalError("Test message", null);
            OrmLog.FatalError("Test message with parameter {0}", new object[] { 1 });
            _ = OrmLog.FatalError(new Exception("Some exception"), "Test message with parameter {0}", new object[] { 1 });
            OrmLog.FatalError("Test message", new object[] { 1 });
            OrmLog.FatalError("Test message {0}", null);
            _ = OrmLog.FatalError(new Exception("Some exeption"));
            OrmLog.FatalError(null, new object[] { 1 });

            Assert.IsTrue(File.Exists(filePath));
            Assert.AreEqual(File.ReadAllLines(filePath).Count(), 35);
        }
예제 #5
0
 private async ValueTask RollbackWithSuppression(Transaction transaction, bool isAsync)
 {
     try {
         if (isAsync)
         {
             await RollbackAsync(transaction).ConfigureAwait(false);
         }
         else
         {
             Rollback(transaction);
         }
     }
     catch (Exception e) {
         OrmLog.Warning(e);
     }
 }