From f5eacced4254996d24acbda29f810d0c527e5549 Mon Sep 17 00:00:00 2001 From: Savorboard Date: Thu, 7 Jun 2018 18:33:48 +0800 Subject: [PATCH] Fixed DateTime localization format conversion error to sql.(#139) --- src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs | 2 +- src/DotNetCore.CAP.PostgreSql/PostgreSqlStorageConnection.cs | 2 +- src/DotNetCore.CAP.SqlServer/SqlServerStorageConnection.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs b/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs index 691717d..442328e 100644 --- a/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs +++ b/src/DotNetCore.CAP.MySql/MySqlStorageConnection.cs @@ -42,7 +42,7 @@ namespace DotNetCore.CAP.MySql public async Task> GetPublishedMessagesOfNeedRetry() { - var fourMinsAgo = DateTime.Now.AddMinutes(-4); + var fourMinsAgo = DateTime.Now.AddMinutes(-4).ToString("O"); var sql = $"SELECT * FROM `{_prefix}.published` WHERE `Retries`<{_capOptions.FailedRetryCount} AND `Added`<'{fourMinsAgo}' AND (`StatusName` = '{StatusName.Failed}' OR `StatusName` = '{StatusName.Scheduled}') LIMIT 200;"; diff --git a/src/DotNetCore.CAP.PostgreSql/PostgreSqlStorageConnection.cs b/src/DotNetCore.CAP.PostgreSql/PostgreSqlStorageConnection.cs index 763407c..e6b3d53 100644 --- a/src/DotNetCore.CAP.PostgreSql/PostgreSqlStorageConnection.cs +++ b/src/DotNetCore.CAP.PostgreSql/PostgreSqlStorageConnection.cs @@ -40,7 +40,7 @@ namespace DotNetCore.CAP.PostgreSql public async Task> GetPublishedMessagesOfNeedRetry() { - var fourMinsAgo = DateTime.Now.AddMinutes(-4); + var fourMinsAgo = DateTime.Now.AddMinutes(-4).ToString("O"); var sql = $"SELECT * FROM \"{Options.Schema}\".\"published\" WHERE \"Retries\"<{_capOptions.FailedRetryCount} AND \"Added\"<'{fourMinsAgo}' AND (\"StatusName\"='{StatusName.Failed}' OR \"StatusName\"='{StatusName.Scheduled}') LIMIT 200;"; diff --git a/src/DotNetCore.CAP.SqlServer/SqlServerStorageConnection.cs b/src/DotNetCore.CAP.SqlServer/SqlServerStorageConnection.cs index 9b931c1..2787fd0 100644 --- a/src/DotNetCore.CAP.SqlServer/SqlServerStorageConnection.cs +++ b/src/DotNetCore.CAP.SqlServer/SqlServerStorageConnection.cs @@ -78,7 +78,7 @@ VALUES(@Name,@Group,@Content,@Retries,@Added,@ExpiresAt,@StatusName);SELECT SCOP public async Task> GetReceivedMessagesOfNeedRetry() { - var fourMinsAgo = DateTime.Now.AddMinutes(-4); + var fourMinsAgo = DateTime.Now.AddMinutes(-4).ToString("O"); var sql = $"SELECT TOP (200) * FROM [{Options.Schema}].[Received] WITH (readpast) WHERE Retries<{_capOptions.FailedRetryCount} AND Added<'{fourMinsAgo}' AND (StatusName = '{StatusName.Failed}' OR StatusName = '{StatusName.Scheduled}')"; using (var connection = new SqlConnection(Options.ConnectionString))