refactor(EnvelopeController): update EnvelopeReceiverReadOnly to use without then-calback-method
This commit is contained in:
parent
95fd16fff0
commit
e2df610544
@ -367,40 +367,39 @@ public class EnvelopeController : ViewControllerBase
|
|||||||
if (DateTime.Now > erro.DateValid)
|
if (DateTime.Now > erro.DateValid)
|
||||||
return View("EnvelopeExpired");
|
return View("EnvelopeExpired");
|
||||||
|
|
||||||
return await _envRcvService.ReadByUuidSignatureAsync(uuid: erro.Envelope!.Uuid, erro.Receiver!.Signature).ThenAsync(
|
var erRes = await _envRcvService.ReadByUuidSignatureAsync(uuid: erro.Envelope!.Uuid, erro.Receiver!.Signature);
|
||||||
SuccessAsync: async er =>
|
if (erRes.IsFailed)
|
||||||
{
|
{
|
||||||
var envelopeKey = (er.Envelope!.Uuid, er.Receiver!.Signature).ToEnvelopeKey();
|
_logger.LogNotice(erRes.Notices);
|
||||||
|
|
||||||
//TODO: implement multi-threading to history process (Task)
|
|
||||||
var hist_res = await _historyService.RecordAsync((int)erro.EnvelopeId, erro.AddedWho, EnvelopeStatus.EnvelopeViewed);
|
|
||||||
if (hist_res.IsFailed)
|
|
||||||
{
|
|
||||||
_logger.LogError(
|
|
||||||
"Although the envelope was sent as read-only, the EnvelopeShared hisotry could not be saved. ReadOnly-Id: {readOnlyKey}\nEnvelope Receiver:\n{envelopeReceiver}",
|
|
||||||
readOnlyId, JsonConvert.SerializeObject(er));
|
|
||||||
_logger.LogNotice(hist_res.Notices);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (er.Envelope.Documents?.FirstOrDefault() is DocumentDto doc && doc.ByteData is not null)
|
|
||||||
{
|
|
||||||
ViewData["DocumentBytes"] = doc.ByteData;
|
|
||||||
ViewData["EnvelopeKey"] = envelopeKey;
|
|
||||||
ViewData["IsReadOnly"] = true;
|
|
||||||
ViewData["ReadOnly"] = erro;
|
|
||||||
ViewData["PSPDFKitLicenseKey"] = _configuration["PSPDFKitLicenseKey"];
|
|
||||||
return View("ShowEnvelope", er);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.LogEnvelopeError(envelopeReceiverId: envelopeKey, message: "No document byte-data was found in ENVELOPE_DOCUMENT table.");
|
|
||||||
return this.ViewDocumentNotFound();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Fail: (messages, notices) =>
|
|
||||||
{
|
|
||||||
_logger.LogNotice(notices);
|
|
||||||
return this.ViewEnvelopeNotFound();
|
return this.ViewEnvelopeNotFound();
|
||||||
});
|
}
|
||||||
|
var er = erRes.Data;
|
||||||
|
|
||||||
|
var envelopeKey = (er.Envelope!.Uuid, er.Receiver!.Signature).ToEnvelopeKey();
|
||||||
|
|
||||||
|
//TODO: implement multi-threading to history process (Task)
|
||||||
|
var hist_res = await _historyService.RecordAsync((int)erro.EnvelopeId, erro.AddedWho, EnvelopeStatus.EnvelopeViewed);
|
||||||
|
if (hist_res.IsFailed)
|
||||||
|
{
|
||||||
|
_logger.LogError(
|
||||||
|
"Although the envelope was sent as read-only, the EnvelopeShared hisotry could not be saved. ReadOnly-Id: {readOnlyKey}\nEnvelope Receiver:\n{envelopeReceiver}",
|
||||||
|
readOnlyId, JsonConvert.SerializeObject(er));
|
||||||
|
_logger.LogNotice(hist_res.Notices);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (er.Envelope.Documents?.FirstOrDefault() is DocumentDto doc && doc.ByteData is not null)
|
||||||
|
{
|
||||||
|
ViewData["DocumentBytes"] = doc.ByteData;
|
||||||
|
ViewData["EnvelopeKey"] = envelopeKey;
|
||||||
|
ViewData["IsReadOnly"] = true;
|
||||||
|
ViewData["ReadOnly"] = erro;
|
||||||
|
ViewData["PSPDFKitLicenseKey"] = _configuration["PSPDFKitLicenseKey"];
|
||||||
|
return View("ShowEnvelope", er);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogEnvelopeError(envelopeReceiverId: envelopeKey, message: "No document byte-data was found in ENVELOPE_DOCUMENT table.");
|
||||||
|
return this.ViewDocumentNotFound();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user