diff --git a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs index 10a1d73..e97cdde 100644 --- a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs +++ b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs @@ -176,7 +176,7 @@ namespace SolarPower.Quartz.Jobs var personal = await operationRepository.GetOperationPersonnel(a.PowerStationId); var Title = $@"電站:{a.PowerStationName} - {WorkType}單 - 編號:{a.PlanId}"; var content = $@" {noticeName} {Environment.NewLine} 內容描述:{a.Description}"; - await operationRepository.InsertNoticeSchedule(personal, Title, content); + await operationRepository.InsertNoticeSchedule(personal, Title, content, 3); var OperationPlans = new OperationCreatePlan() { diff --git a/SolarPower/Repository/Implement/OperationRepository.cs b/SolarPower/Repository/Implement/OperationRepository.cs index 6ade5ac..2f1a88c 100644 --- a/SolarPower/Repository/Implement/OperationRepository.cs +++ b/SolarPower/Repository/Implement/OperationRepository.cs @@ -636,7 +636,7 @@ namespace SolarPower.Repository.Implement } } - public async Task InsertNoticeSchedule(List personal, string Title, string content) + public async Task InsertNoticeSchedule(List personal, string Title, string content, int emailType) { using (IDbConnection conn = this._databaseHelper.GetConnection()) { @@ -648,7 +648,7 @@ namespace SolarPower.Repository.Implement List value = new List(); foreach (MyUser a in personal) { - value.Add($@"(1,'{a.Name}','{a.Email}','{Title}','{content}',{a.Id},3)"); + value.Add($@"(1,'{a.Name}','{a.Email}','{Title}','{content}',{a.Id}, {emailType})"); } string values = string.Join(",", value.ToArray()); @@ -776,5 +776,26 @@ namespace SolarPower.Repository.Implement } } + public async Task> GetAllOperations() + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = @$"SELECT DISTINCT us.* + FROM power_station_operation_personnel ps + LEFT JOIN user us ON ps.UserId = us.Id + WHERE ps.Deleted = 0 AND us.Deleted = 0"; + result = (await conn.QueryAsync(sql)).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } + } } diff --git a/SolarPower/Repository/Interface/IOperationRepository.cs b/SolarPower/Repository/Interface/IOperationRepository.cs index 9630b39..3c1d8e0 100644 --- a/SolarPower/Repository/Interface/IOperationRepository.cs +++ b/SolarPower/Repository/Interface/IOperationRepository.cs @@ -74,7 +74,7 @@ namespace SolarPower.Repository.Interface Task> GetOperationPersonnel(int PowerStationId); - Task InsertNoticeSchedule(List personal, string Title, string content); + Task InsertNoticeSchedule(List personal, string Title, string content, int emailType); Task AddOperationRecordPersonnelAsync(List entity, List properties); @@ -83,6 +83,12 @@ namespace SolarPower.Repository.Interface Task DeleteOperationRecordPersonnel(List operationRecordPersonnels); Task DeleteRecord(List operations); + + /// + /// 取所有維運人員 + /// + /// + Task> GetAllOperations(); } }