ソースを参照

add dashboard of sql server storage impl

master
yangxiaodong 7年前
コミット
591f2c7381
4個のファイルの変更50行の追加0行の削除
  1. +12
    -0
      src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs
  2. +11
    -0
      src/DotNetCore.CAP.PostgreSql/PostgreSqlStorageConnection.cs
  3. +5
    -0
      src/DotNetCore.CAP.SqlServer/SqlServerMonitoringApi.cs
  4. +22
    -0
      src/DotNetCore.CAP.SqlServer/SqlServerStorageConnection.cs

+ 12
- 0
src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs ファイルの表示

@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Dapper;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Models;
using DotNetCore.CAP.Processor.States;
using MySql.Data.MySqlClient;

namespace DotNetCore.CAP.MySql
@@ -117,6 +118,7 @@ VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
}
}


public void Dispose()
{
}
@@ -168,5 +170,15 @@ VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
{
throw new NotImplementedException();
}

public bool ChangePublishedState(int messageId, IState state)
{
throw new NotImplementedException();
}

public bool ChangeReceivedState(int messageId, IState state)
{
throw new NotImplementedException();
}
}
}

+ 11
- 0
src/DotNetCore.CAP.PostgreSql/PostgreSqlStorageConnection.cs ファイルの表示

@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Dapper;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Models;
using DotNetCore.CAP.Processor.States;
using Npgsql;

namespace DotNetCore.CAP.PostgreSql
@@ -153,5 +154,15 @@ namespace DotNetCore.CAP.PostgreSql
{
throw new NotImplementedException();
}

public bool ChangePublishedState(int messageId, IState state)
{
throw new NotImplementedException();
}

public bool ChangeReceivedState(int messageId, IState state)
{
throw new NotImplementedException();
}
}
}

+ 5
- 0
src/DotNetCore.CAP.SqlServer/SqlServerMonitoringApi.cs ファイルの表示

@@ -94,6 +94,10 @@ _options.Schema);
{
where += " and name=@Name";
}
if (!string.IsNullOrEmpty(queryDto.Name))
{
where += " and group=@Group";
}
if (!string.IsNullOrEmpty(queryDto.Content))
{
where += " and content like '%@Content%'";
@@ -106,6 +110,7 @@ _options.Schema);
return conn.Query<MessageDto>(sqlQuery, new
{
StatusName = queryDto.StatusName,
Group = queryDto.Group,
Name = queryDto.Name,
Content = queryDto.Content,
Offset = queryDto.CurrentPage * queryDto.PageSize,


+ 22
- 0
src/DotNetCore.CAP.SqlServer/SqlServerStorageConnection.cs ファイルの表示

@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Dapper;
using DotNetCore.CAP.Infrastructure;
using DotNetCore.CAP.Models;
using DotNetCore.CAP.Processor.States;

namespace DotNetCore.CAP.SqlServer
{
@@ -65,6 +66,16 @@ OUTPUT DELETED.MessageId,DELETED.[MessageType];";
}
}

public bool ChangePublishedState(int messageId, IState state)
{
var sql = $"UPDATE [{_options.Schema}].[Published] SET Retries=Retries+1,StatusName = '{state.Name}' WHERE Id={messageId}";

using (var connection = new SqlConnection(_options.ConnectionString))
{
return connection.Execute(sql) > 0;
}
}

// CapReceviedMessage

public async Task StoreReceivedMessageAsync(CapReceivedMessage message)
@@ -108,6 +119,16 @@ VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
}
}

public bool ChangeReceivedState(int messageId, IState state)
{
var sql = $"UPDATE [{_options.Schema}].[Received] SET Retries=Retries+1,StatusName = '{state.Name}' WHERE Id={messageId}";

using (var connection = new SqlConnection(_options.ConnectionString))
{
return connection.Execute(sql) > 0;
}
}

public void Dispose()
{
}
@@ -161,5 +182,6 @@ VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);";
{
return new StateData();
}

}
}

読み込み中…
キャンセル
保存