Пример #1
0
        /// <summary>
        /// Try to report progress
        /// </summary>
        internal void ReportProgress(SyncContext context, IProgress <ProgressArgs> progress, ProgressArgs args, DbConnection connection = null, DbTransaction transaction = null)
        {
            // Check logger, because we make some reflection here
            if (this.logger.IsEnabled(LogLevel.Information))
            {
                var argsTypeName = args.GetType().Name;
                this.logger.LogInformation(new EventId(args.EventId, argsTypeName), args);

                if (this.logger.IsEnabled(LogLevel.Debug))
                {
                    this.logger.LogDebug(new EventId(args.EventId, argsTypeName), args.Context);
                }
            }

            if (progress == null)
            {
                return;
            }

            if (connection == null && args.Connection != null)
            {
                connection = args.Connection;
            }

            if (transaction == null && args.Transaction != null)
            {
                transaction = args.Transaction;
            }

            var dt           = DateTime.Now;
            var message      = $"{dt.ToLongTimeString()}.{dt.Millisecond}\t {args.Message}";
            var progressArgs = new ProgressArgs(context, message, connection, transaction);

            progress.Report(progressArgs);
        }
Пример #2
0
        /// <summary>
        /// Try to report progress
        /// </summary>
        internal void ReportProgress(SyncContext context, IProgress <ProgressArgs> progress, ProgressArgs args, DbConnection connection = null, DbTransaction transaction = null)
        {
            if (connection == null && args.Connection != null)
            {
                connection = args.Connection;
            }

            if (transaction == null && args.Transaction != null)
            {
                transaction = args.Transaction;
            }

            ReportProgress(context, progress, args.Message, connection, transaction);
        }
Пример #3
0
        /// <summary>
        /// Try to report progress
        /// </summary>
        internal void ReportProgress(SyncContext context, IProgress <ProgressArgs> progress, ProgressArgs args, DbConnection connection = null, DbTransaction transaction = null)
        {
            // Check logger, because we make some reflection here
            if (this.Logger.IsEnabled(LogLevel.Information))
            {
                var argsTypeName = args.GetType().Name.Replace("Args", "");;
                if (this.Logger.IsEnabled(LogLevel.Debug))
                {
                    this.Logger.LogDebug(new EventId(args.EventId, argsTypeName), args.Context);
                }
                else
                {
                    this.Logger.LogInformation(new EventId(args.EventId, argsTypeName), args);
                }
            }

            if (progress == null)
            {
                return;
            }

            if (connection == null && args.Connection != null)
            {
                connection = args.Connection;
            }

            if (transaction == null && args.Transaction != null)
            {
                transaction = args.Transaction;
            }

            if (args.Connection == null || args.Connection != connection)
            {
                args.Connection = connection;
            }

            if (args.Transaction == null || args.Transaction != transaction)
            {
                args.Transaction = transaction;
            }

            progress.Report(args);
        }