初始化
This commit is contained in:
86
Face.SystemTask/Face.SystemTask.csproj
Normal file
86
Face.SystemTask/Face.SystemTask.csproj
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{5CEB682A-8023-4F08-B89D-7216B7BAAA03}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Face.SystemTask</RootNamespace>
|
||||
<AssemblyName>Face.SystemTask</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FluentScheduler, Version=5.5.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FluentScheduler.5.5.1\lib\netstandard2.0\FluentScheduler.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Text.Encodings.Web, Version=4.0.3.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encodings.Web.4.5.1\lib\netstandard2.0\System.Text.Encodings.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="TencentCloudCommon, Version=3.0.902.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\TencentCloudSDK.Common.3.0.902\lib\net45\TencentCloudCommon.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="TencentCloudSms, Version=3.0.902.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\TencentCloudSDK.Sms.3.0.902\lib\net45\TencentCloudSms.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="JobBase.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TimingPlan\TimingPlanJob.cs" />
|
||||
<Compile Include="TimingPlan\TimingPlanRegistry.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Face.Log4Net\Face.Log4Net.csproj">
|
||||
<Project>{5500f9dd-89d9-40f3-b62f-90c6b633d55a}</Project>
|
||||
<Name>Face.Log4Net</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Face.Services\Face.Services.csproj">
|
||||
<Project>{56438f1c-ba3a-4272-964e-c6739ae0b4ec}</Project>
|
||||
<Name>Face.Services</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
10
Face.SystemTask/Face.SystemTask.csproj.vspscc
Normal file
10
Face.SystemTask/Face.SystemTask.csproj.vspscc
Normal file
@@ -0,0 +1,10 @@
|
||||
""
|
||||
{
|
||||
"FILE_VERSION" = "9237"
|
||||
"ENLISTMENT_CHOICE" = "NEVER"
|
||||
"PROJECT_FILE_RELATIVE_PATH" = ""
|
||||
"NUMBER_OF_EXCLUDED_FILES" = "0"
|
||||
"ORIGINAL_PROJECT_FILE_PATH" = ""
|
||||
"NUMBER_OF_NESTED_PROJECTS" = "0"
|
||||
"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER"
|
||||
}
|
||||
95
Face.SystemTask/JobBase.cs
Normal file
95
Face.SystemTask/JobBase.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using FluentScheduler;
|
||||
using System.Web.Hosting;
|
||||
using Face.Log4Net;
|
||||
|
||||
namespace Face.SystemTask
|
||||
{
|
||||
#region PlanJobBase 对IIS回收做处理
|
||||
internal abstract class JobBase : IJob, IRegisteredObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 锁
|
||||
/// </summary>
|
||||
private readonly object _lock = new object();
|
||||
/// <summary>
|
||||
/// 是否已经在回收中
|
||||
/// </summary>
|
||||
private bool _shuttingDown;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化注册
|
||||
/// </summary>
|
||||
public JobBase()
|
||||
{
|
||||
HostingEnvironment.RegisterObject(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写执行代码方法继承
|
||||
/// </summary>
|
||||
public abstract void Plan();
|
||||
|
||||
/// <summary>
|
||||
/// 重写执行
|
||||
/// </summary>
|
||||
public void Execute()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_shuttingDown)
|
||||
return;
|
||||
Plan();//执行任务
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
HostingEnvironment.UnregisterObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写执行代码方法继承 带参数
|
||||
/// </summary>
|
||||
public virtual void Plan(params object[] obj) { }
|
||||
|
||||
/// <summary>
|
||||
/// 重写执行 带参数
|
||||
/// </summary>
|
||||
public void Execute(params object[] obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_shuttingDown)
|
||||
return;
|
||||
Plan(obj);//执行任务
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
HostingEnvironment.UnregisterObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回收调用
|
||||
/// </summary>
|
||||
/// <param name="immediate"></param>
|
||||
public void Stop(bool immediate)
|
||||
{
|
||||
JobManager.RemoveAllJobs();//移除所有定时计划,防止秒级定时计划堆叠执行
|
||||
Log4NetHelper.Log("调用stop:" + DateTime.Now);
|
||||
lock (_lock)
|
||||
{
|
||||
Log4NetHelper.Log("lock结束:" + DateTime.Now);
|
||||
_shuttingDown = true;
|
||||
}
|
||||
HostingEnvironment.UnregisterObject(this);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
36
Face.SystemTask/Properties/AssemblyInfo.cs
Normal file
36
Face.SystemTask/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("Face.SystemTask")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Face.SystemTask")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("5ceb682a-8023-4f08-b89d-7216b7baaa03")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
100
Face.SystemTask/TimingPlan/TimingPlanJob.cs
Normal file
100
Face.SystemTask/TimingPlan/TimingPlanJob.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using Face.Services.Manager;
|
||||
using Face.Services.Tool;
|
||||
using FaceMachines.Services;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Face.SystemTask
|
||||
{
|
||||
//定时作业计划管理
|
||||
internal class TimingPlanJob
|
||||
{
|
||||
#region 作业计划
|
||||
|
||||
#region PlanJob1
|
||||
public class PlanJob1 : JobBase
|
||||
{
|
||||
public override void Plan()
|
||||
{
|
||||
DateTime starttime = DateTime.Now;
|
||||
string ExecProcess = "plan1";
|
||||
|
||||
Trace.WriteLine("1");
|
||||
TimingPlanList.Plan1();
|
||||
|
||||
string msg = "成功执行作业计划“" + ExecProcess + "”,时间在" + DateTime.Now.ToString() + ",用时:" + DateTimeDiff.DateDiff(starttime, DateTime.Now, "ms") + "毫秒";
|
||||
//Logs.WriteTimingPlanLog(msg);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 自定义作业计划
|
||||
|
||||
#region CustomPlanJob1
|
||||
public class CustomPlanJob1 : JobBase
|
||||
{
|
||||
public override void Plan()
|
||||
{
|
||||
//Trace.WriteLine("11");
|
||||
TimingPlanList.CustomPlan1();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 定时作业计划列表
|
||||
/// </summary>
|
||||
public static class TimingPlanList
|
||||
{
|
||||
#region 作业计划方法
|
||||
|
||||
/// <summary>
|
||||
/// 作业计划方法1
|
||||
/// </summary>
|
||||
public static void Plan1()
|
||||
{
|
||||
//业务逻辑
|
||||
try
|
||||
{
|
||||
//Plan1
|
||||
//Logs.WriteTimingPlanLog("自定义作业计划1Plan1");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Logs.WriteErrorTimingPlanLog("Plan1)", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 自定义作业计划方法
|
||||
/// <summary>
|
||||
/// 自定义作业计划方法1
|
||||
/// </summary>
|
||||
public static void CustomPlan1()
|
||||
{
|
||||
//业务逻辑
|
||||
try
|
||||
{
|
||||
UDPHelp.StartReceive();
|
||||
//ChartsDatas.UpdateSetCacheOfDBList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Logs.WriteErrorTimingPlanLog("自定义作业计划1任务1", ex);
|
||||
}
|
||||
|
||||
string msg = "成功执行自定义作业计划1";
|
||||
//Logs.WriteTimingPlanLog(msg);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
36
Face.SystemTask/TimingPlan/TimingPlanRegistry.cs
Normal file
36
Face.SystemTask/TimingPlan/TimingPlanRegistry.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using FluentScheduler;
|
||||
namespace Face.SystemTask
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时作业计划注册管理
|
||||
/// </summary>
|
||||
public class TimingPlanRegistry : Registry
|
||||
{
|
||||
/// <summary>
|
||||
/// 定时作业计划注册 自定义
|
||||
/// </summary>
|
||||
public TimingPlanRegistry()
|
||||
{
|
||||
//NonReentrant防止并发,ToRunNow指定并立即执行后重复执行,ToRunEvery指定后重复执行,ToRunOnceIn指定后执行一次,
|
||||
|
||||
//Schedule<TimingPlanJob.PlanJob1>().WithName(Enum.TimingPlan.Plan1.ToString()).NonReentrant().ToRunEvery(30).Seconds();
|
||||
|
||||
//Schedule<TimingPlanJob.PlanJob2>().WithName(Enum.TimingPlan.Plan2.ToString()).NonReentrant().ToRunEvery(1).Minutes();
|
||||
|
||||
//Schedule<TimingPlanJob.PlanJob3>().WithName(Enum.TimingPlan.Plan3.ToString()).NonReentrant().ToRunEvery(1).Days().At(14, 25);
|
||||
|
||||
//Schedule<TimingPlanJob.PlanJob4>().WithName(Enum.TimingPlan.Plan4.ToString()).NonReentrant().ToRunEvery(1).Weekdays().At(14, 25);
|
||||
|
||||
//Schedule<TimingPlanJob.PlanJob4>().WithName(Enum.TimingPlan.Plan5.ToString()).NonReentrant().ToRunEvery(1).Months().On(16).At(14, 23);
|
||||
|
||||
//一分钟执行一次
|
||||
Schedule<TimingPlanJob.CustomPlanJob1>().WithName("CustomTimingPlan1").NonReentrant().ToRunEvery(1).Minutes();
|
||||
|
||||
//60秒
|
||||
//Schedule<TimingPlanJob.CustomPlanJob2>().WithName("CustomTimingPlan2").NonReentrant().ToRunEvery(60).Seconds();
|
||||
|
||||
//一分钟
|
||||
//Schedule<TimingPlanJob.CustomPlanJob3>().WithName("CustomTimingPlan3").NonReentrant().ToRunEvery(1).Minutes();
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Face.SystemTask/app.config
Normal file
19
Face.SystemTask/app.config
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.9.12.0" newVersion="6.9.12.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7" /></startup></configuration>
|
||||
8
Face.SystemTask/packages.config
Normal file
8
Face.SystemTask/packages.config
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="FluentScheduler" version="5.5.1" targetFramework="net461" />
|
||||
<package id="Newtonsoft.Json" version="13.0.2" targetFramework="net47" />
|
||||
<package id="System.Text.Encodings.Web" version="4.5.1" targetFramework="net47" />
|
||||
<package id="TencentCloudSDK.Common" version="3.0.902" targetFramework="net47" />
|
||||
<package id="TencentCloudSDK.Sms" version="3.0.902" targetFramework="net47" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user