Beispiel #1
0
        /// <summary>
        /// 数值类型默认警告
        /// </summary>
        /// <param name="diagnostics">诊断日志</param>
        /// <param name="property">属性</param>
        public static void DecimalTypeDefaultWarning(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Model.Validation> diagnostics,
            [NotNull] IProperty property)
        {
            Check.NotNull(diagnostics, nameof(diagnostics));
            Check.NotNull(property, nameof(property));

            EventDefinition <string, string> logDefaultDecimalTypeColumn = OracleStrings.LogDefaultDecimalTypeColumn;
            WarningBehavior logBehavior = logDefaultDecimalTypeColumn.GetLogBehavior(diagnostics);

            if (logDefaultDecimalTypeColumn.GetLogBehavior(diagnostics) != WarningBehavior.Ignore)
            {
                logDefaultDecimalTypeColumn.Log(diagnostics, logBehavior, property.Name, property.DeclaringEntityType.DisplayName());
            }
            if (diagnostics.DiagnosticSource.IsEnabled(logDefaultDecimalTypeColumn.EventId.Name))
            {
                diagnostics.DiagnosticSource.Write(logDefaultDecimalTypeColumn.EventId.Name, new PropertyEventData(logDefaultDecimalTypeColumn, DecimalTypeDefaultWarning, property));
            }
        }
