diff --git a/LMS.Common/Attributes/NotEmptyAttribute.cs b/LMS.Common/Attributes/NotEmptyAttribute.cs index a43fb93..b7e3fb0 100644 --- a/LMS.Common/Attributes/NotEmptyAttribute.cs +++ b/LMS.Common/Attributes/NotEmptyAttribute.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; namespace LMS.Common.Attributes { diff --git a/LMS.Common/Dictionary/AllOptions.cs b/LMS.Common/Dictionary/AllOptions.cs index 12c825a..937ed99 100644 --- a/LMS.Common/Dictionary/AllOptions.cs +++ b/LMS.Common/Dictionary/AllOptions.cs @@ -1,5 +1,4 @@ - -using LMS.Common.Enum; +using LMS.Common.Enums; namespace LMS.Common.Dictionary; @@ -37,6 +36,11 @@ public class AllOptions /// 邮件设置相关 Option /// public const string MailSetting = "mailSetting"; + + /// + /// 重置免费次数相关的 Option + /// + public const string ResetFreeCount = "resetFreeCount"; } public static readonly Dictionary> AllOptionsRequestQuery = new() @@ -46,6 +50,7 @@ public class AllOptions { AllOptionKey.Software, ["LaitoolHomePage", "LaitoolNotice", "LaitoolUpdateContent","LaitoolVersion"]}, { AllOptionKey.Trial , ["LaiToolTrialDays"] }, { AllOptionKey.Image, [OptionKeyName.LaitoolFluxApiModelList] }, - { AllOptionKey.MailSetting , [OptionKeyName.SMTPMailSetting] } + { AllOptionKey.MailSetting , [OptionKeyName.SMTPMailSetting] }, + { AllOptionKey.ResetFreeCount, [OptionKeyName.ResetFreeCountSetting] } }; } diff --git a/LMS.Common/Dictionary/SimpleOptions.cs b/LMS.Common/Dictionary/SimpleOptions.cs index a4e59de..c433dac 100644 --- a/LMS.Common/Dictionary/SimpleOptions.cs +++ b/LMS.Common/Dictionary/SimpleOptions.cs @@ -1,4 +1,4 @@ -using LMS.Common.Enum; +using LMS.Common.Enums; namespace LMS.Common.Dictionary; diff --git a/LMS.Common/Enum/MachineEnum.cs b/LMS.Common/Enums/MachineEnum.cs similarity index 100% rename from LMS.Common/Enum/MachineEnum.cs rename to LMS.Common/Enums/MachineEnum.cs diff --git a/LMS.Common/Enum/OptionTypeEnum.cs b/LMS.Common/Enums/OptionTypeEnum.cs similarity index 75% rename from LMS.Common/Enum/OptionTypeEnum.cs rename to LMS.Common/Enums/OptionTypeEnum.cs index 318d89d..dbe41be 100644 --- a/LMS.Common/Enum/OptionTypeEnum.cs +++ b/LMS.Common/Enums/OptionTypeEnum.cs @@ -1,4 +1,4 @@ -namespace LMS.Common.Enum; +namespace LMS.Common.Enums; public enum OptionTypeEnum { @@ -24,4 +24,9 @@ public static class OptionKeyName /// 是否开启邮箱服务 /// public const string EnableMailService = "EnableMailService"; + + /// + /// 重置用户免费次数的setting + /// + public const string ResetFreeCountSetting = "ResetFreeCountSetting"; } diff --git a/LMS.Common/Enum/PermissionEnum.cs b/LMS.Common/Enums/PermissionEnum.cs similarity index 100% rename from LMS.Common/Enum/PermissionEnum.cs rename to LMS.Common/Enums/PermissionEnum.cs diff --git a/LMS.Common/Enum/PromptEnum.cs b/LMS.Common/Enums/PromptEnum.cs similarity index 100% rename from LMS.Common/Enum/PromptEnum.cs rename to LMS.Common/Enums/PromptEnum.cs diff --git a/LMS.Common/Enum/ResponseCodeEnum.cs b/LMS.Common/Enums/ResponseCodeEnum.cs similarity index 100% rename from LMS.Common/Enum/ResponseCodeEnum.cs rename to LMS.Common/Enums/ResponseCodeEnum.cs diff --git a/LMS.Common/Enum/ResponseString.cs b/LMS.Common/Enums/ResponseString.cs similarity index 100% rename from LMS.Common/Enum/ResponseString.cs rename to LMS.Common/Enums/ResponseString.cs diff --git a/LMS.Common/Enum/SoftwareControlEnum.cs b/LMS.Common/Enums/SoftwareControlEnum.cs similarity index 95% rename from LMS.Common/Enum/SoftwareControlEnum.cs rename to LMS.Common/Enums/SoftwareControlEnum.cs index 7a04ac0..421752b 100644 --- a/LMS.Common/Enum/SoftwareControlEnum.cs +++ b/LMS.Common/Enums/SoftwareControlEnum.cs @@ -1,4 +1,4 @@ -namespace LMS.Common.Enum +namespace LMS.Common.Enums { public class SoftwareControlEnum { diff --git a/LMS.Common/Enum/UserStatus.cs b/LMS.Common/Enums/UserStatus.cs similarity index 100% rename from LMS.Common/Enum/UserStatus.cs rename to LMS.Common/Enums/UserStatus.cs diff --git a/LMS.Tools/Extensions/BeijingTimeExtension.cs b/LMS.Common/Extensions/BeijingTimeExtension.cs similarity index 92% rename from LMS.Tools/Extensions/BeijingTimeExtension.cs rename to LMS.Common/Extensions/BeijingTimeExtension.cs index 9622d95..165e6d6 100644 --- a/LMS.Tools/Extensions/BeijingTimeExtension.cs +++ b/LMS.Common/Extensions/BeijingTimeExtension.cs @@ -1,4 +1,4 @@ -namespace LMS.Tools.Extensions +namespace LMS.Common.Extensions { public class BeijingTimeExtension { diff --git a/LMS.Tools/Extensions/ConvertExtension.cs b/LMS.Common/Extensions/ConvertExtension.cs similarity index 97% rename from LMS.Tools/Extensions/ConvertExtension.cs rename to LMS.Common/Extensions/ConvertExtension.cs index b9fb380..5ae3717 100644 --- a/LMS.Tools/Extensions/ConvertExtension.cs +++ b/LMS.Common/Extensions/ConvertExtension.cs @@ -1,4 +1,4 @@ -namespace LMS.Tools.Extensions +namespace LMS.Common.Extensions { public class ConvertExtension { diff --git a/LMS.Tools/Extensions/EnumExtensions.cs b/LMS.Common/Extensions/EnumExtensions.cs similarity index 97% rename from LMS.Tools/Extensions/EnumExtensions.cs rename to LMS.Common/Extensions/EnumExtensions.cs index 03bab85..982e1f6 100644 --- a/LMS.Tools/Extensions/EnumExtensions.cs +++ b/LMS.Common/Extensions/EnumExtensions.cs @@ -1,7 +1,6 @@ using LMS.Common.Attributes; -using static LMS.Common.Enums.PermissionEnum; -namespace LMS.Tools +namespace LMS.Common.Extensions { public static class EnumExtensions { diff --git a/LMS.DAO/LMS.DAO.csproj b/LMS.DAO/LMS.DAO.csproj index 76fc1e0..c2497da 100644 --- a/LMS.DAO/LMS.DAO.csproj +++ b/LMS.DAO/LMS.DAO.csproj @@ -16,7 +16,6 @@ - diff --git a/LMS.Repository/DB/ApiEndpoints.cs b/LMS.Repository/DB/ApiEndpoints.cs index 52212f6..14e79d1 100644 --- a/LMS.Repository/DB/ApiEndpoints.cs +++ b/LMS.Repository/DB/ApiEndpoints.cs @@ -1,4 +1,4 @@ -using LMS.Tools.Extensions; +using LMS.Common.Extensions; namespace LMS.Repository.Models.DB { diff --git a/LMS.Repository/DB/Machine.cs b/LMS.Repository/DB/Machine.cs index c010ac1..50e2601 100644 --- a/LMS.Repository/DB/Machine.cs +++ b/LMS.Repository/DB/Machine.cs @@ -1,6 +1,6 @@ using static LMS.Common.Enums.MachineEnum; -namespace LMS.Repository.Models.DB +namespace LMS.Repository.DB { public class Machine { diff --git a/LMS.Repository/DB/Options.cs b/LMS.Repository/DB/Options.cs index 5695cad..1672250 100644 --- a/LMS.Repository/DB/Options.cs +++ b/LMS.Repository/DB/Options.cs @@ -1,8 +1,6 @@ -using LMS.Common.Enum; +using LMS.Common.Enums; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; namespace LMS.Repository.DB; diff --git a/LMS.Repository/DB/Permission.cs b/LMS.Repository/DB/Permission.cs index 1409a9a..3c42971 100644 --- a/LMS.Repository/DB/Permission.cs +++ b/LMS.Repository/DB/Permission.cs @@ -1,5 +1,4 @@ -using LMS.Common.Enums; -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations.Schema; using System.Text.Json; using static LMS.Common.Enums.PermissionEnum; diff --git a/LMS.Repository/DB/PermissionType.cs b/LMS.Repository/DB/PermissionType.cs index f777d9c..4bf1e8a 100644 --- a/LMS.Repository/DB/PermissionType.cs +++ b/LMS.Repository/DB/PermissionType.cs @@ -1,5 +1,4 @@ using LMS.Common.Enums; -using static LMS.Common.Enums.PermissionEnum; namespace LMS.Repository.Models.DB { diff --git a/LMS.Repository/DB/RsaKeys.cs b/LMS.Repository/DB/RsaKeys.cs index a57bdd9..e86668f 100644 --- a/LMS.Repository/DB/RsaKeys.cs +++ b/LMS.Repository/DB/RsaKeys.cs @@ -1,4 +1,4 @@ -using LMS.Tools.Extensions; +using LMS.Common.Extensions; namespace LMS.Repository.DB { diff --git a/LMS.Repository/DB/User.cs b/LMS.Repository/DB/User.cs index e078bc9..4009867 100644 --- a/LMS.Repository/DB/User.cs +++ b/LMS.Repository/DB/User.cs @@ -1,5 +1,5 @@ -using LMS.Repository.User; -using LMS.Tools.Extensions; +using LMS.Common.Extensions; +using LMS.Repository.User; using Microsoft.AspNetCore.Identity; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/LMS.Repository/DTO/MachineDetailDto.cs b/LMS.Repository/DTO/MachineDetailDto.cs index 5f99351..89458b5 100644 --- a/LMS.Repository/DTO/MachineDetailDto.cs +++ b/LMS.Repository/DTO/MachineDetailDto.cs @@ -1,9 +1,10 @@ -using LMS.Repository.DTO.UserDto; -using LMS.Repository.Models.DB; +using LMS.Repository.DB; +using LMS.Repository.DTO.UserDto; +using LMS.Repository.Machine; namespace LMS.Repository.DTO { - public class MachineDetailDto : Machine + public class MachineDetailDto : MachineModel { public UserBaseDto? CreatedUser { get; set; } diff --git a/LMS.Repository/DTO/MachineDto.cs b/LMS.Repository/DTO/MachineDto.cs index a7b7d43..82a41d6 100644 --- a/LMS.Repository/DTO/MachineDto.cs +++ b/LMS.Repository/DTO/MachineDto.cs @@ -1,6 +1,6 @@ using static LMS.Common.Enums.MachineEnum; -namespace LMS.Repository.DTO.MachineResponse +namespace LMS.Repository.DTO { public class MachineDto { diff --git a/LMS.Repository/DTO/OptionsDto.cs b/LMS.Repository/DTO/OptionsDto.cs index e3cba67..fe109b0 100644 --- a/LMS.Repository/DTO/OptionsDto.cs +++ b/LMS.Repository/DTO/OptionsDto.cs @@ -1,5 +1,4 @@ -using LMS.Common.Enum; -using System.ComponentModel.DataAnnotations; +using LMS.Common.Enums; namespace LMS.Repository.DTO; diff --git a/LMS.Repository/LMS.Repository.csproj b/LMS.Repository/LMS.Repository.csproj index 31743cd..2e48e45 100644 --- a/LMS.Repository/LMS.Repository.csproj +++ b/LMS.Repository/LMS.Repository.csproj @@ -12,7 +12,7 @@ - + diff --git a/LMS.Repository/Machine/MachineModel.cs b/LMS.Repository/Machine/MachineModel.cs index 6f2fe58..be17855 100644 --- a/LMS.Repository/Machine/MachineModel.cs +++ b/LMS.Repository/Machine/MachineModel.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using static LMS.Common.Enums.MachineEnum; -namespace LMS.Repository.Models.Machine +namespace LMS.Repository.Machine { public class MachineModel { diff --git a/LMS.Repository/Options/ResetUserFreeCountSettingModel.cs b/LMS.Repository/Options/ResetUserFreeCountSettingModel.cs new file mode 100644 index 0000000..3b662a3 --- /dev/null +++ b/LMS.Repository/Options/ResetUserFreeCountSettingModel.cs @@ -0,0 +1,9 @@ +namespace LMS.Repository.Options +{ + public class ResetUserFreeCountSettingModel + { + public bool EnableMonthlyReset { get; set; } = false; + + public int OnceFreeCount { get; set; } = 5; + } +} diff --git a/LMS.Repository/Promission/PermissionModel.cs b/LMS.Repository/Promission/PermissionModel.cs index 11d2f42..43f0977 100644 --- a/LMS.Repository/Promission/PermissionModel.cs +++ b/LMS.Repository/Promission/PermissionModel.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using static LMS.Common.Enums.PermissionEnum; -namespace LMS.Repository.RequestModel.Permission +namespace LMS.Repository.Promission { public class PermissionModel { diff --git a/LMS.Repository/Promission/PermissionTypeModel.cs b/LMS.Repository/Promission/PermissionTypeModel.cs index 38744d7..50e9e51 100644 --- a/LMS.Repository/Promission/PermissionTypeModel.cs +++ b/LMS.Repository/Promission/PermissionTypeModel.cs @@ -1,7 +1,7 @@ using static LMS.Common.Enums.PermissionEnum; using System.ComponentModel.DataAnnotations; -namespace LMS.Repository.Models.Promission +namespace LMS.Repository.Promission { public class PermissionTypeModel { diff --git a/LMS.Repository/Software/ModifySoftwareControlValidityModel.cs b/LMS.Repository/Software/ModifySoftwareControlValidityModel.cs index 4e2c08f..870ffcd 100644 --- a/LMS.Repository/Software/ModifySoftwareControlValidityModel.cs +++ b/LMS.Repository/Software/ModifySoftwareControlValidityModel.cs @@ -1,4 +1,4 @@ -using LMS.Common.Enum; +using LMS.Common.Enums; namespace LMS.Repository.Software { diff --git a/LMS.Tools/LMS.Tools.csproj b/LMS.Tools/LMS.Tools.csproj index 1808db5..615b310 100644 --- a/LMS.Tools/LMS.Tools.csproj +++ b/LMS.Tools/LMS.Tools.csproj @@ -7,7 +7,14 @@ - + + + + + + + + diff --git a/LMS.Tools/TaskScheduler/ResetUserFreeCount.cs b/LMS.Tools/TaskScheduler/ResetUserFreeCount.cs new file mode 100644 index 0000000..1d451f6 --- /dev/null +++ b/LMS.Tools/TaskScheduler/ResetUserFreeCount.cs @@ -0,0 +1,67 @@ +using Quartz; +using Microsoft.AspNetCore.Identity; +using LMS.Repository.Models.DB; +using Microsoft.Extensions.Logging; +using LMS.Repository.DB; +using LMS.DAO; +using LMS.Common.Enums; +using Microsoft.EntityFrameworkCore; +using LMS.Repository.Options; + +namespace LMS.Tools.TaskScheduler; + +[DisallowConcurrentExecution] +public class ResetUserFreeCount(ILogger logger, UserManager userManager, ApplicationDbContext context) : IJob +{ + private readonly ILogger _logger = logger; + private readonly UserManager _userManager = userManager; + private readonly ApplicationDbContext _context = context; + + public async Task Execute(IJobExecutionContext context) + { + _logger.LogInformation($"开始执行月度任务 - 当前时间: {DateTime.Now}"); + await ProcessResetUserFreeCount(); + _logger.LogInformation($"月度任务执行完成 - 当前时间: {DateTime.Now}"); + } + + private async Task ProcessResetUserFreeCount() + { + using var transaction = await _context.Database.BeginTransactionAsync(); + try + { + // 这里是您的业务逻辑 + _logger.LogInformation("正在重置用户余换绑次数数据..."); + + // 加载Options + Options? options = await _context.Options.FirstOrDefaultAsync(x => x.Key == OptionKeyName.ResetFreeCountSetting) ?? throw new Exception("未找到重置用户免费次数的设置,请检查!"); + + ResetUserFreeCountSettingModel resetFreeCountSetting = options.GetValueObject() ?? new ResetUserFreeCountSettingModel(); + if (resetFreeCountSetting.EnableMonthlyReset == false) + { + // 不允许重置 + _logger.LogInformation("未开启用户重置换绑次数,有需要请开启!"); + return; + } + + // 获取所有用户 + List users = await _userManager.Users.ToListAsync(); + + // 修改所有的用户的免费次数 + foreach (User user in users) + { + long machineCount = user.AllDeviceCount; + user.FreeCount = resetFreeCountSetting.OnceFreeCount * machineCount; + await _userManager.UpdateAsync(user); + } + await transaction.CommitAsync(); + await _context.SaveChangesAsync(); + _logger.LogInformation("重置用户余换绑次数数据成功!"); + } + catch (Exception ex) + { + await transaction.RollbackAsync(); + _logger.LogError(ex, "月度任务执行失败"); + throw; // 重新抛出异常以便 Quartz 记录作业失败 + } + } +} \ No newline at end of file diff --git a/LMS.service/APIResponseModel.cs b/LMS.service/APIResponseModel.cs index bbdc27b..0679319 100644 --- a/LMS.service/APIResponseModel.cs +++ b/LMS.service/APIResponseModel.cs @@ -1,4 +1,4 @@ -using LMS.Tools; +using LMS.Common.Extensions; using static LMS.Common.Enums.ResponseCodeEnum; namespace LMS.service diff --git a/LMS.service/Configuration/AutoMapperConfig.cs b/LMS.service/Configuration/AutoMapperConfig.cs index b2755fd..f4f7b9f 100644 --- a/LMS.service/Configuration/AutoMapperConfig.cs +++ b/LMS.service/Configuration/AutoMapperConfig.cs @@ -4,12 +4,11 @@ using LMS.Repository.DTO; using LMS.Repository.DTO.PromptDto; using LMS.Repository.DTO.PromptTypeDto; using LMS.Repository.DTO.UserDto; +using LMS.Repository.Machine; using LMS.Repository.Models.DB; -using LMS.Repository.Models.Machine; -using LMS.Repository.Models.Promission; +using LMS.Repository.Promission; using LMS.Repository.PromptModel; -using LMS.Repository.RequestModel.Permission; -using static LMS.Repository.DTO.MachineResponse.MachineDto; +using static LMS.Repository.DTO.MachineDto; namespace Lai_server.Configuration { diff --git a/LMS.service/Configuration/InitConfiguration/DatabaseConfiguration.cs b/LMS.service/Configuration/InitConfiguration/DatabaseConfiguration.cs index a44a91c..075119c 100644 --- a/LMS.service/Configuration/InitConfiguration/DatabaseConfiguration.cs +++ b/LMS.service/Configuration/InitConfiguration/DatabaseConfiguration.cs @@ -1,8 +1,8 @@ -using LMS.Common.Enum; +using LMS.Common.Enums; +using LMS.Common.Extensions; using LMS.DAO; using LMS.Repository.DB; using LMS.Repository.Models.DB; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; @@ -103,7 +103,8 @@ public class DatabaseConfiguration(IServiceProvider serviceProvider) : IHostedSe new Options { Key = "LaiToolTrialDays", Value = "2" , Type = OptionTypeEnum.Number}, new Options { Key = OptionKeyName.LaitoolFluxApiModelList, Value = "{}" , Type = OptionTypeEnum.JSON }, new Options {Key = OptionKeyName.EnableMailService, Value = false.ToString(), Type = OptionTypeEnum.Boolean}, - new Options {Key = OptionKeyName.SMTPMailSetting, Value ="{}" , Type = OptionTypeEnum.JSON } + new Options {Key = OptionKeyName.SMTPMailSetting, Value ="{}" , Type = OptionTypeEnum.JSON }, + new Options { Key = OptionKeyName.ResetFreeCountSetting, Value = "{}", Type = OptionTypeEnum.JSON}, ]; // 遍历所有的配置项,如果没有则添加 diff --git a/LMS.service/Configuration/InitConfiguration/RsaConfigurattions.cs b/LMS.service/Configuration/InitConfiguration/RsaConfigurattions.cs index f42f210..8132878 100644 --- a/LMS.service/Configuration/InitConfiguration/RsaConfigurattions.cs +++ b/LMS.service/Configuration/InitConfiguration/RsaConfigurattions.cs @@ -1,7 +1,7 @@ -using LMS.Common.RSAKey; +using LMS.Common.Extensions; +using LMS.Common.RSAKey; using LMS.DAO; using LMS.Repository.DB; -using LMS.Tools.Extensions; using Microsoft.EntityFrameworkCore; namespace LMS.service.Configuration.InitConfiguration diff --git a/LMS.service/Configuration/QuartzTaskSchedulerConfig.cs b/LMS.service/Configuration/QuartzTaskSchedulerConfig.cs new file mode 100644 index 0000000..9996b6d --- /dev/null +++ b/LMS.service/Configuration/QuartzTaskSchedulerConfig.cs @@ -0,0 +1,62 @@ +using LMS.Tools.TaskScheduler; +using Quartz; +namespace LMS.service.Configuration +{ + public static class QuartzTaskSchedulerConfig + { + public static void AddQuartzTaskSchedulerService(this IServiceCollection services) + { + // 注册 Quartz 服务 + services.AddQuartz(q => + { + + // 配置作业 + var jobKey = new JobKey("MonthlyTask", "DefaultGroup"); + + // 方法1:通过配置属性设置时区 + // 获取中国时区 + TimeZoneInfo chinaTimeZone; + try + { + // 尝试获取 Windows 时区名称 + chinaTimeZone = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time"); + } + catch + { + try + { + // 尝试获取 Linux 时区名称 + chinaTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Asia/Shanghai"); + } + catch + { + // 如果都不可用,使用 UTC+8 + chinaTimeZone = TimeZoneInfo.CreateCustomTimeZone( + "China_Custom", + new TimeSpan(8, 0, 0), + "China Custom Time", + "China Standard Time"); + } + } + + // 添加作业 + q.AddJob(opts => opts.WithIdentity(jobKey)); + + // 添加触发器 - 每月1号凌晨0点执行 + q.AddTrigger(opts => opts + .ForJob(jobKey) + .WithIdentity("MonthlyTaskTrigger", "DefaultGroup") + .WithCronSchedule("0 0 18 24 * ?")); // 每月1号凌晨0点 + }); + + // 添加 Quartz 托管服务 + services.AddQuartzHostedService(options => + { + options.WaitForJobsToComplete = true; + }); + + // 注册作业 + services.AddTransient(); + } + } +} diff --git a/LMS.service/Controllers/MachineController.cs b/LMS.service/Controllers/MachineController.cs index 7aa81a0..b5c9334 100644 --- a/LMS.service/Controllers/MachineController.cs +++ b/LMS.service/Controllers/MachineController.cs @@ -1,14 +1,14 @@ -using LMS.Repository.DTO; -using LMS.Repository.Models.DB; -using LMS.Repository.Models.Machine; +using LMS.Common.Extensions; +using LMS.Repository.DB; +using LMS.Repository.DTO; +using LMS.Repository.Machine; using LMS.service.Service; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.ComponentModel.DataAnnotations; using static LMS.Common.Enums.MachineEnum; using static LMS.Common.Enums.ResponseCodeEnum; -using static LMS.Repository.DTO.MachineResponse.MachineDto; +using static LMS.Repository.DTO.MachineDto; namespace LMS.service.Controllers { diff --git a/LMS.service/Controllers/OptionsController.cs b/LMS.service/Controllers/OptionsController.cs index 83b7ae9..36e5d99 100644 --- a/LMS.service/Controllers/OptionsController.cs +++ b/LMS.service/Controllers/OptionsController.cs @@ -1,9 +1,9 @@ -using LMS.Repository.DB; +using LMS.Common.Extensions; +using LMS.Repository.DB; using LMS.Repository.DTO; using LMS.Repository.Models.DB; using LMS.Repository.Options; using LMS.service.Service; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using static LMS.Common.Enums.ResponseCodeEnum; diff --git a/LMS.service/Controllers/PermissionController.cs b/LMS.service/Controllers/PermissionController.cs index c8ad1a1..7d918bb 100644 --- a/LMS.service/Controllers/PermissionController.cs +++ b/LMS.service/Controllers/PermissionController.cs @@ -1,8 +1,7 @@ -using LMS.Repository.Models.Promission; -using LMS.Repository.RequestModel.Permission; +using LMS.Common.Extensions; +using LMS.Repository.Promission; using LMS.service; using LMS.service.Service.PermissionService; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using static LMS.Common.Enums.ResponseCodeEnum; diff --git a/LMS.service/Controllers/PromptController.cs b/LMS.service/Controllers/PromptController.cs index aa8f556..b78c751 100644 --- a/LMS.service/Controllers/PromptController.cs +++ b/LMS.service/Controllers/PromptController.cs @@ -1,10 +1,10 @@ -using LMS.DAO; +using LMS.Common.Extensions; +using LMS.DAO; using LMS.Repository.DTO; using LMS.Repository.DTO.PromptDto; using LMS.Repository.DTO.PromptTypeDto; using LMS.Repository.PromptModel; using LMS.service.Service.PromptService; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.ComponentModel.DataAnnotations; diff --git a/LMS.service/Controllers/RoleController.cs b/LMS.service/Controllers/RoleController.cs index 63670d1..588ed1e 100644 --- a/LMS.service/Controllers/RoleController.cs +++ b/LMS.service/Controllers/RoleController.cs @@ -1,8 +1,8 @@ -using LMS.Repository.DTO; +using LMS.Common.Extensions; +using LMS.Repository.DTO; using LMS.Repository.Models.DB; using LMS.Repository.Role; using LMS.service.Service.RoleService; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; diff --git a/LMS.service/Controllers/SoftWareController.cs b/LMS.service/Controllers/SoftWareController.cs index 3b66eef..402592d 100644 --- a/LMS.service/Controllers/SoftWareController.cs +++ b/LMS.service/Controllers/SoftWareController.cs @@ -1,8 +1,8 @@ -using LMS.Repository.DTO; +using LMS.Common.Extensions; +using LMS.Repository.DTO; using LMS.Repository.DTO.Software; using LMS.Repository.Software; using LMS.service.Service.SoftwareService; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.ComponentModel.DataAnnotations; diff --git a/LMS.service/Controllers/UserController.cs b/LMS.service/Controllers/UserController.cs index 131698f..890fb49 100644 --- a/LMS.service/Controllers/UserController.cs +++ b/LMS.service/Controllers/UserController.cs @@ -1,11 +1,11 @@ -using LMS.DAO; +using LMS.Common.Extensions; +using LMS.DAO; using LMS.Repository.DTO; using LMS.Repository.DTO.UserDto; using LMS.Repository.Models.DB; using LMS.Repository.Models.User; using LMS.Repository.User; using LMS.service.Service.UserService; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; diff --git a/LMS.service/Extensions/Mail/EmailService.cs b/LMS.service/Extensions/Mail/EmailService.cs index 1c8c282..28c39aa 100644 --- a/LMS.service/Extensions/Mail/EmailService.cs +++ b/LMS.service/Extensions/Mail/EmailService.cs @@ -1,4 +1,4 @@ -using LMS.Common.Enum; +using LMS.Common.Enums; using LMS.DAO; using MailKit.Net.Smtp; using MailKit.Security; diff --git a/LMS.service/LMS.service.csproj b/LMS.service/LMS.service.csproj index 5be8ef6..b8ef9a2 100644 --- a/LMS.service/LMS.service.csproj +++ b/LMS.service/LMS.service.csproj @@ -27,6 +27,8 @@ + + diff --git a/LMS.service/Program.cs b/LMS.service/Program.cs index 8402867..937386f 100644 --- a/LMS.service/Program.cs +++ b/LMS.service/Program.cs @@ -36,6 +36,7 @@ builder.Services.AddLoggerService(); builder.Host.UseSerilog(); // ؼ裺ע Serilog.ILogger DI builder.Services.AddSingleton(Log.Logger); +builder.Services.AddQuartzTaskSchedulerService(); builder.Services.AddDbContext(options => { diff --git a/LMS.service/Service/ForwardWordService.cs b/LMS.service/Service/ForwardWordService.cs index 4c0183a..8a4e242 100644 --- a/LMS.service/Service/ForwardWordService.cs +++ b/LMS.service/Service/ForwardWordService.cs @@ -8,10 +8,10 @@ using static LMS.Common.Enums.ResponseCodeEnum; using System.Net; using System.Text; using LMS.Repository.Model; -using LMS.Tools; using Betalgo.Ranul.OpenAI.Managers; using Betalgo.Ranul.OpenAI; using Betalgo.Ranul.OpenAI.ObjectModels.RequestModels; +using LMS.Common.Extensions; namespace LMS.service.Service; diff --git a/LMS.service/Service/MachineService.cs b/LMS.service/Service/MachineService.cs index 19cc4f0..bb2222b 100644 --- a/LMS.service/Service/MachineService.cs +++ b/LMS.service/Service/MachineService.cs @@ -1,12 +1,11 @@ using AutoMapper; +using LMS.Common.Extensions; using LMS.DAO; using LMS.Repository.DB; using LMS.Repository.DTO; using LMS.Repository.DTO.UserDto; +using LMS.Repository.Machine; using LMS.Repository.Models.DB; -using LMS.Repository.Models.Machine; -using LMS.Tools; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -14,8 +13,8 @@ using System.Collections.Generic; using System.Linq; using static LMS.Common.Enums.MachineEnum; using static LMS.Common.Enums.ResponseCodeEnum; -using static LMS.Repository.DTO.MachineResponse.MachineDto; -using Machine = LMS.Repository.Models.DB.Machine; +using static LMS.Repository.DTO.MachineDto; +using Machine = LMS.Repository.DB.Machine; namespace LMS.service.Service { diff --git a/LMS.service/Service/PermissionService/PermissionService.cs b/LMS.service/Service/PermissionService/PermissionService.cs index 85811cf..2b0c9ab 100644 --- a/LMS.service/Service/PermissionService/PermissionService.cs +++ b/LMS.service/Service/PermissionService/PermissionService.cs @@ -1,16 +1,14 @@ using AutoMapper; using LMS.Common.Enums; +using LMS.Common.Extensions; using LMS.DAO; using LMS.DAO.MachineDAO; using LMS.DAO.PermissionDAO; using LMS.DAO.RoleDAO; using LMS.DAO.UserDAO; using LMS.Repository.Models.DB; -using LMS.Repository.Models.Promission; -using LMS.Repository.RequestModel.Permission; +using LMS.Repository.Promission; using LMS.service.Data; -using LMS.Tools; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; diff --git a/LMS.service/Service/PromptService/PromptService.cs b/LMS.service/Service/PromptService/PromptService.cs index 49c8df5..200ba1a 100644 --- a/LMS.service/Service/PromptService/PromptService.cs +++ b/LMS.service/Service/PromptService/PromptService.cs @@ -1,4 +1,5 @@ using AutoMapper; +using LMS.Common.Extensions; using LMS.DAO; using LMS.DAO.UserDAO; using LMS.Repository.DB; @@ -8,7 +9,6 @@ using LMS.Repository.DTO.PromptTypeDto; using LMS.Repository.DTO.UserDto; using LMS.Repository.Models.DB; using LMS.Repository.PromptModel; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; diff --git a/LMS.service/Service/PromptService/PromptTypeService.cs b/LMS.service/Service/PromptService/PromptTypeService.cs index c734091..8c2f736 100644 --- a/LMS.service/Service/PromptService/PromptTypeService.cs +++ b/LMS.service/Service/PromptService/PromptTypeService.cs @@ -1,4 +1,5 @@ using AutoMapper; +using LMS.Common.Extensions; using LMS.DAO; using LMS.DAO.UserDAO; using LMS.Repository.DTO; @@ -6,7 +7,6 @@ using LMS.Repository.DTO.PromptTypeDto; using LMS.Repository.DTO.UserDto; using LMS.Repository.Models.DB; using LMS.Repository.PromptModel; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; diff --git a/LMS.service/Service/RoleService/RoleService.cs b/LMS.service/Service/RoleService/RoleService.cs index 25227df..ce7a80a 100644 --- a/LMS.service/Service/RoleService/RoleService.cs +++ b/LMS.service/Service/RoleService/RoleService.cs @@ -1,10 +1,10 @@ using AutoMapper; +using LMS.Common.Extensions; using LMS.DAO; using LMS.Repository.DTO; using LMS.Repository.DTO.UserDto; using LMS.Repository.Models.DB; using LMS.Repository.Role; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; diff --git a/LMS.service/Service/SoftwareService/SoftwareControlService.cs b/LMS.service/Service/SoftwareService/SoftwareControlService.cs index cac3ead..4e8de4c 100644 --- a/LMS.service/Service/SoftwareService/SoftwareControlService.cs +++ b/LMS.service/Service/SoftwareService/SoftwareControlService.cs @@ -1,5 +1,6 @@ using AutoMapper; -using LMS.Common.Enum; +using LMS.Common.Enums; +using LMS.Common.Extensions; using LMS.DAO; using LMS.DAO.UserDAO; using LMS.Repository.DB; @@ -9,7 +10,6 @@ using LMS.Repository.DTO.UserDto; using LMS.Repository.Models.DB; using LMS.Repository.Software; using LMS.Tools; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; diff --git a/LMS.service/Service/SoftwareService/SoftwareService.cs b/LMS.service/Service/SoftwareService/SoftwareService.cs index 72b6ace..2d887a9 100644 --- a/LMS.service/Service/SoftwareService/SoftwareService.cs +++ b/LMS.service/Service/SoftwareService/SoftwareService.cs @@ -1,4 +1,5 @@ using AutoMapper; +using LMS.Common.Extensions; using LMS.DAO; using LMS.DAO.UserDAO; using LMS.Repository.DB; @@ -7,7 +8,6 @@ using LMS.Repository.DTO.Software; using LMS.Repository.DTO.UserDto; using LMS.Repository.Models.DB; using LMS.Repository.Software; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using static LMS.Common.Enums.ResponseCodeEnum; diff --git a/LMS.service/Service/UserService/LoginService.cs b/LMS.service/Service/UserService/LoginService.cs index 647b7db..6cc6b40 100644 --- a/LMS.service/Service/UserService/LoginService.cs +++ b/LMS.service/Service/UserService/LoginService.cs @@ -1,5 +1,5 @@ - -using LMS.Common.Enum; +using LMS.Common.Enums; +using LMS.Common.Extensions; using LMS.Common.Password; using LMS.Common.RSAKey; using LMS.DAO; @@ -8,7 +8,6 @@ using LMS.Repository.DB; using LMS.Repository.Models.DB; using LMS.Repository.Models.User; using LMS.Repository.User; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; diff --git a/LMS.service/Service/UserService/SecurityService.cs b/LMS.service/Service/UserService/SecurityService.cs index f1de082..49156a8 100644 --- a/LMS.service/Service/UserService/SecurityService.cs +++ b/LMS.service/Service/UserService/SecurityService.cs @@ -1,10 +1,10 @@ -using LMS.Common.RSAKey; +using LMS.Common.Extensions; +using LMS.Common.RSAKey; using LMS.DAO; using LMS.Repository.DB; using LMS.Repository.Models.DB; using LMS.Repository.User; using LMS.service.Data; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using System.Collections.Concurrent; diff --git a/LMS.service/Service/UserService/UserService.cs b/LMS.service/Service/UserService/UserService.cs index c8835b3..a1f2e17 100644 --- a/LMS.service/Service/UserService/UserService.cs +++ b/LMS.service/Service/UserService/UserService.cs @@ -1,4 +1,5 @@ -using LMS.Common.Enum; +using LMS.Common.Enums; +using LMS.Common.Extensions; using LMS.Common.RSAKey; using LMS.DAO; using LMS.DAO.UserDAO; @@ -8,7 +9,6 @@ using LMS.Repository.DTO.UserDto; using LMS.Repository.Models.DB; using LMS.Repository.Models.User; using LMS.Repository.User; -using LMS.Tools.Extensions; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; diff --git a/LMS.service/appsettings.json b/LMS.service/appsettings.json index 9a3b867..d0c9600 100644 --- a/LMS.service/appsettings.json +++ b/LMS.service/appsettings.json @@ -26,6 +26,6 @@ ], "Enrich": [ "FromLogContext" ] }, - "Version": "1.0.5", + "Version": "1.0.6", "AllowedHosts": "*" }