本文整理汇总了C#中DocumentDatabase.AddAlert方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentDatabase.AddAlert方法的具体用法?C# DocumentDatabase.AddAlert怎么用?C# DocumentDatabase.AddAlert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentDatabase
的用法示例。
在下文中一共展示了DocumentDatabase.AddAlert方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecordWriteError
public void RecordWriteError(Exception e, DocumentDatabase database, int count = 1, DateTime? newErrorTime = null)
{
WriteErrorCount += count;
if (WriteErrorCount < 100)
return;
if (WriteErrorCount <= SuccessCount)
return;
if (newErrorTime != null)
{
LastErrorTime = newErrorTime.Value;
return;
}
database.AddAlert(LastAlert = new Alert
{
AlertLevel = AlertLevel.Error,
CreatedAt = SystemTime.UtcNow,
Message = "Could not tolerate write error ratio and stopped current replication cycle for " + name + Environment.NewLine + this,
Title = "Sql Replication write error hit ratio too high",
Exception = e.ToString(),
UniqueKey = "Sql Replication Write Error Ratio: " + name
});
throw new InvalidOperationException("Could not tolerate write error ratio and stopped current replication cycle for " + name + Environment.NewLine + this, e);
}
示例2: MarkScriptAsInvalid
public void MarkScriptAsInvalid(DocumentDatabase database, string script)
{
ScriptErrorCount = int.MaxValue;
LastErrorTime = DateTime.MaxValue;
database.AddAlert(LastAlert = new Alert
{
AlertLevel = AlertLevel.Error,
CreatedAt = SystemTime.UtcNow,
Message = string.Format("Could not parse script for {0} " + Environment.NewLine + "Script: {1}", name, script),
Title = "Could not parse Script",
UniqueKey = "Script Parse Error: " + name
});
}
示例3: RecordWriteError
public void RecordWriteError(Exception e, DocumentDatabase database, int count = 1, DateTime? suspendUntil = null)
{
WriteErrorCount += count;
LastErrorTime = SystemTime.UtcNow;
LastAlert = new Alert
{
AlertLevel = AlertLevel.Error,
CreatedAt = SystemTime.UtcNow,
Message = "Last SQL eplication operation for " + name + " was failed",
Title = "SQL replication error",
Exception = e.ToString(),
UniqueKey = "Sql Replication Error: " + name
};
if (WriteErrorCount < 100)
return;
if (WriteErrorCount <= SuccessCount)
return;
if (suspendUntil != null)
{
SuspendUntil = suspendUntil.Value;
return;
}
LastAlert = new Alert
{
AlertLevel = AlertLevel.Error,
CreatedAt = SystemTime.UtcNow,
Message = "Could not tolerate write error ratio and stopped current replication cycle for " + name + Environment.NewLine + this,
Title = "Sql Replication write error hit ratio too high",
Exception = e.ToString(),
UniqueKey = "Sql Replication Write Error Ratio: " + name
};
if (reportToDatabaseAlerts)
{
database.AddAlert(LastAlert);
}
throw new InvalidOperationException("Could not tolerate write error ratio and stopped current replication cycle for " + name + Environment.NewLine + this, e);
}
示例4: RelationalDatabaseWriter
public RelationalDatabaseWriter( DocumentDatabase database, SqlReplicationConfig cfg, SqlReplicationStatistics replicationStatistics)
{
this.database = database;
this.cfg = cfg;
this.replicationStatistics = replicationStatistics;
providerFactory = GetDbProviderFactory(cfg);
commandBuilder = providerFactory.CreateCommandBuilder();
connection = providerFactory.CreateConnection();
Debug.Assert(connection != null);
Debug.Assert(commandBuilder != null);
connection.ConnectionString = cfg.ConnectionString;
try
{
connection.Open();
}
catch (Exception e)
{
database.AddAlert(new Alert
{
AlertLevel = AlertLevel.Error,
CreatedAt = SystemTime.UtcNow,
Exception = e.ToString(),
Title = "Sql Replication could not open connection",
Message = "Sql Replication could not open connection to " + connection.ConnectionString,
UniqueKey = "Sql Replication Connection Error: " + connection.ConnectionString
});
throw;
}
tx = connection.BeginTransaction();
}
示例5: RelationalDatabaseWriter
public RelationalDatabaseWriter( DocumentDatabase database, SqlReplicationConfig cfg, SqlReplicationStatistics replicationStatistics)
{
this.database = database;
this.cfg = cfg;
this.replicationStatistics = replicationStatistics;
providerFactory = GetDbProviderFactory(cfg);
commandBuilder = providerFactory.CreateCommandBuilder();
connection = providerFactory.CreateConnection();
Debug.Assert(connection != null);
Debug.Assert(commandBuilder != null);
connection.ConnectionString = cfg.ConnectionString;
if (SqlServerFactoryNames.Contains(cfg.FactoryName))
{
IsSqlServerFactoryType = true;
}
try
{
connection.Open();
}
catch (Exception e)
{
database.AddAlert(new Alert
{
AlertLevel = AlertLevel.Error,
CreatedAt = SystemTime.UtcNow,
Exception = e.ToString(),
Title = "Sql Replication could not open connection",
Message = "Sql Replication could not open connection to " + connection.ConnectionString,
UniqueKey = "Sql Replication Connection Error: " + connection.ConnectionString
});
throw;
}
tx = connection.BeginTransaction();
stringParserList = GenerateStringParsers();
sqlReplicationMetrics = database.StartupTasks.OfType<SqlReplicationTask>().FirstOrDefault().GetSqlReplicationMetricsManager(cfg);
}
示例6: RecordScriptError
public void RecordScriptError(DocumentDatabase database)
{
ScriptErrorCount++;
if (ScriptErrorCount < 100)
return;
if (ScriptErrorCount <= ScriptSuccessCount)
return;
database.AddAlert(LastAlert = new Alert
{
AlertLevel = AlertLevel.Error,
CreatedAt = SystemTime.UtcNow,
Message = "Could not tolerate script error ratio and stopped current replication cycle for " + name + Environment.NewLine + this,
Title = "Sql Replication script error hit ratio too high",
UniqueKey = "Sql Replication Script Error Ratio: " + name
});
throw new InvalidOperationException("Could not tolerate script error ratio and stopped current replication cycle for " + name + Environment.NewLine + this);
}
示例7: RecordScriptError
public void RecordScriptError(DocumentDatabase database, Exception e)
{
ScriptErrorCount++;
LastErrorTime = SystemTime.UtcNow;
LastAlert = new Alert
{
AlertLevel = AlertLevel.Error,
CreatedAt = SystemTime.UtcNow,
Message = "Replication script for " + name + " was failed",
Title = "SQL replication error",
Exception = e.ToString(),
UniqueKey = "Sql Replication Error: " + name
};
if (ScriptErrorCount < 100)
return;
if (ScriptErrorCount <= ScriptSuccessCount)
return;
LastAlert = new Alert
{
AlertLevel = AlertLevel.Error,
CreatedAt = SystemTime.UtcNow,
Message = "Could not tolerate script error ratio and stopped current replication cycle for " + name + Environment.NewLine + this,
Title = "Sql Replication script error hit ratio too high",
UniqueKey = "Sql Replication Script Error Ratio: " + name
};
if (reportToDatabaseAlerts)
{
database.AddAlert(LastAlert);
}
throw new InvalidOperationException("Could not tolerate script error ratio and stopped current replication cycle for " + name + Environment.NewLine + this);
}
示例8: RelationalDatabaseWriter
public RelationalDatabaseWriter( DocumentDatabase database, SqlReplicationConfig cfg, SqlReplicationStatistics replicationStatistics)
{
this.database = database;
this.cfg = cfg;
this.replicationStatistics = replicationStatistics;
providerFactory = GetDbProviderFactory(cfg);
commandBuilder = providerFactory.CreateCommandBuilder();
connection = providerFactory.CreateConnection();
Debug.Assert(connection != null);
Debug.Assert(commandBuilder != null);
connection.ConnectionString = cfg.ConnectionString;
try
{
connection.Open();
}
catch (Exception e)
{
database.AddAlert(new Alert
{
AlertLevel = AlertLevel.Error,
CreatedAt = SystemTime.UtcNow,
Exception = e.ToString(),
Title = "Sql Replication could not open connection",
Message = "Sql Replication could not open connection to " + connection.ConnectionString,
UniqueKey = "Sql Replication Connection Error: " + connection.ConnectionString
});
throw;
}
tx = connection.BeginTransaction();
stringParserList = new List<Func<DbParameter, string, bool>> {
(colParam, value) => {
if( char.IsDigit( value[ 0 ] ) ) {
DateTime dateTime;
if (DateTime.TryParseExact(value, Default.OnlyDateTimeFormat, CultureInfo.InvariantCulture,
DateTimeStyles.RoundtripKind, out dateTime))
{
switch( providerFactory.GetType( ).Name ) {
case "MySqlClientFactory":
colParam.Value = dateTime.ToString( "yyyy-MM-dd HH:mm:ss.ffffff" );
break;
default:
colParam.Value = dateTime;
break;
}
return true;
}
}
return false;
},
(colParam, value) => {
if( char.IsDigit( value[ 0 ] ) ) {
DateTimeOffset dateTimeOffset;
if( DateTimeOffset.TryParseExact( value, Default.DateTimeFormatsToRead, CultureInfo.InvariantCulture,
DateTimeStyles.RoundtripKind, out dateTimeOffset ) ) {
switch( providerFactory.GetType( ).Name ) {
case "MySqlClientFactory":
colParam.Value = dateTimeOffset.ToUniversalTime().ToString( "yyyy-MM-dd HH:mm:ss.ffffff" );
break;
default:
colParam.Value = dateTimeOffset;
break;
}
return true;
}
}
return false;
}
};
}