Skip to content

Commit

Permalink
update v6.2.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
yswenli committed Jul 11, 2021
1 parent 849003b commit d07d0dc
Show file tree
Hide file tree
Showing 15 changed files with 224 additions and 778 deletions.
8 changes: 1 addition & 7 deletions SAEA.WebRedisManager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30011.22
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SAEA.WebRedisManagerForNet", "SAEA.WebRedisManagerForNet\SAEA.WebRedisManagerForNet.csproj", "{598C65E6-356A-47FF-922B-16349D83C9A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SAEA.WebRedisManager", "SAEA.WebRedisManager\SAEA.WebRedisManager.csproj", "{BCE122A2-20C5-4CE9-8353-63369347407A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SAEA.WebRedisManager", "SAEA.WebRedisManager\SAEA.WebRedisManager.csproj", "{BCE122A2-20C5-4CE9-8353-63369347407A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{598C65E6-356A-47FF-922B-16349D83C9A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{598C65E6-356A-47FF-922B-16349D83C9A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{598C65E6-356A-47FF-922B-16349D83C9A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{598C65E6-356A-47FF-922B-16349D83C9A1}.Release|Any CPU.Build.0 = Release|Any CPU
{BCE122A2-20C5-4CE9-8353-63369347407A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BCE122A2-20C5-4CE9-8353-63369347407A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCE122A2-20C5-4CE9-8353-63369347407A}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
60 changes: 60 additions & 0 deletions SAEA.WebRedisManager/AppService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/****************************************************************************
*项目名称:SAEA.WebRedisManager
*CLR 版本:4.0.30319.42000
*机器名称:WALLE-PC
*命名空间:SAEA.WebRedisManager
*类 名 称:AppService
*版 本 号:V1.0.0.0
*创建人: yswenli
*电子邮箱:yswenli@outlook.com
*修改时间:2021/7/8 18:24:22
*描述:
*=====================================================================
*修改时间:2021/7/8 18:24:22
*修 改 人: yswenli
*版 本 号: V1.0.0.0
*描 述:
*****************************************************************************/
using System.Threading;
using System.Threading.Tasks;

using Microsoft.Extensions.Hosting;

using SAEA.Common;
using SAEA.MVC;
using SAEA.WebRedisManager.Libs;

namespace SAEA.WebRedisManager
{
public class AppService : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await Task.Yield();

var config = SAEAMvcApplicationConfigBuilder.Read();

config.Port = 16379;

config.IsStaticsCached = false;

SAEAMvcApplicationConfigBuilder.Write(config);

//启动api

SAEAMvcApplication mvcApplication = new SAEAMvcApplication(config);

mvcApplication.Start();

//启动websocket

WebSocketsHelper webSocketsHelper = new WebSocketsHelper(port: 16666);

webSocketsHelper.Start();

ConsoleHelper.WriteLine("SAEA.WebRedisManager Already started");

ConsoleHelper.WriteLine($"Please open on Browser:http://127.0.0.1:{config.Port}/");
}
}
}
19 changes: 17 additions & 2 deletions SAEA.WebRedisManager/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,27 @@ public class UserController : Controller
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <param name="code"></param>
/// <returns></returns>
public ActionResult Login(string userName, string password, string code)
//public ActionResult Login(string userName, string password, string code)
//{
// if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) return Json(new JsonResult<string>() { Code = 2, Message = "用户名或密码不能为空" });

// return Json(new UserService().Login(userName, password, code));
//}


/// <summary>
/// 登录
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <returns></returns>
public ActionResult Login(string userName, string password)
{
if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) return Json(new JsonResult<string>() { Code = 2, Message = "用户名或密码不能为空" });

return Json(new UserService().Login(userName, password, code));
return Json(new UserService().Login(userName, password));
}

/// <summary>
Expand Down
57 changes: 57 additions & 0 deletions SAEA.WebRedisManager/Libs/WorkerServiceHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/****************************************************************************
*项目名称:SAEA.WebRedisManager.Libs
*CLR 版本:4.0.30319.42000
*机器名称:WALLE-PC
*命名空间:SAEA.WebRedisManager.Libs
*类 名 称:WorkerServiceHelper
*版 本 号:V1.0.0.0
*创建人: yswenli
*电子邮箱:yswenli@outlook.com
*修改时间:2021/7/8 18:24:22
*描述:
*=====================================================================
*修改时间:2021/7/8 18:24:22
*修 改 人: yswenli
*版 本 号: V1.0.0.0
*描 述:
*****************************************************************************/
using System.Runtime.InteropServices;

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace SAEA.WebRedisManager.Libs
{
public static class WorkerServiceHelper
{
/// <summary>
/// 创建传统类型的服务容器
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="args"></param>
/// <returns></returns>
public static IHostBuilder CreateHostBuilder<T>(string[] args) where T : class, IHostedService
{
bool isWinPlantform = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

if (isWinPlantform)
{
return Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<T>();
}).UseWindowsService();
}
else
{
return Host.CreateDefaultBuilder(args)
.UseSystemd()
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<T>();
});

}
}
}
}
50 changes: 21 additions & 29 deletions SAEA.WebRedisManager/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
using SAEA.Common;
using SAEA.MVC;
/****************************************************************************
*项目名称:SAEA.WebRedisManager
*CLR 版本:4.0.30319.42000
*机器名称:WALLE-PC
*命名空间:SAEA.WebRedisManager
*类 名 称:Program
*版 本 号:V1.0.0.0
*创建人: yswenli
*电子邮箱:yswenli@outlook.com
*修改时间:2021/7/8 18:24:22
*描述:
*=====================================================================
*修改时间:2021/7/8 18:24:22
*修 改 人: yswenli
*版 本 号: V1.0.0.0
*描 述:
*****************************************************************************/
using Microsoft.Extensions.Hosting;

