Skip to content

Commit d07d0dc

Browse files
committed
update v6.2.6.4
1 parent 849003b commit d07d0dc

15 files changed

+224
-778
lines changed

SAEA.WebRedisManager.sln

+1-7
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.0.30011.22
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SAEA.WebRedisManagerForNet", "SAEA.WebRedisManagerForNet\SAEA.WebRedisManagerForNet.csproj", "{598C65E6-356A-47FF-922B-16349D83C9A1}"
7-
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SAEA.WebRedisManager", "SAEA.WebRedisManager\SAEA.WebRedisManager.csproj", "{BCE122A2-20C5-4CE9-8353-63369347407A}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SAEA.WebRedisManager", "SAEA.WebRedisManager\SAEA.WebRedisManager.csproj", "{BCE122A2-20C5-4CE9-8353-63369347407A}"
97
EndProject
108
Global
119
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1210
Debug|Any CPU = Debug|Any CPU
1311
Release|Any CPU = Release|Any CPU
1412
EndGlobalSection
1513
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16-
{598C65E6-356A-47FF-922B-16349D83C9A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17-
{598C65E6-356A-47FF-922B-16349D83C9A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
18-
{598C65E6-356A-47FF-922B-16349D83C9A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
19-
{598C65E6-356A-47FF-922B-16349D83C9A1}.Release|Any CPU.Build.0 = Release|Any CPU
2014
{BCE122A2-20C5-4CE9-8353-63369347407A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2115
{BCE122A2-20C5-4CE9-8353-63369347407A}.Debug|Any CPU.Build.0 = Debug|Any CPU
2216
{BCE122A2-20C5-4CE9-8353-63369347407A}.Release|Any CPU.ActiveCfg = Release|Any CPU

SAEA.WebRedisManager/AppService.cs

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/****************************************************************************
2+
*项目名称:SAEA.WebRedisManager
3+
*CLR 版本:4.0.30319.42000
4+
*机器名称:WALLE-PC
5+
*命名空间:SAEA.WebRedisManager
6+
*类 名 称:AppService
7+
*版 本 号:V1.0.0.0
8+
*创建人: yswenli
9+
*电子邮箱:[email protected]
10+
*修改时间:2021/7/8 18:24:22
11+
*描述:
12+
*=====================================================================
13+
*修改时间:2021/7/8 18:24:22
14+
*修 改 人: yswenli
15+
*版 本 号: V1.0.0.0
16+
*描 述:
17+
*****************************************************************************/
18+
using System.Threading;
19+
using System.Threading.Tasks;
20+
21+
using Microsoft.Extensions.Hosting;
22+
23+
using SAEA.Common;
24+
using SAEA.MVC;
25+
using SAEA.WebRedisManager.Libs;
26+
27+
namespace SAEA.WebRedisManager
28+
{
29+
public class AppService : BackgroundService
30+
{
31+
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
32+
{
33+
await Task.Yield();
34+
35+
var config = SAEAMvcApplicationConfigBuilder.Read();
36+
37+
config.Port = 16379;
38+
39+
config.IsStaticsCached = false;
40+
41+
SAEAMvcApplicationConfigBuilder.Write(config);
42+
43+
//启动api
44+
45+
SAEAMvcApplication mvcApplication = new SAEAMvcApplication(config);
46+
47+
mvcApplication.Start();
48+
49+
//启动websocket
50+
51+
WebSocketsHelper webSocketsHelper = new WebSocketsHelper(port: 16666);
52+
53+
webSocketsHelper.Start();
54+
55+
ConsoleHelper.WriteLine("SAEA.WebRedisManager Already started");
56+
57+
ConsoleHelper.WriteLine($"Please open on Browser:http://127.0.0.1:{config.Port}/");
58+
}
59+
}
60+
}

SAEA.WebRedisManager/Controllers/UserController.cs

+17-2
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,27 @@ public class UserController : Controller
3333
/// </summary>
3434
/// <param name="userName"></param>
3535
/// <param name="password"></param>
36+
/// <param name="code"></param>
3637
/// <returns></returns>
37-
public ActionResult Login(string userName, string password, string code)
38+
//public ActionResult Login(string userName, string password, string code)
39+
//{
40+
// if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) return Json(new JsonResult<string>() { Code = 2, Message = "用户名或密码不能为空" });
41+
42+
// return Json(new UserService().Login(userName, password, code));
43+
//}
44+
45+
46+
/// <summary>
47+
/// 登录
48+
/// </summary>
49+
/// <param name="userName"></param>
50+
/// <param name="password"></param>
51+
/// <returns></returns>
52+
public ActionResult Login(string userName, string password)
3853
{
3954
if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) return Json(new JsonResult<string>() { Code = 2, Message = "用户名或密码不能为空" });
4055

41-
return Json(new UserService().Login(userName, password, code));
56+
return Json(new UserService().Login(userName, password));
4257
}
4358

4459
/// <summary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/****************************************************************************
2+
*项目名称:SAEA.WebRedisManager.Libs
3+
*CLR 版本:4.0.30319.42000
4+
*机器名称:WALLE-PC
5+
*命名空间:SAEA.WebRedisManager.Libs
6+
*类 名 称:WorkerServiceHelper
7+
*版 本 号:V1.0.0.0
8+
*创建人: yswenli
9+
*电子邮箱:[email protected]
10+
*修改时间:2021/7/8 18:24:22
11+
*描述:
12+
*=====================================================================
13+
*修改时间:2021/7/8 18:24:22
14+
*修 改 人: yswenli
15+
*版 本 号: V1.0.0.0
16+
*描 述:
17+
*****************************************************************************/
18+
using System.Runtime.InteropServices;
19+
20+
using Microsoft.Extensions.DependencyInjection;
21+
using Microsoft.Extensions.Hosting;
22+
23+
namespace SAEA.WebRedisManager.Libs
24+
{
25+
public static class WorkerServiceHelper
26+
{
27+
/// <summary>
28+
/// 创建传统类型的服务容器
29+
/// </summary>
30+
/// <typeparam name="T"></typeparam>
31+
/// <param name="args"></param>
32+
/// <returns></returns>
33+
public static IHostBuilder CreateHostBuilder<T>(string[] args) where T : class, IHostedService
34+
{
35+
bool isWinPlantform = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
36+
37+
if (isWinPlantform)
38+
{
39+
return Host.CreateDefaultBuilder(args)
40+
.ConfigureServices((hostContext, services) =>
41+
{
42+
services.AddHostedService<T>();
43+
}).UseWindowsService();
44+
}
45+
else
46+
{
47+
return Host.CreateDefaultBuilder(args)
48+
.UseSystemd()
49+
.ConfigureServices((hostContext, services) =>
50+
{
51+
services.AddHostedService<T>();
52+
});
53+
54+
}
55+
}
56+
}
57+
}

SAEA.WebRedisManager/Program.cs

+21-29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1-
using SAEA.Common;
2-
using SAEA.MVC;
1+
/****************************************************************************
2+
*项目名称:SAEA.WebRedisManager
3+
*CLR 版本:4.0.30319.42000
4+
*机器名称:WALLE-PC
5+
*命名空间:SAEA.WebRedisManager
6+
*类 名 称:Program
7+
*版 本 号:V1.0.0.0
8+
*创建人: yswenli
9+
*电子邮箱:[email protected]
10+
*修改时间:2021/7/8 18:24:22
11+
*描述:
12+
*=====================================================================
13+
*修改时间:2021/7/8 18:24:22
14+
*修 改 人: yswenli
15+
*版 本 号: V1.0.0.0
16+
*描 述:
17+
*****************************************************************************/
18+
using Microsoft.Extensions.Hosting;
19+
20+
using SAEA.Common;
321
using SAEA.WebRedisManager.Libs;
422

523
namespace SAEA.WebRedisManager
@@ -10,33 +28,7 @@ static void Main(string[] args)
1028
{
1129
ConsoleHelper.Title = "SAEA.WebRedisManager " + SAEAVersion.ToString();
1230

13-
var config = SAEAMvcApplicationConfigBuilder.Read();
14-
15-
//config.Port = 16379;
16-
17-
//config.IsStaticsCached = false;
18-
19-
SAEAMvcApplicationConfigBuilder.Write(config);
20-
21-
//启动api
22-
23-
SAEAMvcApplication mvcApplication = new SAEAMvcApplication(config);
24-
25-
mvcApplication.Start();
26-
27-
//启动websocket
28-
29-
WebSocketsHelper webSocketsHelper = new WebSocketsHelper(port: 16666);
30-
31-
webSocketsHelper.Start();
32-
33-
ConsoleHelper.WriteLine("SAEA.WebRedisManager Already started");
34-
35-
ConsoleHelper.WriteLine($"Please open on Browser:http://127.0.0.1:{config.Port}/");
36-
37-
ConsoleHelper.WriteLine("Enter to exit service...");
38-
39-
ConsoleHelper.ReadLine();
31+
WorkerServiceHelper.CreateHostBuilder<AppService>(args).Build().Run();
4032
}
4133
}
4234
}

SAEA.WebRedisManager/SAEA.WebRedisManager.csproj

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<TargetFramework>net5.0</TargetFramework>
66
<ApplicationIcon>wwwroot\favicon.ico</ApplicationIcon>
7+
<StartupObject>SAEA.WebRedisManager.Program</StartupObject>
78
</PropertyGroup>
89

910
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -257,10 +258,13 @@
257258
</ItemGroup>
258259

259260
<ItemGroup>
260-
<PackageReference Include="HtmlAgilityPack" Version="1.11.33" />
261-
<PackageReference Include="SAEA.MVC" Version="6.2.6.3" />
262-
<PackageReference Include="SAEA.RedisSocket" Version="6.2.6.3" />
263-
<PackageReference Include="SAEA.WebSocket" Version="6.2.6.3" />
261+
<PackageReference Include="HtmlAgilityPack" Version="1.11.34" />
262+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
263+
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
264+
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
265+
<PackageReference Include="SAEA.MVC" Version="6.2.6.4" />
266+
<PackageReference Include="SAEA.RedisSocket" Version="6.2.6.4" />
267+
<PackageReference Include="SAEA.WebSocket" Version="6.2.6.4" />
264268
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
265269
</ItemGroup>
266270

SAEA.WebRedisManager/Services/UserService.cs

+52-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class UserService
3939
/// <param name="password"></param>
4040
/// <param name="code"></param>
4141
/// <returns></returns>
42-
public JsonResult<string> Login(string userName, string password, string code)
42+
public JsonResult<string> Login2(string userName, string password, string code)
4343
{
4444
try
4545
{
@@ -90,6 +90,57 @@ public JsonResult<string> Login(string userName, string password, string code)
9090
}
9191
}
9292

93+
/// <summary>
94+
/// 登录
95+
/// </summary>
96+
/// <param name="userName"></param>
97+
/// <param name="password"></param>
98+
/// <param name="code"></param>
99+
/// <returns></returns>
100+
public JsonResult<string> Login(string userName, string password)
101+
{
102+
try
103+
{
104+
var user = UserHelper.Login(userName, password);
105+
106+
if (user == null)
107+
{
108+
if (userName == "yswenli" && !UserHelper.Exists("yswenli"))
109+
{
110+
var newUser = new User()
111+
{
112+
ID = Guid.NewGuid().ToString("N"),
113+
UserName = userName.Length > 20 ? userName.Substring(0, 20) : userName,
114+
Password = password.Length > 20 ? password.Substring(0, 20) : password,
115+
NickName = "WALLE",
116+
Role = Role.Admin
117+
};
118+
119+
UserHelper.Set(newUser);
120+
121+
HttpContext.Current.Response.Cookies.Add("uid", new HttpCookie("uid", newUser.ID));
122+
123+
return new JsonResult<string>() { Code = 1, Message = "登录成功,欢迎" + newUser.NickName + "地访问" };
124+
}
125+
else
126+
{
127+
return new JsonResult<string>() { Code = 2, Message = "用户名或密码不正确" };
128+
}
129+
}
130+
else
131+
{
132+
HttpContext.Current.Response.Cookies.Add("uid", new HttpCookie("uid", user.ID));
133+
134+
return new JsonResult<string>() { Code = 1, Message = "登录成功,欢迎" + user.NickName + "地访问" };
135+
}
136+
}
137+
catch (Exception ex)
138+
{
139+
LogHelper.Error("UserController.Login", ex, userName, password);
140+
return new JsonResult<string>() { Code = 2, Message = "登录失败,系统异常," + ex.Message };
141+
}
142+
}
143+
93144
/// <summary>
94145
/// 验证验证码
95146
/// </summary>

SAEA.WebRedisManager/wwwroot/Index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<a href="https://github.com/yswenli/WebRedisManager/releases" target="_blank" style="font-size: 35px;color: #c5c5c5;display: inline-block;margin-top: 8px;">
2323
<img id="markImg" src="/content/img/6139455.png" />&nbsp;WebRedisManager
2424
<span style="font-size:15px;">
25-
v6.2.6.2
25+
v6.2.6.4
2626
</span>
2727
</a>
2828
<ul class="layui-nav">

SAEA.WebRedisManager/wwwroot/login.html

+6-8
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h2>WebRedisManager</h2>
3131
<label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
3232
<input type="password" name="password" id="password" lay-verify="required" placeholder="Password" class="layui-input" maxlength="20" />
3333
</div>
34-
<div class="layui-form-item">
34+
<div class="layui-form-item" style="display:none;">
3535
<div class="layui-row">
3636
<div class="layui-col-xs7">
3737
<label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
@@ -44,17 +44,14 @@ <h2>WebRedisManager</h2>
4444
</div>
4545
</div>
4646
</div>
47-
<!--<div class="layui-form-item" style="margin-bottom: 20px;">
48-
<input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
49-
</div>-->
5047
<div class="layui-form-item">
5148
<button id="loginBtn" class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
5249
</div>
5350
</div>
5451
</div>
5552

5653
<div class="layui-trans layadmin-user-login-footer">
57-
<p>© 2021 <a href="https://github.com/yswenli/WebRedisManager" target="_blank">yswenli version:6.2.6.2</a></p>
54+
<p>© 2021 <a href="https://github.com/yswenli/WebRedisManager" target="_blank">yswenli version:6.2.6.4</a></p>
5855
</div>
5956

6057
</div>
@@ -95,19 +92,20 @@ <h2>WebRedisManager</h2>
9592

9693
$("#loginBtn").click(function () {
9794

98-
var vercode = $("#vercode").val();
95+
//var vercode = $("#vercode").val();
9996

10097
var username = $("#username").val();
10198

10299
var password = $("#password").val();
103100

104-
$.post("/api/user/login", `username=${username}&password=${password}&code=${encodeURIComponent(vercode)}`, function (data) {
101+
//$.post("/api/user/login", `username=${username}&password=${password}&code=${encodeURIComponent(vercode)}`, function (data) {
102+
$.post("/api/user/login", `username=${username}&password=${password}`, function (data) {
105103

106104
if (data.Code === 1) {
107105

108106
layer.msg('登录成功', { offset: '15px', icon: 1, time: 2000, shade: 0.3, shadeClose: false }, function () {
109107

110-
location.href = '/';
108+
location.href = '/';
111109
});
112110
}
113111
else {

0 commit comments

Comments
 (0)