Compare commits

...

4 Commits

Author SHA1 Message Date
Developer 02
8de0d70e7b Merge branch 'master' of http://git.dd:3000/AppStd/EnvelopeGenerator 2024-04-04 08:58:25 +02:00
Developer 02
b43b1ef866 Implementierte individuelle Controller für alle Tabellen unter Verwendung der WebCore.API Bibliothek. 2024-04-04 08:58:03 +02:00
Developer 02
b8d4abb7b2 feat: Implementierung von Repositories, Services und DTOs für alle Entitäten
- Notwendige Repositories, Services und DTOs für jede Entität, die SQL-Tabellen entspricht, unter Verwendung der WebCore-Bibliothek erstellt.
- Mapping-Profile für effiziente Datentransformation definiert.
- Dependency Injections für Repositories und Services als scoped konfiguriert, um eine korrekte Lebenszyklusverwaltung zu gewährleisten.
2024-04-03 14:14:19 +02:00
Developer 02
b65766ce24 Alle Entitäten wurden mit Attributen erstellt und zu EFCore DBContex hinzugefügt. 2024-04-02 14:53:25 +02:00
92 changed files with 1652 additions and 301 deletions

View File

@@ -0,0 +1,11 @@
using DigitalData.Core.Contracts.Application;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Contracts
{
public interface IDocumentReceiverElementService : IBasicCRUDService<IDocumentReceiverElementRepository, DocumentReceiverElementDto, DocumentReceiverElement, int>
{
}
}

View File

@@ -0,0 +1,11 @@
using DigitalData.Core.Contracts.Application;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Contracts
{
public interface IDocumentStatusService : IBasicCRUDService<IDocumentStatusRepository, DocumentStatusDto, DocumentStatus, int>
{
}
}

View File

@@ -0,0 +1,11 @@
using DigitalData.Core.Contracts.Application;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Contracts
{
public interface IEmailTemplateService : IBasicCRUDService<IEmailTemplateRepository, EmailTemplateDto, EmailTemplate, int>
{
}
}

View File

@@ -0,0 +1,11 @@
using DigitalData.Core.Contracts.Application;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Contracts
{
public interface IEnvelopeCertificateService : IBasicCRUDService<IEnvelopeCertificateRepository, EnvelopeCertificateDto, EnvelopeCertificate, int>
{
}
}

View File

@@ -0,0 +1,11 @@
using DigitalData.Core.Contracts.Application;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Contracts
{
public interface IEnvelopeHistoryService : IBasicCRUDService<IEnvelopeHistoryRepository, EnvelopeHistoryDto, EnvelopeHistory, long>
{
}
}

View File

@@ -0,0 +1,11 @@
using DigitalData.Core.Contracts.Application;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Contracts
{
public interface IEnvelopeReceiverService : IBasicCRUDService<IEnvelopeReceiverRepository, EnvelopeReceiverDto, EnvelopeReceiver, int>
{
}
}

View File

@@ -0,0 +1,11 @@
using DigitalData.Core.Contracts.Application;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Contracts
{
public interface IEnvelopeService : IBasicCRUDService<IEnvelopeRepository, EnvelopeDto, Envelope, int>
{
}
}

View File

@@ -0,0 +1,11 @@
using DigitalData.Core.Contracts.Application;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Contracts
{
public interface IEnvelopeTypeService : IBasicCRUDService<IEnvelopeTypeRepository, EnvelopeTypeDto, EnvelopeType, int>
{
}
}

View File

@@ -0,0 +1,11 @@
using DigitalData.Core.Contracts.Application;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Contracts
{
public interface IReceiverService : IBasicCRUDService<IReceiverRepository, ReceiverDto, Receiver, int>
{
}
}

View File

@@ -0,0 +1,11 @@
using DigitalData.Core.Contracts.Application;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Contracts
{
public interface IUserReceiverService : IBasicCRUDService<IUserReceiverRepository, UserReceiverDto, UserReceiver, int>
{
}
}

View File

@@ -1,15 +1,12 @@
namespace EnvelopeGenerator.Application.DTOs
{
public record ConfigDto
{
public string DocumentPath { get; init; }
public int SendingProfile { get; init; }
public string SignatureHost { get; init; }
public string ExternalProgramName { get; init; }
public string ExportPath { get; init; }
public string DocumentPathDmz { get; init; }
public string ExportPathDmz { get; init; }
public string SignedMailPath { get; init; }
public string DocumentPathMoveAftsend { get; init; }
}
public record ConfigDto(
string DocumentPath,
int SendingProfile,
string SignatureHost,
string ExternalProgramName,
string ExportPath,
string DocumentPathDmz,
string ExportPathDmz,
string DocumentPathMoveAftsend);
}

View File

@@ -0,0 +1,21 @@
namespace EnvelopeGenerator.Application.DTOs
{
public record DocumentReceiverElementDto(
int Guid,
int DocumentId,
int ReceiverId,
int ElementType,
double PositionX,
double PositionY,
double Width,
double Height,
int Page,
bool Required,
string? Tooltip,
bool ReadOnly,
int AnnotationIndex,
DateTime AddedWhen,
DateTime? ChangedWhen,
EnvelopeDocumentDto? Document,
EnvelopeReceiverDto? Receiver);
}

View File

@@ -0,0 +1,12 @@
namespace EnvelopeGenerator.Application.DTOs
{
public record DocumentStatusDto(
int Guid,
int EnvelopeId,
int ReceiverId,
int Status,
DateTime? StatusChangedWhen,
string Value,
DateTime AddedWhen,
DateTime? ChangedWhen);
}

View File

@@ -0,0 +1,8 @@
namespace EnvelopeGenerator.Application.DTOs
{
public record EmailTemplateDto(
int Guid,
string Name,
string Body,
string Subject);
}

View File

@@ -0,0 +1,12 @@
namespace EnvelopeGenerator.Application.DTOs
{
public record EnvelopeCertificateDto(
int Guid,
int EnvelopeId,
string EnvelopeUuid,
string EnvelopeSubject,
int CreatorId,
string CreatorName,
string CreatorEmail,
int EnvelopeStatus);
}

View File

@@ -0,0 +1,27 @@
namespace EnvelopeGenerator.Application.DTOs
{
public record EnvelopeDto(
int Guid,
int UserId,
int Status,
string EnvelopeUuid,
string Message,
DateTime? ExpiresWhen,
DateTime? ExpiresWarningWhen,
DateTime AddedWhen,
DateTime? ChangedWhen,
string Title,
int? ContractType,
string Language,
bool? SendReminderEmails,
int? FirstReminderDays,
int? ReminderIntervalDays,
int? EnvelopeType,
int? CertificationType,
bool? UseAccessCode,
int? FinalEmailToCreator,
int? FinalEmailToReceivers,
int? ExpiresWhenDays,
int? ExpiresWarningWhenDays,
bool DmzMoved);
}

View File

@@ -0,0 +1,10 @@
namespace EnvelopeGenerator.Application.DTOs
{
public record EnvelopeHistoryDto(
long Guid,
int EnvelopeId,
string UserReference,
int Status,
DateTime AddedWhen,
DateTime? ActionDate);
}

View File

@@ -0,0 +1,14 @@
namespace EnvelopeGenerator.Application.DTOs
{
public record EnvelopeReceiverDto(
int EnvelopeId,
int ReceiverId,
int Sequence,
string Name,
string JobTitle,
string CompanyName,
string PrivateMessage,
string AccessCode,
DateTime AddedWhen,
DateTime? ChangedWhen);
}

View File

@@ -0,0 +1,19 @@
namespace EnvelopeGenerator.Application.DTOs
{
public record EnvelopeTypeDto(
int Guid,
string Title,
string Language,
int? ExpiresDays,
int? CertificationType,
bool? UseAccessCode,
int? FinalEmailToCreator,
int? FinalEmailToReceivers,
DateTime AddedWhen,
DateTime? ChangedWhen,
int? ExpiresWarningDays,
bool? SendReminderEmails,
int? FirstReminderDays,
int? ReminderIntervalDays,
int? ContractType);
}

View File

@@ -0,0 +1,8 @@
namespace EnvelopeGenerator.Application.DTOs
{
public record ReceiverDto(
int Guid,
string EmailAddress,
string Signature,
DateTime AddedWhen);
}

View File