using SAEA.Common;
using SAEA.WebRedisManager.Libs;

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

var config = SAEAMvcApplicationConfigBuilder.Read();

//config.Port = 16379;

//config.IsStaticsCached = false;

SAEAMvcApplicationConfigBuilder.Write(config);

//启动api

SAEAMvcApplication mvcApplication = new SAEAMvcApplication(config);

mvcApplication.Start();

//启动websocket

WebSocketsHelper webSocketsHelper = new WebSocketsHelper(port: 16666);

webSocketsHelper.Start();

ConsoleHelper.WriteLine("SAEA.WebRedisManager Already started");

ConsoleHelper.WriteLine($"Please open on Browser:http://127.0.0.1:{config.Port}/");

ConsoleHelper.WriteLine("Enter to exit service...");

ConsoleHelper.ReadLine();
WorkerServiceHelper.CreateHostBuilder<AppService>(args).Build().Run();
}
}
}
14 changes: 9 additions & 5 deletions SAEA.WebRedisManager/SAEA.WebRedisManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<ApplicationIcon>wwwroot\favicon.ico</ApplicationIcon>
<StartupObject>SAEA.WebRedisManager.Program</StartupObject>
</PropertyGroup>

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

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.33" />
<PackageReference Include="SAEA.MVC" Version="6.2.6.3" />
<PackageReference Include="SAEA.RedisSocket" Version="6.2.6.3" />
<PackageReference Include="SAEA.WebSocket" Version="6.2.6.3" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.34" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="SAEA.MVC" Version="6.2.6.4" />
<PackageReference Include="SAEA.RedisSocket" Version="6.2.6.4" />
<PackageReference Include="SAEA.WebSocket" Version="6.2.6.4" />
<PackageReference Include="System.Drawing.Common" Version="5.0.2" />
</ItemGroup>

