From e8d5f2b39db1e22f6ba940e4c7f28d5f9ce35bc2 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期四, 04 八月 2022 10:25:51 +0800 Subject: [PATCH] 新增任务模块(目前仅有自定义实时任务与自定义计划任务) --- Service/IStation.Service4Job/custom/custom_cron_job/CustomCronJob_Instance.cs | 61 + Service/IStation.Service4Job/custom/custom_real_job/CustomRealJob_NO.cs | 35 Service/IStation.Service4Job/custom/custom_real_job/cache/CustomRealJobCacheHelper.cs | 63 + Application/IStation.Application4Job/custom_cron_job/_/dto/AddCustomCronJobInput.cs | 46 + Application/IStation.Application4Basic/IStation.Application4Basic.csproj | 1 Entity/IStation.Entity4Job/IStation.Entity4Job.csproj | 16 Service/IStation.Service4Job/custom/custom_cron_job/CustomCronJob.cs | 271 ++++++ Service/IStation.Service4Job/custom/custom_cron_job/CustomCronJob_NO.cs | 35 Settings/IStation.Settings/paras_settings.json | 6 DAL/IStation.DAL4Job/custom/CustomCronJob.cs | 29 Model/IStation.Model4Job/IStation.Model4Job.csproj | 16 DAL/IStation.DAL4Job/helpers/ConfigHelper.cs | 68 + Service/IStation.Service4Job/custom/custom_real_job/CustomRealJob.cs | 272 ++++++ Application/IStation.Application4Job/custom_real_job/_/dto/CustomRealJobDto.cs | 100 ++ Entity/IStation.Entity4Job/custom/CustomCronJob.cs | 84 + Settings/IStation.Settings/models/Paras.cs | 5 Service/IStation.Service4Job/custom/custom_cron_job/cache/CustomCronJobCacheHelper.cs | 63 + Entity/IStation.Entity4Job/custom/CustomRealJob.cs | 84 + DAL/IStation.DAL4Job/custom/CustomRealJob.cs | 29 Model/IStation.Model4Job/custom/CustomCronJob.cs | 131 +++ Application/IStation.Application4Job/custom_cron_job/_/dto/CustomCronJobDto.cs | 100 ++ DAL/IStation.DAL4Job/IStation.DAL4Job.csproj | 17 Model/IStation.Model4Job/custom/CustomRealJob.cs | 131 +++ Settings/IStation.Settings/models/job/Paras_Job.cs | 19 Core/IStation.WebApi.Core/applicationconfig.json | 7 Application/IStation.Application4Job/custom_real_job/_/dto/AddCustomRealJobInput.cs | 46 + Settings/IStation.Settings/models/job/Paras_Job_DataBase.cs | 20 Application/IStation.Application4Job/custom_cron_job/_/dto/UpdateCustomCronJobInput.cs | 52 + Application/IStation.Application4Job/custom_real_job/_/CustomRealJob_Controller.cs | 214 ++++ Service/IStation.Service4Job/custom/custom_real_job/CustomRealJob_Instance.cs | 61 + IStation.WebApi.sln | 37 Service/IStation.Service4Job/IStation.Service4Job.csproj | 18 Application/IStation.Application4Job/IStation.Application4Job.csproj | 17 Service/IStation.Service4Job/helpers/ConfigHelper.cs | 41 Settings/IStation.Settings/paras/Settings.cs | 8 Application/IStation.Application4Job/custom_cron_job/_/CustomCronJob_Controller.cs | 214 ++++ Application/IStation.Application4Job/config/Mapper.cs | 51 + Service/IStation.Service4Job/helpers/CacheHelper.cs | 40 Entry/IStation.WebApi.Entry/IStation.WebApi.Entry.csproj | 1 Application/IStation.Application4Job/custom_real_job/_/dto/UpdateCustomRealJobInput.cs | 52 + 40 files changed, 2,559 insertions(+), 2 deletions(-) diff --git a/Application/IStation.Application4Basic/IStation.Application4Basic.csproj b/Application/IStation.Application4Basic/IStation.Application4Basic.csproj index 1781383..01aa00a 100644 --- a/Application/IStation.Application4Basic/IStation.Application4Basic.csproj +++ b/Application/IStation.Application4Basic/IStation.Application4Basic.csproj @@ -24,7 +24,6 @@ </ItemGroup> <ItemGroup> - <ProjectReference Include="..\..\Component\IStation.Log4Net\IStation.Log4Net.csproj" /> <ProjectReference Include="..\..\Service\IStation.Service4Basic\IStation.Service4Basic.csproj" /> <ProjectReference Include="..\IStation.Application4Core\IStation.Application4Core.csproj" /> </ItemGroup> diff --git a/Application/IStation.Application4Job/IStation.Application4Job.csproj b/Application/IStation.Application4Job/IStation.Application4Job.csproj new file mode 100644 index 0000000..ea6b1ed --- /dev/null +++ b/Application/IStation.Application4Job/IStation.Application4Job.csproj @@ -0,0 +1,17 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net6.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>disable</Nullable> + <AssemblyName>IStation.Application4Job</AssemblyName> + <RootNamespace>IStation.Application</RootNamespace> + <GenerateDocumentationFile>True</GenerateDocumentationFile> + </PropertyGroup> + + <ItemGroup> + <ProjectReference Include="..\..\Service\IStation.Service4Job\IStation.Service4Job.csproj" /> + <ProjectReference Include="..\IStation.Application4Core\IStation.Application4Core.csproj" /> + </ItemGroup> + +</Project> diff --git a/Application/IStation.Application4Job/config/Mapper.cs b/Application/IStation.Application4Job/config/Mapper.cs new file mode 100644 index 0000000..5711dca --- /dev/null +++ b/Application/IStation.Application4Job/config/Mapper.cs @@ -0,0 +1,51 @@ +锘縰sing Mapster; +using System; +namespace IStation.Application +{ + /// <summary> + /// + /// </summary> + public class Mapper : IRegister + { + /// <summary> + /// + /// </summary> + /// <param name="config"></param> + public void Register(TypeAdapterConfig config) + { + + + #region 鑷畾涔夊疄鏃朵换鍔� + + config.ForType<Model.CustomRealJob, CustomRealJobDto>(); + + config.ForType<AddCustomRealJobInput, Model.CustomRealJob>() + .Map(dest => dest.CreateTime, src => DateTime.Now) + .Map(dest => dest.CreateUserID, src => UserManager.UserID) + .Map(dest => dest.UseStatus, src => Model.eUseStatus.Enable); + + config.ForType<UpdateCustomRealJobInput, Model.CustomRealJob>() + .Map(dest => dest.UpdateTime, src => DateTime.Now) + .Map(dest => dest.UpdateUserID, src => UserManager.UserID); + + #endregion + + #region 鑷畾涔夎鍒掍换鍔� + + config.ForType<Model.CustomCronJob, CustomCronJobDto>(); + + config.ForType<AddCustomCronJobInput, Model.CustomCronJob>() + .Map(dest => dest.CreateTime, src => DateTime.Now) + .Map(dest => dest.CreateUserID, src => UserManager.UserID) + .Map(dest => dest.UseStatus, src => Model.eUseStatus.Enable); + + config.ForType<UpdateCustomCronJobInput, Model.CustomCronJob>() + .Map(dest => dest.UpdateTime, src => DateTime.Now) + .Map(dest => dest.UpdateUserID, src => UserManager.UserID); + + #endregion + + + } + } +} \ No newline at end of file diff --git a/Application/IStation.Application4Job/custom_cron_job/_/CustomCronJob_Controller.cs b/Application/IStation.Application4Job/custom_cron_job/_/CustomCronJob_Controller.cs new file mode 100644 index 0000000..8657578 --- /dev/null +++ b/Application/IStation.Application4Job/custom_cron_job/_/CustomCronJob_Controller.cs @@ -0,0 +1,214 @@ +锘縰sing Microsoft.AspNetCore.Mvc; +using System.Net; +using System.Net.Http.Headers; +using Microsoft.Extensions.Hosting.Internal; +using Microsoft.AspNetCore.Http.Extensions; +using IStation.Untity; +using Furion.DynamicApiController; +using System.ComponentModel.DataAnnotations; +using Mapster; +using Furion.DataValidation; + +namespace IStation.Application +{ + /// <summary> + /// CustomCronJob + /// </summary> + [Route("Job/CustomCronJob")] + [ApiDescriptionSettings("Job", Name = "鑷畾涔夎鍒掍换鍔�", Order = 900)] + public class CustomCronJob_Controller : IDynamicApiController + { + private readonly Service.CustomCronJob _service = new Service.CustomCronJob(); + + #region Query + + /// <summary> + ///鑾峰彇鎵�鏈� + /// </summary> + [Route("GetAll@V1.0")] + [HttpGet] + public List<CustomCronJobDto> GetAll() + { + var list = _service.GetAll(); + var vmList = list?.Select(x => new CustomCronJobDto(x)).ToList(); + return vmList; + } + + /// <summary> + /// 閫氳繃 ID 鑾峰彇 + /// </summary> + [Route("GetByID@V1.0")] + [HttpGet] + public CustomCronJobDto GetByID([FromQuery][Required] IDInput input) + { + var model = _service.GetByID(input.ID); + if (model == null) + return default; + var vm = new CustomCronJobDto(model); + return vm; + } + + /// <summary> + /// 閫氳繃 Ids 鑾峰彇 + /// </summary> + [Route("GetByIds@V1.0")] + [HttpGet] + public List<CustomCronJobDto> GetByIds([FromQuery] IdsInput model) + { + var ids = LongListHelper.ToList(model.Ids); + var list = _service.GetByIds(ids); + var vmList = list?.Select(x => new CustomCronJobDto(x)).ToList(); + return vmList; + } + + #endregion + + #region Insert + + /// <summary> + /// 鎻掑叆涓�鏉� + /// </summary> + [Route("Insert@V1.0")] + [HttpPost] + public long Insert(AddCustomCronJobInput input) + { + if (input == null) + return default; + var model = input.Adapt<AddCustomCronJobInput, Model.CustomCronJob>(); + var id = _service.Insert(model); + return id; + } + + /// <summary> + /// 鎻掑叆澶氭潯 + /// </summary> + [Route("Inserts@V1.0")] + [HttpPost] + public bool Inserts(List<AddCustomCronJobInput> inputList) + { + if (inputList == null || inputList.Count < 1) + return false; + var list = inputList.Select(x => x.Adapt<AddCustomCronJobInput, Model.CustomCronJob>()).ToList(); + var bol = _service.Inserts(list); + return bol; + } + + #endregion + + #region Update + + /// <summary> + /// 鏇存柊涓�鏉� + /// </summary> + [Route("Update@V1.0")] + [HttpPut] + public bool Update(UpdateCustomCronJobInput input) + { + if (input == null) + return false; + var model = _service.GetByID(input.ID); + if (model == null) + return false; + var rhs = new Model.CustomCronJob(model); + input.Adapt(rhs); + var bol = _service.Update(rhs); + return bol; + } + + /// <summary> + /// 鏇存柊澶氭潯 + /// </summary> + [Route("Updates@V1.0")] + [HttpPut] + public bool Updates(List<UpdateCustomCronJobInput> inputList) + { + if (inputList == null || inputList.Count() < 1) + { + return false; + } + var modelList = _service.GetByIds(inputList.Select(x => x.ID).ToList()); + if (modelList == null || modelList.Count < 1) + return false; + var rhsList = new List<Model.CustomCronJob>(); + modelList.ForEach(x => { + var input = inputList.Find(t => t.ID == x.ID); + if (input != null) + { + var rhs = new Model.CustomCronJob(x); + input.Adapt(rhs); + rhsList.Add(rhs); + } + }); + if (rhsList.Count < 1) + return false; + var bol = _service.Updates(rhsList); + return bol; + } + + /// <summary> + /// 鏇存柊浣跨敤鐘舵�� + /// </summary> + [Route("UpdateUseStatus@V1.0")] + [HttpPut] + public bool UpdateUseStatus([Required] UpdateUseStatusInput intput) + { + var bol = _service.UpdateUseStatus(intput.ID, intput.UseStatus, UserManager.UserID, DateTime.Now); + return bol; + } + + #endregion + + #region Exist + + + /// <summary> + /// 鍒ゆ柇 NO 鏄惁瀛樺湪 + /// </summary> + [Route("IsExistNO@V1.0")] + [HttpGet] + public bool IsExistNO + ( + [Required,DataValidation(AllowEmptyStrings =false)] + string NO + ) + { + var bol = _service.IsExistNO(NO); + return bol; + } + + /// <summary> + /// 鍒ゆ柇 NO 鏄惁瀛樺湪 ExceptID + /// </summary> + [Route("IsExistNOExceptID@V1.0")] + [HttpGet] + public bool IsExistNOExceptID + ( + [Required,DataValidation(AllowEmptyStrings =false)] + string NO, + [Required,Range(1,long.MaxValue,ErrorMessage ="ExceptID 蹇呴』澶т簬0")] + long ExceptID + ) + { + var bol = _service.IsExistNOExceptID(NO, ExceptID); + return bol; + } + + #endregion + + #region Delete + + /// <summary> + /// 閫氳繃 ID 鍒犻櫎 + /// </summary> + [Route("DeleteByID@V1.0")] + [HttpDelete] + public DeleteReasonOutput DeleteByID([FromQuery][Required] IDInput input) + { + var bol = _service.DeleteByID(input.ID, out string msg); + return new DeleteReasonOutput() { Success = bol, Reason = msg }; + } + + #endregion + + } +} \ No newline at end of file diff --git a/Application/IStation.Application4Job/custom_cron_job/_/dto/AddCustomCronJobInput.cs b/Application/IStation.Application4Job/custom_cron_job/_/dto/AddCustomCronJobInput.cs new file mode 100644 index 0000000..c7b7d75 --- /dev/null +++ b/Application/IStation.Application4Job/custom_cron_job/_/dto/AddCustomCronJobInput.cs @@ -0,0 +1,46 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation.Application +{ + /// <summary> + /// 娣诲姞鑷畾涔夎鍒掍换鍔� + /// </summary> + public class AddCustomCronJobInput + { + + /// <summary> + /// 缂栧彿 + /// </summary> + public string NO { get; set; } + + /// <summary> + /// 鍚嶇О + /// </summary> + public string Name { get; set; } + + /// <summary> + /// Cron琛ㄨ揪寮� + /// </summary> + public string Expression { get; set; } + + /// <summary> + /// 閲嶇疆 锛堝垎閽燂級 + /// </summary> + public int Repeat { get; set; } + + /// <summary> + /// 鎵ц鏂囦欢 + /// </summary> + public string Execution { get; set; } + + /// <summary> + /// 璇存槑 + /// </summary> + public string Description { get; set; } + + } +} diff --git a/Application/IStation.Application4Job/custom_cron_job/_/dto/CustomCronJobDto.cs b/Application/IStation.Application4Job/custom_cron_job/_/dto/CustomCronJobDto.cs new file mode 100644 index 0000000..b05abbd --- /dev/null +++ b/Application/IStation.Application4Job/custom_cron_job/_/dto/CustomCronJobDto.cs @@ -0,0 +1,100 @@ +锘縰sing IStation.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation.Application +{ + /// <summary> + /// 鑷畾涔夎鍒掍换鍔to + /// </summary> + public class CustomCronJobDto + { + /// <summary> + /// + /// </summary> + public CustomCronJobDto() { } + + /// <summary> + /// + /// </summary> + public CustomCronJobDto(Model.CustomCronJob rhs) + { + this.ID = rhs.ID; + this.NO = rhs.NO; + this.Name = rhs.Name; + this.Expression = rhs.Expression; + this.Repeat = rhs.Repeat; + this.Execution = rhs.Execution; + this.UseStatus = rhs.UseStatus; + this.Description = rhs.Description; + this.CreateUserID = rhs.CreateUserID; + this.CreateTime = rhs.CreateTime; + this.UpdateUserID = rhs.UpdateUserID; + this.UpdateTime = rhs.UpdateTime; + } + + /// <summary> + /// id + /// </summary> + public long ID { get; set; } + + /// <summary> + /// 缂栧彿 + /// </summary> + public string NO { get; set; } + + /// <summary> + /// 鍚嶇О + /// </summary> + public string Name { get; set; } + + /// <summary> + /// Cron琛ㄨ揪寮� + /// </summary> + public string Expression { get; set; } + + /// <summary> + /// 閲嶇疆 锛堝垎閽燂級 + /// </summary> + public int Repeat { get; set; } + + /// <summary> + /// 鎵ц鏂囦欢 + /// </summary> + public string Execution { get; set; } + + /// <summary> + /// 浣跨敤鐘舵�� + /// </summary> + public eUseStatus UseStatus { get; set; } + + /// <summary> + /// 璇存槑 + /// </summary> + public string Description { get; set; } + + /// <summary> + /// 鍒涘缓鐢ㄦ埛id + /// </summary> + public long CreateUserID { get; set; } + + /// <summary> + /// 鍒涘缓鏃堕棿 + /// </summary> + public DateTime CreateTime { get; set; } + + /// <summary> + /// 鏇存柊鐢ㄦ埛id + /// </summary> + public long? UpdateUserID { get; set; } + + /// <summary> + /// 鏇存柊鏃堕棿 + /// </summary> + public DateTime? UpdateTime { get; set; } + + } +} diff --git a/Application/IStation.Application4Job/custom_cron_job/_/dto/UpdateCustomCronJobInput.cs b/Application/IStation.Application4Job/custom_cron_job/_/dto/UpdateCustomCronJobInput.cs new file mode 100644 index 0000000..82cc08d --- /dev/null +++ b/Application/IStation.Application4Job/custom_cron_job/_/dto/UpdateCustomCronJobInput.cs @@ -0,0 +1,52 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation.Application +{ + /// <summary> + /// 鏇存柊鑷畾涔� + /// </summary> + public class UpdateCustomCronJobInput + { + + /// <summary> + /// id + /// </summary> + public long ID { get; set; } + + /// <summary> + /// 缂栧彿 + /// </summary> + public string NO { get; set; } + + /// <summary> + /// 鍚嶇О + /// </summary> + public string Name { get; set; } + + /// <summary> + /// Cron琛ㄨ揪寮� + /// </summary> + public string Expression { get; set; } + + /// <summary> + /// 閲嶇疆 锛堝垎閽燂級 + /// </summary> + public int Repeat { get; set; } + + /// <summary> + /// 鎵ц鏂囦欢 + /// </summary> + public string Execution { get; set; } + + /// <summary> + /// 璇存槑 + /// </summary> + public string Description { get; set; } + + + } +} diff --git a/Application/IStation.Application4Job/custom_real_job/_/CustomRealJob_Controller.cs b/Application/IStation.Application4Job/custom_real_job/_/CustomRealJob_Controller.cs new file mode 100644 index 0000000..9f26c6e --- /dev/null +++ b/Application/IStation.Application4Job/custom_real_job/_/CustomRealJob_Controller.cs @@ -0,0 +1,214 @@ +锘縰sing Microsoft.AspNetCore.Mvc; +using System.Net; +using System.Net.Http.Headers; +using Microsoft.Extensions.Hosting.Internal; +using Microsoft.AspNetCore.Http.Extensions; +using IStation.Untity; +using Furion.DynamicApiController; +using System.ComponentModel.DataAnnotations; +using Mapster; +using Furion.DataValidation; + +namespace IStation.Application +{ + /// <summary> + /// CustomRealJob + /// </summary> + [Route("Job/CustomRealJob")] + [ApiDescriptionSettings("Job", Name = "鑷畾涔夊疄鏃朵换鍔�", Order = 1000)] + public class CustomRealJob_Controller : IDynamicApiController + { + private readonly Service.CustomRealJob _service = new Service.CustomRealJob(); + + #region Query + + /// <summary> + ///鑾峰彇鎵�鏈� + /// </summary> + [Route("GetAll@V1.0")] + [HttpGet] + public List<CustomRealJobDto> GetAll() + { + var list = _service.GetAll(); + var vmList = list?.Select(x => new CustomRealJobDto(x)).ToList(); + return vmList; + } + + /// <summary> + /// 閫氳繃 ID 鑾峰彇 + /// </summary> + [Route("GetByID@V1.0")] + [HttpGet] + public CustomRealJobDto GetByID([FromQuery][Required] IDInput input) + { + var model = _service.GetByID(input.ID); + if (model == null) + return default; + var vm = new CustomRealJobDto(model); + return vm; + } + + /// <summary> + /// 閫氳繃 Ids 鑾峰彇 + /// </summary> + [Route("GetByIds@V1.0")] + [HttpGet] + public List<CustomRealJobDto> GetByIds([FromQuery] IdsInput model) + { + var ids = LongListHelper.ToList(model.Ids); + var list = _service.GetByIds(ids); + var vmList = list?.Select(x => new CustomRealJobDto(x)).ToList(); + return vmList; + } + + #endregion + + #region Insert + + /// <summary> + /// 鎻掑叆涓�鏉� + /// </summary> + [Route("Insert@V1.0")] + [HttpPost] + public long Insert(AddCustomRealJobInput input) + { + if (input == null) + return default; + var model = input.Adapt<AddCustomRealJobInput, Model.CustomRealJob>(); + var id = _service.Insert(model); + return id; + } + + /// <summary> + /// 鎻掑叆澶氭潯 + /// </summary> + [Route("Inserts@V1.0")] + [HttpPost] + public bool Inserts(List<AddCustomRealJobInput> inputList) + { + if (inputList == null || inputList.Count < 1) + return false; + var list = inputList.Select(x => x.Adapt<AddCustomRealJobInput, Model.CustomRealJob>()).ToList(); + var bol = _service.Inserts(list); + return bol; + } + + #endregion + + #region Update + + /// <summary> + /// 鏇存柊涓�鏉� + /// </summary> + [Route("Update@V1.0")] + [HttpPut] + public bool Update(UpdateCustomRealJobInput input) + { + if (input == null) + return false; + var model = _service.GetByID(input.ID); + if (model == null) + return false; + var rhs = new Model.CustomRealJob(model); + input.Adapt(rhs); + var bol = _service.Update(rhs); + return bol; + } + + /// <summary> + /// 鏇存柊澶氭潯 + /// </summary> + [Route("Updates@V1.0")] + [HttpPut] + public bool Updates(List<UpdateCustomRealJobInput> inputList) + { + if (inputList == null || inputList.Count() < 1) + { + return false; + } + var modelList = _service.GetByIds(inputList.Select(x => x.ID).ToList()); + if (modelList == null || modelList.Count < 1) + return false; + var rhsList = new List<Model.CustomRealJob>(); + modelList.ForEach(x => { + var input = inputList.Find(t => t.ID == x.ID); + if (input != null) + { + var rhs = new Model.CustomRealJob(x); + input.Adapt(rhs); + rhsList.Add(rhs); + } + }); + if (rhsList.Count < 1) + return false; + var bol = _service.Updates(rhsList); + return bol; + } + + /// <summary> + /// 鏇存柊浣跨敤鐘舵�� + /// </summary> + [Route("UpdateUseStatus@V1.0")] + [HttpPut] + public bool UpdateUseStatus([Required] UpdateUseStatusInput intput) + { + var bol = _service.UpdateUseStatus(intput.ID, intput.UseStatus,UserManager.UserID,DateTime.Now); + return bol; + } + + #endregion + + #region Exist + + + /// <summary> + /// 鍒ゆ柇 NO 鏄惁瀛樺湪 + /// </summary> + [Route("IsExistNO@V1.0")] + [HttpGet] + public bool IsExistNO + ( + [Required,DataValidation(AllowEmptyStrings =false)] + string NO + ) + { + var bol = _service.IsExistNO(NO); + return bol; + } + + /// <summary> + /// 鍒ゆ柇 NO 鏄惁瀛樺湪 ExceptID + /// </summary> + [Route("IsExistNOExceptID@V1.0")] + [HttpGet] + public bool IsExistNOExceptID + ( + [Required,DataValidation(AllowEmptyStrings =false)] + string NO, + [Required,Range(1,long.MaxValue,ErrorMessage ="ExceptID 蹇呴』澶т簬0")] + long ExceptID + ) + { + var bol = _service.IsExistNOExceptID(NO, ExceptID); + return bol; + } + + #endregion + + #region Delete + + /// <summary> + /// 閫氳繃 ID 鍒犻櫎 + /// </summary> + [Route("DeleteByID@V1.0")] + [HttpDelete] + public DeleteReasonOutput DeleteByID([FromQuery][Required] IDInput input) + { + var bol = _service.DeleteByID(input.ID, out string msg); + return new DeleteReasonOutput() { Success = bol, Reason = msg }; + } + + #endregion + + } +} \ No newline at end of file diff --git a/Application/IStation.Application4Job/custom_real_job/_/dto/AddCustomRealJobInput.cs b/Application/IStation.Application4Job/custom_real_job/_/dto/AddCustomRealJobInput.cs new file mode 100644 index 0000000..fa5836c --- /dev/null +++ b/Application/IStation.Application4Job/custom_real_job/_/dto/AddCustomRealJobInput.cs @@ -0,0 +1,46 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation.Application +{ + /// <summary> + /// 娣诲姞鑷畾涔夊疄鏃朵换鍔� + /// </summary> + public class AddCustomRealJobInput + { + + /// <summary> + /// 缂栧彿 + /// </summary> + public string NO { get; set; } + + /// <summary> + /// 鍚嶇О + /// </summary> + public string Name { get; set; } + + /// <summary> + /// 闂撮殧 锛堢鏁帮級 + /// </summary> + public int Interval { get; set; } + + /// <summary> + /// 閲嶇疆 锛堝垎閽燂級 + /// </summary> + public int Repeat { get; set; } + + /// <summary> + /// 鎵ц鏂囦欢 + /// </summary> + public string Execution { get; set; } + + /// <summary> + /// 璇存槑 + /// </summary> + public string Description { get; set; } + + } +} diff --git a/Application/IStation.Application4Job/custom_real_job/_/dto/CustomRealJobDto.cs b/Application/IStation.Application4Job/custom_real_job/_/dto/CustomRealJobDto.cs new file mode 100644 index 0000000..8475433 --- /dev/null +++ b/Application/IStation.Application4Job/custom_real_job/_/dto/CustomRealJobDto.cs @@ -0,0 +1,100 @@ +锘縰sing IStation.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation.Application +{ + /// <summary> + /// 鑷畾涔夊疄鏃朵换鍔to + /// </summary> + public class CustomRealJobDto + { + /// <summary> + /// + /// </summary> + public CustomRealJobDto() { } + + /// <summary> + /// + /// </summary> + public CustomRealJobDto(Model.CustomRealJob rhs) + { + this.ID = rhs.ID; + this.NO = rhs.NO; + this.Name = rhs.Name; + this.Interval = rhs.Interval; + this.Repeat = rhs.Repeat; + this.Execution = rhs.Execution; + this.UseStatus = rhs.UseStatus; + this.Description = rhs.Description; + this.CreateUserID = rhs.CreateUserID; + this.CreateTime = rhs.CreateTime; + this.UpdateUserID = rhs.UpdateUserID; + this.UpdateTime = rhs.UpdateTime; + } + + /// <summary> + /// id + /// </summary> + public long ID { get; set; } + + /// <summary> + /// 缂栧彿 + /// </summary> + public string NO { get; set; } + + /// <summary> + /// 鍚嶇О + /// </summary> + public string Name { get; set; } + + /// <summary> + /// 闂撮殧 锛堢鏁帮級 + /// </summary> + public int Interval { get; set; } + + /// <summary> + /// 閲嶇疆 锛堝垎閽燂級 + /// </summary> + public int Repeat { get; set; } + + /// <summary> + /// 鎵ц鏂囦欢 + /// </summary> + public string Execution { get; set; } + + /// <summary> + /// 浣跨敤鐘舵�� + /// </summary> + public eUseStatus UseStatus { get; set; } + + /// <summary> + /// 璇存槑 + /// </summary> + public string Description { get; set; } + + /// <summary> + /// 鍒涘缓鐢ㄦ埛id + /// </summary> + public long CreateUserID { get; set; } + + /// <summary> + /// 鍒涘缓鏃堕棿 + /// </summary> + public DateTime CreateTime { get; set; } + + /// <summary> + /// 鏇存柊鐢ㄦ埛id + /// </summary> + public long? UpdateUserID { get; set; } + + /// <summary> + /// 鏇存柊鏃堕棿 + /// </summary> + public DateTime? UpdateTime { get; set; } + + } +} diff --git a/Application/IStation.Application4Job/custom_real_job/_/dto/UpdateCustomRealJobInput.cs b/Application/IStation.Application4Job/custom_real_job/_/dto/UpdateCustomRealJobInput.cs new file mode 100644 index 0000000..ecc6faf --- /dev/null +++ b/Application/IStation.Application4Job/custom_real_job/_/dto/UpdateCustomRealJobInput.cs @@ -0,0 +1,52 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation.Application +{ + /// <summary> + /// 鏇存柊鑷畾涔� + /// </summary> + public class UpdateCustomRealJobInput + { + + /// <summary> + /// id + /// </summary> + public long ID { get; set; } + + /// <summary> + /// 缂栧彿 + /// </summary> + public string NO { get; set; } + + /// <summary> + /// 鍚嶇О + /// </summary> + public string Name { get; set; } + + /// <summary> + /// 闂撮殧 锛堢鏁帮級 + /// </summary> + public int Interval { get; set; } + + /// <summary> + /// 閲嶇疆 锛堝垎閽燂級 + /// </summary> + public int Repeat { get; set; } + + /// <summary> + /// 鎵ц鏂囦欢 + /// </summary> + public string Execution { get; set; } + + /// <summary> + /// 璇存槑 + /// </summary> + public string Description { get; set; } + + + } +} diff --git a/Core/IStation.WebApi.Core/applicationconfig.json b/Core/IStation.WebApi.Core/applicationconfig.json index 3d48863..124d242 100644 --- a/Core/IStation.WebApi.Core/applicationconfig.json +++ b/Core/IStation.WebApi.Core/applicationconfig.json @@ -143,6 +143,13 @@ "Order": 84, "Description": "澶у睆妯″潡", "Version": "V1" + }, + { + "Group": "Job", + "Title": "浠诲姟妯″潡", + "Order": 83, + "Description": "浠诲姟妯″潡", + "Version": "V1" } ] } diff --git a/DAL/IStation.DAL4Job/IStation.DAL4Job.csproj b/DAL/IStation.DAL4Job/IStation.DAL4Job.csproj new file mode 100644 index 0000000..86b96b9 --- /dev/null +++ b/DAL/IStation.DAL4Job/IStation.DAL4Job.csproj @@ -0,0 +1,17 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net6.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>disable</Nullable> + <AssemblyName>IStation.DAL4Job</AssemblyName> + <RootNamespace>IStation.DAL</RootNamespace> + <GenerateDocumentationFile>True</GenerateDocumentationFile> + </PropertyGroup> + + <ItemGroup> + <ProjectReference Include="..\..\Entity\IStation.Entity4Job\IStation.Entity4Job.csproj" /> + <ProjectReference Include="..\IStation.DAL\IStation.DAL.csproj" /> + </ItemGroup> + +</Project> diff --git a/DAL/IStation.DAL4Job/custom/CustomCronJob.cs b/DAL/IStation.DAL4Job/custom/CustomCronJob.cs new file mode 100644 index 0000000..a89d4a0 --- /dev/null +++ b/DAL/IStation.DAL4Job/custom/CustomCronJob.cs @@ -0,0 +1,29 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; + +namespace IStation.DAL +{ + /// <summary> + /// 鑷畾涔夎鍒掍换鍔� + /// </summary> + public partial class CustomCronJob : BaseTraceDAL_UseStatus<Entity.CustomCronJob> + { + /// <summary> + /// + /// </summary> + public override ConnectionConfig ConnectionConfig + { + get { return ConfigHelper.DefaultConnectionConfig; } + + } + + + + + + + } +} \ No newline at end of file diff --git a/DAL/IStation.DAL4Job/custom/CustomRealJob.cs b/DAL/IStation.DAL4Job/custom/CustomRealJob.cs new file mode 100644 index 0000000..f07a68a --- /dev/null +++ b/DAL/IStation.DAL4Job/custom/CustomRealJob.cs @@ -0,0 +1,29 @@ +锘縰sing SqlSugar; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; + +namespace IStation.DAL +{ + /// <summary> + /// 鑷畾涔夊疄鏃朵换鍔� + /// </summary> + public partial class CustomRealJob : BaseTraceDAL_UseStatus<Entity.CustomRealJob> + { + /// <summary> + /// + /// </summary> + public override ConnectionConfig ConnectionConfig + { + get { return ConfigHelper.DefaultConnectionConfig; } + + } + + + + + + + } +} \ No newline at end of file diff --git a/DAL/IStation.DAL4Job/helpers/ConfigHelper.cs b/DAL/IStation.DAL4Job/helpers/ConfigHelper.cs new file mode 100644 index 0000000..89fd375 --- /dev/null +++ b/DAL/IStation.DAL4Job/helpers/ConfigHelper.cs @@ -0,0 +1,68 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SqlSugar; + +namespace IStation.DAL +{ + internal class ConfigHelper + { + /// <summary> + /// 榛樿杩炴帴瀛楃涓� + /// </summary> + public static string DefaultConnString + { + get + { + return Settings.Job.DataBase.ConnectString; + } + } + + /// <summary> + /// 榛樿杩炴帴閰嶇疆 + /// </summary> + public static ConnectionConfig DefaultConnectionConfig + { + get + { + return new ConnectionConfig() + { + DbType = SqlSugar.DbType.PostgreSQL,//鏁版嵁搴撶被鍨� + ConnectionString = DefaultConnString, + IsAutoCloseConnection = true,//鏄惁鑷姩鍏抽棴 + MoreSettings = new ConnMoreSettings() + { + //PgSqlIsAutoToLower = false //鏁版嵁搴撳瓨鍦ㄥぇ鍐欏瓧娈电殑 锛岄渶瑕佹妸杩欎釜璁句负false 锛屽苟涓斿疄浣撳拰瀛楁鍚嶇О瑕佷竴鏍� + }, + AopEvents = new AopEvents + { + OnLogExecuting = (sql, p) => + { + // Console.WriteLine(sql); + } + } + }; + } + } + + + + + + + + + + + + + + + + } +} diff --git a/Entity/IStation.Entity4Job/IStation.Entity4Job.csproj b/Entity/IStation.Entity4Job/IStation.Entity4Job.csproj new file mode 100644 index 0000000..0e3807a --- /dev/null +++ b/Entity/IStation.Entity4Job/IStation.Entity4Job.csproj @@ -0,0 +1,16 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net6.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>disable</Nullable> + <AssemblyName>IStation.Entity4Job</AssemblyName> + <RootNamespace>IStation.Entity</RootNamespace> + <GenerateDocumentationFile>True</GenerateDocumentationFile> + </PropertyGroup> + + <ItemGroup> + <ProjectReference Include="..\IStation.Entity\IStation.Entity.csproj" /> + </ItemGroup> + +</Project> diff --git a/Entity/IStation.Entity4Job/custom/CustomCronJob.cs b/Entity/IStation.Entity4Job/custom/CustomCronJob.cs new file mode 100644 index 0000000..c013fee --- /dev/null +++ b/Entity/IStation.Entity4Job/custom/CustomCronJob.cs @@ -0,0 +1,84 @@ +锘縰sing System; +using System.Text; +using System.Collections.Generic; +using System.Data; +using System.Runtime.Serialization; +using SqlSugar; + +namespace IStation.Entity +{ + /// <summary> + /// 鑷畾涔夎鍒掍换鍔� + /// </summary> + [SugarTable("custom_cron_job")] + public class CustomCronJob : BaseTraceEntity, System.ICloneable, IUseStatus + { + /// <summary> + /// + /// </summary> + public CustomCronJob() { } + + /// <summary> + /// + /// </summary> + public CustomCronJob(CustomCronJob rhs) : base(rhs) + { + this.NO = rhs.NO; + this.Name = rhs.Name; + this.Expression = rhs.Expression; + this.Repeat = rhs.Repeat; + this.Execution = rhs.Execution; + this.UseStatus = rhs.UseStatus; + this.Description = rhs.Description; + } + + /// <summary> + /// 缂栧彿 + /// </summary> + public string NO { get; set; } + + /// <summary> + /// 鍚嶇О + /// </summary> + public string Name { get; set; } + + /// <summary> + /// Cron琛ㄨ揪寮� + /// </summary> + public string Expression { get; set; } + + /// <summary> + /// 閲嶇疆 锛堝垎閽燂級 + /// </summary> + public int Repeat { get; set; } + + /// <summary> + /// 鎵ц鏂囦欢 + /// </summary> + public string Execution { get; set; } + + /// <summary> + /// 浣跨敤鐘舵�� + /// </summary> + public int UseStatus { get; set; } + + /// <summary> + /// 璇存槑 + /// </summary> + public string Description { get; set; } + + /// <summary> + /// + /// </summary> + public CustomCronJob Clone() + { + return (CustomCronJob)this.MemberwiseClone(); + } + + object ICloneable.Clone() + { + return this.MemberwiseClone(); + } + } + +} \ No newline at end of file diff --git a/Entity/IStation.Entity4Job/custom/CustomRealJob.cs b/Entity/IStation.Entity4Job/custom/CustomRealJob.cs new file mode 100644 index 0000000..3186a86 --- /dev/null +++ b/Entity/IStation.Entity4Job/custom/CustomRealJob.cs @@ -0,0 +1,84 @@ +锘縰sing System; +using System.Text; +using System.Collections.Generic; +using System.Data; +using System.Runtime.Serialization; +using SqlSugar; + +namespace IStation.Entity +{ + /// <summary> + /// 鑷畾涔夊疄鏃朵换鍔� + /// </summary> + [SugarTable("custom_real_job")] + public class CustomRealJob : BaseTraceEntity, System.ICloneable, IUseStatus + { + /// <summary> + /// + /// </summary> + public CustomRealJob() { } + + /// <summary> + /// + /// </summary> + public CustomRealJob(CustomRealJob rhs) : base(rhs) + { + this.NO = rhs.NO; + this.Name = rhs.Name; + this.Interval = rhs.Interval; + this.Repeat = rhs.Repeat; + this.Execution = rhs.Execution; + this.UseStatus = rhs.UseStatus; + this.Description= rhs.Description; + } + + /// <summary> + /// 缂栧彿 + /// </summary> + public string NO { get; set; } + + /// <summary> + /// 鍚嶇О + /// </summary> + public string Name { get; set; } + + /// <summary> + /// 闂撮殧 锛堢鏁帮級 + /// </summary> + public int Interval { get; set; } + + /// <summary> + /// 閲嶇疆 锛堝垎閽燂級 + /// </summary> + public int Repeat { get; set; } + + /// <summary> + /// 鎵ц鏂囦欢 + /// </summary> + public string Execution { get; set; } + + /// <summary> + /// 浣跨敤鐘舵�� + /// </summary> + public int UseStatus { get; set; } + + /// <summary> + /// 璇存槑 + /// </summary> + public string Description { get; set; } + + /// <summary> + /// + /// </summary> + public CustomRealJob Clone() + { + return (CustomRealJob)this.MemberwiseClone(); + } + + object ICloneable.Clone() + { + return this.MemberwiseClone(); + } + } + +} \ No newline at end of file diff --git a/Entry/IStation.WebApi.Entry/IStation.WebApi.Entry.csproj b/Entry/IStation.WebApi.Entry/IStation.WebApi.Entry.csproj index 8a9486d..92dd563 100644 --- a/Entry/IStation.WebApi.Entry/IStation.WebApi.Entry.csproj +++ b/Entry/IStation.WebApi.Entry/IStation.WebApi.Entry.csproj @@ -18,6 +18,7 @@ <ProjectReference Include="..\..\Application\IStation.Application4Eta\IStation.Application4Eta.csproj" /> <ProjectReference Include="..\..\Application\IStation.Application4File\IStation.Application4File.csproj" /> <ProjectReference Include="..\..\Application\IStation.Application4Inspect\IStation.Application4Inspect.csproj" /> + <ProjectReference Include="..\..\Application\IStation.Application4Job\IStation.Application4Job.csproj" /> <ProjectReference Include="..\..\Application\IStation.Application4LargeScreen\IStation.Application4LargeScreen.csproj" /> <ProjectReference Include="..\..\Application\IStation.Application4Main\IStation.Application4Main.csproj" /> <ProjectReference Include="..\..\Application\IStation.Application4Map\IStation.Application4Map.csproj" /> diff --git a/IStation.WebApi.sln b/IStation.WebApi.sln index e2d6236..df9b38a 100644 --- a/IStation.WebApi.sln +++ b/IStation.WebApi.sln @@ -231,7 +231,17 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.Epanet", "Component\IStation.Epanet\IStation.Epanet.csproj", "{8FAA3265-3846-4D4C-990B-50B63F788711}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Application4LargeScreen", "Application\IStation.Application4LargeScreen\IStation.Application4LargeScreen.csproj", "{C18E7387-5CFA-4BC4-9886-ED25DE6DCFAE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IStation.Application4LargeScreen", "Application\IStation.Application4LargeScreen\IStation.Application4LargeScreen.csproj", "{C18E7387-5CFA-4BC4-9886-ED25DE6DCFAE}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Entity4Job", "Entity\IStation.Entity4Job\IStation.Entity4Job.csproj", "{3A241303-BECA-4D81-B01E-8F75A6D70304}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Model4Job", "Model\IStation.Model4Job\IStation.Model4Job.csproj", "{EE323F42-77EC-4AE4-B39C-F922DA61945D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.DAL4Job", "DAL\IStation.DAL4Job\IStation.DAL4Job.csproj", "{C7C288AF-B39C-4E4A-9E0D-9D9943693E85}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Service4Job", "Service\IStation.Service4Job\IStation.Service4Job.csproj", "{71B73D1F-56ED-44D3-A3E3-B409A2DF88F4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IStation.Application4Job", "Application\IStation.Application4Job\IStation.Application4Job.csproj", "{398CD0EE-C62E-4E44-85FB-AC04A0DE30CE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -651,6 +661,26 @@ {C18E7387-5CFA-4BC4-9886-ED25DE6DCFAE}.Debug|Any CPU.Build.0 = Debug|Any CPU {C18E7387-5CFA-4BC4-9886-ED25DE6DCFAE}.Release|Any CPU.ActiveCfg = Release|Any CPU {C18E7387-5CFA-4BC4-9886-ED25DE6DCFAE}.Release|Any CPU.Build.0 = Release|Any CPU + {3A241303-BECA-4D81-B01E-8F75A6D70304}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A241303-BECA-4D81-B01E-8F75A6D70304}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A241303-BECA-4D81-B01E-8F75A6D70304}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A241303-BECA-4D81-B01E-8F75A6D70304}.Release|Any CPU.Build.0 = Release|Any CPU + {EE323F42-77EC-4AE4-B39C-F922DA61945D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE323F42-77EC-4AE4-B39C-F922DA61945D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE323F42-77EC-4AE4-B39C-F922DA61945D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE323F42-77EC-4AE4-B39C-F922DA61945D}.Release|Any CPU.Build.0 = Release|Any CPU + {C7C288AF-B39C-4E4A-9E0D-9D9943693E85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7C288AF-B39C-4E4A-9E0D-9D9943693E85}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7C288AF-B39C-4E4A-9E0D-9D9943693E85}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7C288AF-B39C-4E4A-9E0D-9D9943693E85}.Release|Any CPU.Build.0 = Release|Any CPU + {71B73D1F-56ED-44D3-A3E3-B409A2DF88F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {71B73D1F-56ED-44D3-A3E3-B409A2DF88F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {71B73D1F-56ED-44D3-A3E3-B409A2DF88F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {71B73D1F-56ED-44D3-A3E3-B409A2DF88F4}.Release|Any CPU.Build.0 = Release|Any CPU + {398CD0EE-C62E-4E44-85FB-AC04A0DE30CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {398CD0EE-C62E-4E44-85FB-AC04A0DE30CE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {398CD0EE-C62E-4E44-85FB-AC04A0DE30CE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {398CD0EE-C62E-4E44-85FB-AC04A0DE30CE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -758,6 +788,11 @@ {1ABA1E05-4B21-4E9A-9654-42F5AC5F9FBA} = {B1548C2C-C3C2-47C0-8F6E-B265D0603099} {8FAA3265-3846-4D4C-990B-50B63F788711} = {8999E5DD-B675-4FFB-AEE4-CC96FC483845} {C18E7387-5CFA-4BC4-9886-ED25DE6DCFAE} = {C7614DA2-0679-407D-B9E3-66D448DD7488} + {3A241303-BECA-4D81-B01E-8F75A6D70304} = {A24F4CA7-C6A3-4663-9A07-017814E614E7} + {EE323F42-77EC-4AE4-B39C-F922DA61945D} = {61C58B21-80C9-4092-ACC5-141B424D15E8} + {C7C288AF-B39C-4E4A-9E0D-9D9943693E85} = {49E7CA43-7FD9-48A3-B0DB-6D99FA93F393} + {71B73D1F-56ED-44D3-A3E3-B409A2DF88F4} = {3BE2BA1A-B93F-4EDE-BC37-915663317C33} + {398CD0EE-C62E-4E44-85FB-AC04A0DE30CE} = {C7614DA2-0679-407D-B9E3-66D448DD7488} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {18D1EA07-81E5-4443-8512-F303BC79DCF4} diff --git a/Model/IStation.Model4Job/IStation.Model4Job.csproj b/Model/IStation.Model4Job/IStation.Model4Job.csproj new file mode 100644 index 0000000..43724a3 --- /dev/null +++ b/Model/IStation.Model4Job/IStation.Model4Job.csproj @@ -0,0 +1,16 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net6.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>disable</Nullable> + <AssemblyName>IStation.Model4Job</AssemblyName> + <RootNamespace>IStation.Model</RootNamespace> + <GenerateDocumentationFile>True</GenerateDocumentationFile> + </PropertyGroup> + + <ItemGroup> + <ProjectReference Include="..\IStation.Model\IStation.Model.csproj" /> + </ItemGroup> + +</Project> diff --git a/Model/IStation.Model4Job/custom/CustomCronJob.cs b/Model/IStation.Model4Job/custom/CustomCronJob.cs new file mode 100644 index 0000000..2269157 --- /dev/null +++ b/Model/IStation.Model4Job/custom/CustomCronJob.cs @@ -0,0 +1,131 @@ +锘縰sing System; +using System.Text; +using System.Collections.Generic; +using System.Data; +using System.Runtime.Serialization; + +namespace IStation.Model +{ + /// <summary> + /// 鑷畾涔夎鍒掍换鍔� + /// </summary> + public class CustomCronJob : System.ICloneable + { + /// <summary> + /// + /// </summary> + public CustomCronJob() { } + + /// <summary> + /// + /// </summary> + public CustomCronJob(CustomCronJob rhs) + { + this.ID = rhs.ID; + this.NO = rhs.NO; + this.Name = rhs.Name; + this.Expression = rhs.Expression; + this.Repeat = rhs.Repeat; + this.Execution = rhs.Execution; + this.UseStatus = rhs.UseStatus; + this.Description = rhs.Description; + this.CreateUserID = rhs.CreateUserID; + this.CreateTime = rhs.CreateTime; + this.UpdateUserID = rhs.UpdateUserID; + this.UpdateTime = rhs.UpdateTime; + } + + /// <summary> + /// 閲嶇疆 + /// </summary> + public void Reset(CustomCronJob rhs) + { + this.ID = rhs.ID; + this.NO = rhs.NO; + this.Name = rhs.Name; + this.Expression = rhs.Expression; + this.Repeat = rhs.Repeat; + this.Execution = rhs.Execution; + this.UseStatus = rhs.UseStatus; + this.Description = rhs.Description; + this.CreateUserID = rhs.CreateUserID; + this.CreateTime = rhs.CreateTime; + this.UpdateUserID = rhs.UpdateUserID; + this.UpdateTime = rhs.UpdateTime; + } + + /// <summary> + /// id + /// </summary> + public long ID { get; set; } + + /// <summary> + /// 缂栧彿 + /// </summary> + public string NO { get; set; } + + /// <summary> + /// 鍚嶇О + /// </summary> + public string Name { get; set; } + + /// <summary> + /// Cron琛ㄨ揪寮� + /// </summary> + public string Expression { get; set; } + + /// <summary> + /// 閲嶇疆 锛堝垎閽燂級 + /// </summary> + public int Repeat { get; set; } + + /// <summary> + /// 鎵ц鏂囦欢 + /// </summary> + public string Execution { get; set; } + + /// <summary> + /// 浣跨敤鐘舵�� + /// </summary> + public eUseStatus UseStatus { get; set; } + + /// <summary> + /// 璇存槑 + /// </summary> + public string Description { get; set; } + + /// <summary> + /// 鍒涘缓鐢ㄦ埛id + /// </summary> + public long CreateUserID { get; set; } + + /// <summary> + /// 鍒涘缓鏃堕棿 + /// </summary> + public DateTime CreateTime { get; set; } + + /// <summary> + /// 鏇存柊鐢ㄦ埛id + /// </summary> + public long? UpdateUserID { get; set; } + + /// <summary> + /// 鏇存柊鏃堕棿 + /// </summary> + public DateTime? UpdateTime { get; set; } + + /// <summary> + /// + /// </summary> + public CustomCronJob Clone() + { + return (CustomCronJob)this.MemberwiseClone(); + } + + object ICloneable.Clone() + { + return this.MemberwiseClone(); + } + } + +} \ No newline at end of file diff --git a/Model/IStation.Model4Job/custom/CustomRealJob.cs b/Model/IStation.Model4Job/custom/CustomRealJob.cs new file mode 100644 index 0000000..ee95ccb --- /dev/null +++ b/Model/IStation.Model4Job/custom/CustomRealJob.cs @@ -0,0 +1,131 @@ +锘縰sing System; +using System.Text; +using System.Collections.Generic; +using System.Data; +using System.Runtime.Serialization; + +namespace IStation.Model +{ + /// <summary> + /// 鑷畾涔夊疄鏃朵换鍔� + /// </summary> + public class CustomRealJob : System.ICloneable + { + /// <summary> + /// + /// </summary> + public CustomRealJob() { } + + /// <summary> + /// + /// </summary> + public CustomRealJob(CustomRealJob rhs) + { + this.ID = rhs.ID; + this.NO = rhs.NO; + this.Name = rhs.Name; + this.Interval = rhs.Interval; + this.Repeat = rhs.Repeat; + this.Execution = rhs.Execution; + this.UseStatus = rhs.UseStatus; + this.Description = rhs.Description; + this.CreateUserID = rhs.CreateUserID; + this.CreateTime = rhs.CreateTime; + this.UpdateUserID = rhs.UpdateUserID; + this.UpdateTime = rhs.UpdateTime; + } + + /// <summary> + /// 閲嶇疆 + /// </summary> + public void Reset(CustomRealJob rhs) + { + this.ID = rhs.ID; + this.NO = rhs.NO; + this.Name = rhs.Name; + this.Interval = rhs.Interval; + this.Repeat = rhs.Repeat; + this.Execution = rhs.Execution; + this.UseStatus = rhs.UseStatus; + this.Description = rhs.Description; + this.CreateUserID = rhs.CreateUserID; + this.CreateTime = rhs.CreateTime; + this.UpdateUserID = rhs.UpdateUserID; + this.UpdateTime = rhs.UpdateTime; + } + + /// <summary> + /// id + /// </summary> + public long ID { get; set; } + + /// <summary> + /// 缂栧彿 + /// </summary> + public string NO { get; set; } + + /// <summary> + /// 鍚嶇О + /// </summary> + public string Name { get; set; } + + /// <summary> + /// 闂撮殧 锛堢鏁帮級 + /// </summary> + public int Interval { get; set; } + + /// <summary> + /// 閲嶇疆 锛堝垎閽燂級 + /// </summary> + public int Repeat { get; set; } + + /// <summary> + /// 鎵ц鏂囦欢 + /// </summary> + public string Execution { get; set; } + + /// <summary> + /// 浣跨敤鐘舵�� + /// </summary> + public eUseStatus UseStatus { get; set; } + + /// <summary> + /// 璇存槑 + /// </summary> + public string Description { get; set; } + + /// <summary> + /// 鍒涘缓鐢ㄦ埛id + /// </summary> + public long CreateUserID { get; set; } + + /// <summary> + /// 鍒涘缓鏃堕棿 + /// </summary> + public DateTime CreateTime { get; set; } + + /// <summary> + /// 鏇存柊鐢ㄦ埛id + /// </summary> + public long? UpdateUserID { get; set; } + + /// <summary> + /// 鏇存柊鏃堕棿 + /// </summary> + public DateTime? UpdateTime { get; set; } + + /// <summary> + /// + /// </summary> + public CustomRealJob Clone() + { + return (CustomRealJob)this.MemberwiseClone(); + } + + object ICloneable.Clone() + { + return this.MemberwiseClone(); + } + } + +} \ No newline at end of file diff --git a/Service/IStation.Service4Job/IStation.Service4Job.csproj b/Service/IStation.Service4Job/IStation.Service4Job.csproj new file mode 100644 index 0000000..e678663 --- /dev/null +++ b/Service/IStation.Service4Job/IStation.Service4Job.csproj @@ -0,0 +1,18 @@ +<Project Sdk="Microsoft.NET.Sdk"> + + <PropertyGroup> + <TargetFramework>net6.0</TargetFramework> + <ImplicitUsings>enable</ImplicitUsings> + <Nullable>disable</Nullable> + <AssemblyName>IStation.Service4Job</AssemblyName> + <RootNamespace>IStation.Service</RootNamespace> + <GenerateDocumentationFile>True</GenerateDocumentationFile> + </PropertyGroup> + + <ItemGroup> + <ProjectReference Include="..\..\DAL\IStation.DAL4Job\IStation.DAL4Job.csproj" /> + <ProjectReference Include="..\..\Model\IStation.Model4Job\IStation.Model4Job.csproj" /> + <ProjectReference Include="..\IStation.Service4Basic\IStation.Service4Basic.csproj" /> + </ItemGroup> + +</Project> diff --git a/Service/IStation.Service4Job/custom/custom_cron_job/CustomCronJob.cs b/Service/IStation.Service4Job/custom/custom_cron_job/CustomCronJob.cs new file mode 100644 index 0000000..b752ee0 --- /dev/null +++ b/Service/IStation.Service4Job/custom/custom_cron_job/CustomCronJob.cs @@ -0,0 +1,271 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using IStation.Untity; + +namespace IStation.Service +{ + /// <summary> + /// 鑷畾涔夎鍒掍换鍔� + /// </summary> + public partial class CustomCronJob + { + #region Cache + + //鑾峰彇缂撳瓨 + private List<Model.CustomCronJob> GetCache() + { + var all = CustomCronJobCacheHelper.GetSet(() => + { + var dal = new DAL.CustomCronJob(); + var entity_list = dal.GetAll(); + var model_list = Entity2Models(entity_list); + if (model_list == null) + { + model_list = new List<Model.CustomCronJob>(); + } + return model_list; + }, ConfigHelper.CacheKeepTime, ConfigHelper.CacheRandomTime); + return all; + } + + //閫氳繃 ID 鏇存柊缂撳瓨 + private void UpdateCache(long ID) + { + var dal = new DAL.CustomCronJob(); + var entity_ds = dal.GetByID(ID); + var model_ds = Entity2Model(entity_ds); + var all = GetCache(); + var model = all.Find(x => x.ID == ID); + if (model == null) + { + all.Add(model_ds); + } + else + { + model.Reset(model_ds); + } + } + + //閫氳繃 Ids 鏇存柊缂撳瓨 + private void UpdateCache(List<long> Ids) + { + if (Ids == null || Ids.Count() < 1) + return; + var dal = new DAL.CustomCronJob(); + var entity_list = dal.GetByIds(Ids); + var model_list = Entity2Models(entity_list); + var all = GetCache(); + all.RemoveAll(x => Ids.Contains(x.ID)); + if (model_list != null && model_list.Count > 0) + { + all.AddRange(model_list); + } + } + + //绉婚櫎缂撳瓨 + private void RemoveCache(long ID) + { + var all = GetCache(); + all.RemoveAll(x => x.ID == ID); + } + + #endregion + + #region Query + + /// <summary> + /// 鑾峰彇鎵�鏈� + /// </summary> + public List<Model.CustomCronJob> GetAll() + { + var all = GetCache(); + return all.OrderBy(x => x.CreateTime).ToList(); + } + + /// <summary> + /// 閫氳繃 ID 鑾峰彇 + /// </summary> + public Model.CustomCronJob GetByID(long ID) + { + var all = GetAll(); + return all.Find(x => x.ID == ID); + } + + /// <summary> + /// 閫氳繃 ID 鑾峰彇 + /// </summary> + public List<Model.CustomCronJob> GetByIds(List<long> Ids) + { + if (Ids == null || Ids.Count() < 1) + return default; + var all = GetAll(); + return all.Where(x => Ids.Contains(x.ID)).OrderBy(x => x.CreateTime).ToList(); + } + + #endregion + + #region Insert + + /// <summary> + /// 娣诲姞涓�鏉� + /// </summary> + public long Insert(Model.CustomCronJob model) + { + if (model == null) + return default; + var entity = Model2Entity(model); + if (string.IsNullOrEmpty(entity.NO)) + { + entity.NO = CreateNO(); + } + var dal = new DAL.CustomCronJob(); + var id = dal.Insert(entity); + if (id > 0) + { + UpdateCache(id); + } + return id; + } + + /// <summary> + /// 鎵归噺鎻掑叆 + /// </summary> + public bool Inserts(List<Model.CustomCronJob> list) + { + if (list == null || list.Count() < 1) + return default; + var dal = new DAL.CustomCronJob(); + var entityList = Model2Entities(list); + entityList.ForEach(x => { + if (string.IsNullOrEmpty(x.NO)) + x.NO = CreateNO(); + }); + var ids = dal.InsertsR(entityList); + if (ids != null && ids.Count > 0) + { + UpdateCache(ids); + return true; + } + return false; + } + + #endregion + + #region Update + + /// <summary> + /// 鏇存柊涓�鏉� + /// </summary> + public bool Update(Model.CustomCronJob model) + { + if (model == null) + return default; + var entity = Model2Entity(model); + var dal = new DAL.CustomCronJob(); + var bol = dal.Update(entity); + if (bol) + { + UpdateCache(model.ID); + } + return bol; + } + + /// <summary> + /// 鎵归噺鏇存柊 + /// </summary> + public bool Updates(List<Model.CustomCronJob> list) + { + if (list == null || list.Count() < 1) + return default; + var entity_list = Model2Entities(list.ToList()); + var dal = new DAL.CustomCronJob(); + var bol = dal.Updates(entity_list); + if (bol) + { + UpdateCache(list.Select(x => x.ID).ToList()); + } + return bol; + } + + /// <summary> + /// 鏇存柊浣跨敤鐘舵�� + /// </summary> + public bool UpdateUseStatus(long ID, Model.eUseStatus UseStatus, long UpdateUserID, DateTime UpdateTime) + { + if (ID < 1) + return default; + var dal = new DAL.CustomCronJob(); + var bol = dal.UpdateUseStatus(ID, (int)UseStatus, UpdateUserID, UpdateTime); + if (bol) + { + UpdateCache(ID); + } + return bol; + } + + #endregion + + #region Exist + + /// <summary> + /// 鏍规嵁 ID 鍒ゆ柇鏄惁瀛樺湪 + /// </summary> + public bool IsExistByID(long ID) + { + var all = GetAll(); + return all.Exists(x => x.ID == ID); + } + + /// <summary> + /// 鍒ゆ柇Code鏄惁瀛樺湪 + /// </summary> + public bool IsExistNO(string NO) + { + if (string.IsNullOrEmpty(NO)) + return default; + var all = GetAll(); + if (all == null || all.Count < 1) + return default; + return all.Exists(x => !string.IsNullOrEmpty(x.NO) && x.NO.ToUpper() == NO.ToUpper()); + } + + /// <summary> + /// 鍒ゆ柇NO鏄惁瀛樺湪 ExceptID + /// </summary> + public bool IsExistNOExceptID(string NO, long ExceptID) + { + if (string.IsNullOrEmpty(NO)) + return default; + var all = GetAll(); + if (all == null || all.Count < 1) + return default; + return all.Exists(x => !string.IsNullOrEmpty(x.NO) && x.NO.ToUpper() == NO.ToUpper() && x.ID != ExceptID); + } + + #endregion + + #region Delete + + /// <summary> + /// 閫氳繃 ID 鍒犻櫎 + /// </summary> + public bool DeleteByID(long ID, out string Msg) + { + Msg = string.Empty; + var dal = new DAL.CustomCronJob(); + var bol = dal.DeleteByID(ID); + if (bol) + { + RemoveCache(ID); + } + return bol; + } + + #endregion + + } +} + diff --git a/Service/IStation.Service4Job/custom/custom_cron_job/CustomCronJob_Instance.cs b/Service/IStation.Service4Job/custom/custom_cron_job/CustomCronJob_Instance.cs new file mode 100644 index 0000000..34d12d6 --- /dev/null +++ b/Service/IStation.Service4Job/custom/custom_cron_job/CustomCronJob_Instance.cs @@ -0,0 +1,61 @@ +锘縰sing AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation.Service +{ + public partial class CustomCronJob + { + //Entity to GetModel + private Model.CustomCronJob Entity2Model(Entity.CustomCronJob entity) + { + if (entity == null) + return default; + var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.CustomCronJob, Model.CustomCronJob>()).CreateMapper(); + var model = mapper.Map<Entity.CustomCronJob, Model.CustomCronJob>(entity); + return model; + } + + //Entities to GetModels + private List<Model.CustomCronJob> Entity2Models(List<Entity.CustomCronJob> entities) + { + if (entities == null || entities.Count() < 1) + return default; + var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.CustomCronJob, Model.CustomCronJob>()).CreateMapper(); + var models = mapper.Map<List<Entity.CustomCronJob>, List<Model.CustomCronJob>>(entities); + return models; + } + + //Model to Entity + private Entity.CustomCronJob Model2Entity(Model.CustomCronJob model) + { + if (model == null) + return default; + var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.CustomCronJob, Entity.CustomCronJob>()).CreateMapper(); + var entity = mapper.Map<Model.CustomCronJob, Entity.CustomCronJob>(model); + return entity; + } + + //Models to Entities + private List<Entity.CustomCronJob> Model2Entities(List<Model.CustomCronJob> models) + { + if (models == null || models.Count < 1) + return default; + var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.CustomCronJob, Entity.CustomCronJob>()).CreateMapper(); + var entities = mapper.Map<List<Model.CustomCronJob>, List<Entity.CustomCronJob>>(models); + return entities; + } + + //Model to Entity + private void Model2Entity(Model.CustomCronJob model, Entity.CustomCronJob entity) + { + if (model == null || entity == null) + return; + var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.CustomCronJob, Entity.CustomCronJob>()).CreateMapper(); + mapper.Map(model, entity); + } + } +} diff --git a/Service/IStation.Service4Job/custom/custom_cron_job/CustomCronJob_NO.cs b/Service/IStation.Service4Job/custom/custom_cron_job/CustomCronJob_NO.cs new file mode 100644 index 0000000..b6632ef --- /dev/null +++ b/Service/IStation.Service4Job/custom/custom_cron_job/CustomCronJob_NO.cs @@ -0,0 +1,35 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation.Service +{ + public partial class CustomCronJob + { + /// <summary> + /// 鍒涘缓缂栧彿 + /// </summary> + private string CreateNO() + { + var all = GetAll(); + var noList = all.Select(x => x.NO).ToList(); + var number = noList.Count + 1; + var no = GetFormatNO(number); + while (noList.Contains(no)) + { + number++; + no = GetFormatNO(number); + } + return no; + } + + //鑾峰彇鏍煎紡鍖朜O + private string GetFormatNO(int number) + { + return $"CCJ-{number:000000}"; + } + + } +} diff --git a/Service/IStation.Service4Job/custom/custom_cron_job/cache/CustomCronJobCacheHelper.cs b/Service/IStation.Service4Job/custom/custom_cron_job/cache/CustomCronJobCacheHelper.cs new file mode 100644 index 0000000..432bc8c --- /dev/null +++ b/Service/IStation.Service4Job/custom/custom_cron_job/cache/CustomCronJobCacheHelper.cs @@ -0,0 +1,63 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using IStation.Untity; + +namespace IStation.Service +{ + /// <summary> + /// CustomCronJob + /// 缂撳瓨杈呭姪绫� + /// </summary> + internal class CustomCronJobCacheHelper + { + private const string _contentKey = "CustomCronJobListKey"; + + private static string GetCacheKey() + { + var contentKey = string.Format("{0}", _contentKey); + return CacheHelper.GetCacheKey(contentKey); + } + + /// <summary> + /// 璁剧疆缂撳瓨 + /// </summary> + public static void Set(List<Model.CustomCronJob> list, int Minites = 30, int RandomSeconds = 0) + { + var cacheKey = GetCacheKey(); + MemoryCacheHelper.Set(cacheKey, list, Minites * 60 + RandomSeconds); + } + + /// <summary> + /// 鑾峰彇缂撳瓨 + /// </summary> + /// <returns></returns> + public static List<Model.CustomCronJob> Get() + { + var cacheKey = GetCacheKey(); + return MemoryCacheHelper.Get<List<Model.CustomCronJob>>(cacheKey); + } + + /// <summary> + /// 鑾峰彇璁剧疆缂撳瓨 + /// </summary> + public static List<Model.CustomCronJob> GetSet(Func<List<Model.CustomCronJob>> func, int Minites = 30, int RandomSeconds = 0) + { + var cacheKey = GetCacheKey(); + return MemoryCacheHelper.GetSet(cacheKey, func, Minites * 60 + RandomSeconds); + } + + /// <summary> + /// 绉婚櫎缂撳瓨 + /// </summary> + public static void Remove() + { + var cacheKey = GetCacheKey(); + MemoryCacheHelper.Remove(cacheKey); + } + + + } +} diff --git a/Service/IStation.Service4Job/custom/custom_real_job/CustomRealJob.cs b/Service/IStation.Service4Job/custom/custom_real_job/CustomRealJob.cs new file mode 100644 index 0000000..ca1de2e --- /dev/null +++ b/Service/IStation.Service4Job/custom/custom_real_job/CustomRealJob.cs @@ -0,0 +1,272 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using IStation.Untity; + +namespace IStation.Service +{ + /// <summary> + /// 鑷畾涔夊疄鏃朵换鍔� + /// </summary> + public partial class CustomRealJob + { + #region Cache + + //鑾峰彇缂撳瓨 + private List<Model.CustomRealJob> GetCache() + { + var all = CustomRealJobCacheHelper.GetSet(() => + { + var dal = new DAL.CustomRealJob(); + var entity_list = dal.GetAll(); + var model_list = Entity2Models(entity_list); + if (model_list == null) + { + model_list = new List<Model.CustomRealJob>(); + } + return model_list; + }, ConfigHelper.CacheKeepTime, ConfigHelper.CacheRandomTime); + return all; + } + + //閫氳繃 ID 鏇存柊缂撳瓨 + private void UpdateCache(long ID) + { + var dal = new DAL.CustomRealJob(); + var entity_ds = dal.GetByID(ID); + var model_ds = Entity2Model(entity_ds); + var all = GetCache(); + var model = all.Find(x => x.ID == ID); + if (model == null) + { + all.Add(model_ds); + } + else + { + model.Reset(model_ds); + } + } + + //閫氳繃 Ids 鏇存柊缂撳瓨 + private void UpdateCache(List<long> Ids) + { + if (Ids == null || Ids.Count() < 1) + return; + var dal = new DAL.CustomRealJob(); + var entity_list = dal.GetByIds(Ids); + var model_list = Entity2Models(entity_list); + var all = GetCache(); + all.RemoveAll(x => Ids.Contains(x.ID)); + if (model_list != null && model_list.Count > 0) + { + all.AddRange(model_list); + } + } + + //绉婚櫎缂撳瓨 + private void RemoveCache(long ID) + { + var all = GetCache(); + all.RemoveAll(x => x.ID == ID); + } + + #endregion + + #region Query + + /// <summary> + /// 鑾峰彇鎵�鏈� + /// </summary> + public List<Model.CustomRealJob> GetAll() + { + var all = GetCache(); + return all.OrderBy(x => x.CreateTime).ToList(); + } + + /// <summary> + /// 閫氳繃 ID 鑾峰彇 + /// </summary> + public Model.CustomRealJob GetByID(long ID) + { + var all = GetAll(); + return all.Find(x => x.ID == ID); + } + + /// <summary> + /// 閫氳繃 ID 鑾峰彇 + /// </summary> + public List<Model.CustomRealJob> GetByIds(List<long> Ids) + { + if (Ids == null || Ids.Count() < 1) + return default; + var all = GetAll(); + return all.Where(x => Ids.Contains(x.ID)).OrderBy(x => x.CreateTime).ToList(); + } + + + #endregion + + #region Insert + + /// <summary> + /// 娣诲姞涓�鏉� + /// </summary> + public long Insert(Model.CustomRealJob model) + { + if (model == null) + return default; + var entity = Model2Entity(model); + if (string.IsNullOrEmpty(entity.NO)) + { + entity.NO = CreateNO(); + } + var dal = new DAL.CustomRealJob(); + var id = dal.Insert(entity); + if (id > 0) + { + UpdateCache(id); + } + return id; + } + + /// <summary> + /// 鎵归噺鎻掑叆 + /// </summary> + public bool Inserts(List<Model.CustomRealJob> list) + { + if (list == null || list.Count() < 1) + return default; + var dal = new DAL.CustomRealJob(); + var entityList = Model2Entities(list); + entityList.ForEach(x => { + if (string.IsNullOrEmpty(x.NO)) + x.NO = CreateNO(); + }); + var ids = dal.InsertsR(entityList); + if (ids != null && ids.Count > 0) + { + UpdateCache(ids); + return true; + } + return false; + } + + #endregion + + #region Update + + /// <summary> + /// 鏇存柊涓�鏉� + /// </summary> + public bool Update(Model.CustomRealJob model) + { + if (model == null) + return default; + var entity = Model2Entity(model); + var dal = new DAL.CustomRealJob(); + var bol = dal.Update(entity); + if (bol) + { + UpdateCache(model.ID); + } + return bol; + } + + /// <summary> + /// 鎵归噺鏇存柊 + /// </summary> + public bool Updates(List<Model.CustomRealJob> list) + { + if (list == null || list.Count() < 1) + return default; + var entity_list = Model2Entities(list.ToList()); + var dal = new DAL.CustomRealJob(); + var bol = dal.Updates(entity_list); + if (bol) + { + UpdateCache(list.Select(x => x.ID).ToList()); + } + return bol; + } + + /// <summary> + /// 鏇存柊浣跨敤鐘舵�� + /// </summary> + public bool UpdateUseStatus(long ID, Model.eUseStatus UseStatus,long UpdateUserID,DateTime UpdateTime) + { + if (ID < 1) + return default; + var dal = new DAL.CustomRealJob(); + var bol = dal.UpdateUseStatus(ID, (int)UseStatus,UpdateUserID,UpdateTime); + if (bol) + { + UpdateCache(ID); + } + return bol; + } + + #endregion + + #region Exist + + /// <summary> + /// 鏍规嵁 ID 鍒ゆ柇鏄惁瀛樺湪 + /// </summary> + public bool IsExistByID(long ID) + { + var all = GetAll(); + return all.Exists(x => x.ID == ID); + } + + /// <summary> + /// 鍒ゆ柇Code鏄惁瀛樺湪 + /// </summary> + public bool IsExistNO(string NO) + { + if (string.IsNullOrEmpty(NO)) + return default; + var all = GetAll(); + if (all == null || all.Count < 1) + return default; + return all.Exists(x => !string.IsNullOrEmpty(x.NO) && x.NO.ToUpper() == NO.ToUpper()); + } + + /// <summary> + /// 鍒ゆ柇NO鏄惁瀛樺湪 ExceptID + /// </summary> + public bool IsExistNOExceptID(string NO, long ExceptID) + { + if (string.IsNullOrEmpty(NO)) + return default; + var all = GetAll(); + if (all == null || all.Count < 1) + return default; + return all.Exists(x => !string.IsNullOrEmpty(x.NO) && x.NO.ToUpper() == NO.ToUpper() && x.ID != ExceptID); + } + + #endregion + + #region Delete + + /// <summary> + /// 閫氳繃 ID 鍒犻櫎 + /// </summary> + public bool DeleteByID(long ID, out string Msg) + { + Msg = string.Empty; + var dal = new DAL.CustomRealJob(); + var bol = dal.DeleteByID(ID); + if (bol) + { + RemoveCache(ID); + } + return bol; + } + + #endregion + + } +} + diff --git a/Service/IStation.Service4Job/custom/custom_real_job/CustomRealJob_Instance.cs b/Service/IStation.Service4Job/custom/custom_real_job/CustomRealJob_Instance.cs new file mode 100644 index 0000000..071f136 --- /dev/null +++ b/Service/IStation.Service4Job/custom/custom_real_job/CustomRealJob_Instance.cs @@ -0,0 +1,61 @@ +锘縰sing AutoMapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation.Service +{ + public partial class CustomRealJob + { + //Entity to GetModel + private Model.CustomRealJob Entity2Model(Entity.CustomRealJob entity) + { + if (entity == null) + return default; + var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.CustomRealJob, Model.CustomRealJob>()).CreateMapper(); + var model = mapper.Map<Entity.CustomRealJob, Model.CustomRealJob>(entity); + return model; + } + + //Entities to GetModels + private List<Model.CustomRealJob> Entity2Models(List<Entity.CustomRealJob> entities) + { + if (entities == null || entities.Count() < 1) + return default; + var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Entity.CustomRealJob, Model.CustomRealJob>()).CreateMapper(); + var models = mapper.Map<List<Entity.CustomRealJob>, List<Model.CustomRealJob>>(entities); + return models; + } + + //Model to Entity + private Entity.CustomRealJob Model2Entity(Model.CustomRealJob model) + { + if (model == null) + return default; + var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.CustomRealJob, Entity.CustomRealJob>()).CreateMapper(); + var entity = mapper.Map<Model.CustomRealJob, Entity.CustomRealJob>(model); + return entity; + } + + //Models to Entities + private List<Entity.CustomRealJob> Model2Entities(List<Model.CustomRealJob> models) + { + if (models == null || models.Count < 1) + return default; + var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.CustomRealJob, Entity.CustomRealJob>()).CreateMapper(); + var entities = mapper.Map<List<Model.CustomRealJob>, List<Entity.CustomRealJob>>(models); + return entities; + } + + //Model to Entity + private void Model2Entity(Model.CustomRealJob model, Entity.CustomRealJob entity) + { + if (model == null || entity == null) + return; + var mapper = new MapperConfiguration(cfg => cfg.CreateMap<Model.CustomRealJob, Entity.CustomRealJob>()).CreateMapper(); + mapper.Map(model, entity); + } + } +} diff --git a/Service/IStation.Service4Job/custom/custom_real_job/CustomRealJob_NO.cs b/Service/IStation.Service4Job/custom/custom_real_job/CustomRealJob_NO.cs new file mode 100644 index 0000000..1c27ff7 --- /dev/null +++ b/Service/IStation.Service4Job/custom/custom_real_job/CustomRealJob_NO.cs @@ -0,0 +1,35 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation.Service +{ + public partial class CustomRealJob + { + /// <summary> + /// 鍒涘缓缂栧彿 + /// </summary> + private string CreateNO() + { + var all=GetAll(); + var noList = all.Select(x => x.NO).ToList(); + var number = noList.Count + 1; + var no = GetFormatNO(number); + while (noList.Contains(no)) + { + number++; + no = GetFormatNO(number); + } + return no; + } + + //鑾峰彇鏍煎紡鍖朜O + private string GetFormatNO(int number) + { + return $"CRJ-{number:000000}"; + } + + } +} diff --git a/Service/IStation.Service4Job/custom/custom_real_job/cache/CustomRealJobCacheHelper.cs b/Service/IStation.Service4Job/custom/custom_real_job/cache/CustomRealJobCacheHelper.cs new file mode 100644 index 0000000..86f2bb2 --- /dev/null +++ b/Service/IStation.Service4Job/custom/custom_real_job/cache/CustomRealJobCacheHelper.cs @@ -0,0 +1,63 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using IStation.Untity; + +namespace IStation.Service +{ + /// <summary> + /// CustomRealJob + /// 缂撳瓨杈呭姪绫� + /// </summary> + internal class CustomRealJobCacheHelper + { + private const string _contentKey = "CustomRealJobListKey"; + + private static string GetCacheKey() + { + var contentKey = string.Format("{0}", _contentKey); + return CacheHelper.GetCacheKey(contentKey); + } + + /// <summary> + /// 璁剧疆缂撳瓨 + /// </summary> + public static void Set(List<Model.CustomRealJob> list, int Minites = 30, int RandomSeconds = 0) + { + var cacheKey = GetCacheKey(); + MemoryCacheHelper.Set(cacheKey, list, Minites * 60 + RandomSeconds); + } + + /// <summary> + /// 鑾峰彇缂撳瓨 + /// </summary> + /// <returns></returns> + public static List<Model.CustomRealJob> Get() + { + var cacheKey = GetCacheKey(); + return MemoryCacheHelper.Get<List<Model.CustomRealJob>>(cacheKey); + } + + /// <summary> + /// 鑾峰彇璁剧疆缂撳瓨 + /// </summary> + public static List<Model.CustomRealJob> GetSet(Func<List<Model.CustomRealJob>> func, int Minites = 30, int RandomSeconds = 0) + { + var cacheKey = GetCacheKey(); + return MemoryCacheHelper.GetSet(cacheKey, func, Minites * 60 + RandomSeconds); + } + + /// <summary> + /// 绉婚櫎缂撳瓨 + /// </summary> + public static void Remove() + { + var cacheKey = GetCacheKey(); + MemoryCacheHelper.Remove(cacheKey); + } + + + } +} diff --git a/Service/IStation.Service4Job/helpers/CacheHelper.cs b/Service/IStation.Service4Job/helpers/CacheHelper.cs new file mode 100644 index 0000000..29ee6a8 --- /dev/null +++ b/Service/IStation.Service4Job/helpers/CacheHelper.cs @@ -0,0 +1,40 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation.Service +{ + /// <summary> + /// 缂撳瓨杈呭姪绫� + /// </summary> + internal class CacheHelper + { + private const string _cacheKeyPrefix = "*Default_Job_Prefix*";//缂撳瓨閿墠缂� + + /// <summary> + /// 鑾峰彇缂撳瓨閿� + /// </summary> + public static string GetCacheKey(string keyContent) + { + return string.Format("{0}_{1}", _cacheKeyPrefix, keyContent); + } + + /// <summary> + /// 娓呴櫎鍏ㄩ儴 + /// </summary> + public static void Clear() + { + MemoryCacheHelper.Remove((key) => + { + return key.StartsWith(_cacheKeyPrefix); + }); + } + + + + + + } +} diff --git a/Service/IStation.Service4Job/helpers/ConfigHelper.cs b/Service/IStation.Service4Job/helpers/ConfigHelper.cs new file mode 100644 index 0000000..269056b --- /dev/null +++ b/Service/IStation.Service4Job/helpers/ConfigHelper.cs @@ -0,0 +1,41 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using IStation.Untity; + +namespace IStation.Service +{ + /// <summary> + /// 閰嶇疆杈呭姪绫� + /// </summary> + internal class ConfigHelper + { + /// <summary> + /// 缂撳瓨淇濇寔鏃堕棿 锛堝垎閽燂級 + /// </summary> + public static int CacheKeepTime + { + get + { + return Settings.MemoryCache.KeepTime; + } + } + + /// <summary> + /// 缂撳瓨闅忔満鏃堕棿 锛堢锛� + /// </summary> + public static int CacheRandomTime + { + get + { + return RandomHelper.Random(0, Settings.MemoryCache.RandomTime); + } + } + + + + } +} diff --git a/Settings/IStation.Settings/models/Paras.cs b/Settings/IStation.Settings/models/Paras.cs index 16f53d2..b7fd9bc 100644 --- a/Settings/IStation.Settings/models/Paras.cs +++ b/Settings/IStation.Settings/models/Paras.cs @@ -100,6 +100,11 @@ public Paras_Repair Repair { get; set; } /// <summary> + /// 浠诲姟鍙傛暟 + /// </summary> + public Paras_Job Job { get; set; } + + /// <summary> /// 宸℃鍙傛暟 /// </summary> public Paras_Inspect Inspect { get; set; } diff --git a/Settings/IStation.Settings/models/job/Paras_Job.cs b/Settings/IStation.Settings/models/job/Paras_Job.cs new file mode 100644 index 0000000..3842856 --- /dev/null +++ b/Settings/IStation.Settings/models/job/Paras_Job.cs @@ -0,0 +1,19 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation +{ + /// <summary> + /// Job鍙傛暟 + /// </summary> + public class Paras_Job + { + /// <summary> + /// 鏁版嵁搴� + /// </summary> + public Paras_Job_DataBase DataBase { get; set; } + } +} diff --git a/Settings/IStation.Settings/models/job/Paras_Job_DataBase.cs b/Settings/IStation.Settings/models/job/Paras_Job_DataBase.cs new file mode 100644 index 0000000..6d8c09d --- /dev/null +++ b/Settings/IStation.Settings/models/job/Paras_Job_DataBase.cs @@ -0,0 +1,20 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IStation +{ + /// <summary> + /// 鏁版嵁搴� + /// </summary> + public class Paras_Job_DataBase + { + /// <summary> + /// 杩炴帴瀛楃涓� + /// </summary> + public string ConnectString { get; set; } + } + +} diff --git a/Settings/IStation.Settings/paras/Settings.cs b/Settings/IStation.Settings/paras/Settings.cs index d57436e..569af72 100644 --- a/Settings/IStation.Settings/paras/Settings.cs +++ b/Settings/IStation.Settings/paras/Settings.cs @@ -157,6 +157,14 @@ } /// <summary> + /// Job 鍙傛暟 + /// </summary> + public static Paras_Job Job + { + get { return SettingsHelper.Get().Job; } + } + + /// <summary> /// Inspect 鍙傛暟 /// </summary> public static Paras_Inspect Inspect diff --git a/Settings/IStation.Settings/paras_settings.json b/Settings/IStation.Settings/paras_settings.json index 2c1aa4e..b96c76c 100644 --- a/Settings/IStation.Settings/paras_settings.json +++ b/Settings/IStation.Settings/paras_settings.json @@ -160,6 +160,12 @@ } }, + "Job": { + "DataBase": { + "ConnectString": "PORT=5432;DATABASE=istation_job_test;HOST=101.133.223.111;PASSWORD=Eventech2010;USER ID=postgres;" + } + }, + "Inspect": { "DataBase": { "ConnectString": "PORT=5432;DATABASE=istation_inspect_test;HOST=101.133.223.111;PASSWORD=Eventech2010;USER ID=postgres;", -- Gitblit v1.9.3