@@ -0,0 +1,11 @@
namespace EnvelopeGenerator.Application.DTOs
{
public record UserReceiverDto(
int Guid,
int UserId,
int ReceiverId,
string Name,
string CompanyName,
string JobTitle,
DateTime AddedWhen);
}

View File

@@ -8,11 +8,33 @@ namespace EnvelopeGenerator.Application.MappingProfiles
{
public BasicDtoMappingProfile()
{
// Entity to DTO mappings
CreateMap<Config, ConfigDto>();
CreateMap<DocumentReceiverElement, DocumentReceiverElementDto>();
CreateMap<DocumentStatus, DocumentStatusDto>();
CreateMap<EmailTemplate, EmailTemplateDto>();
CreateMap<Envelope, EnvelopeDto>();
CreateMap<EnvelopeCertificate, EnvelopeCertificateDto>();
CreateMap<EnvelopeDocument, EnvelopeDocumentDto>();
CreateMap<EnvelopeHistory, EnvelopeHistoryDto>();
CreateMap<EnvelopeReceiver, EnvelopeReceiverDto>();
CreateMap<EnvelopeType, EnvelopeTypeDto>();
CreateMap<Receiver, ReceiverDto>();
CreateMap<UserReceiver, UserReceiverDto>();
// DTO to Entity mappings
CreateMap<ConfigDto, Config>();
CreateMap<DocumentReceiverElementDto, DocumentReceiverElement>();
CreateMap<DocumentStatusDto, DocumentStatus>();
CreateMap<EmailTemplateDto, EmailTemplate>();
CreateMap<EnvelopeDto, Envelope>();
CreateMap<EnvelopeCertificateDto, EnvelopeCertificate>();
CreateMap<EnvelopeDocumentDto, EnvelopeDocument>();
CreateMap<EnvelopeHistoryDto, EnvelopeHistory>();
CreateMap<EnvelopeReceiverDto, EnvelopeReceiver>();
CreateMap<EnvelopeTypeDto, EnvelopeType>();
CreateMap<ReceiverDto, Receiver>();
CreateMap<UserReceiverDto, UserReceiver>();
}
}
}
}

View File

@@ -0,0 +1,18 @@
using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.Contracts.CultureServices;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Services
{
public class DocumentReceiverElementService : BasicCRUDService<IDocumentReceiverElementRepository, DocumentReceiverElementDto, DocumentReceiverElement, int>, IDocumentReceiverElementService
{
public DocumentReceiverElementService(IDocumentReceiverElementRepository repository, IKeyTranslationService translationService, IMapper mapper)
: base(repository, translationService, mapper)
{
}
}
}

View File

@@ -0,0 +1,18 @@
using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.Contracts.CultureServices;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Services
{
public class DocumentStatusService : BasicCRUDService<IDocumentStatusRepository, DocumentStatusDto, DocumentStatus, int>, IDocumentStatusService
{
public DocumentStatusService(IDocumentStatusRepository repository, IKeyTranslationService translationService, IMapper mapper)
: base(repository, translationService, mapper)
{
}
}
}

View File

@@ -0,0 +1,18 @@
using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.Contracts.CultureServices;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Services
{
public class EmailTemplateService : BasicCRUDService<IEmailTemplateRepository, EmailTemplateDto, EmailTemplate, int>, IEmailTemplateService
{
public EmailTemplateService(IEmailTemplateRepository repository, IKeyTranslationService translationService, IMapper mapper)
: base(repository, translationService, mapper)
{
}
}
}

View File

@@ -0,0 +1,18 @@
using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.Contracts.CultureServices;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Services
{
public class EnvelopeCertificateService : BasicCRUDService<IEnvelopeCertificateRepository, EnvelopeCertificateDto, EnvelopeCertificate, int>, IEnvelopeCertificateService
{
public EnvelopeCertificateService(IEnvelopeCertificateRepository repository, IKeyTranslationService translationService, IMapper mapper)
: base(repository, translationService, mapper)
{
}
}
}

View File

@@ -0,0 +1,18 @@
using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.Contracts.CultureServices;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Services
{
public class EnvelopeHistoryService : BasicCRUDService<IEnvelopeHistoryRepository, EnvelopeHistoryDto, EnvelopeHistory, long>, IEnvelopeHistoryService
{
public EnvelopeHistoryService(IEnvelopeHistoryRepository repository, IKeyTranslationService translationService, IMapper mapper)
: base(repository, translationService, mapper)
{
}
}
}

View File

@@ -0,0 +1,18 @@
using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.Contracts.CultureServices;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Services
{
public class EnvelopeReceiverService : BasicCRUDService<IEnvelopeReceiverRepository, EnvelopeReceiverDto, EnvelopeReceiver, int>, IEnvelopeReceiverService
{
public EnvelopeReceiverService(IEnvelopeReceiverRepository repository, IKeyTranslationService translationService, IMapper mapper)
: base(repository, translationService, mapper)
{
}
}
}

View File

@@ -0,0 +1,18 @@
using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.Contracts.CultureServices;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Services
{
public class EnvelopeService : BasicCRUDService<IEnvelopeRepository, EnvelopeDto, Envelope, int>, IEnvelopeService
{
public EnvelopeService(IEnvelopeRepository repository, IKeyTranslationService translationService, IMapper mapper)
: base(repository, translationService, mapper)
{
}
}
}

View File

@@ -0,0 +1,18 @@
using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.Contracts.CultureServices;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Services
{
public class EnvelopeTypeService : BasicCRUDService<IEnvelopeTypeRepository, EnvelopeTypeDto, EnvelopeType, int>, IEnvelopeTypeService
{
public EnvelopeTypeService(IEnvelopeTypeRepository repository, IKeyTranslationService translationService, IMapper mapper)
: base(repository, translationService, mapper)
{
}
}
}

View File

@@ -0,0 +1,18 @@
using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.Contracts.CultureServices;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Services
{
public class ReceiverService : BasicCRUDService<IReceiverRepository, ReceiverDto, Receiver, int>, IReceiverService
{
public ReceiverService(IReceiverRepository repository, IKeyTranslationService translationService, IMapper mapper)
: base(repository, translationService, mapper)
{
}
}
}

View File

@@ -0,0 +1,18 @@
using AutoMapper;
using DigitalData.Core.Application;
using DigitalData.Core.Contracts.CultureServices;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Services
{
public class UserReceiverService : BasicCRUDService<IUserReceiverRepository, UserReceiverDto, UserReceiver, int>, IUserReceiverService
{
public UserReceiverService(IUserReceiverRepository repository, IKeyTranslationService translationService, IMapper mapper)
: base(repository, translationService, mapper)
{
}
}
}

View File

@@ -40,4 +40,4 @@ namespace EnvelopeGenerator.Domain.Entities
[DefaultValue("")] // This sets the default value for DOCUMENT_PATH_MOVE_AFTSEND
public string DocumentPathMoveAftsend { get; set; }
}
}
}

View File

@@ -0,0 +1,85 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBSIG_DOCUMENT_RECEIVER_ELEMENT", Schema = "dbo")]
public class DocumentReceiverElement
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public int Guid { get; set; }
[Required]
[Column("DOCUMENT_ID")]
public int DocumentId { get; set; }
[Required]
[Column("RECEIVER_ID")]
public int ReceiverId { get; set; }
[Required]
[Column("ELEMENT_TYPE")]
[DefaultValue(0)]
public int ElementType { get; set; }
[Required]
[Column("POSITION_X")]
[DefaultValue(0)]
public double PositionX { get; set; }
[Required]
[Column("POSITION_Y")]
[DefaultValue(0)]
public double PositionY { get; set; }
[Required]
[Column("WIDTH")]
[DefaultValue(0)]
public double Width { get; set; }
[Required]
[Column("HEIGHT")]
[DefaultValue(0)]
public double Height { get; set; }
[Required]
[Column("PAGE")]
[DefaultValue(1)]
public int Page { get; set; }
[Required]
[Column("REQUIRED")]
[DefaultValue(false)]
public bool Required { get; set; }
[Column("TOOLTIP")]
public string? Tooltip { get; set; }
[Required]
[Column("READ_ONLY")]
[DefaultValue(false)]
public bool ReadOnly { get; set; }
[Required]
[Column("ANNOTATION_INDEX")]
[DefaultValue(0)]
public int AnnotationIndex { get; set; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
[DefaultValue("GETDATE()")]
public DateTime AddedWhen { get; set; }
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime? ChangedWhen { get; set; }
[ForeignKey("DocumentId")]
public virtual EnvelopeDocument? Document { get; set; }
[ForeignKey("ReceiverId")]
public virtual Receiver? Receiver { get; set; }
}
}

