修改swagger首页
This commit is contained in:
19
taskschedule/Tnb.TaskScheduler.Entitys/Entity/SnowId.cs
Normal file
19
taskschedule/Tnb.TaskScheduler.Entitys/Entity/SnowId.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using JNPF.Common.Const;
|
||||
using JNPF.Common.Contracts;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JNPF.TaskScheduler.Entitys.Entity;
|
||||
|
||||
/// <summary>
|
||||
/// 定时任务
|
||||
/// 版 本:V3.2
|
||||
/// 版 权:拓通智联科技有限公司(http://www.tuotong-tech.com)
|
||||
/// 日 期:2021-06-01 .
|
||||
/// </summary>
|
||||
[SugarTable("snowid")]
|
||||
[Tenant(ClaimConst.TENANTID)]
|
||||
public class SnowIdEntity : IEntity<string>
|
||||
{
|
||||
//[SugarColumn(ColumnName = "id")]
|
||||
public string Id { get; set; }
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.TaskScheduler.Entitys.Entity;
|
||||
using SqlSugar;
|
||||
|
||||
namespace JNPF.TaskScheduler.Listener;
|
||||
@@ -9,42 +12,55 @@ namespace JNPF.TaskScheduler.Listener;
|
||||
/// </summary>
|
||||
public class SpareTimeDemo : ISpareTimeWorker
|
||||
{
|
||||
/// <summary>
|
||||
/// 3秒后出勤统计.
|
||||
/// </summary>
|
||||
/// <param name="timer">参数</param>
|
||||
/// <param name="count">次数</param>
|
||||
[SpareTime("* * * * * ?", "执行Sql", ExecuteType = SpareTimeExecuteTypes.Serial)]
|
||||
public void ExecSql(SpareTimer timer, long count)
|
||||
/// <summary>
|
||||
/// 3秒后出勤统计.
|
||||
/// </summary>
|
||||
/// <param name="timer">参数</param>
|
||||
/// <param name="count">次数</param>
|
||||
[SpareTime("* * * * * ?", "生成雪花Id", ExecuteType = SpareTimeExecuteTypes.Serial)]
|
||||
public void GenerateSnowId(SpareTimer timer, long count)
|
||||
{
|
||||
// 创建作用域
|
||||
Scoped.Create((factory, scope) =>
|
||||
{
|
||||
// 创建作用域
|
||||
Scoped.Create((factory, scope) =>
|
||||
try
|
||||
{
|
||||
// 数据库操作
|
||||
var sqlSugarRepository = App.GetService<ISqlSugarRepository<SnowIdEntity>>(scope.ServiceProvider);
|
||||
List<SnowIdEntity> ls = new List<SnowIdEntity>();
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
// 数据库操作
|
||||
var sqlSugarRepository = App.GetService<ISqlSugarRepository<UserEntity>>(scope.ServiceProvider);
|
||||
sqlSugarRepository.DeleteById("226890444955452677");
|
||||
});
|
||||
}
|
||||
ls.Add(new SnowIdEntity { Id = SnowflakeIdHelper.NextId() });
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
sqlSugarRepository.InsertRange(ls);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("GenerateSnowId错误:", ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 3秒后出勤统计.
|
||||
/// </summary>
|
||||
/// <param name="timer">参数</param>
|
||||
/// <param name="count">次数</param>
|
||||
[SpareTime("0 0/1 * * * ?", "执行Sql1", ExecuteType = SpareTimeExecuteTypes.Serial)]
|
||||
public void ExecSql1(SpareTimer timer, long count)
|
||||
/// <summary>
|
||||
/// 3秒后出勤统计.
|
||||
/// </summary>
|
||||
/// <param name="timer">参数</param>
|
||||
/// <param name="count">次数</param>
|
||||
[SpareTime("0 0/1 * * * ?", "执行Sql1", ExecuteType = SpareTimeExecuteTypes.Serial)]
|
||||
public void ExecSql1(SpareTimer timer, long count)
|
||||
{
|
||||
// 创建作用域
|
||||
Scoped.Create((factory, scope) =>
|
||||
{
|
||||
// 创建作用域
|
||||
Scoped.Create((factory, scope) =>
|
||||
{
|
||||
var start = DateTime.Now;
|
||||
Console.WriteLine(start.ToString("yyyy-MM-dd HH:mm:ss") + ":任务开始-----------");
|
||||
// 数据库操作
|
||||
var sqlSugarRepository = App.GetService<ISqlSugarRepository<UserEntity>>(scope.ServiceProvider);
|
||||
sqlSugarRepository.DeleteById("226890444955452677");
|
||||
var end = DateTime.Now;
|
||||
Console.WriteLine(end.ToString("yyyy-MM-dd HH:mm:ss") + ":任务结束-----------");
|
||||
Console.WriteLine($"SQL执行了:{count} 次,耗时:{(end - start).TotalMilliseconds}ms");
|
||||
});
|
||||
}
|
||||
var start = DateTime.Now;
|
||||
Console.WriteLine(start.ToString("yyyy-MM-dd HH:mm:ss") + ":任务开始-----------");
|
||||
// 数据库操作
|
||||
var sqlSugarRepository = App.GetService<ISqlSugarRepository<UserEntity>>(scope.ServiceProvider);
|
||||
sqlSugarRepository.DeleteById("226890444955452677");
|
||||
var end = DateTime.Now;
|
||||
Console.WriteLine(end.ToString("yyyy-MM-dd HH:mm:ss") + ":任务结束-----------");
|
||||
Console.WriteLine($"SQL执行了:{count} 次,耗时:{(end - start).TotalMilliseconds}ms");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user