1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- using Dapper;
- using EVCB_OCPP.Domain;
- using EVCB_OCPP.TaskScheduler.Helper;
- using Microsoft.Data.SqlClient;
- using Microsoft.Extensions.Logging;
- using Quartz;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace EVCB_OCPP.TaskScheduler.Jobs
- {
- [DisallowConcurrentExecution]
- public class DeleteServerMessageJob : IJob
- {
- public DeleteServerMessageJob(ILogger<DeleteServerMessageJob> logger, SqlConnectionFactory<MainDBContext> mainDBConnectionFactory)
- {
- this.logger = logger;
- this.mainDBConnectionFactory = mainDBConnectionFactory;
- }
- private readonly ILogger<DeleteServerMessageJob> logger;
- private readonly SqlConnectionFactory<MainDBContext> mainDBConnectionFactory;
- public async Task Execute(IJobExecutionContext context)
- {
- logger.LogDebug(this.ToString() + " :Start........");
- int counter = 0;
- while (counter < 5)
- {
- counter++;
- using (var dbConn = await mainDBConnectionFactory.CreateAsync())
- {
- dbConn.Open();
- string sqlstring = "Delete Top(10000) from ServerMessage";
- await dbConn.ExecuteAsync(sqlstring);
- }
- }
- logger.LogDebug(this.ToString() + " :Finished........");
- }
- }
- }
|