View File

@@ -0,0 +1,45 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBSIG_DOCUMENT_STATUS", Schema = "dbo")]
public class DocumentStatus
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public int Guid { get; set; }
[Required]
[Column("ENVELOPE_ID")]
public int EnvelopeId { get; set; }
[Required]
[Column("RECEIVER_ID")]
public int ReceiverId { get; set; }
[Required]
[Column("STATUS")]
public int Status { get; set; }
[Column("STATUS_CHANGED_WHEN", TypeName = "datetime")]
public DateTime? StatusChangedWhen { get; set; }
[Column("VALUE", TypeName = "nvarchar(max)")]
public string Value { get; set; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime AddedWhen { get; set; }
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime? ChangedWhen { get; set; }
[ForeignKey("EnvelopeId")]
public virtual Envelope? Envelope { get; set; }
[ForeignKey("ReceiverId")]
public virtual Receiver? Receiver { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBSIG_EMAIL_TEMPLATE", Schema = "dbo")]
public class EmailTemplate
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public int Guid { get; set; }
[Column("NAME", TypeName = "nvarchar(64)")]
public string Name { get; set; }
[Column("BODY", TypeName = "nvarchar(max)")]
public string Body { get; set; }
[Column("SUBJECT", TypeName = "nvarchar(512)")]
public string Subject { get; set; }
}
}

View File

@@ -0,0 +1,86 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBSIG_ENVELOPE", Schema = "dbo")]
public class Envelope
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public int Guid { get; set; }
[Required]
[Column("USER_ID")]
public int UserId { get; set; }
[Required]
[Column("STATUS")]
public int Status { get; set; }
[Required]
[Column("ENVELOPE_UUID", TypeName = "nvarchar(36)")]
public string EnvelopeUuid { get; set; }
[Required]
[Column("MESSAGE", TypeName = "nvarchar(max)")]
public string Message { get; set; }
[Column("EXPIRES_WHEN", TypeName = "datetime")]
public DateTime? ExpiresWhen { get; set; }
[Column("EXPIRES_WARNING_WHEN", TypeName = "datetime")]
public DateTime? ExpiresWarningWhen { get; set; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime AddedWhen { get; set; }
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime? ChangedWhen { get; set; }
[Column("TITLE", TypeName = "nvarchar(128)")]
public string Title { get; set; }
[Column("CONTRACT_TYPE")]
public int? ContractType { get; set; }
[Column("LANGUAGE", TypeName = "nvarchar(5)")]
public string Language { get; set; }
[Column("SEND_REMINDER_EMAILS")]
public bool? SendReminderEmails { get; set; }
[Column("FIRST_REMINDER_DAYS")]
public int? FirstReminderDays { get; set; }
[Column("REMINDER_INTERVAL_DAYS")]
public int? ReminderIntervalDays { get; set; }
[Column("ENVELOPE_TYPE")]
public int? EnvelopeType { get; set; }
[Column("CERTIFICATION_TYPE")]
public int? CertificationType { get; set; }
[Column("USE_ACCESS_CODE")]
public bool? UseAccessCode { get; set; }
[Column("FINAL_EMAIL_TO_CREATOR")]
public int? FinalEmailToCreator { get; set; }
[Column("FINAL_EMAIL_TO_RECEIVERS")]
public int? FinalEmailToReceivers { get; set; }
[Column("EXPIRES_WHEN_DAYS")]
public int? ExpiresWhenDays { get; set; }
[Column("EXPIRES_WARNING_WHEN_DAYS")]
public int? ExpiresWarningWhenDays { get; set; }
[Required]
[Column("DMZ_MOVED")]
public bool DmzMoved { get; set; }
}
}

View File

@@ -0,0 +1,42 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBSIG_ENVELOPE_CERTIFICATE", Schema = "dbo")]
public class EnvelopeCertificate
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public int Guid { get; set; }
[Required]
[Column("ENVELOPE_ID")]
public int EnvelopeId { get; set; }
[Required]
[Column("ENVELOPE_UUID", TypeName = "nvarchar(36)")]
public string EnvelopeUuid { get; set; }
[Required]
[Column("ENVELOPE_SUBJECT", TypeName = "nvarchar(512)")]
public string EnvelopeSubject { get; set; }
[Required]
[Column("CREATOR_ID")]
public int CreatorId { get; set; }
[Required]
[Column("CREATOR_NAME", TypeName = "nvarchar(128)")]
public string CreatorName { get; set; }
[Required]
[Column("CREATOR_EMAIL", TypeName = "nvarchar(128)")]
public string CreatorEmail { get; set; }
[Required]
[Column("ENVELOPE_STATUS")]
public int EnvelopeStatus { get; set; }
}
}

View File

@@ -8,23 +8,23 @@ namespace EnvelopeGenerator.Domain.Entities
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID", TypeName = "int")]
[Column("GUID")]
public int Guid { get; set; }
[Column("ENVELOPE_ID", TypeName = "int")]
[Required]
[Column("ENVELOPE_ID")]
public int EnvelopeId { get; set; }
[Column("FILENAME", TypeName = "nvarchar(256)")]
[Required]
[Column("FILENAME", TypeName = "nvarchar(256)")]
public string Filename { get; set; }
[Column("FILEPATH", TypeName = "nvarchar(256)")]
[Required]
[Column("FILEPATH", TypeName = "nvarchar(256)")]
public string Filepath { get; set; }
[Column("ADDED_WHEN", TypeName = "datetime")]
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime AddedWhen { get; set; }
[Column("FILENAME_ORIGINAL", TypeName = "nvarchar(256)")]

View File

@@ -0,0 +1,33 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBSIG_ENVELOPE_HISTORY", Schema = "dbo")]
public class EnvelopeHistory
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public long Guid { get; set; }
[Required]
[Column("ENVELOPE_ID")]
public int EnvelopeId { get; set; }
[Required]
[Column("USER_REFERENCE", TypeName = "nvarchar(128)")]
public string UserReference { get; set; }
[Required]
[Column("STATUS")]
public int Status { get; set; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime AddedWhen { get; set; }
[Column("ACTION_DATE", TypeName = "datetime")]
public DateTime? ActionDate { get; set; }
}
}

View File

@@ -0,0 +1,42 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBSIG_ENVELOPE_RECEIVER", Schema = "dbo")]
public class EnvelopeReceiver
{
[Column("ENVELOPE_ID")]
public int EnvelopeId { get; set; }
[Column("RECEIVER_ID")]
public int ReceiverId { get; set; }
[Required]
[Column("SEQUENCE")]
public int Sequence { get; set; }
[Column("NAME", TypeName = "nvarchar(128)")]
public string Name { get; set; }
[Column("JOB_TITLE", TypeName = "nvarchar(128)")]
public string JobTitle { get; set; }
[Column("COMPANY_NAME", TypeName = "nvarchar(128)")]
public string CompanyName { get; set; }
[Column("PRIVATE_MESSAGE", TypeName = "nvarchar(max)")]
public string PrivateMessage { get; set; }
[Column("ACCESS_CODE", TypeName = "nvarchar(64)")]
public string AccessCode { get; set; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime AddedWhen { get; set; }
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime? ChangedWhen { get; set; }
}
}

View File

