add job log when re-opening

This commit is contained in:
Gary Sharp
2023-11-03 15:50:01 +11:00
parent b6945d9bbd
commit 3ec2ea7d37
4 changed files with 23 additions and 11 deletions
+2
View File
@@ -54,6 +54,8 @@ namespace Disco.Services.Interop
return "video/x-ms-wmv";
case "mov":
return "video/quicktime";
case "js":
return "application/javascript";
}
// Check System Registry
+15 -2
View File
@@ -661,7 +661,9 @@ namespace Disco.Services
JobId = j.Id,
TechUserId = Technician.UserId,
Timestamp = DateTime.Now,
Comments = string.Format("# Job Forcibly Closed\r\n{0}", string.IsNullOrWhiteSpace(Reason) ? "<no reason provided>" : Reason)
Comments = $@"## Job Forcibly Closed
{(string.IsNullOrWhiteSpace(Reason) ? "<no reason provided>" : Reason)}"
};
Database.JobLogs.Add(jobLog);
@@ -700,11 +702,22 @@ namespace Disco.Services
return j.ClosedDate.HasValue;
}
public static void OnReopen(this Job j)
public static void OnReopen(this Job j, DiscoDataContext database, User technician)
{
if (!j.CanReopen())
throw new InvalidOperationException("Reopen was Denied");
var log = new JobLog()
{
JobId = j.Id,
TechUserId = technician.UserId,
Timestamp = DateTime.Now,
Comments = $@"## Job Re-Opened
Previously Closed by {j.ClosedTechUser.DisplayName} [`@{j.ClosedTechUser.FriendlyId()}`] at `{j.ClosedDate:yyyy-MM-dd HH:mm}`.",
};
database.JobLogs.Add(log);
j.ClosedDate = null;
j.ClosedTechUserId = null;
}