初始化
This commit is contained in:
14
Face.RegularDeleteLogs/Face.RegularDeleteLogs.csproj
Normal file
14
Face.RegularDeleteLogs/Face.RegularDeleteLogs.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SqlSugarCore" Version="5.1.4.197" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<_LastSelectedProfileId>E:\Project\Faces\Face.RegularDeleteLogs\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
30
Face.RegularDeleteLogs/Program.cs
Normal file
30
Face.RegularDeleteLogs/Program.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using SqlSugar;
|
||||
using System.Diagnostics;
|
||||
static SqlSugarClient GesmartDb()
|
||||
{
|
||||
SqlSugarClient Db = new(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = "Server=blv-cloud-db.mysql.rds.aliyuncs.com;Database=Face;Uid=blv_rcu;Pwd=fnadiaJDIJ7546;charset=utf8;port=3307;",
|
||||
DbType = SqlSugar.DbType.MySql,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true,
|
||||
});
|
||||
//用来打印Sql方便调式
|
||||
Db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value));
|
||||
Debug.WriteLine(sql);
|
||||
};
|
||||
return Db;
|
||||
}
|
||||
using (SqlSugarClient db = GesmartDb())
|
||||
{
|
||||
// 直接在SQL中使用日期函数,无需参数
|
||||
int rowsAffected = db.Ado.ExecuteCommand(
|
||||
"DELETE FROM pmslog WHERE Creationtime < DATE_SUB(CURDATE(), INTERVAL 45 DAY);"+
|
||||
"DELETE FROM pmsinterface WHERE DateTime < DATE_SUB(CURDATE(), INTERVAL 45 DAY);" +
|
||||
"DELETE FROM devicestatushistory WHERE CreateTime < DATE_SUB(CURDATE(), INTERVAL 45 DAY);"
|
||||
);
|
||||
Console.WriteLine("已经执行" + rowsAffected);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>bin\Release\net8.0\publish\win-x64\</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PublishReadyToRun>false</PublishReadyToRun>
|
||||
<PublishTrimmed>false</PublishTrimmed>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<History>True|2025-07-02T06:39:50.7034332Z||;True|2025-07-02T14:34:39.4894638+08:00||;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user