@@ -0,0 +1,60 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBSIG_ENVELOPE_TYPE", Schema = "dbo")]
public class EnvelopeType
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public int Guid { get; set; }
[Required]
[Column("TITLE", TypeName = "nvarchar(128)")]
public string Title { get; set; }
[Column("LANGUAGE", TypeName = "nvarchar(5)")]
public string Language { get; set; }
[Column("EXPIRES_DAYS")]
public int? ExpiresDays { get; set; }
[Column("CERTIFICATION_TYPE")]
public int? CertificationType { get; set; }
[Column("USE_ACCESS_CODE")]
public bool? UseAccessCode { get; set; }
[Column("FINAL_EMAIL_TO_CREATOR")]
public int? FinalEmailToCreator { get; set; }
[Column("FINAL_EMAIL_TO_RECEIVERS")]
public int? FinalEmailToReceivers { get; set; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime AddedWhen { get; set; }
[Column("CHANGED_WHEN", TypeName = "datetime")]
public DateTime? ChangedWhen { get; set; }
[Column("EXPIRES_WARNING_DAYS")]
public int? ExpiresWarningDays { get; set; }
[Column("SEND_REMINDER_EMAILS")]
public bool? SendReminderEmails { get; set; }
[Column("FIRST_REMINDER_DAYS")]
public int? FirstReminderDays { get; set; }
[Column("REMINDER_INTERVAL_DAYS")]
public int? ReminderIntervalDays { get; set; }
[Column("CONTRACT_TYPE")]
public int? ContractType { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBSIG_RECEIVER", Schema = "dbo")]
public class Receiver
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public int Guid { get; set; }
[Required]
[Column("EMAIL_ADDRESS", TypeName = "nvarchar(128)")]
public string EmailAddress { get; set; }
[Required]
[Column("SIGNATURE", TypeName = "nvarchar(64)")]
public string Signature { get; set; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime AddedWhen { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Domain.Entities
{
[Table("TBSIG_USER_RECEIVER", Schema = "dbo")]
public class UserReceiver
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Column("GUID")]
public int Guid { get; set; }
[Required]
[Column("USER_ID")]
public int UserId { get; set; }
[Required]
[Column("RECEIVER_ID")]
public int ReceiverId { get; set; }
[Required]
[Column("NAME", TypeName = "nvarchar(128)")]
public string Name { get; set; }
[Column("COMPANY_NAME", TypeName = "nvarchar(128)")]
public string CompanyName { get; set; }
[Column("JOB_TITLE", TypeName = "nvarchar(128)")]
public string JobTitle { get; set; }
[Required]
[Column("ADDED_WHEN", TypeName = "datetime")]
public DateTime AddedWhen { get; set; }
}
}

View File

@@ -1,5 +1,4 @@
using DigitalData.Core.Contracts.Application;
using DigitalData.Core.Contracts.Infrastructure;
using DigitalData.Core.Contracts.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Infrastructure.Contracts

View File

@@ -0,0 +1,9 @@
using DigitalData.Core.Contracts.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Infrastructure.Contracts
{
public interface IDocumentReceiverElementRepository : ICRUDRepository<DocumentReceiverElement, int>
{
}
}

View File

@@ -0,0 +1,9 @@
using DigitalData.Core.Contracts.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Infrastructure.Contracts
{
public interface IDocumentStatusRepository : ICRUDRepository<DocumentStatus, int>
{
}
}

View File

@@ -0,0 +1,9 @@
using DigitalData.Core.Contracts.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Infrastructure.Contracts
{
public interface IEmailTemplateRepository : ICRUDRepository<EmailTemplate, int>
{
}
}

View File

@@ -0,0 +1,9 @@
using DigitalData.Core.Contracts.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Infrastructure.Contracts
{
public interface IEnvelopeCertificateRepository : ICRUDRepository<EnvelopeCertificate, int>
{
}
}

View File

@@ -0,0 +1,9 @@
using DigitalData.Core.Contracts.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Infrastructure.Contracts
{
public interface IEnvelopeHistoryRepository : ICRUDRepository<EnvelopeHistory, long>
{
}
}

View File

@@ -0,0 +1,9 @@
using DigitalData.Core.Contracts.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Infrastructure.Contracts
{
public interface IEnvelopeReceiverRepository : ICRUDRepository<EnvelopeReceiver, int>
{
}
}

View File

@@ -0,0 +1,9 @@
using DigitalData.Core.Contracts.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Infrastructure.Contracts
{
public interface IEnvelopeRepository : ICRUDRepository<Envelope, int>
{
}
}

View File

@@ -0,0 +1,9 @@
using DigitalData.Core.Contracts.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Infrastructure.Contracts
{
public interface IEnvelopeTypeRepository : ICRUDRepository<EnvelopeType, int>
{
}
}

View File

@@ -0,0 +1,9 @@
using DigitalData.Core.Contracts.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Infrastructure.Contracts
{
public interface IReceiverRepository : ICRUDRepository<Receiver, int>
{
}
}

View File

@@ -0,0 +1,9 @@
using DigitalData.Core.Contracts.Infrastructure;
using EnvelopeGenerator.Domain.Entities;
namespace EnvelopeGenerator.Infrastructure.Contracts
{
public interface IUserReceiverRepository : ICRUDRepository<UserReceiver, int>
{
}
}

View File

@@ -12,7 +12,19 @@ namespace DigitalData.UserManager.Infrastructure.Repositories
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Config>().HasNoKey();
modelBuilder.Entity<EnvelopeReceiver>().HasNoKey();
modelBuilder.Entity<EnvelopeDocument>();
modelBuilder.Entity<DocumentReceiverElement>();
modelBuilder.Entity<DocumentStatus>();
modelBuilder.Entity<EmailTemplate>();
modelBuilder.Entity<Envelope>();
modelBuilder.Entity<EnvelopeCertificate>();
modelBuilder.Entity<EnvelopeHistory>();
modelBuilder.Entity<EnvelopeType>();
modelBuilder.Entity<Receiver>();
modelBuilder.Entity<UserReceiver>();
base.OnModelCreating(modelBuilder);
}

View File

@@ -0,0 +1,14 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Infrastructure.Repositories
{
public class DocumentReceiverElementRepository : CRUDRepository<DocumentReceiverElement, int, EGDbContext>, IDocumentReceiverElementRepository
{
public DocumentReceiverElementRepository(EGDbContext dbContext) : base(dbContext)
{
}
}
}

View File

@@ -0,0 +1,14 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Infrastructure.Repositories
{
public class DocumentStatusRepository : CRUDRepository<DocumentStatus, int, EGDbContext>, IDocumentStatusRepository
{
public DocumentStatusRepository(EGDbContext dbContext) : base(dbContext)
{
}
}
}

View File

@@ -0,0 +1,14 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Infrastructure.Repositories
{
public class EmailTemplateRepository : CRUDRepository<EmailTemplate, int, EGDbContext>, IEmailTemplateRepository
{
public EmailTemplateRepository(EGDbContext dbContext) : base(dbContext)
{
}
}
}

View File

@@ -0,0 +1,14 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Infrastructure.Repositories
{
public class EnvelopeCertificateRepository : CRUDRepository<EnvelopeCertificate, int, EGDbContext>, IEnvelopeCertificateRepository
{
public EnvelopeCertificateRepository(EGDbContext dbContext) : base(dbContext)
{
}
}
}

View File

@@ -0,0 +1,14 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Infrastructure.Repositories
{
public class EnvelopeHistoryRepository : CRUDRepository<EnvelopeHistory, long, EGDbContext>, IEnvelopeHistoryRepository
{
public EnvelopeHistoryRepository(EGDbContext dbContext) : base(dbContext)
{
}
}
}

View File

@@ -0,0 +1,14 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Infrastructure.Repositories
{
public class EnvelopeRepository : CRUDRepository<Envelope, int, EGDbContext>, IEnvelopeRepository
{
public EnvelopeRepository(EGDbContext dbContext) : base(dbContext)
{
}
}
}

View File

@@ -0,0 +1,14 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Infrastructure.Repositories
{
public class EnvelopeTypeRepository : CRUDRepository<EnvelopeType, int, EGDbContext>, IEnvelopeTypeRepository
{
public EnvelopeTypeRepository(EGDbContext dbContext) : base(dbContext)
{
}
}
}

View File

@@ -0,0 +1,14 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Infrastructure.Repositories
{
public class EnvelopeReceiverRepository : CRUDRepository<EnvelopeReceiver, int, EGDbContext>, IEnvelopeReceiverRepository
{
public EnvelopeReceiverRepository(EGDbContext dbContext) : base(dbContext)
{
}
}
}

View File

@@ -0,0 +1,14 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Infrastructure.Repositories
{
public class ReceiverRepository : CRUDRepository<Receiver, int, EGDbContext>, IReceiverRepository
{
public ReceiverRepository(EGDbContext dbContext) : base(dbContext)
{
}
}
}

View File

@@ -0,0 +1,14 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Infrastructure.Repositories
{
public class UserReceiverRepository : CRUDRepository<UserReceiver, int, EGDbContext>, IUserReceiverRepository
{
public UserReceiverRepository(EGDbContext dbContext) : base(dbContext)
{
}
}
}

View File

@@ -2,27 +2,29 @@
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Mvc;
using System.Text;
namespace EnvelopeGenerator.Web.Controllers
{
public class BaseController : Controller
{
internal DatabaseService database;
internal LogConfig logConfig;
internal State state;
public Logger logger;
public BaseController(DatabaseService database, LoggingService logging)
internal ILogger _logger;
public BaseController(DatabaseService database, ILogger logger)
{
this.database = database;
this.logConfig = logging.LogConfig;
this.logger = logging.LogConfig.GetLogger();
this.state = database.State;
_logger = logger;
}
internal ObjectResult ErrorResponse(Exception e)
{
logger.Error(e);
// Log the detailed error message.
_logger.LogError(e, "An unexpected error occurred.");
return Problem(
statusCode: 500,
detail: e.Message,

View File

@@ -1,18 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Services;
using static EnvelopeGenerator.Common.Constants;
using EnvelopeGenerator.Application.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class DocumentController : BaseController
{
private readonly EnvelopeService envelopeService;
private readonly EnvelopeOldService envelopeService;
private readonly ActionService? actionService;
private readonly IEnvelopeDocumentService _envDocService;
public DocumentController(DatabaseService database, LoggingService logging, EnvelopeService envelope, IEnvelopeDocumentService envDocService) : base(database, logging)
public DocumentController(DatabaseService database, EnvelopeOldService envelope, IEnvelopeDocumentService envDocService, ILogger<DocumentController> logger) : base(database, logger)
{
envelopeService = envelope;
actionService = database.Services?.actionService;
@@ -25,15 +24,12 @@ namespace EnvelopeGenerator.Web.Controllers
{
try
{
logger.Info("DocumentController/Get");
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeResponse response = await envelopeService.LoadEnvelope(envelopeKey);
// Load document info
var Request = ControllerContext.HttpContext.Request;
var document = await envelopeService.GetDocument(Request, envelopeKey);
var document = await envelopeService.GetDocument(index, envelopeKey);
// Load the document from disk
var bytes = await envelopeService.GetDocumentContents(document);
@@ -41,9 +37,9 @@ namespace EnvelopeGenerator.Web.Controllers
// Return the document as bytes
return File(bytes, "application/octet-stream");
}
catch (Exception e)
catch(Exception ex)
{
return ErrorResponse(e);
return ErrorResponse(ex);
}
}
@@ -53,19 +49,17 @@ namespace EnvelopeGenerator.Web.Controllers
{
try
{
logger.Info("DocumentController/Open");
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeResponse response = await envelopeService.LoadEnvelope(envelopeKey);
actionService.OpenEnvelope(response.Envelope, response.Receiver);
actionService?.OpenEnvelope(response.Envelope, response.Receiver);
return Ok(new object());
}
catch (Exception e)
catch(Exception ex)
{
return ErrorResponse(e);
return ErrorResponse(ex);
}
}

View File

@@ -1,4 +1,5 @@
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Common;
using EnvelopeGenerator.Web.Services;
using Microsoft.AspNetCore.Mvc;
@@ -6,13 +7,13 @@ namespace EnvelopeGenerator.Web.Controllers
{
public class EnvelopeController : BaseController
{
private readonly EnvelopeService envelopeService;
private readonly ActionService actionService;
private readonly EnvelopeOldService envelopeService;
private readonly ActionService? actionService;
public EnvelopeController(DatabaseService database, LoggingService logging, EnvelopeService envelope) : base(database, logging)
public EnvelopeController(DatabaseService database, EnvelopeOldService envelope, ILogger<EnvelopeController> logger) : base(database, logger)
{
envelopeService = envelope;
actionService = database.Services?.actionService;
actionService = database?.Services?.actionService;
}
[HttpGet]
@@ -21,8 +22,6 @@ namespace EnvelopeGenerator.Web.Controllers
{
try
{
logger.Info("EnvelopeController/Get");
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeResponse response = await envelopeService.LoadEnvelope(envelopeKey);
@@ -32,7 +31,7 @@ namespace EnvelopeGenerator.Web.Controllers
return Problem(statusCode: 403);
}
logger.Debug("Loaded envelope [{0}] for receiver [{1}]", response.Envelope.Id, response.Envelope.Id);
_logger.LogInformation("Loaded envelope [{0}] for receiver [{1}]", response.Envelope.Id, response.Envelope.Id);
return Json(response);
}
catch (Exception e)
@@ -43,12 +42,10 @@ namespace EnvelopeGenerator.Web.Controllers
[HttpPost]
[Route("api/envelope/{envelopeKey}")]
public async Task<IActionResult> Update(string envelopeKey)
public async Task<IActionResult> Update(string envelopeKey, int index)
{
try
{
logger.Info("EnvelopeController/Update");
// Validate Envelope Key and load envelope
envelopeService.EnsureValidEnvelopeKey(envelopeKey);
EnvelopeResponse response = await envelopeService.LoadEnvelope(envelopeKey);
@@ -59,10 +56,9 @@ namespace EnvelopeGenerator.Web.Controllers
return Problem(statusCode: 403);
}
var Request = ControllerContext.HttpContext.Request;
var document = envelopeService.GetDocument(Request, envelopeKey);
var document = envelopeService.GetDocument(index, envelopeKey);
string annotationData = await envelopeService.EnsureValidAnnotationData(Request);
string? annotationData = await envelopeService.EnsureValidAnnotationData(Request);
envelopeService.InsertDocumentStatus(new DocumentStatus()
{
@@ -74,7 +70,7 @@ namespace EnvelopeGenerator.Web.Controllers
var signResult = actionService?.SignEnvelope(response.Envelope, response.Receiver);
return Ok(new object());
return Ok();
}
catch (Exception e)
{

View File

@@ -1,15 +0,0 @@
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class EnvelopeDocumentTestController : CRUDControllerBase<EnvelopeDocumentTestController, IEnvelopeDocumentService, IEnvelopeDocumentRepository, EnvelopeDocumentDto, EnvelopeDocumentDto, EnvelopeDocumentDto, EnvelopeDocument, int>
{
public EnvelopeDocumentTestController(ILogger<EnvelopeDocumentTestController> logger, IEnvelopeDocumentService service) : base(logger, service)
{
}
}
}

View File

@@ -9,11 +9,13 @@ namespace EnvelopeGenerator.Web.Controllers
{
public class HomeController : BaseController
{
private readonly EnvelopeService _envelopeService;
private readonly EnvelopeOldService _envelopeService;
private readonly IConfiguration _config;
public HomeController(DatabaseService databaseService, LoggingService loggingService, EnvelopeService envelopeService): base(databaseService, loggingService)
public HomeController(DatabaseService databaseService, EnvelopeOldService envelopeService, ILogger<HomeController> logger, IConfiguration configuration) : base(databaseService, logger)
{
_envelopeService = envelopeService;
_config = configuration;
}
[HttpGet]
@@ -25,12 +27,11 @@ namespace EnvelopeGenerator.Web.Controllers
[HttpPost]
[Route("/")]
public IActionResult DebugEnvelopes()
public IActionResult DebugEnvelopes([FromForm] string password)
{
try
{
StringValues passwordFromForm = HttpContext.Request.Form["password"];
string passwordFromConfig = database.GetAppSetting("Config:AdminPassword");
var passwordFromConfig = _config["Config:AdminPassword"] ?? throw new InvalidOperationException("No admin password configured!");
if (passwordFromConfig == null)
{
@@ -38,14 +39,6 @@ namespace EnvelopeGenerator.Web.Controllers
return View("Index");
}
if (passwordFromForm.Count != 1)
{
ViewData["error"] = "No admin password configured!";
return View("Index");
}
string password = passwordFromForm[0];
if (password == null)
{
ViewData["error"] = "No password supplied!";
@@ -107,7 +100,7 @@ namespace EnvelopeGenerator.Web.Controllers
return Redirect($"/EnvelopeKey/{envelopeReceiverId}/Locked");
}
if (accessCode.Equals(access_code, StringComparison.Ordinal))
if (accessCode == access_code)
{
bool actionResult = database.Services.actionService.EnterCorrectAccessCode(response.Envelope, response.Receiver);
ViewData["EnvelopeKey"] = envelopeReceiverId;

View File

@@ -6,10 +6,11 @@ using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class ConfigTestController : CRUDControllerBase<ConfigTestController, IConfigService, IConfigRepository, ConfigDto, ConfigDto, ConfigDto, Config, int>
public class TestConfigController : BasicCRUDControllerBase<TestConfigController, IConfigService, IConfigRepository, ConfigDto, Config, int>
{
public ConfigTestController(ILogger<ConfigTestController> logger, IConfigService service) : base(logger, service)
public TestConfigController(ILogger<TestConfigController> logger, IConfigService service) : base(logger, service)
{
}
}
}

View File

@@ -0,0 +1,16 @@
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class TestDocumentReceiverElementController : BasicCRUDControllerBase<TestDocumentReceiverElementController, IDocumentReceiverElementService, IDocumentReceiverElementRepository, DocumentReceiverElementDto, DocumentReceiverElement, int>
{
public TestDocumentReceiverElementController(ILogger<TestDocumentReceiverElementController> logger, IDocumentReceiverElementService service) : base(logger, service)
{
}
}
}

View File

@@ -0,0 +1,16 @@
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class TestDocumentStatusController : BasicCRUDControllerBase<TestDocumentStatusController, IDocumentStatusService, IDocumentStatusRepository, DocumentStatusDto, DocumentStatus, int>
{
public TestDocumentStatusController(ILogger<TestDocumentStatusController> logger, IDocumentStatusService service) : base(logger, service)
{
}
}
}

View File

@@ -0,0 +1,16 @@
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class TestEmailTemplateController : CRUDControllerBase<TestEmailTemplateController, IEmailTemplateService, IEmailTemplateRepository, EmailTemplateDto, EmailTemplateDto, EmailTemplateDto, EmailTemplate, int>
{
public TestEmailTemplateController(ILogger<TestEmailTemplateController> logger, IEmailTemplateService service) : base(logger, service)
{
}
}
}

View File

@@ -0,0 +1,16 @@
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class TestEnvelopeCertificateController : BasicCRUDControllerBase<TestEnvelopeCertificateController, IEnvelopeCertificateService, IEnvelopeCertificateRepository, EnvelopeCertificateDto, EnvelopeCertificate, int>
{
public TestEnvelopeCertificateController(ILogger<TestEnvelopeCertificateController> logger, IEnvelopeCertificateService service) : base(logger, service)
{
}
}
}

View File

@@ -0,0 +1,16 @@
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class TestEnvelopeController : CRUDControllerBase<TestEnvelopeController, IEnvelopeService, IEnvelopeRepository, EnvelopeDto, EnvelopeDto, EnvelopeDto, Envelope, int>
{
public TestEnvelopeController(ILogger<TestEnvelopeController> logger, IEnvelopeService service) : base(logger, service)
{
}
}
}

View File

@@ -0,0 +1,16 @@
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class TestEnvelopeDocumentController : BasicCRUDControllerBase<TestEnvelopeDocumentController, IEnvelopeDocumentService, IEnvelopeDocumentRepository, EnvelopeDocumentDto, EnvelopeDocument, int>
{
public TestEnvelopeDocumentController(ILogger<TestEnvelopeDocumentController> logger, IEnvelopeDocumentService service) : base(logger, service)
{
}
}
}

View File

@@ -0,0 +1,16 @@
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class TestEnvelopeHistoryController : BasicCRUDControllerBase<TestEnvelopeHistoryController, IEnvelopeHistoryService, IEnvelopeHistoryRepository, EnvelopeHistoryDto, EnvelopeHistory, long>
{
public TestEnvelopeHistoryController(ILogger<TestEnvelopeHistoryController> logger, IEnvelopeHistoryService service) : base(logger, service)
{
}
}
}

View File

@@ -0,0 +1,16 @@
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class TestEnvelopeReceiverController : BasicCRUDControllerBase<TestEnvelopeReceiverController, IEnvelopeReceiverService, IEnvelopeReceiverRepository, EnvelopeReceiverDto, EnvelopeReceiver, int>
{
public TestEnvelopeReceiverController(ILogger<TestEnvelopeReceiverController> logger, IEnvelopeReceiverService service) : base(logger, service)
{
}
}
}

View File

@@ -0,0 +1,16 @@
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class TestEnvelopeTypeController : BasicCRUDControllerBase<TestEnvelopeTypeController, IEnvelopeTypeService, IEnvelopeTypeRepository, EnvelopeTypeDto, EnvelopeType, int>
{
public TestEnvelopeTypeController(ILogger<TestEnvelopeTypeController> logger, IEnvelopeTypeService service) : base(logger, service)
{
}
}
}

View File

@@ -0,0 +1,16 @@
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class TestReceiverController : BasicCRUDControllerBase<TestReceiverController, IReceiverService, IReceiverRepository, ReceiverDto, Receiver, int>
{
public TestReceiverController(ILogger<TestReceiverController> logger, IReceiverService service) : base(logger, service)
{
}
}
}

View File

@@ -0,0 +1,16 @@
using DigitalData.Core.API;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Web.Controllers
{
public class TestUserReceiverController : BasicCRUDControllerBase<TestUserReceiverController, IUserReceiverService, IUserReceiverRepository, UserReceiverDto, UserReceiver, int>
{
public TestUserReceiverController(ILogger<TestUserReceiverController> logger, IUserReceiverService service) : base(logger, service)
{
}
}
}

View File

@@ -17,6 +17,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.15" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.2.5" />
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.0" />
<PackageReference Include="Quartz" Version="3.8.0" />
<PackageReference Include="Quartz.AspNetCore" Version="3.8.0" />
<PackageReference Include="Quartz.Plugins" Version="3.8.0" />

View File

@@ -7,73 +7,102 @@ using EnvelopeGenerator.Infrastructure.Contracts;
using EnvelopeGenerator.Infrastructure.Repositories;
using EnvelopeGenerator.Web.Services;
using Microsoft.EntityFrameworkCore;
using NLog;
using Quartz;
using NLog.Web;
namespace EnvelopeGenerator.Web
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
logger.Info("Logging initialized!");
try
{
public class Program
var builder = WebApplication.CreateBuilder(args);
builder.Logging.ClearProviders();
builder.Host.UseNLog();
// Add base services
builder.Services.AddScoped<DatabaseService>();
// Add higher order services
builder.Services.AddScoped<EnvelopeOldService>();
// Add services to the container.
builder.Services.AddControllersWithViews().AddJsonOptions(q =>
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Prevents serialization error when serializing SvgBitmap in EnvelopeReceiver
q.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
});
// Add base services
builder.Services.AddSingleton<LoggingService>();
builder.Services.AddScoped<DatabaseService>();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// Add higher order services
builder.Services.AddScoped<EnvelopeService>();
builder.Services.AddKeyTranslationService();
// Add services to the container.
builder.Services.AddControllersWithViews().AddJsonOptions(q =>
{
// Prevents serialization error when serializing SvgBitmap in EnvelopeReceiver
q.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
});
//AddEF Core dbcontext
var connStr = builder.Configuration["Config:ConnectionString"];
builder.Services.AddDbContext<EGDbContext>(options =>
options.UseSqlServer(connStr));
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
//Inject CRUD Service and repositories
builder.Services.AddScoped<IConfigRepository, ConfigRepository>();
builder.Services.AddScoped<IDocumentReceiverElementRepository, DocumentReceiverElementRepository>();
builder.Services.AddScoped<IEnvelopeDocumentRepository, EnvelopeDocumentRepository>();
builder.Services.AddScoped<IConfigRepository, ConfigRepository>();
builder.Services.AddScoped<IDocumentReceiverElementRepository, DocumentReceiverElementRepository>();
builder.Services.AddScoped<IDocumentStatusRepository, DocumentStatusRepository>();
builder.Services.AddScoped<IEmailTemplateRepository, EmailTemplateRepository>();
builder.Services.AddScoped<IEnvelopeRepository, EnvelopeRepository>();
builder.Services.AddScoped<IEnvelopeCertificateRepository, EnvelopeCertificateRepository>();
builder.Services.AddScoped<IEnvelopeDocumentRepository, EnvelopeDocumentRepository>();
builder.Services.AddScoped<IEnvelopeHistoryRepository, EnvelopeHistoryRepository>();
builder.Services.AddScoped<IEnvelopeReceiverRepository, EnvelopeReceiverRepository>();
builder.Services.AddScoped<IEnvelopeTypeRepository, EnvelopeTypeRepository>();
builder.Services.AddScoped<IReceiverRepository, ReceiverRepository>();
builder.Services.AddScoped<IUserReceiverRepository, UserReceiverRepository>();
builder.Services.AddKeyTranslationService();
builder.Services.AddScoped<IConfigService, ConfigService>();
builder.Services.AddScoped<IDocumentReceiverElementService, DocumentReceiverElementService>();
builder.Services.AddScoped<IEnvelopeDocumentService, EnvelopeDocumentService>();
builder.Services.AddScoped<IDocumentStatusService, DocumentStatusService>();
builder.Services.AddScoped<IEmailTemplateService, EmailTemplateService>();
builder.Services.AddScoped<IEnvelopeService, EnvelopeService>();
builder.Services.AddScoped<IEnvelopeCertificateService, EnvelopeCertificateService>();
builder.Services.AddScoped<IEnvelopeDocumentService, EnvelopeDocumentService>();
builder.Services.AddScoped<IEnvelopeHistoryService, EnvelopeHistoryService>();
builder.Services.AddScoped<IEnvelopeReceiverService, EnvelopeReceiverService>();
builder.Services.AddScoped<IEnvelopeTypeService, EnvelopeTypeService>();
builder.Services.AddScoped<IReceiverService, ReceiverService>();
builder.Services.AddScoped<IUserReceiverService, UserReceiverService>();
//AddEF Core dbcontext
var connStr = builder.Configuration["Config:ConnectionString"];
builder.Services.AddDbContext<EGDbContext>(options =>
options.UseSqlServer(connStr));
//Auto mapping profiles
builder.Services.AddAutoMapper(typeof(BasicDtoMappingProfile).Assembly);
//Inject CRUD Service and repositories
builder.Services.AddScoped<IConfigRepository, ConfigRepository>();
builder.Services.AddScoped<IEnvelopeDocumentRepository, EnvelopeDocumentRepository>();
var app = builder.Build();
builder.Services.AddScoped<IConfigService, ConfigService>();
builder.Services.AddScoped<IEnvelopeDocumentService, EnvelopeDocumentService>();
//Auto mapping profiles
builder.Services.AddAutoMapper(typeof(BasicDtoMappingProfile).Assembly);
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllers();
app.Run();
}
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllers();
app.Run();
}
catch(Exception ex)
{
logger.Error(ex, "Stopped program because of exception");
throw;
}

View File

@@ -1,18 +0,0 @@
using DigitalData.Modules.Logging;
namespace EnvelopeGenerator.Web.Services
{
public class BaseService
{
internal readonly LogConfig logConfig;
internal readonly IConfiguration config;
internal Logger logger;
public BaseService(IConfiguration Config, LoggingService Logging)
{
logConfig = Logging.LogConfig;
logger = Logging.LogConfig.GetLogger();
config = Config;
}
}
}

View File

@@ -1,14 +1,16 @@
using DigitalData.Modules.Database;
using DigitalData.Modules.Logging;
using EnvelopeGenerator.Common;
namespace EnvelopeGenerator.Web.Services
{
public class DatabaseService: BaseService
public class DatabaseService
{
public MSSQLServer MSSQL { get; set; }
public IConfiguration Config { get; set; }
public State State { get; set; }
ILogger<DatabaseService> _logger;
public State? State { get; set; }
public class ServiceContainer
{
@@ -48,62 +50,43 @@ namespace EnvelopeGenerator.Web.Services
public readonly ModelContainer? Models;
public readonly ServiceContainer? Services;
public DatabaseService(IConfiguration pConfig, LoggingService pLogging) : base(pConfig, pLogging)
public DatabaseService(ILogger<DatabaseService> logger, IConfiguration config)
{
logger = pLogging.LogConfig.GetLogger();
Config = pConfig;
LogConfig logConfig = new LogConfig(LogConfig.PathType.CustomPath, config["Config:LogPath"], null, "Digital Data", "ECM.EnvelopeGenerator.Web");
_logger = logger;
logger.Debug("Establishing MSSQL Database connection..");
MSSQL = new MSSQLServer(logConfig, pConfig["Config:ConnectionString"]);
_logger.LogInformation("Establishing MSSQL Database connection..");
MSSQL = new MSSQLServer(logConfig, config["Config:ConnectionString"]);
if (MSSQL.DBInitialized == true)
{
logger.Debug("MSSQL Connection established: [{0}]", MSSQL.MaskedConnectionString);
var state = GetState();
_logger.LogInformation("MSSQL Connection established: [{0}]", MSSQL.MaskedConnectionString);
Models = new(state);
Services = new(state);
/// <summary>
/// There is a circular dependency between state and models
/// All models need a state object, including the config Model
/// The state object needs to be filled with the DbConfig property,
/// which is obtained by the config Model.
/// So first, the config model is initialized with an incomplete state object,
/// then all the other models with the DbConfig property filled.
/// </summary>
State = new State
{
Database = MSSQL,
LogConfig = logConfig,
UserId = 0,
DbConfig = null
};
var configModel = new ConfigModel(State);
State.DbConfig = configModel.LoadConfiguration();
State = state;
Models = new(State);
Services = new(State);
}
else
{
logger.Error("Connection could not be established!");
_logger.LogInformation("Connection could not be established!");
}
}
public string? GetAppSetting(string key)
{
return Config[key];
}
/// <summary>
/// There is a circular dependency between state and models
/// All models need a state object, including the config Model
/// The state object needs to be filled with the DbConfig property,
/// which is obtained by the config Model.
/// So first, the config model is initialized with an incomplete state object,
/// then all the other models with the DbConfig property filled.
/// </summary>
private State GetState()
{
var state = GetInitialState();
var configModel = new ConfigModel(state);
state.DbConfig = configModel.LoadConfiguration();
return state;
}
private State GetInitialState()
{
return new State
{
Database = MSSQL,
LogConfig = logConfig,
UserId = 0,
DbConfig = null
};
}
}
}

View File

@@ -1,11 +1,10 @@
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Common;
using Microsoft.Extensions.Primitives;
using System.Text;
namespace EnvelopeGenerator.Web.Services
{
public class EnvelopeService : BaseService
public class EnvelopeOldService
{
private readonly ReceiverModel receiverModel;
private readonly EnvelopeModel envelopeModel;
@@ -13,16 +12,15 @@ namespace EnvelopeGenerator.Web.Services
private readonly DocumentStatusModel documentStatusModel;
private IConfigService _configService;
private readonly IConfigService _configService;
private readonly ILogger<EnvelopeOldService> _logger;
public EnvelopeService(IConfiguration Config, LoggingService Logging, DatabaseService database, IConfigService configService) : base(Config, Logging)
public EnvelopeOldService(DatabaseService database, IConfigService configService, ILogger<EnvelopeOldService> logger)
{
logger = Logging.LogConfig.GetLogger();
_logger = logger;
if (database.Models == null)
{
if (database.Models is null)
throw new ArgumentNullException("Models not loaded.");
}
receiverModel = database.Models.receiverModel;
envelopeModel = database.Models.envelopeModel;
@@ -34,14 +32,14 @@ namespace EnvelopeGenerator.Web.Services
public void EnsureValidEnvelopeKey(string envelopeKey)
{
logger.Debug("Parsing EnvelopeKey..");
_logger.LogInformation("Parsing EnvelopeKey..");
if (string.IsNullOrEmpty(envelopeKey))
throw new ArgumentNullException("EnvelopeKey");
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(envelopeKey);
logger.Debug("EnvelopeUUID: [{0}]", result.Item1);
logger.Debug("ReceiverSignature: [{0}]", result.Item2);
_logger.LogInformation("EnvelopeUUID: [{0}]", result.Item1);
_logger.LogInformation("ReceiverSignature: [{0}]", result.Item2);
if (string.IsNullOrEmpty(result.Item1))
throw new ArgumentNullException("EnvelopeUUID");
@@ -52,43 +50,43 @@ namespace EnvelopeGenerator.Web.Services
public async Task<EnvelopeResponse> LoadEnvelope(string pEnvelopeKey)
{
logger.Debug("Loading Envelope by Key [{0}]", pEnvelopeKey);
_logger.LogInformation("Loading Envelope by Key [{0}]", pEnvelopeKey);
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(pEnvelopeKey);
var envelopeUuid = result.Item1;
var receiverSignature = result.Item2;
var receiverId = receiverModel.GetReceiverIdBySignature(receiverSignature);
logger.Debug("Resolved receiver signature to receiverId [{0}]", receiverId);
_logger.LogInformation("Resolved receiver signature to receiverId [{0}]", receiverId);
logger.Debug("Loading envelope..");
_logger.LogInformation("Loading envelope..");
Envelope? envelope = envelopeModel.GetByUuid(envelopeUuid);
if (envelope == null)
{
logger.Warn("Envelope not found");
_logger.LogWarning("Envelope not found");
throw new NullReferenceException("Envelope not found");
}
logger.Debug("Envelope loaded");
_logger.LogInformation("Envelope loaded");
if (envelope.Receivers == null)
{
logger.Warn("Receivers for envelope not loaded");
_logger.LogWarning("Receivers for envelope not loaded");
throw new NullReferenceException("Receivers for envelope not loaded");
}
logger.Debug("Envelope receivers found: [{0}]", envelope.Receivers.Count);
_logger.LogInformation("Envelope receivers found: [{0}]", envelope.Receivers.Count);
EnvelopeReceiver? receiver = envelope.Receivers.Where(r => r.Id == receiverId).SingleOrDefault();
if (receiver == null)
{
logger.Warn("Receiver [{0}] not found", receiverId);
_logger.LogWarning("Receiver [{0}] not found", receiverId);
throw new NullReferenceException("Receiver not found");
}
logger.Debug("Loading documents for receiver [{0}]", receiver.Email);
_logger.LogInformation("Loading documents for receiver [{0}]", receiver.Email);
// filter elements by receiver
envelope.Documents = envelope.Documents.Select((document) =>
@@ -111,7 +109,7 @@ namespace EnvelopeGenerator.Web.Services
}
else
{
logger.Error(configResult.Messages);
_logger.LogError(string.Join(". ", configResult.Messages));
throw new InvalidOperationException(String.Join(". ", configResult.Messages));
}
@@ -150,52 +148,28 @@ namespace EnvelopeGenerator.Web.Services
{
try
{
logger.Debug("Parsing annotation data from request..");
_logger.LogInformation("Parsing annotation data from request..");
using MemoryStream ms = new();
await request.BodyReader.CopyToAsync(ms);
var bytes = ms.ToArray();
logger.Debug("Annotation data parsed, size: [{0}]", bytes.Length);
_logger.LogInformation("Annotation data parsed, size: [{0}]", bytes.Length);
return Encoding.UTF8.GetString(bytes);
}
catch (Exception e)
{
logger.Error(e);
_logger.LogError(e, "Inner Service Error");
throw new ArgumentNullException("AnnotationData");
}
}
public int EnsureValidDocumentIndex(HttpRequest request)
{
if (!request.Query.TryGetValue("index", out StringValues documentIndexStringList))
{
logger.Warn("There is no query parameter called index");
throw new ArgumentNullException("DocumentIndex");
}
if (documentIndexStringList.FirstOrDefault() == null)
{
logger.Warn("There is no query parameter called index");
throw new ArgumentNullException("DocumentIndex");
}
if (!int.TryParse(documentIndexStringList.First(), out int documentIndex))
{
logger.Warn("Invalid document index [{0}]", documentIndexStringList.First());
throw new ArgumentNullException("DocumentIndex");
}
return documentIndex;
}
public async Task<EnvelopeDocument> GetDocument(HttpRequest request, string envelopeKey)
public async Task<EnvelopeDocument> GetDocument(int documentId, string envelopeKey)
{
EnvelopeResponse response = await LoadEnvelope(envelopeKey);
int documentId = EnsureValidDocumentIndex(request);
logger.Debug("Loading document for Id [{0}]", documentId);
_logger.LogInformation("Loading document for Id [{0}]", documentId);
var document = response.Envelope.Documents.
Where(d => d.Id == documentId).
@@ -203,25 +177,25 @@ namespace EnvelopeGenerator.Web.Services
if (document == null)
throw new ArgumentException("DocumentId");
logger.Debug("Document [{0}] loaded!", documentId);
_logger.LogInformation("Document [{0}] loaded!", documentId);
return document;
}
public bool InsertDocumentStatus(Common.DocumentStatus documentStatus)
{
logger.Debug("Saving annotation data..");
_logger.LogInformation("Saving annotation data..");
return documentStatusModel.InsertOrUpdate(documentStatus);
}
public async Task<byte[]> GetDocumentContents(EnvelopeDocument document)
{
logger.Debug("Loading file [{0}]", document.Filepath);
_logger.LogInformation("Loading file [{0}]", document.Filepath);
var bytes = await File.ReadAllBytesAsync(document.Filepath);
logger.Info("File loaded, size: [{0}]", bytes.Length);
_logger.LogInformation("File loaded, size: [{0}]", bytes.Length);
return bytes;
}
}
}
}

View File

@@ -1,25 +0,0 @@
using DigitalData.Modules.Logging;
namespace EnvelopeGenerator.Web.Services
{
public class LoggingService
{
public LogConfig LogConfig { get; set; }
public LoggingService(IConfiguration Config)
{
LogConfig = new LogConfig(LogConfig.PathType.CustomPath, Config["Config:LogPath"], null, "Digital Data", "ECM.EnvelopeGenerator.Web");
var logger = LogConfig.GetLogger();
logger.Info("Logging initialized!");
var debugLog = bool.Parse(Config["Config:LogDebug"]);
logger.Info("Setting DEBUG Logging to: [{0}]", debugLog);
LogConfig.Debug = debugLog;
var jsonLog = bool.Parse(Config["Config:LogJson"]);
logger.Info("Setting JSON Logging to: [{0}]", jsonLog);
LogConfig.Debug = jsonLog;
}
}
}

View File

@@ -1,7 +1,42 @@
@{
ViewData["Title"] = "Dokument unterschreiben";
}
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
</li>
</ul>
<form class="d-flex" role="search">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
<script>
document.addEventListener("DOMContentLoaded", async () => {
const app = new App("#app", "@ViewData["EnvelopeKey"]");

View File

@@ -2,16 +2,45 @@
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
"Default": "Warning",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"Microsoft.AspNetCore.Hosting.Diagnostics": "Warning"
}
},
"Config": {
"ConnectionString": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;",
//preivous connection string without Encrypt=false and TrustServerCertificate=True -> "Server=sDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;"
"LogPath": "E:\\EnvelopeGenerator\\Logs",
"LogDebug": true,
"LogJson": true,
"AdminPassword": "dd"
"AdminPassword": "dd",
"NLog": {
"throwConfigExceptions": true,
"targets": {
"infoLogs": {
"type": "File",
"fileName": "E:\\EnvelopeGenerator\\Logs\\${shortdate}-ECM.EnvelopeGenerator.Web-Info.log",
"maxArchiveDays": 30
},
"errorLogs": {
"type": "File",
"fileName": "E:\\EnvelopeGenerator\\Logs\\${shortdate}-ECM.EnvelopeGenerator.Web-Error.log",
"maxArchiveDays": 30
}
},
"rules": [
{
"logger": "*",
"minLevel": "Info",
"writeTo": "infoLogs"
},
{
"logger": "*",
"minLevel": "Error",
"writeTo": "errorLogs"
},
{
"logger": "Namespace.Controllers.*",
"minLevel": "Error",
"writeTo": "errorLogs",
"final": true
}
]
}
}

View File

@@ -1,8 +1,32 @@
{
"name": "EnvelopeGenerator.Web",
"version": "1.0.0",
"lockfileVersion": 1,
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "EnvelopeGenerator.Web",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"prettier": "^3.1.0"
}
},
"node_modules/prettier": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.0.tgz",
"integrity": "sha512-TQLvXjq5IAibjh8EpBIkNKxO749UEWABoiIZehEPiY4GNpVdhaFKqSTu+QrlU6D2dPAfubRmtJTi4K4YkQ5eXw==",
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
}
},
"dependencies": {
"prettier": {
"version": "3.1.0",