Browse Source

添加JobItem是否禁用字段

master
wanggang 1 year ago
parent
commit
110750d5a3
  1. 39
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs
  2. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/JobItem.cs
  3. 4966
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727005325_vmi5.Designer.cs
  4. 24
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727005325_vmi5.cs
  5. 4
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

39
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Startup.cs

@ -20,7 +20,7 @@ public class Startup
{ {
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddSignalR(o => o.EnableDetailedErrors=true); services.AddSignalR(o => o.EnableDetailedErrors = true);
AppDomain.CurrentDomain.GetAssemblies().SelectMany(o => o.GetTypes()) AppDomain.CurrentDomain.GetAssemblies().SelectMany(o => o.GetTypes())
.Where(o => o.IsClass && !o.IsAbstract && o.IsAssignableTo(typeof(IJobService))) .Where(o => o.IsClass && !o.IsAbstract && o.IsAssignableTo(typeof(IJobService)))
.ForEach(o => services.AddTransient(o)); .ForEach(o => services.AddTransient(o));
@ -65,25 +65,28 @@ public class Startup
var jobItemRepository = db.Set<JobItem>(); var jobItemRepository = db.Set<JobItem>();
var jobLogRepository = db.Set<JobLog>(); var jobLogRepository = db.Set<JobLog>();
var jobItem = jobItemRepository.FirstOrDefault(o => o.Id == jobId); var jobItem = jobItemRepository.FirstOrDefault(o => o.Id == jobId);
jobItem.IsRunning = true; if (!jobItem.IsDisabled)
db.SaveChanges();
var jobLog = new JobLog { JobId = jobId, Start = DateTime.Now };
try
{ {
jobService.Invoke(); jobItem.IsRunning = true;
jobLog.Success = true;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
jobLog.Exception = ex.ToString();
}
finally
{
jobLog.End = DateTime.Now;
jobLogRepository.Add(jobLog);
jobItem.IsRunning = false;
db.SaveChanges(); db.SaveChanges();
var jobLog = new JobLog { JobId = jobId, Start = DateTime.Now };
try
{
jobService.Invoke();
jobLog.Success = true;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
jobLog.Exception = ex.ToString();
}
finally
{
jobLog.End = DateTime.Now;
jobLogRepository.Add(jobLog);
jobItem.IsRunning = false;
db.SaveChanges();
}
} }
}).Cron(job.Cron); }).Cron(job.Cron);
} }

1
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Vmi/JobItem.cs

@ -10,6 +10,7 @@ public class JobItem : Entity<Guid>, IHasConcurrencyStamp
this.Id = id; this.Id = id;
} }
public bool IsDisabled { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Cron { get; set; } public string Cron { get; set; }
public string Service { get; set; } public string Service { get; set; }

4966
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727005325_vmi5.Designer.cs

File diff suppressed because it is too large

24
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230727005325_vmi5.cs

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class vmi5 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "IsDisabled",
table: "Set_JobItem",
type: "bit",
nullable: false,
defaultValue: false);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "IsDisabled",
table: "Set_JobItem");
}
}
}

4
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

@ -3748,6 +3748,9 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasMaxLength(50) .HasMaxLength(50)
.HasColumnType("nvarchar(50)"); .HasColumnType("nvarchar(50)");
b.Property<bool>("IsDisabled")
.HasColumnType("bit");
b.Property<bool>("IsRunning") b.Property<bool>("IsRunning")
.HasColumnType("bit"); .HasColumnType("bit");
@ -3773,6 +3776,7 @@ namespace Win.Sfs.SettleAccount.Migrations
{ {
Id = new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"), Id = new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
Cron = "0 0 8 26 *", Cron = "0 0 8 26 *",
IsDisabled = false,
IsRunning = false, IsRunning = false,
Name = "库存快照", Name = "库存快照",
Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiService" Service = "Win.Sfs.SettleAccount.Entities.BQ.VmiService"

Loading…
Cancel
Save