master
wufan 4 months ago
commit f09a4a579e

@ -0,0 +1,13 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# Rider 忽略的文件
/.idea.Hangfire.Job.iml
/modules.xml
/projectSettingsUpdater.xml
/contentModel.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hangfire.Job", "Hangfire.Job\Hangfire.Job.csproj", "{C0A6E59A-E820-4008-A95B-483391FEDAA7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C0A6E59A-E820-4008-A95B-483391FEDAA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0A6E59A-E820-4008-A95B-483391FEDAA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0A6E59A-E820-4008-A95B-483391FEDAA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0A6E59A-E820-4008-A95B-483391FEDAA7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

@ -0,0 +1,10 @@
using Microsoft.AspNetCore.Mvc;
namespace Hangfire.Job.Controllers;
[ApiController]
[Route("[controller]")]
public class HangfireController : ControllerBase
{
}

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FaceIT.Hangfire.Tags.SqlServer" Version="1.9.2" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.3" />
<PackageReference Include="Hangfire.Core" Version="1.8.3" />
<PackageReference Include="Hangfire.HttpJob" Version="3.8.1" />
<PackageReference Include="Hangfire.SqlServer" Version="1.8.3" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
</ItemGroup>
</Project>

@ -0,0 +1,30 @@
using Hangfire;
using Hangfire.Console;
using Hangfire.HttpJob;
using Hangfire.Tags.SqlServer;
var builder = WebApplication.CreateBuilder(args);
var connectionString = builder.Configuration["ConnectionStrings:Default"];
builder.Services.AddHangfire(config => config
.UseSqlServerStorage(connectionString)
// .UseConsole(new ConsoleOptions()
// {
// BackgroundColor = "#000079"
// })
// .UseTagsWithSql()
.UseHangfireHttpJob()
);
builder.Services.AddHangfireServer();
var app = builder.Build();
app.UseHangfireDashboard();
// app.UseHangfireServer();
app.MapGet("/", () => "Hangfire service is running!");
app.Run();

@ -0,0 +1,31 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:1930",
"sslPort": 44394
}
},
"profiles": {
"Hangfire.Job": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "hangfire",
"applicationUrl": "http://localhost:8093",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

@ -0,0 +1,20 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Hangfire": "Information"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"Default": "server=192.168.1.248;database=HangfireDB;uid=sa;pwd=123;TrustServerCertificate=True;"
},
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://0.0.0.0:8093"
}
}
}
}
Loading…
Cancel
Save