Expand Down
53 changes: 52 additions & 1 deletion SAEA.WebRedisManager/Services/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class UserService
/// <param name="password"></param>
/// <param name="code"></param>
/// <returns></returns>
public JsonResult<string> Login(string userName, string password, string code)
public JsonResult<string> Login2(string userName, string password, string code)
{
try
{
Expand Down Expand Up @@ -90,6 +90,57 @@ public JsonResult<string> Login(string userName, string password, string code)
}
}

/// <summary>
/// 登录
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <param name="code"></param>
/// <returns></returns>
public JsonResult<string> Login(string userName, string password)
{
try
{
var user = UserHelper.Login(userName, password);

if (user == null)
{
if (userName == "yswenli" && !UserHelper.Exists("yswenli"))
{
var newUser = new User()
{
ID = Guid.NewGuid().ToString("N"),
UserName = userName.Length > 20 ? userName.Substring(0, 20) : userName,
Password = password.Length > 20 ? password.Substring(0, 20) : password,
NickName = "WALLE",
Role = Role.Admin
};

UserHelper.Set(newUser);

HttpContext.Current.Response.Cookies.Add("uid", new HttpCookie("uid", newUser.ID));

return new JsonResult<string>() { Code = 1, Message = "登录成功,欢迎" + newUser.NickName + "地访问" };
}
else
{
return new JsonResult<string>() { Code = 2, Message = "用户名或密码不正确" };
}
}
else
{
HttpContext.Current.Response.Cookies.Add("uid", new HttpCookie("uid", user.ID));

return new JsonResult<string>() { Code = 1, Message = "登录成功,欢迎" + user.NickName + "地访问" };
}
}
catch (Exception ex)
{
LogHelper.Error("UserController.Login", ex, userName, password);
return new JsonResult<string>() { Code = 2, Message = "登录失败,系统异常," + ex.Message };
}
}

/// <summary>
/// 验证验证码
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion SAEA.WebRedisManager/wwwroot/Index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<a href="https://github.com/yswenli/WebRedisManager/releases" target="_blank" style="font-size: 35px;color: #c5c5c5;display: inline-block;margin-top: 8px;">
<img id="markImg" src="/content/img/6139455.png" />&nbsp;WebRedisManager
<span style="font-size:15px;">
v6.2.6.2
v6.2.6.4
</span>
</a>
<ul class="layui-nav">
Expand Down
14 changes: 6 additions & 8 deletions SAEA.WebRedisManager/wwwroot/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h2>WebRedisManager</h2>
<label class="layadmin-user-login-icon layui-icon layui-icon-password" for="LAY-user-login-password"></label>
<input type="password" name="password" id="password" lay-verify="required" placeholder="Password" class="layui-input" maxlength="20" />
</div>
<div class="layui-form-item">
<div class="layui-form-item" style="display:none;">
<div class="layui-row">
<div class="layui-col-xs7">
<label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode"></label>
Expand All @@ -44,17 +44,14 @@ <h2>WebRedisManager</h2>
</div>
</div>
</div>
<!--<div class="layui-form-item" style="margin-bottom: 20px;">
<input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
</div>-->
<div class="layui-form-item">
<button id="loginBtn" class="layui-btn layui-btn-fluid" lay-submit lay-filter="LAY-user-login-submit">登 入</button>
</div>
</div>
</div>

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

</div>
Expand Down Expand Up @@ -95,19 +92,20 @@ <h2>WebRedisManager</h2>

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

var vercode = $("#vercode").val();
//var vercode = $("#vercode").val();

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

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

$.post("/api/user/login", `username=${username}&password=${password}&code=${encodeURIComponent(vercode)}`, function (data) {
//$.post("/api/user/login", `username=${username}&password=${password}&code=${encodeURIComponent(vercode)}`, function (data) {
$.post("/api/user/login", `username=${username}&password=${password}`, function (data) {

if (data.Code === 1) {

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

location.href = '/';
location.href = '/';
});
}
else {
Expand Down
Loading

0 comments on commit d07d0dc

Please sign in to comment.