Commit 591f2c73 authored by yangxiaodong's avatar yangxiaodong

add dashboard of sql server storage impl

parent e9aaf305
......@@ -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();
}
}
}
\ No newline at end of file
......@@ -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();
}
}
}
\ No newline at end of file
......@@ -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,
......
......@@ -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();
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment