Pdf Import Rewrite

Pdf Import rewritten to greatly improve QR Code detection, reduce
reliance on iTextSharp and improve thumbnails. Fixes #50
This commit is contained in:
Gary Sharp
2016-08-26 09:46:35 +10:00
parent 44f6d325db
commit 5ea9a814d6
98 changed files with 3168 additions and 3202 deletions
@@ -0,0 +1,9 @@
namespace Disco.Models.Repository
{
public enum AttachmentTypes
{
Device,
Job,
User
}
}
@@ -0,0 +1,24 @@
using System;
namespace Disco.Models.Repository
{
public interface IAttachment
{
int Id { get; set; }
object Reference { get; }
string TechUserId { get; set; }
string Filename { get; set; }
string MimeType { get; set; }
DateTime Timestamp { get; set; }
string Comments { get; set; }
string DocumentTemplateId { get; set; }
AttachmentTypes AttachmentType { get; }
}
}
@@ -0,0 +1,9 @@
namespace Disco.Models.Repository
{
public interface IAttachmentTarget
{
string AttachmentReferenceId { get; }
AttachmentTypes HasAttachmentType { get; }
}
}
+11 -5
View File
@@ -7,9 +7,9 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Disco.Models.Repository
{
public class Device
public class Device : IAttachmentTarget
{
[Required(ErrorMessage="The Serial Number is Required"), Key, StringLength(60)]
[Required(ErrorMessage = "The Serial Number is Required"), Key, StringLength(60)]
public string SerialNumber { get; set; }
[StringLength(40)]
@@ -18,7 +18,7 @@ namespace Disco.Models.Repository
public string Location { get; set; }
public int? DeviceModelId { get; set; }
[Range(1, int.MaxValue, ErrorMessage="A valid Device Profile is Required")]
[Range(1, int.MaxValue, ErrorMessage = "A valid Device Profile is Required")]
public int DeviceProfileId { get; set; }
public int? DeviceBatchId { get; set; }
@@ -26,7 +26,7 @@ namespace Disco.Models.Repository
public string DeviceDomainId { get; set; }
public string AssignedUserId { get; set; }
public DateTime? LastNetworkLogonDate { get; set; }
public bool AllowUnauthenticatedEnrol { get; set; }
public DateTime CreatedDate { get; set; }
@@ -48,7 +48,7 @@ namespace Disco.Models.Repository
public virtual IList<DeviceDetail> DeviceDetails { get; set; }
public virtual IList<DeviceAttachment> DeviceAttachments { get; set; }
public virtual IList<DeviceCertificate> DeviceCertificates { get; set; }
[InverseProperty("DeviceSerialNumber")]
public virtual IList<Job> Jobs { get; set; }
@@ -85,5 +85,11 @@ namespace Disco.Models.Repository
return index < 0 ? null : DeviceDomainId.Substring(0, index);
}
}
[NotMapped]
public string AttachmentReferenceId { get { return SerialNumber; } }
[NotMapped]
public AttachmentTypes HasAttachmentType { get { return AttachmentTypes.Device; } }
}
}
@@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Disco.Models.Repository
{
public class DeviceAttachment
public class DeviceAttachment : IAttachment
{
[Key]
public int Id { get; set; }
@@ -24,6 +21,12 @@ namespace Disco.Models.Repository
public string DocumentTemplateId { get; set; }
[NotMapped]
public object Reference { get { return DeviceSerialNumber; } }
[NotMapped]
public AttachmentTypes AttachmentType { get { return AttachmentTypes.Device; } }
[InverseProperty("DeviceAttachments"), ForeignKey("DeviceSerialNumber")]
public virtual Device Device { get; set; }
@@ -32,6 +35,5 @@ namespace Disco.Models.Repository
[ForeignKey("DocumentTemplateId")]
public virtual DocumentTemplate DocumentTemplate { get; set; }
}
}
@@ -35,6 +35,25 @@ namespace Disco.Models.Repository
[InverseProperty("DocumentTemplates")]
public virtual IList<JobSubType> JobSubTypes { get; set; }
[NotMapped]
public AttachmentTypes AttachmentType
{
get
{
switch (Scope)
{
case DocumentTemplateScopes.Device:
return AttachmentTypes.Device;
case DocumentTemplateScopes.Job:
return AttachmentTypes.Job;
case DocumentTemplateScopes.User:
return AttachmentTypes.User;
default:
throw new ArgumentException("Unexpected Document Scope");
}
}
}
public static class DocumentTemplateScopes
{
public const string Device = "Device";
+12 -1
View File
@@ -7,7 +7,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Disco.Models.Repository
{
public class Job
public class Job : IAttachmentTarget
{
[Key]
public int Id { get; set; }
@@ -75,6 +75,12 @@ namespace Disco.Models.Repository
public virtual JobMetaWarranty JobMetaWarranty { get; set; }
public virtual JobMetaNonWarranty JobMetaNonWarranty { get; set; }
[NotMapped]
public string AttachmentReferenceId { get { return Id.ToString(); } }
[NotMapped]
public AttachmentTypes HasAttachmentType { get { return AttachmentTypes.Job; } }
#region Helper Members
public decimal JobComponentsTotalCost()
{
@@ -86,6 +92,11 @@ namespace Disco.Models.Repository
}
#endregion
public override string ToString()
{
return $"Job #{Id}";
}
public static class JobStatusIds
{
public const string AwaitingAccountingPayment = "AwaitingAccountingPayment";
+7 -4
View File
@@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Disco.Models.Repository
{
public class JobAttachment
public class JobAttachment : IAttachment
{
[Key]
public int Id { get; set; }
@@ -25,6 +22,12 @@ namespace Disco.Models.Repository
public string DocumentTemplateId { get; set; }
[NotMapped]
public object Reference { get { return JobId; } }
[NotMapped]
public AttachmentTypes AttachmentType { get { return AttachmentTypes.Job; } }
[ForeignKey("JobId"), InverseProperty("JobAttachments")]
public virtual Job Job { get; set; }
+7 -1
View File
@@ -7,7 +7,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Disco.Models.Repository
{
public class User
public class User : IAttachmentTarget
{
[StringLength(50), Key, Column("Id")]
public string UserId { get; set; }
@@ -60,6 +60,12 @@ namespace Disco.Models.Repository
}
}
[NotMapped]
public string AttachmentReferenceId { get { return UserId; } }
[NotMapped]
public AttachmentTypes HasAttachmentType { get { return AttachmentTypes.User; } }
public override string ToString()
{
return string.Format("{0} ({1})", this.DisplayName, this.UserId);
@@ -1,13 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Disco.Models.Repository
{
public class UserAttachment
public class UserAttachment : IAttachment
{
[Key]
public int Id { get; set; }
@@ -24,6 +21,12 @@ namespace Disco.Models.Repository
public string DocumentTemplateId { get; set; }
[NotMapped]
public object Reference { get { return UserId; } }
[NotMapped]
public AttachmentTypes AttachmentType { get { return AttachmentTypes.User; } }
[ForeignKey("UserId"), InverseProperty("UserAttachments")]
public virtual User User { get; set; }