Compare commits
3 Commits
8613b11f70
...
ff5536d3ea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff5536d3ea | ||
|
|
e69dccb2e1 | ||
|
|
8d5e24c6a7 |
@@ -14,6 +14,11 @@
|
|||||||
Created = 0
|
Created = 0
|
||||||
End Enum
|
End Enum
|
||||||
|
|
||||||
|
Public Enum DocumentStatus
|
||||||
|
Created = 0
|
||||||
|
Signed = 1
|
||||||
|
End Enum
|
||||||
|
|
||||||
Public Enum EnvelopeHistoryActionType
|
Public Enum EnvelopeHistoryActionType
|
||||||
Created = 0
|
Created = 0
|
||||||
Saved = 1
|
Saved = 1
|
||||||
|
|||||||
10
EnvelopeGenerator.Common/Entities/DocumentStatus.vb
Normal file
10
EnvelopeGenerator.Common/Entities/DocumentStatus.vb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
Public Class DocumentStatus
|
||||||
|
|
||||||
|
Public Property Id As Integer
|
||||||
|
Public Property EnvelopeId As Integer
|
||||||
|
Public Property ReceiverId As Integer
|
||||||
|
Public Property Value As String
|
||||||
|
Public Property Status As Constants.DocumentStatus = Constants.DocumentStatus.Created
|
||||||
|
Public Property StatusChangedWhen As Date
|
||||||
|
|
||||||
|
End Class
|
||||||
@@ -95,6 +95,7 @@
|
|||||||
<Compile Include="Constants.vb" />
|
<Compile Include="Constants.vb" />
|
||||||
<Compile Include="Entities\DbConfig.vb" />
|
<Compile Include="Entities\DbConfig.vb" />
|
||||||
<Compile Include="Entities\ElementMetadata.vb" />
|
<Compile Include="Entities\ElementMetadata.vb" />
|
||||||
|
<Compile Include="Entities\DocumentStatus.vb" />
|
||||||
<Compile Include="Entities\ElementStatus.vb" />
|
<Compile Include="Entities\ElementStatus.vb" />
|
||||||
<Compile Include="Entities\EmailData.vb" />
|
<Compile Include="Entities\EmailData.vb" />
|
||||||
<Compile Include="Entities\EmailTemplate.vb" />
|
<Compile Include="Entities\EmailTemplate.vb" />
|
||||||
@@ -112,6 +113,7 @@
|
|||||||
<Compile Include="Models\ConfigModel.vb" />
|
<Compile Include="Models\ConfigModel.vb" />
|
||||||
<Compile Include="Models\DocumentModel.vb" />
|
<Compile Include="Models\DocumentModel.vb" />
|
||||||
<Compile Include="Models\ElementModel.vb" />
|
<Compile Include="Models\ElementModel.vb" />
|
||||||
|
<Compile Include="Models\DocumentStatusModel.vb" />
|
||||||
<Compile Include="Models\ElementStatusModel.vb" />
|
<Compile Include="Models\ElementStatusModel.vb" />
|
||||||
<Compile Include="Models\EmailModel.vb" />
|
<Compile Include="Models\EmailModel.vb" />
|
||||||
<Compile Include="Models\EnvelopeModel.vb" />
|
<Compile Include="Models\EnvelopeModel.vb" />
|
||||||
|
|||||||
89
EnvelopeGenerator.Common/Models/DocumentStatusModel.vb
Normal file
89
EnvelopeGenerator.Common/Models/DocumentStatusModel.vb
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
Imports System.Data.SqlClient
|
||||||
|
|
||||||
|
Public Class DocumentStatusModel
|
||||||
|
Inherits BaseModel
|
||||||
|
|
||||||
|
Public Sub New(pState As State)
|
||||||
|
MyBase.New(pState)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Function InsertOrUpdate(pDocumentStatus As DocumentStatus) As Boolean
|
||||||
|
If pDocumentStatus.Id = 0 Then
|
||||||
|
Return Insert(pDocumentStatus)
|
||||||
|
Else
|
||||||
|
Return Update(pDocumentStatus)
|
||||||
|
End If
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function Insert(pDocumentStatus As DocumentStatus) As Boolean
|
||||||
|
Try
|
||||||
|
Dim oSql = "INSERT INTO [dbo].[TBSIG_DOCUMENT_STATUS]
|
||||||
|
([ENVELOPE_ID]
|
||||||
|
,[RECEIVER_ID]
|
||||||
|
,[STATUS]
|
||||||
|
,[STATUS_CHANGED_WHEN]
|
||||||
|
,[VALUE])
|
||||||
|
VALUES
|
||||||
|
(@ENVELOPE_ID
|
||||||
|
,@RECEIVER_ID
|
||||||
|
,@STATUS
|
||||||
|
,@STATUS_CHANGED_WHEN
|
||||||
|
,@VALUE)"
|
||||||
|
|
||||||
|
Dim oCommand As New SqlCommand(oSql)
|
||||||
|
oCommand.Parameters.Add("ENVELOPE_ID", SqlDbType.Int).Value = pDocumentStatus.EnvelopeId
|
||||||
|
oCommand.Parameters.Add("RECEIVER_ID", SqlDbType.Int).Value = pDocumentStatus.ReceiverId
|
||||||
|
oCommand.Parameters.Add("STATUS", SqlDbType.NVarChar).Value = pDocumentStatus.Status.ToString()
|
||||||
|
oCommand.Parameters.Add("STATUS_CHANGED_WHEN", SqlDbType.DateTime).Value = Now()
|
||||||
|
oCommand.Parameters.Add("VALUE", SqlDbType.NVarChar).Value = pDocumentStatus.Value
|
||||||
|
|
||||||
|
If Database.ExecuteNonQuery(oCommand) Then
|
||||||
|
pDocumentStatus.Id = GetElementId(pDocumentStatus)
|
||||||
|
Return True
|
||||||
|
Else
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
Return False
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Function Update(pDocumentStatus As DocumentStatus) As Boolean
|
||||||
|
Try
|
||||||
|
Dim oSql = "UPDATE [dbo].[TBSIG_DOCUMENT_STATUS]
|
||||||
|
SET [STATUS] = @STATUS
|
||||||
|
,[STATUS_CHANGED_WHEN] = @STATUS_CHANGED_WHEN
|
||||||
|
,[CHANGED_WHEN] = @CHANGED_WHEN
|
||||||
|
,[VALUE] = @VALUE
|
||||||
|
WHERE GUID = @GUID"
|
||||||
|
|
||||||
|
Dim oCommand As New SqlCommand(oSql)
|
||||||
|
oCommand.Parameters.Add("GUID", SqlDbType.Int).Value = pDocumentStatus.Id
|
||||||
|
oCommand.Parameters.Add("STATUS", SqlDbType.NVarChar).Value = pDocumentStatus.Status.ToString()
|
||||||
|
oCommand.Parameters.Add("STATUS_CHANGED_WHEN", SqlDbType.DateTime).Value = Now()
|
||||||
|
oCommand.Parameters.Add("CHANGED_WHEN", SqlDbType.DateTime).Value = Now()
|
||||||
|
oCommand.Parameters.Add("VALUE", SqlDbType.NVarChar).Value = pDocumentStatus.Value
|
||||||
|
|
||||||
|
If Database.ExecuteNonQuery(oCommand) Then
|
||||||
|
Return True
|
||||||
|
Else
|
||||||
|
Return False
|
||||||
|
End If
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
Return False
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Function GetElementId(pDocument As DocumentStatus) As Integer
|
||||||
|
Try
|
||||||
|
Return Database.GetScalarValue($"SELECT MAX(GUID) FROM TBSIG_DOCUMENT_STATUS
|
||||||
|
WHERE ENVELOPE_ID = {pDocument.EnvelopeId} AND RECEIVER_ID = {pDocument.ReceiverId}")
|
||||||
|
|
||||||
|
Catch ex As Exception
|
||||||
|
Logger.Error(ex)
|
||||||
|
Return Nothing
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
|
End Class
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using DigitalData.Modules.Logging;
|
using DigitalData.Modules.Database;
|
||||||
|
using DigitalData.Modules.Logging;
|
||||||
using EnvelopeGenerator.Common;
|
using EnvelopeGenerator.Common;
|
||||||
using EnvelopeGenerator.Common.My.Resources;
|
using EnvelopeGenerator.Common.My.Resources;
|
||||||
using EnvelopeGenerator.Web.Services;
|
using EnvelopeGenerator.Web.Services;
|
||||||
@@ -17,7 +18,7 @@ namespace EnvelopeGenerator.Web.Handler
|
|||||||
/// Returns a
|
/// Returns a
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IResult HandleGetEnvelope(HttpContext ctx, DatabaseService database, LoggingService logging)
|
public IResult HandleGetEnvelope(HttpContext ctx, DatabaseService database, LoggingService logging)
|
||||||
{
|
{
|
||||||
var logger = logging.LogConfig.GetLogger("FileHandler");
|
var logger = logging.LogConfig.GetLogger("FileHandler");
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ namespace EnvelopeGenerator.Web.Handler
|
|||||||
/// Returns a document for the supplied EnvelopeKey and Document Id / Index
|
/// Returns a document for the supplied EnvelopeKey and Document Id / Index
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>file buffer of the requested document</returns>
|
/// <returns>file buffer of the requested document</returns>
|
||||||
public async static Task<IResult> HandleGetDocument(HttpContext ctx, DatabaseService database, LoggingService logging)
|
public async Task<IResult> HandleGetDocument(HttpContext ctx, DatabaseService database, LoggingService logging)
|
||||||
{
|
{
|
||||||
var logger = logging.LogConfig.GetLogger("FileHandler");
|
var logger = logging.LogConfig.GetLogger("FileHandler");
|
||||||
|
|
||||||
@@ -80,7 +81,7 @@ namespace EnvelopeGenerator.Web.Handler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async static Task<IResult> HandlePostDocument(HttpContext ctx, DatabaseService database, LoggingService logging)
|
public async Task<IResult> HandlePostDocument(HttpContext ctx, DatabaseService database, LoggingService logging)
|
||||||
{
|
{
|
||||||
var logger = logging.LogConfig.GetLogger("FileHandler");
|
var logger = logging.LogConfig.GetLogger("FileHandler");
|
||||||
|
|
||||||
@@ -110,10 +111,7 @@ namespace EnvelopeGenerator.Web.Handler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IResult> HandlePostEnvelope(HttpContext ctx, DatabaseService database, LoggingService logging)
|
||||||
|
|
||||||
|
|
||||||
public async static Task<IResult> HandlePostEnvelope(HttpContext ctx, DatabaseService database, LoggingService logging)
|
|
||||||
{
|
{
|
||||||
var logger = logging.LogConfig.GetLogger("FileHandler");
|
var logger = logging.LogConfig.GetLogger("FileHandler");
|
||||||
|
|
||||||
@@ -129,14 +127,23 @@ namespace EnvelopeGenerator.Web.Handler
|
|||||||
int documentId = EnsureValidDocumentIndex(logger, ctx.Request);
|
int documentId = EnsureValidDocumentIndex(logger, ctx.Request);
|
||||||
var document = GetDocument(r.Envelope, documentId);
|
var document = GetDocument(r.Envelope, documentId);
|
||||||
|
|
||||||
var annotationData = EnsureValidAnnotationData(logger, ctx.Request);
|
string? annotationData = await EnsureValidAnnotationData(logger, ctx.Request);
|
||||||
|
|
||||||
if (annotationData == null)
|
if (annotationData == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("AnnotationData");
|
throw new ArgumentNullException("AnnotationData");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Save annotations to database
|
State state = GetState(logging.LogConfig, database.MSSQL);
|
||||||
|
DocumentStatusModel model = new(state);
|
||||||
|
|
||||||
|
model.InsertOrUpdate(new DocumentStatus()
|
||||||
|
{
|
||||||
|
EnvelopeId = r.Envelope.Id,
|
||||||
|
ReceiverId = r.ReceiverId,
|
||||||
|
Value = annotationData,
|
||||||
|
Status = Common.Constants.DocumentStatus.Signed
|
||||||
|
});
|
||||||
|
|
||||||
return Results.Ok();
|
return Results.Ok();
|
||||||
}
|
}
|
||||||
@@ -146,11 +153,18 @@ namespace EnvelopeGenerator.Web.Handler
|
|||||||
logger.Error(e);
|
logger.Error(e);
|
||||||
return Results.Problem();
|
return Results.Problem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int EnsureValidDocumentIndex(Logger logger, HttpRequest request)
|
private State GetState(LogConfig LogConfig, MSSQLServer Database)
|
||||||
|
{
|
||||||
|
return new State
|
||||||
|
{
|
||||||
|
LogConfig = LogConfig,
|
||||||
|
Database = Database,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private int EnsureValidDocumentIndex(Logger logger, HttpRequest request)
|
||||||
{
|
{
|
||||||
if (request.Query.TryGetValue("index", out StringValues documentIndexString))
|
if (request.Query.TryGetValue("index", out StringValues documentIndexString))
|
||||||
{
|
{
|
||||||
@@ -169,7 +183,7 @@ namespace EnvelopeGenerator.Web.Handler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string EnsureValidEnvelopeKey(Logger logger, HttpRequest request)
|
private string EnsureValidEnvelopeKey(Logger logger, HttpRequest request)
|
||||||
{
|
{
|
||||||
logger.Debug("Parsing EnvelopeKey..");
|
logger.Debug("Parsing EnvelopeKey..");
|
||||||
var envelopeKey = request.RouteValues["envelopeKey"] as string;
|
var envelopeKey = request.RouteValues["envelopeKey"] as string;
|
||||||
@@ -190,7 +204,7 @@ namespace EnvelopeGenerator.Web.Handler
|
|||||||
return envelopeKey;
|
return envelopeKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<string> EnsureValidAnnotationData(Logger logger, HttpRequest request)
|
private async Task<string?> EnsureValidAnnotationData(Logger logger, HttpRequest request)
|
||||||
{
|
{
|
||||||
logger.Debug("Parsing AnnotationData..");
|
logger.Debug("Parsing AnnotationData..");
|
||||||
|
|
||||||
@@ -210,7 +224,7 @@ namespace EnvelopeGenerator.Web.Handler
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EnvelopeDocument GetDocument(Common.Envelope envelope, int documentId)
|
private EnvelopeDocument GetDocument(Common.Envelope envelope, int documentId)
|
||||||
{
|
{
|
||||||
var document = envelope.Documents.
|
var document = envelope.Documents.
|
||||||
Where(d => d.Id == documentId).
|
Where(d => d.Id == documentId).
|
||||||
|
|||||||
5
EnvelopeGenerator.Web/Pages/FinishEnvelope.razor
Normal file
5
EnvelopeGenerator.Web/Pages/FinishEnvelope.razor
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
@page "/EnvelopeKey/Finish"
|
||||||
|
|
||||||
|
<h3>Dokumente signiert</h3>
|
||||||
|
|
||||||
|
<p>Sie haben den Umschlag erfolgreich signiert!</p>
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using EnvelopeGenerator.Web.Handler;
|
using EnvelopeGenerator.Web.Handler;
|
||||||
using EnvelopeGenerator.Web.Services;
|
using EnvelopeGenerator.Web.Services;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.AspNetCore.Components.Web;
|
using Microsoft.AspNetCore.Components.Web;
|
||||||
|
|
||||||
@@ -35,10 +36,12 @@ app.UseStaticFiles();
|
|||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
// Add file download endpoint
|
// Add file download endpoint
|
||||||
app.MapGet("/api/document/{envelopeKey}", FileHandler.HandleGetDocument);
|
FileHandler handler = new();
|
||||||
app.MapPost("/api/document/{envelopeKey}", FileHandler.HandlePostDocument);
|
|
||||||
app.MapGet("/api/envelope/{envelopeKey}", FileHandler.HandleGetEnvelope);
|
app.MapGet("/api/document/{envelopeKey}", handler.HandleGetDocument);
|
||||||
app.MapPost("/api/envelope/{envelopeKey}", FileHandler.HandlePostEnvelope);
|
app.MapPost("/api/document/{envelopeKey}", handler.HandlePostDocument);
|
||||||
|
app.MapGet("/api/envelope/{envelopeKey}", handler.HandleGetEnvelope);
|
||||||
|
app.MapPost("/api/envelope/{envelopeKey}", handler.HandlePostEnvelope);
|
||||||
|
|
||||||
// Blazor plumbing
|
// Blazor plumbing
|
||||||
app.MapBlazorHub();
|
app.MapBlazorHub();
|
||||||
|
|||||||
@@ -78,7 +78,11 @@ export class App {
|
|||||||
const json = await App.Instance.exportInstantJSON()
|
const json = await App.Instance.exportInstantJSON()
|
||||||
console.log(json);
|
console.log(json);
|
||||||
console.log(JSON.stringify(json));
|
console.log(JSON.stringify(json));
|
||||||
const result = await App.Network.postEnvelope(App.envelopeKey, App.currentDocument.id, JSON.stringify(json))
|
const result: boolean = await App.Network.postEnvelope(App.envelopeKey, App.currentDocument.id, JSON.stringify(json))
|
||||||
|
|
||||||
|
if (result == true) {
|
||||||
|
alert("Dokument erfolgreich signiert!")
|
||||||
|
}
|
||||||
|
|
||||||
// Flatten the annotations and save the document to disk
|
// Flatten the annotations and save the document to disk
|
||||||
/*
|
/*
|
||||||
@@ -202,7 +206,7 @@ class Network {
|
|||||||
.then(res => res.json());
|
.then(res => res.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
public postEnvelope(envelopeKey: string, documentId: number, jsonString: string): Promise<any> {
|
public postEnvelope(envelopeKey: string, documentId: number, jsonString: string): Promise<boolean> {
|
||||||
const options: RequestInit = {
|
const options: RequestInit = {
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -210,11 +214,23 @@ class Network {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return fetch(`/api/envelope/${envelopeKey}?index=${documentId}`, options)
|
return fetch(`/api/envelope/${envelopeKey}?index=${documentId}`, options)
|
||||||
.then(res => {
|
.then(this.handleResponse)
|
||||||
console.log(res)
|
.then((res: Response) => {
|
||||||
res.json()
|
if (!res.ok) {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private handleResponse(res: Response) {
|
||||||
|
if (!res.ok) {
|
||||||
|
console.log(`Request failed with status ${res.status}`)
|
||||||
|
return res
|
||||||
|
} else {
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -133,16 +133,12 @@ var App = /** @class */ (function () {
|
|||||||
json = _a.sent();
|
json = _a.sent();
|
||||||
console.log(json);
|
console.log(json);
|
||||||
console.log(JSON.stringify(json));
|
console.log(JSON.stringify(json));
|
||||||
return [4 /*yield*/, App.Network.postEnvelope(App.envelopeKey, App.currentDocument.id, JSON.stringify(json))
|
return [4 /*yield*/, App.Network.postEnvelope(App.envelopeKey, App.currentDocument.id, JSON.stringify(json))];
|
||||||
// Flatten the annotations and save the document to disk
|
|
||||||
/*
|
|
||||||
const buffer = await App.Instance.exportPDF({ flatten: true });
|
|
||||||
const result = await App.Network.postDocument(App.envelopeKey, App.currentDocument.id, buffer);
|
|
||||||
console.log(result)
|
|
||||||
*/
|
|
||||||
];
|
|
||||||
case 3:
|
case 3:
|
||||||
result = _a.sent();
|
result = _a.sent();
|
||||||
|
if (result == true) {
|
||||||
|
alert("Dokument erfolgreich signiert!");
|
||||||
|
}
|
||||||
return [2 /*return*/];
|
return [2 /*return*/];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -286,11 +282,24 @@ var Network = /** @class */ (function () {
|
|||||||
body: jsonString
|
body: jsonString
|
||||||
};
|
};
|
||||||
return fetch("/api/envelope/".concat(envelopeKey, "?index=").concat(documentId), options)
|
return fetch("/api/envelope/".concat(envelopeKey, "?index=").concat(documentId), options)
|
||||||
|
.then(this.handleResponse)
|
||||||
.then(function (res) {
|
.then(function (res) {
|
||||||
console.log(res);
|
if (!res.ok) {
|
||||||
res.json();
|
return false;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Network.prototype.handleResponse = function (res) {
|
||||||
|
if (!res.ok) {
|
||||||
|
console.log("Request failed with status ".concat(res.status));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
return Network;
|
return Network;
|
||||||
}());
|
}());
|
||||||
var UI = /** @class */ (function () {
|
var UI = /** @class */ (function () {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user