Skip to content

Commit

Permalink
升级 NET451 到 NET462 #2588
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreySu committed Apr 3, 2022
1 parent b58d1ad commit 328697f
Show file tree
Hide file tree
Showing 86 changed files with 255 additions and 278 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Senparc.CO2NET.Utilities;
using Senparc.CO2NET.Trace;

#if NET451
#if NET462
using System.Web;
#else
using Microsoft.AspNetCore.Http;
Expand Down Expand Up @@ -112,7 +112,7 @@ public void Save(Config config)
{
doc.Root.Element("Versions").Add(new XElement("Version", version));
}
#if NET451
#if NET462
doc.Save(GetDatabaseFilePath());
#else
using (FileStream fs = new FileStream(GetDatabaseFilePath(), FileMode.OpenOrCreate, FileAccess.ReadWrite))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
using Senparc.Weixin.MP.Helpers;
using Senparc.Weixin.MP;
//DPBMARK_END
#if NET451
#if NET462
using System.Web;
using System.Configuration;
using Senparc.Weixin.Sample.CommonService.TemplateMessage;//DPBMARK MP DPBMARK_END
Expand Down Expand Up @@ -69,7 +69,7 @@ public ResponseMessageBase GetResponseMessage(RequestMessageEventBase requestMes
var strongResponseMessage = requestMessage.CreateResponseMessage<ResponseMessageText>();

//获取Senparc.Weixin.MP.dll版本信息
#if NET451
#if NET462
var dllPath = HttpContext.Current.Server.MapPath("~/bin/Senparc.Weixin.MP.dll");
#else
//var dllPath = ServerUtility.ContentRootMapPath("~/bin/Release/netcoreapp2.2/Senparc.Weixin.MP.dll");//本地测试路径
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using System.Threading;
using System.Threading.Tasks;

#if NET451
#if NET462
using System.Web;
#else
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.Linq;
using System.Threading.Tasks;

#if NET451
#if NET462
using System.Web;
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
using Senparc.CO2NET.Cache;
using Senparc.Weixin.MP;

#if NET451
#if NET462
using System.Web;
using System.Configuration;
using System.Web.Configuration;
Expand Down Expand Up @@ -211,7 +211,7 @@ public override async Task<IResponseMessageBase> OnTextRequestAsync(RequestMessa
#endregion

var responseXml = MessageAgent.RequestXml(this,
#if NET451
#if NET462
null,
#else
Senparc.CO2NET.SenparcDI.GetServiceProvider(),
Expand Down Expand Up @@ -266,7 +266,7 @@ public override async Task<IResponseMessageBase> OnTextRequestAsync(RequestMessa
.Keyword("AsyncTest", () =>
{
//异步并发测试(提供给单元测试使用)
#if NET451
#if NET462
var begin = SystemTime.Now;
int t1, t2, t3;
System.Threading.ThreadPool.GetAvailableThreads(out t1, out t3);
Expand Down Expand Up @@ -413,7 +413,7 @@ public override async Task<IResponseMessageBase> OnTextRequestAsync(RequestMessa
}
else
{
#if !NET451
#if !NET462
var httpContextAccessor = base.ServiceProvider.GetService<IHttpContextAccessor>();
defaultResponseMessage.Content = $"ServiceProvider 载入成功,从 IHttpContextAccessor 读取当前服务器协议:{httpContextAccessor.HttpContext.Request.Scheme}";
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
using System.Linq;
using System.Threading.Tasks;

//#if NET451
//#if NET462
//using System.Web;
//#endif

Expand All @@ -40,7 +40,7 @@ public partial class CustomMessageHandler
private string GetWelcomeInfo()
{
//获取Senparc.Weixin.MP.dll版本信息
#if NET451
#if NET462
var filePath = ServerUtility.ContentRootMapPath("~/bin/Senparc.Weixin.MP.dll");//发布路径
#else
//var filePath = ServerUtility.ContentRootMapPath("~/bin/Release/netcoreapp2.2/Senparc.Weixin.MP.dll");//本地测试路径
Expand Down Expand Up @@ -189,7 +189,7 @@ public override IResponseMessageBase OnEvent_ClickRequest(RequestMessageEvent_Cl
{
//上传缩略图

#if NET451
#if NET462
var filePath = "~/Images/Logo.thumb.jpg";
#else
var filePath = "~/wwwroot/Images/Logo.thumb.jpg";
Expand All @@ -212,7 +212,7 @@ public override IResponseMessageBase OnEvent_ClickRequest(RequestMessageEvent_Cl
case "SubClickRoot_Image":
{
//上传图片
#if NET451
#if NET462
var filePath = "~/Images/Logo.jpg";
#else
var filePath = "~/wwwroot/Images/Logo.jpg";
Expand Down Expand Up @@ -248,7 +248,7 @@ public override IResponseMessageBase OnEvent_ClickRequest(RequestMessageEvent_Cl
//获取返回的XML
var dt1 = SystemTime.Now;
reponseMessage = MessageAgent.RequestResponseMessage(this,
#if NET451
#if NET462
null,
#else
Senparc.CO2NET.SenparcDI.GetServiceProvider(),
Expand All @@ -270,7 +270,7 @@ public override IResponseMessageBase OnEvent_ClickRequest(RequestMessageEvent_Cl
{
//原始方法为:MessageAgent.RequestXml(this,agentUrl, agentToken, RequestDocument.ToString());//获取返回的XML
reponseMessage = this.RequestResponseMessage(
#if NET451
#if NET462
null,
#else
Senparc.CO2NET.SenparcDI.GetServiceProvider(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using Senparc.NeuChar.Helpers;


#if NET451
#if NET462
using System.Web.Configuration;
using Senparc.Weixin.Sample.CommonService.CustomMessageHandler;
using Senparc.Weixin.Sample.CommonService.OpenTicket;
Expand All @@ -37,7 +37,7 @@ public class OpenCheckMessageHandler : MessageHandler<CustomMessageContext>

//private string testAppId = "wx570bc396a51b8ff8";

#if NET451
#if NET462
private string componentAppId = Config.SenparcWeixinSetting.Component_Appid;
private string componentSecret = Config.SenparcWeixinSetting.Component_Secret;
#else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//DPBMARK_FILE WebSocket
#if NET451
#if NET462

using System;
using System.Linq;
Expand Down Expand Up @@ -49,7 +49,7 @@ public override async Task OnMessageReceiced(WebSocketHelper webSocketHandler, R
var result = string.Concat(message.Reverse());
await webSocketHandler.SendMessage(result);

#if NET451
#if NET462
var appId = Config.SenparcWeixinSetting.WxOpenAppId;//与微信小程序账号后台的AppId设置保持一致,区分大小写。
#else
var appId = "WxOpenAppId";//与微信小程序账号后台的AppId设置保持一致,区分大小写。
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//DPBMARK_FILE WebSocket
#if !NET451
#if !NET462
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
using Senparc.CO2NET.Extensions;
using Senparc.Weixin.MP;

#if NET451
#if NET462
using System.Web.Configuration;
#else

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<None Remove="Properties\**" />
</ItemGroup>

<ItemGroup>
<None Remove="packages.config" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Senparc.NeuChar" Version="2.0.5.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Senparc.Weixin.Entities.TemplateMessage;
using Senparc.Weixin.MP.AdvancedAPIs.TemplateMessage;

#if NET451
#if NET462
using System.Web;
#else
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -72,7 +72,7 @@ public WeixinTemplate_ExceptionAlert(string _first, string host, string service,
string newMessage = null;
try
{
#if !NET451
#if !NET462

var httpContextAccessor = Senparc.CO2NET.SenparcDI.GetServiceProvider().GetService<IHttpContextAccessor>();
var httpContext = httpContextAccessor.HttpContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using System.Threading;
using System.Threading.Tasks;

#if NET451
#if NET462
using System.Web.Routing;
using System.Web.WebSockets;
#else
Expand All @@ -35,7 +35,7 @@ namespace Senparc.WebSocket
/// </summary>
public class WebSocketHelper
{
#if NET451
#if NET462
public System.Net.WebSockets.WebSocket WebSocket { get; set; }
#else
public SenparcWebSocketHubBase WebSocket { get; set; }
Expand All @@ -50,7 +50,7 @@ public class WebSocketHelper
/// </summary>
///// <param name="webSocketContext"></param>
/// <param name="cancellationToken"></param>
#if NET451
#if NET462
public WebSocketHelper(System.Net.WebSockets.WebSocket socket,/*AspNetWebSocketContext webSocketContext,*/ CancellationToken cancellationToken)
{
WebSocket = socket;
Expand All @@ -68,7 +68,7 @@ public WebSocketHelper(SenparcWebSocketHubBase hub, CancellationToken cancellati
/// </summary>
/// <param name="message">文字消息</param>
/// <returns></returns>
#if NET451
#if NET462
public async Task SendMessage(string message)
#else
public async Task SendMessage(string message, IClientProxy clientProxy)
Expand All @@ -83,7 +83,7 @@ public async Task SendMessage(string message, IClientProxy clientProxy)
var newString = Senparc.CO2NET.Helpers.SerializerHelper.GetJsonString(data);
//String.Format("Hello, " + receiveString + " ! Time {0}", DateTimeOffset.Now.ToString());

#if NET451
#if NET462
Byte[] bytes = System.Text.Encoding.UTF8.GetBytes(newString);
await WebSocket.SendAsync(new ArraySegment<byte>(bytes),
WebSocketMessageType.Text, true, _cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
----------------------------------------------------------------*/

#if !NET451
#if !NET462
using Microsoft.Extensions.DependencyInjection;
using Senparc.CO2NET.RegisterServices;
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Net.WebSockets;
using System.Threading.Tasks;

#if NET451
#if NET462
using System.Web.Script.Serialization;
#else
using Microsoft.AspNetCore.Builder;
Expand All @@ -18,7 +18,7 @@ namespace Senparc.WebSocket
{
public partial class WebSocketHandler
{
#if NET451
#if NET462
private static async Task HandleMessage(System.Net.WebSockets.WebSocket webSocket)
{
//Gets the current WebSocket object.
Expand Down Expand Up @@ -85,7 +85,7 @@ await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure,
};


#if NET451
#if NET462
JavaScriptSerializer js = new JavaScriptSerializer();
receivedMessage = js.Deserialize<ReceivedMessage>(receiveString);
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Threading.Tasks;
using System.Threading;

#if NET451
#if NET462

#else
using Microsoft.AspNetCore.Builder;
Expand All @@ -18,7 +18,7 @@
namespace Senparc.WebSocket
{

#if !NET451
#if !NET462

//.NET Core(SignalR) 不需要

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
//using Microsoft.AspNetCore.Routing;
//using Microsoft.AspNetCore.WebSockets;

#if NET451
#if NET462
using System.Web;
using System.Web.Routing;
using System.Web.WebSockets;
#endif

namespace Senparc.WebSocket
{
#if NET451
#if NET462
/// <summary>
/// WebSocket处理程序
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
using System.Text;
using System.Threading.Tasks;

#if NET451
#if NET462
using System.Web.Routing;
#endif

namespace Senparc.WebSocket
{
#if NET451
#if NET462
/// <summary>
/// WebSocketRoute
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
using System.Threading.Tasks;
//using Microsoft.AspNetCore.Http;
//using Microsoft.AspNetCore.Routing;
#if NET451
#if NET462
using System.Web;
using System.Web.Routing;
#endif

namespace Senparc.WebSocket
{
#if NET451
#if NET462
/// <summary>
/// WebSocketHansler,处理WebSocket请求
/// </summary>
Expand Down
Loading

0 comments on commit 328697f

Please sign in to comment.