Beispiel #2
0
        /// <summary>
        /// 表找到
        /// </summary>
        /// <param name="diagnostics">诊断日志</param>
        /// <param name="tableName">表名</param>
        public static void TableFound(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
            [NotNull] string tableName)
        {
            EventDefinition <string> logFoundTable = OracleStrings.LogFoundTable;
            WarningBehavior          logBehavior   = logFoundTable.GetLogBehavior(diagnostics);

            if (logBehavior != WarningBehavior.Ignore)
            {
                logFoundTable.Log(diagnostics, logBehavior, tableName);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 缺少方案警告
        /// </summary>
        /// <param name="diagnostics">诊断日志</param>
        /// <param name="schemaName">方案名</param>
        public static void MissingSchemaWarning(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
            [CanBeNull] string schemaName)
        {
            EventDefinition <string> logMissingSchema = OracleStrings.LogMissingSchema;
            WarningBehavior          logBehavior      = logMissingSchema.GetLogBehavior(diagnostics);

            if (logBehavior != WarningBehavior.Ignore)
            {
                logMissingSchema.Log(diagnostics, logBehavior, schemaName);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 唯一约束找到
        /// </summary>
        /// <param name="diagnostics">诊断日志</param>
        /// <param name="uniqueConstraintName">唯一约束名</param>
        /// <param name="tableName">表名</param>
        public static void UniqueConstraintFound(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
            [NotNull] string uniqueConstraintName,
            [NotNull] string tableName)
        {
            EventDefinition <string, string> logFoundUniqueConstraint = OracleStrings.LogFoundUniqueConstraint;
            WarningBehavior logBehavior = logFoundUniqueConstraint.GetLogBehavior(diagnostics);

            if (logBehavior != WarningBehavior.Ignore)
            {
                logFoundUniqueConstraint.Log(diagnostics, logBehavior, uniqueConstraintName, tableName);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 主键找到
        /// </summary>
        /// <param name="diagnostics">诊断日志</param>
        /// <param name="primaryKeyName">主键名</param>
        /// <param name="tableName">表名</param>
        public static void PrimaryKeyFound(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
            [NotNull] string primaryKeyName,
            [NotNull] string tableName)
        {
            EventDefinition <string, string> logFoundPrimaryKey = OracleStrings.LogFoundPrimaryKey;
            WarningBehavior logBehavior = logFoundPrimaryKey.GetLogBehavior(diagnostics);

            if (logBehavior != WarningBehavior.Ignore)
            {
                logFoundPrimaryKey.Log(diagnostics, logBehavior, primaryKeyName, tableName);
            }
        }
Beispiel #6
0
        /// <summary>
        /// 外键找到
        /// </summary>
        /// <param name="diagnostics">诊断日志</param>
        /// <param name="foreignKeyName">外键名</param>
        /// <param name="tableName">表名</param>
        /// <param name="principalTableName">关联的表名</param>
        public static void ForeignKeyReferencesMissingPrincipalTableWarning(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
            [CanBeNull] string foreignKeyName,
            [CanBeNull] string tableName,
            [CanBeNull] string principalTableName)
        {
            EventDefinition <string, string, string> logPrincipalTableNotInSelectionSet = OracleStrings.LogPrincipalTableNotInSelectionSet;
            WarningBehavior logBehavior = logPrincipalTableNotInSelectionSet.GetLogBehavior(diagnostics);

            if (logBehavior != WarningBehavior.Ignore)
            {
                logPrincipalTableNotInSelectionSet.Log(diagnostics, logBehavior, foreignKeyName, tableName, principalTableName);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 索引找到
        /// </summary>
        /// <param name="diagnostics">诊断日志</param>
        /// <param name="indexName">索引名称</param>
        /// <param name="tableName">表名称</param>
        /// <param name="unique">是否唯一</param>
        public static void IndexFound(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
            [NotNull] string indexName,
            [NotNull] string tableName,
            bool unique)
        {
            EventDefinition <string, string, bool> logFoundIndex = OracleStrings.LogFoundIndex;
            WarningBehavior logBehavior = logFoundIndex.GetLogBehavior(diagnostics);

            if (logBehavior != WarningBehavior.Ignore)
            {
                logFoundIndex.Log(diagnostics, logBehavior, indexName, tableName, unique);
            }
        }
Beispiel #8
0
        /// <summary>
        /// 外键主体列丢失警告
        /// </summary>
        /// <param name="diagnostics">诊断日志</param>
        /// <param name="foreignKeyName">外键名</param>
        /// <param name="tableName">表名</param>
        /// <param name="principalColumnName">关联的表列名</param>
        /// <param name="principalTableName">关联的表名</param>
        public static void ForeignKeyPrincipalColumnMissingWarning(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
            [NotNull] string foreignKeyName,
            [NotNull] string tableName,
            [NotNull] string principalColumnName,
            [NotNull] string principalTableName)
        {
            EventDefinition <string, string, string, string> logPrincipalColumnNotFound = OracleStrings.LogPrincipalColumnNotFound;
            WarningBehavior logBehavior = logPrincipalColumnNotFound.GetLogBehavior(diagnostics);

            if (logBehavior != WarningBehavior.Ignore)
            {
                logPrincipalColumnNotFound.Log(diagnostics, logBehavior, foreignKeyName, tableName, principalColumnName, principalTableName);
            }
        }
Beispiel #9
0
        /// <summary>
        /// 外键找到
        /// </summary>
        /// <param name="diagnostics">诊断日志</param>
        /// <param name="foreignKeyName">外键名</param>
        /// <param name="tableName">表名</param>
        /// <param name="principalTableName">关联的主表名</param>
        /// <param name="onDeleteAction">删除操作</param>
        public static void ForeignKeyFound(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Scaffolding> diagnostics,
            [NotNull] string foreignKeyName,
            [NotNull] string tableName,
            [NotNull] string principalTableName,
            [NotNull] string onDeleteAction)
        {
            EventDefinition <string, string, string, string> logFoundForeignKey = OracleStrings.LogFoundForeignKey;
            WarningBehavior logBehavior = logFoundForeignKey.GetLogBehavior(diagnostics);

            if (logBehavior != WarningBehavior.Ignore)
            {
                logFoundForeignKey.Log(diagnostics, logBehavior, foreignKeyName, tableName, principalTableName, onDeleteAction);
            }
        }
Beispiel #10
0
        public static void ExecutingSqlQuery(
            [NotNull] this IDiagnosticsLogger <DbLoggerCategory.Database.Command> diagnosticsLogger,
            CosmosSqlQuery cosmosSqlQuery)
        {
            var definition = new EventDefinition <string, string, string>(
                CoreEventId.ProviderBaseId,
                LogLevel.Debug,
                LoggerMessage.Define <string, string, string>(
                    LogLevel.Debug,
                    CoreEventId.ProviderBaseId,
                    "Executing Sql Query [Parameters=[{parameters}]]{newLine}{commandText}"));

            var warningBehavior = definition.GetLogBehavior(diagnosticsLogger);

            definition.Log(
                diagnosticsLogger,
                warningBehavior,
                FormatParameters(cosmosSqlQuery.Parameters),
                Environment.NewLine,
                cosmosSqlQuery.Query);
        }