Browse Source

Fix multiple issues

* Unreference the **Volo.Abp.Json.Newtonsoft** package.
* Remove the user history message sql statement.
pull/767/head
cKey 3 years ago
parent
commit
4162e9f08a
  1. 8
      aspnet-core/LINGYUN.MicroService.All.sln
  2. 2
      aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj
  3. 4
      aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/AbpBaiduLocationModule.cs
  4. 15
      aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/BaiduLocationHttpClient.cs
  5. 2
      aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN.Abp.Location.Tencent.csproj
  6. 4
      aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN/Abp/Location/Tencent/AbpTencentLocationModule.cs
  7. 11
      aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN/Abp/Location/Tencent/TencentLocationHttpClient.cs
  8. 492
      aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs
  9. 2
      aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj
  10. 2
      aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN.Abp.PushPlus.csproj
  11. 2
      aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN/Abp/PushPlus/AbpPushPlusModule.cs
  12. 2
      aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN.Abp.WeChat.csproj
  13. 2
      aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN/Abp/WeChat/AbpWeChatModule.cs
  14. 2
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj
  15. 2
      aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/AbpWxPusherModule.cs

8
aspnet-core/LINGYUN.MicroService.All.sln

@ -549,6 +549,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Notifications.H
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Localization.Persistence", "modules\localization\LINGYUN.Abp.Localization.Persistence\LINGYUN.Abp.Localization.Persistence.csproj", "{42A0FC3F-C38E-4FF4-B78A-5ED29DF144BF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{52E60F16-6304-4E37-A220-C94D8C5D27DC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{F3E04039-7BEE-46F8-B33B-FE13E977DCCA}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\release.yml = ..\.github\workflows\release.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -1670,6 +1677,7 @@ Global
{B153F98A-7DA9-4A12-A1D7-105BE9408FA1} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E}
{EFC5C34F-81A1-4EFC-966F-50B646C54FA6} = {1A23BB7F-1839-4204-88C5-7E9A6C9FBF1E}
{42A0FC3F-C38E-4FF4-B78A-5ED29DF144BF} = {90E88EAC-4291-4406-8D88-EFDF61B11292}
{F3E04039-7BEE-46F8-B33B-FE13E977DCCA} = {52E60F16-6304-4E37-A220-C94D8C5D27DC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718}

2
aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN.Abp.Location.Baidu.csproj

@ -18,9 +18,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="$(MicrosoftPackageVersion)" />
<PackageReference Include="Volo.Abp.Localization" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Json.Newtonsoft" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Threading" Version="$(VoloAbpPackageVersion)" />
</ItemGroup>

4
aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/AbpBaiduLocationModule.cs

@ -1,8 +1,7 @@
using LINGYUN.Abp.Location.Baidu.Localization;
using Microsoft.Extensions.DependencyInjection;
using Polly;
using System;
using Volo.Abp.Json.Newtonsoft;
using System;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
@ -12,7 +11,6 @@ namespace LINGYUN.Abp.Location.Baidu
{
[DependsOn(
typeof(AbpLocationModule),
typeof(AbpJsonNewtonsoftModule),
typeof(AbpThreadingModule))]
public class AbpBaiduLocationModule : AbpModule
{

15
aspnet-core/modules/common/LINGYUN.Abp.Location.Baidu/LINGYUN/Abp/Location/Baidu/BaiduLocationHttpClient.cs

@ -1,9 +1,10 @@
using LINGYUN.Abp.Location.Baidu.Response;
using LINGYUN.Abp.Location.Baidu.Localization;
using LINGYUN.Abp.Location.Baidu.Response;
using LINGYUN.Abp.Location.Baidu.Utils;
using LINGYUN.Abp.Location.Baidu.Localization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
@ -13,7 +14,6 @@ using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Json;
using Volo.Abp.Threading;
namespace LINGYUN.Abp.Location.Baidu
@ -21,20 +21,17 @@ namespace LINGYUN.Abp.Location.Baidu
public class BaiduLocationHttpClient : ITransientDependency
{
protected BaiduLocationOptions Options { get; }
protected IJsonSerializer JsonSerializer { get; }
protected IServiceProvider ServiceProvider { get; }
protected IHttpClientFactory HttpClientFactory { get; }
protected ICancellationTokenProvider CancellationTokenProvider { get; }
public BaiduLocationHttpClient(
IOptions<BaiduLocationOptions> options,
IJsonSerializer jsonSerializer,
IServiceProvider serviceProvider,
IHttpClientFactory httpClientFactory,
ICancellationTokenProvider cancellationTokenProvider)
{
Options = options.Value;
JsonSerializer = jsonSerializer;
ServiceProvider = serviceProvider;
HttpClientFactory = httpClientFactory;
CancellationTokenProvider = cancellationTokenProvider;
@ -58,7 +55,7 @@ namespace LINGYUN.Abp.Location.Baidu
}
var requestUrl = BuildRequestUrl(baiduMapUrl, baiduMapPath, requestParamters);
var responseContent = await MakeRequestAndGetResultAsync(requestUrl);
var baiduLocationResponse = JsonSerializer.Deserialize<BaiduIpGeocodeResponse>(responseContent);
var baiduLocationResponse = JsonConvert.DeserializeObject<BaiduIpGeocodeResponse>(responseContent);
if (!baiduLocationResponse.IsSuccess())
{
var localizerFactory = ServiceProvider.GetRequiredService<IStringLocalizerFactory>();
@ -111,7 +108,7 @@ namespace LINGYUN.Abp.Location.Baidu
}
var requestUrl = BuildRequestUrl(baiduMapUrl, baiduMapPath, requestParamters);
var responseContent = await MakeRequestAndGetResultAsync(requestUrl);
var baiduLocationResponse = JsonSerializer.Deserialize<BaiduGeocodeResponse>(responseContent);
var baiduLocationResponse = JsonConvert.DeserializeObject<BaiduGeocodeResponse>(responseContent);
if (!baiduLocationResponse.IsSuccess())
{
var localizerFactory = ServiceProvider.GetRequiredService<IStringLocalizerFactory>();
@ -163,7 +160,7 @@ namespace LINGYUN.Abp.Location.Baidu
requestParamters["location"] = string.Format("{0}%2C{1}", lat, lng);
var requestUrl = BuildRequestUrl(baiduMapUrl, baiduMapPath, requestParamters);
var responseContent = await MakeRequestAndGetResultAsync(requestUrl);
var baiduLocationResponse = JsonSerializer.Deserialize<BaiduReGeocodeResponse>(responseContent);
var baiduLocationResponse = JsonConvert.DeserializeObject<BaiduReGeocodeResponse>(responseContent);
if (!baiduLocationResponse.IsSuccess())
{
var localizerFactory = ServiceProvider.GetRequiredService<IStringLocalizerFactory>();

2
aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN.Abp.Location.Tencent.csproj

@ -18,9 +18,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="$(MicrosoftPackageVersion)" />
<PackageReference Include="Volo.Abp.Localization" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Json.Newtonsoft" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Threading" Version="$(VoloAbpPackageVersion)" />
</ItemGroup>

4
aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN/Abp/Location/Tencent/AbpTencentLocationModule.cs

@ -1,8 +1,7 @@
using LINGYUN.Abp.Location.Tencent.Localization;
using Microsoft.Extensions.DependencyInjection;
using Polly;
using System;
using Volo.Abp.Json.Newtonsoft;
using System;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
@ -12,7 +11,6 @@ namespace LINGYUN.Abp.Location.Tencent
{
[DependsOn(
typeof(AbpLocationModule),
typeof(AbpJsonNewtonsoftModule),
typeof(AbpThreadingModule))]
public class AbpTencentLocationModule : AbpModule
{

11
aspnet-core/modules/common/LINGYUN.Abp.Location.Tencent/LINGYUN/Abp/Location/Tencent/TencentLocationHttpClient.cs

@ -1,9 +1,10 @@
using LINGYUN.Abp.Location.Tencent.Response;
using LINGYUN.Abp.Location.Tencent.Localization;
using LINGYUN.Abp.Location.Tencent.Response;
using LINGYUN.Abp.Location.Tencent.Utils;
using LINGYUN.Abp.Location.Tencent.Localization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
@ -13,7 +14,6 @@ using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Json;
using Volo.Abp.Threading;
namespace LINGYUN.Abp.Location.Tencent
@ -21,20 +21,17 @@ namespace LINGYUN.Abp.Location.Tencent
public class TencentLocationHttpClient : ITransientDependency
{
protected TencentLocationOptions Options { get; }
protected IJsonSerializer JsonSerializer { get; }
protected IServiceProvider ServiceProvider { get; }
protected IHttpClientFactory HttpClientFactory { get; }
protected ICancellationTokenProvider CancellationTokenProvider { get; }
public TencentLocationHttpClient(
IOptions<TencentLocationOptions> options,
IJsonSerializer jsonSerializer,
IServiceProvider serviceProvider,
IHttpClientFactory httpClientFactory,
ICancellationTokenProvider cancellationTokenProvider)
{
Options = options.Value;
JsonSerializer = jsonSerializer;
ServiceProvider = serviceProvider;
HttpClientFactory = httpClientFactory;
CancellationTokenProvider = cancellationTokenProvider;
@ -193,7 +190,7 @@ namespace LINGYUN.Abp.Location.Tencent
{
var requestUrl = BuildRequestUrl(url, path, paramters);
var responseContent = await MakeRequestAndGetResultAsync(requestUrl);
var tencentLocationResponse = JsonSerializer.Deserialize<TResponse>(responseContent);
var tencentLocationResponse = JsonConvert.DeserializeObject<TResponse>(responseContent);
if (!tencentLocationResponse.IsSuccessed)
{
if (Options.VisableErrorToClient)

492
aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Chat/EfCoreMessageRepository.cs

@ -167,263 +167,263 @@ namespace LINGYUN.Abp.MessageService.Chat
#region SQL 原型
var sqlBuilder = new StringBuilder(1280);
sqlBuilder.AppendLine("SELECT");
sqlBuilder.AppendLine(" msg.* ");
sqlBuilder.AppendLine("FROM");
sqlBuilder.AppendLine(" (");
sqlBuilder.AppendLine(" SELECT");
sqlBuilder.AppendLine(" um.Content,");
sqlBuilder.AppendLine(" um.CreationTime,");
sqlBuilder.AppendLine(" um.CreatorId,");
sqlBuilder.AppendLine(" um.SendUserName,");
sqlBuilder.AppendLine(" ac.NickName AS Object,");
sqlBuilder.AppendLine(" ac.AvatarUrl,");
sqlBuilder.AppendLine(" um.Source,");
sqlBuilder.AppendLine(" um.MessageId,");
sqlBuilder.AppendLine(" um.Type,");
sqlBuilder.AppendLine(" um.TenantId,");
sqlBuilder.AppendLine(" um.ReceiveUserId,");
sqlBuilder.AppendLine(" '' AS GroupId,");
sqlBuilder.AppendLine(" um.ExtraProperties");
sqlBuilder.AppendLine(" FROM");
sqlBuilder.AppendLine(" (");
sqlBuilder.AppendLine(" SELECT");
sqlBuilder.AppendLine(" um.* ");
sqlBuilder.AppendLine(" FROM");
sqlBuilder.AppendLine(" appusermessages um");
sqlBuilder.AppendLine(" INNER JOIN ( SELECT max( um.MessageId ) AS MessageId FROM appusermessages um");
sqlBuilder.AppendLine(" WHERE");
sqlBuilder.AppendLine(" um.ReceiveUserId = @ReceiveUserId");
if (state.HasValue)
{
sqlBuilder.AppendLine(" AND um.State = @State");
}
if (CurrentTenant.IsAvailable)
{
sqlBuilder.AppendLine(" AND um.TenantId = @TenantId");
}
sqlBuilder.AppendLine(" GROUP BY um.ReceiveUserId ) gum ON um.MessageId = gum.MessageId");
sqlBuilder.AppendLine(" ) um");
sqlBuilder.AppendLine(" LEFT JOIN appuserchatcards ac ON ac.UserId = um.CreatorId ");
sqlBuilder.AppendLine(" UNION ALL");
sqlBuilder.AppendLine(" SELECT");
sqlBuilder.AppendLine(" gm.Content,");
sqlBuilder.AppendLine(" gm.CreationTime,");
sqlBuilder.AppendLine(" gm.CreatorId,");
sqlBuilder.AppendLine(" gm.SendUserName,");
sqlBuilder.AppendLine(" ag.Name AS Object,");
sqlBuilder.AppendLine(" ag.AvatarUrl,");
sqlBuilder.AppendLine(" gm.Source,");
sqlBuilder.AppendLine(" gm.MessageId,");
sqlBuilder.AppendLine(" gm.Type,");
sqlBuilder.AppendLine(" gm.TenantId,");
sqlBuilder.AppendLine(" '' AS ReceiveUserId,");
sqlBuilder.AppendLine(" gm.GroupId,");
sqlBuilder.AppendLine(" gm.ExtraProperties");
sqlBuilder.AppendLine(" FROM");
sqlBuilder.AppendLine(" appgroupmessages gm");
sqlBuilder.AppendLine(" INNER JOIN (");
sqlBuilder.AppendLine(" SELECT");
sqlBuilder.AppendLine(" max( gm.MessageId ) AS MessageId ");
sqlBuilder.AppendLine(" FROM");
sqlBuilder.AppendLine(" appuserchatcards ac");
sqlBuilder.AppendLine(" LEFT JOIN appuserchatgroups acg ON acg.UserId = ac.UserId");
sqlBuilder.AppendLine(" LEFT JOIN appgroupmessages gm ON gm.GroupId = acg.GroupId ");
sqlBuilder.AppendLine(" WHERE");
sqlBuilder.AppendLine(" ac.UserId = @ReceiveUserId ");
if (state.HasValue)
{
sqlBuilder.AppendLine(" AND gm.State = @State");
}
if (CurrentTenant.IsAvailable)
{
sqlBuilder.AppendLine(" AND gm.TenantId = @TenantId");
}
sqlBuilder.AppendLine(" GROUP BY");
sqlBuilder.AppendLine(" gm.GroupId");
sqlBuilder.AppendLine(" ) ggm ON ggm.MessageId = gm.MessageId ");
sqlBuilder.AppendLine(" INNER JOIN appchatgroups ag on ag.GroupId = gm.GroupId");
sqlBuilder.AppendLine(" ) AS msg");
sqlBuilder.AppendLine("ORDER BY ");
sqlBuilder.AppendLine(" @Sorting");
sqlBuilder.AppendLine(" LIMIT @MaxResultCount");
using var dbContection = dbContext.Database.GetDbConnection();
await dbContection.OpenAsync();
using var command = dbContection.CreateCommand();
command.Transaction = dbContext.Database.CurrentTransaction?.GetDbTransaction();
command.CommandText = sqlBuilder.ToString();
var receivedUser = command.CreateParameter();
receivedUser.DbType = System.Data.DbType.Guid;
receivedUser.ParameterName = "@ReceiveUserId";
receivedUser.Value = userId;
command.Parameters.Add(receivedUser);
var sorttingParam = command.CreateParameter();
sorttingParam.DbType = System.Data.DbType.String;
sorttingParam.ParameterName = "@Sorting";
sorttingParam.Value = sorting;
command.Parameters.Add(sorttingParam);
var limitParam = command.CreateParameter();
limitParam.DbType = System.Data.DbType.Int32;
limitParam.ParameterName = "@MaxResultCount";
limitParam.Value = maxResultCount;
command.Parameters.Add(limitParam);
if (state.HasValue)
{
var stateParam = command.CreateParameter();
stateParam.DbType = System.Data.DbType.Int32;
stateParam.ParameterName = "@State";
stateParam.Value = (int)state.Value;
command.Parameters.Add(stateParam);
}
if (CurrentTenant.IsAvailable)
{
var tenantParam = command.CreateParameter();
tenantParam.DbType = System.Data.DbType.Guid;
tenantParam.ParameterName = "@TenantId";
tenantParam.Value = CurrentTenant.Id.Value;
command.Parameters.Add(tenantParam);
}
var messages = new List<LastChatMessage>();
using var reader = await command.ExecuteReaderAsync();
T GetValue<T>(DbDataReader reader, int index)
{
var value = reader.GetValue(index);
if (value == null || value == DBNull.Value)
{
return default;
}
//var sqlBuilder = new StringBuilder(1280);
//sqlBuilder.AppendLine("SELECT");
//sqlBuilder.AppendLine(" msg.* ");
//sqlBuilder.AppendLine("FROM");
//sqlBuilder.AppendLine(" (");
//sqlBuilder.AppendLine(" SELECT");
//sqlBuilder.AppendLine(" um.Content,");
//sqlBuilder.AppendLine(" um.CreationTime,");
//sqlBuilder.AppendLine(" um.CreatorId,");
//sqlBuilder.AppendLine(" um.SendUserName,");
//sqlBuilder.AppendLine(" ac.NickName AS Object,");
//sqlBuilder.AppendLine(" ac.AvatarUrl,");
//sqlBuilder.AppendLine(" um.Source,");
//sqlBuilder.AppendLine(" um.MessageId,");
//sqlBuilder.AppendLine(" um.Type,");
//sqlBuilder.AppendLine(" um.TenantId,");
//sqlBuilder.AppendLine(" um.ReceiveUserId,");
//sqlBuilder.AppendLine(" '' AS GroupId,");
//sqlBuilder.AppendLine(" um.ExtraProperties");
//sqlBuilder.AppendLine(" FROM");
//sqlBuilder.AppendLine(" (");
//sqlBuilder.AppendLine(" SELECT");
//sqlBuilder.AppendLine(" um.* ");
//sqlBuilder.AppendLine(" FROM");
//sqlBuilder.AppendLine(" appusermessages um");
//sqlBuilder.AppendLine(" INNER JOIN ( SELECT max( um.MessageId ) AS MessageId FROM appusermessages um");
//sqlBuilder.AppendLine(" WHERE");
//sqlBuilder.AppendLine(" um.ReceiveUserId = @ReceiveUserId");
//if (state.HasValue)
//{
// sqlBuilder.AppendLine(" AND um.State = @State");
//}
//if (CurrentTenant.IsAvailable)
//{
// sqlBuilder.AppendLine(" AND um.TenantId = @TenantId");
//}
//sqlBuilder.AppendLine(" GROUP BY um.ReceiveUserId ) gum ON um.MessageId = gum.MessageId");
//sqlBuilder.AppendLine(" ) um");
//sqlBuilder.AppendLine(" LEFT JOIN appuserchatcards ac ON ac.UserId = um.CreatorId ");
//sqlBuilder.AppendLine(" UNION ALL");
//sqlBuilder.AppendLine(" SELECT");
//sqlBuilder.AppendLine(" gm.Content,");
//sqlBuilder.AppendLine(" gm.CreationTime,");
//sqlBuilder.AppendLine(" gm.CreatorId,");
//sqlBuilder.AppendLine(" gm.SendUserName,");
//sqlBuilder.AppendLine(" ag.Name AS Object,");
//sqlBuilder.AppendLine(" ag.AvatarUrl,");
//sqlBuilder.AppendLine(" gm.Source,");
//sqlBuilder.AppendLine(" gm.MessageId,");
//sqlBuilder.AppendLine(" gm.Type,");
//sqlBuilder.AppendLine(" gm.TenantId,");
//sqlBuilder.AppendLine(" '' AS ReceiveUserId,");
//sqlBuilder.AppendLine(" gm.GroupId,");
//sqlBuilder.AppendLine(" gm.ExtraProperties");
//sqlBuilder.AppendLine(" FROM");
//sqlBuilder.AppendLine(" appgroupmessages gm");
//sqlBuilder.AppendLine(" INNER JOIN (");
//sqlBuilder.AppendLine(" SELECT");
//sqlBuilder.AppendLine(" max( gm.MessageId ) AS MessageId ");
//sqlBuilder.AppendLine(" FROM");
//sqlBuilder.AppendLine(" appuserchatcards ac");
//sqlBuilder.AppendLine(" LEFT JOIN appuserchatgroups acg ON acg.UserId = ac.UserId");
//sqlBuilder.AppendLine(" LEFT JOIN appgroupmessages gm ON gm.GroupId = acg.GroupId ");
//sqlBuilder.AppendLine(" WHERE");
//sqlBuilder.AppendLine(" ac.UserId = @ReceiveUserId ");
//if (state.HasValue)
//{
// sqlBuilder.AppendLine(" AND gm.State = @State");
//}
//if (CurrentTenant.IsAvailable)
//{
// sqlBuilder.AppendLine(" AND gm.TenantId = @TenantId");
//}
//sqlBuilder.AppendLine(" GROUP BY");
//sqlBuilder.AppendLine(" gm.GroupId");
//sqlBuilder.AppendLine(" ) ggm ON ggm.MessageId = gm.MessageId ");
//sqlBuilder.AppendLine(" INNER JOIN appchatgroups ag on ag.GroupId = gm.GroupId");
//sqlBuilder.AppendLine(" ) AS msg");
//sqlBuilder.AppendLine("ORDER BY ");
//sqlBuilder.AppendLine(" @Sorting");
//sqlBuilder.AppendLine(" LIMIT @MaxResultCount");
//using var dbContection = dbContext.Database.GetDbConnection();
//await dbContection.OpenAsync();
//using var command = dbContection.CreateCommand();
//command.Transaction = dbContext.Database.CurrentTransaction?.GetDbTransaction();
//command.CommandText = sqlBuilder.ToString();
//var receivedUser = command.CreateParameter();
//receivedUser.DbType = System.Data.DbType.Guid;
//receivedUser.ParameterName = "@ReceiveUserId";
//receivedUser.Value = userId;
//command.Parameters.Add(receivedUser);
//var sorttingParam = command.CreateParameter();
//sorttingParam.DbType = System.Data.DbType.String;
//sorttingParam.ParameterName = "@Sorting";
//sorttingParam.Value = sorting;
//command.Parameters.Add(sorttingParam);
//var limitParam = command.CreateParameter();
//limitParam.DbType = System.Data.DbType.Int32;
//limitParam.ParameterName = "@MaxResultCount";
//limitParam.Value = maxResultCount;
//command.Parameters.Add(limitParam);
//if (state.HasValue)
//{
// var stateParam = command.CreateParameter();
// stateParam.DbType = System.Data.DbType.Int32;
// stateParam.ParameterName = "@State";
// stateParam.Value = (int)state.Value;
// command.Parameters.Add(stateParam);
//}
//if (CurrentTenant.IsAvailable)
//{
// var tenantParam = command.CreateParameter();
// tenantParam.DbType = System.Data.DbType.Guid;
// tenantParam.ParameterName = "@TenantId";
// tenantParam.Value = CurrentTenant.Id.Value;
// command.Parameters.Add(tenantParam);
//}
//var messages = new List<LastChatMessage>();
//using var reader = await command.ExecuteReaderAsync();
//T GetValue<T>(DbDataReader reader, int index)
//{
// var value = reader.GetValue(index);
// if (value == null || value == DBNull.Value)
// {
// return default;
// }
var valueType = typeof(T);
var converter = TypeDescriptor.GetConverter(valueType);
if (converter.CanConvertFrom(value.GetType()))
{
return (T)converter.ConvertFrom(value);
}
return (T)Convert.ChangeType(value, typeof(T));
};
ExtraPropertyDictionary GetExtraProperties(DbDataReader reader, int index)
{
var value = reader.GetValue(index);
if (value == null || value == DBNull.Value)
{
return new ExtraPropertyDictionary();
}
var extraPropertiesAsJson = value.ToString();
if (extraPropertiesAsJson.IsNullOrEmpty() || extraPropertiesAsJson == "{}")
{
return new ExtraPropertyDictionary();
}
// var valueType = typeof(T);
// var converter = TypeDescriptor.GetConverter(valueType);
// if (converter.CanConvertFrom(value.GetType()))
// {
// return (T)converter.ConvertFrom(value);
// }
// return (T)Convert.ChangeType(value, typeof(T));
//};
//ExtraPropertyDictionary GetExtraProperties(DbDataReader reader, int index)
//{
// var value = reader.GetValue(index);
// if (value == null || value == DBNull.Value)
// {
// return new ExtraPropertyDictionary();
// }
// var extraPropertiesAsJson = value.ToString();
// if (extraPropertiesAsJson.IsNullOrEmpty() || extraPropertiesAsJson == "{}")
// {
// return new ExtraPropertyDictionary();
// }
var deserializeOptions = new JsonSerializerOptions();
deserializeOptions.Converters.Add(new ObjectToInferredTypesConverter());
// var deserializeOptions = new JsonSerializerOptions();
// deserializeOptions.Converters.Add(new ObjectToInferredTypesConverter());
var dictionary = JsonSerializer.Deserialize<ExtraPropertyDictionary>(extraPropertiesAsJson, deserializeOptions) ??
new ExtraPropertyDictionary();
// var dictionary = JsonSerializer.Deserialize<ExtraPropertyDictionary>(extraPropertiesAsJson, deserializeOptions) ??
// new ExtraPropertyDictionary();
return dictionary;
}
// return dictionary;
//}
while (reader.Read())
{
messages.Add(new LastChatMessage
{
Content = GetValue<string>(reader, 0),
SendTime = GetValue<DateTime>(reader, 1),
FormUserId = GetValue<Guid>(reader, 2),
FormUserName = GetValue<string>(reader, 3),
Object = GetValue<string>(reader, 4),
AvatarUrl = GetValue<string>(reader, 5),
Source = (MessageSourceType)GetValue<int>(reader, 6),
MessageId = GetValue<string>(reader, 7),
MessageType = (MessageType)GetValue<int>(reader, 8),
TenantId = GetValue<Guid?>(reader, 9),
ToUserId = GetValue<string>(reader, 10),
GroupId = GetValue<string>(reader, 11),
ExtraProperties = GetExtraProperties(reader, 12),
});
}
//while (reader.Read())
//{
// messages.Add(new LastChatMessage
// {
// Content = GetValue<string>(reader, 0),
// SendTime = GetValue<DateTime>(reader, 1),
// FormUserId = GetValue<Guid>(reader, 2),
// FormUserName = GetValue<string>(reader, 3),
// Object = GetValue<string>(reader, 4),
// AvatarUrl = GetValue<string>(reader, 5),
// Source = (MessageSourceType)GetValue<int>(reader, 6),
// MessageId = GetValue<string>(reader, 7),
// MessageType = (MessageType)GetValue<int>(reader, 8),
// TenantId = GetValue<Guid?>(reader, 9),
// ToUserId = GetValue<string>(reader, 10),
// GroupId = GetValue<string>(reader, 11),
// ExtraProperties = GetExtraProperties(reader, 12),
// });
//}
return messages;
//return messages;
#endregion
#region 待 EF 团队解决此问题
//// 聚合用户消息
//var aggreUserMsgIdQuery = dbContext.Set<UserMessage>()
// .Where(msg => msg.ReceiveUserId == userId)
// .WhereIf(state.HasValue, x => x.SendState == state)
// .GroupBy(msg => msg.ReceiveUserId)
// .Select(msg => new
// {
// MessageId = msg.Max(x => x.MessageId)
// });
//var joinUserMsg = from um in dbContext.Set<UserMessage>()
// join aum in aggreUserMsgIdQuery
// on um.MessageId equals aum.MessageId
// join ucc in dbContext.Set<UserChatCard>()
// on um.CreatorId equals ucc.UserId
// select new LastChatMessage
// {
// Content = um.Content,
// SendTime = um.CreationTime,
// FormUserId = um.CreatorId.Value,
// FormUserName = um.SendUserName,
// Object = ucc.NickName,
// AvatarUrl = ucc.AvatarUrl,
// Source = um.Source,
// MessageId = Convert.ToString(um.MessageId),
// MessageType = um.Type,
// TenantId = um.TenantId,
// // ToUserId = Convert.ToString(um.ReceiveUserId),
// // GroupId = "",
// };
//// 聚合群组消息
//var aggreGroupMsgIdQuery = from ucc in dbContext.Set<UserChatCard>()
// join ucg in dbContext.Set<UserChatGroup>()
// on ucc.UserId equals ucg.UserId
// join gm in dbContext.Set<GroupMessage>()
// on ucg.GroupId equals gm.GroupId
// where ucc.UserId.Equals(userId)
// group gm by gm.GroupId into ggm
// select new
// {
// MessageId = ggm.Max(gm => gm.MessageId),
// };
//var joinGroupMsg = from gm in dbContext.Set<GroupMessage>()
// join agm in aggreGroupMsgIdQuery
// on gm.MessageId equals agm.MessageId
// join cg in dbContext.Set<ChatGroup>()
// on gm.GroupId equals cg.GroupId
// select new LastChatMessage
// {
// Content = gm.Content,
// SendTime = gm.CreationTime,
// FormUserId = gm.CreatorId.Value,
// FormUserName = gm.SendUserName,
// Object = cg.Name,
// AvatarUrl = cg.AvatarUrl,
// Source = gm.Source,
// MessageId = Convert.ToString(gm.MessageId),
// MessageType = gm.Type,
// TenantId = gm.TenantId,
// // ToUserId = "",
// // GroupId = Convert.ToString(gm.GroupId)
// };
//return await joinUserMsg
// .Concat(joinGroupMsg)
// .OrderBy(sorting)
// .Take(maxResultCount)
// .ToListAsync(GetCancellationToken(cancellationToken));
var aggreUserMsgIdQuery = dbContext.Set<UserMessage>()
.Where(msg => msg.ReceiveUserId == userId)
.WhereIf(state.HasValue, x => x.State == state)
.GroupBy(msg => msg.ReceiveUserId)
.Select(msg => new
{
MessageId = msg.Max(x => x.MessageId)
});
var joinUserMsg = from um in dbContext.Set<UserMessage>()
join aum in aggreUserMsgIdQuery
on um.MessageId equals aum.MessageId
join ucc in dbContext.Set<UserChatCard>()
on um.CreatorId equals ucc.UserId
select new LastChatMessage
{
Content = Convert.ToString(um.Content),
SendTime = um.CreationTime,
FormUserId = um.CreatorId.Value,
FormUserName = Convert.ToString(um.SendUserName),
Object = Convert.ToString(ucc.NickName),
AvatarUrl = Convert.ToString(ucc.AvatarUrl),
Source = um.Source,
MessageId = Convert.ToString(um.MessageId),
MessageType = um.Type,
TenantId = um.TenantId,
ToUserId = Convert.ToString(um.ReceiveUserId),
GroupId = Convert.ToString(""),
};
// 聚合群组消息
var aggreGroupMsgIdQuery = from ucc in dbContext.Set<UserChatCard>()
join ucg in dbContext.Set<UserChatGroup>()
on ucc.UserId equals ucg.UserId
join gm in dbContext.Set<GroupMessage>()
on ucg.GroupId equals gm.GroupId
where ucc.UserId.Equals(userId)
group gm by gm.GroupId into ggm
select new
{
MessageId = ggm.Max(gm => gm.MessageId),
};
var joinGroupMsg = from gm in dbContext.Set<GroupMessage>()
join agm in aggreGroupMsgIdQuery
on gm.MessageId equals agm.MessageId
join cg in dbContext.Set<ChatGroup>()
on gm.GroupId equals cg.GroupId
select new LastChatMessage
{
Content = Convert.ToString(gm.Content),
SendTime = gm.CreationTime,
FormUserId = gm.CreatorId.Value,
FormUserName = Convert.ToString(gm.SendUserName),
Object = Convert.ToString(cg.Name),
AvatarUrl = Convert.ToString(cg.AvatarUrl),
Source = gm.Source,
MessageId = Convert.ToString(gm.MessageId),
MessageType = gm.Type,
TenantId = gm.TenantId,
ToUserId = Convert.ToString(""),
GroupId = Convert.ToString(gm.GroupId)
};
return await joinUserMsg
.Concat(joinGroupMsg)
.OrderBy(sorting)
.Take(maxResultCount)
.ToListAsync(GetCancellationToken(cancellationToken));
#endregion

2
aspnet-core/modules/platform/LINGYUN.Platform.Domain/LINGYUN.Platform.Domain.csproj

@ -9,11 +9,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.BlobStoring" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Settings" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Json.Newtonsoft" Version="$(VoloAbpPackageVersion)" />
</ItemGroup>
<ItemGroup>

2
aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN.Abp.PushPlus.csproj

@ -18,7 +18,7 @@
<ItemGroup>
<PackageReference Include="Volo.Abp.Caching" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Json.Newtonsoft" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftPackageVersion)" />
</ItemGroup>

2
aspnet-core/modules/pushplus/LINGYUN.Abp.PushPlus/LINGYUN/Abp/PushPlus/AbpPushPlusModule.cs

@ -2,7 +2,6 @@
using LINGYUN.Abp.PushPlus.Localization;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Caching;
using Volo.Abp.Json.Newtonsoft;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.Settings;
@ -11,7 +10,6 @@ using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.PushPlus;
[DependsOn(
typeof(AbpJsonNewtonsoftModule),
typeof(AbpSettingsModule),
typeof(AbpCachingModule),
typeof(AbpFeaturesLimitValidationModule))]

2
aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN.Abp.WeChat.csproj

@ -19,7 +19,7 @@
<ItemGroup>
<PackageReference Include="Volo.Abp.Features" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Caching" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Json.Newtonsoft" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftPackageVersion)" />
</ItemGroup>

2
aspnet-core/modules/wechat/LINGYUN.Abp.WeChat/LINGYUN/Abp/WeChat/AbpWeChatModule.cs

@ -3,7 +3,6 @@ using Microsoft.Extensions.DependencyInjection;
using System;
using Volo.Abp.Caching;
using Volo.Abp.Features;
using Volo.Abp.Json.Newtonsoft;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.Settings;
@ -14,7 +13,6 @@ namespace LINGYUN.Abp.WeChat
[DependsOn(
typeof(AbpCachingModule),
typeof(AbpFeaturesModule),
typeof(AbpJsonNewtonsoftModule),
typeof(AbpSettingsModule))]
public class AbpWeChatModule : AbpModule
{

2
aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN.Abp.WxPusher.csproj

@ -18,7 +18,7 @@
<ItemGroup>
<PackageReference Include="Volo.Abp.Caching" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Volo.Abp.Json.Newtonsoft" Version="$(VoloAbpPackageVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
<PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftPackageVersion)" />
</ItemGroup>

2
aspnet-core/modules/wx-pusher/LINGYUN.Abp.WxPusher/LINGYUN/Abp/WxPusher/AbpWxPusherModule.cs

@ -4,7 +4,6 @@ using LINGYUN.Abp.WxPusher.User;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Volo.Abp.Caching;
using Volo.Abp.Json.Newtonsoft;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.Settings;
@ -13,7 +12,6 @@ using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.WxPusher;
[DependsOn(
typeof(AbpJsonNewtonsoftModule),
typeof(AbpSettingsModule),
typeof(AbpCachingModule),
typeof(AbpFeaturesLimitValidationModule))]

Loading…
Cancel
Save