add job log when re-opening
This commit is contained in:
@@ -268,8 +268,6 @@ namespace Disco.BI.Interop.Pdf
|
||||
var pageUniqueIdBytes = pageUniqueId.ToQRCodeBytes();
|
||||
|
||||
// Encode to QRCode byte array
|
||||
var pageUniqueIdWidth = (int)pdfFieldPosition.position.Width;
|
||||
var pageUniqueIdHeight = (int)pdfFieldPosition.position.Height;
|
||||
var pageUniqueIdEncoded = QRCodeBinaryEncoder.Encode(pageUniqueIdBytes, out var qrWidth, out var qrHeight);
|
||||
|
||||
// Encode byte array to Image
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.Services.Documents;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.Services.Job;
|
||||
using Disco.Models.Services.Jobs.JobLists;
|
||||
using Disco.Services;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Documents;
|
||||
using Disco.Services.Interop;
|
||||
using Disco.Services.Jobs.JobLists;
|
||||
using Disco.Services.Jobs.Statistics;
|
||||
using Disco.Services.Users;
|
||||
using Disco.Services.Web;
|
||||
using Disco.Web.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
@@ -1729,12 +1726,14 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
[DiscoAuthorize(Claims.Job.Actions.Reopen)]
|
||||
public virtual ActionResult Reopen(int id, bool redirect)
|
||||
{
|
||||
var j = Database.Jobs.Find(id);
|
||||
var j = Database.Jobs
|
||||
.Include(x => x.ClosedTechUser)
|
||||
.FirstOrDefault(x => x.Id == id);
|
||||
if (j != null)
|
||||
{
|
||||
if (j.CanReopen())
|
||||
{
|
||||
j.OnReopen();
|
||||
j.OnReopen(Database, CurrentUser);
|
||||
|
||||
Database.SaveChanges();
|
||||
if (redirect)
|
||||
|
||||
Reference in New Issue
Block a user