Esempio n. 1
0
        public IActionResult GetEnvelopeStatus([FromServices] IStatusBuilder builder, string envelopeId)
        {
            try
            {
                string username, password;
                ExtractHeaderValues(Request.Headers, out username, out password);

                if (envelopeId == null)
                {
                    throw new SigSvcParamError("Request format incorrect; check query string syntax passes envelopeId correctly.");
                }

                IResponse response;
                if (builder.Build(envelopeId, username, password, out response))
                {
                    return(ResultFormatter.Format(200, response));
                }
                else
                {
                    return(ResultFormatter.Format(400, response));
                }
            }
            catch (SigSvcPostBodyError error)
            {
                _logger.Error(error, "GET envelope/{envelopeId}/status");
                return(ResultFormatter.Format(400, error));
            }
            catch (Exception exc)
            {
                _logger.Error(exc, "GET envelope/{envelopeId}/status");
                return(ResultFormatter.Format(500, exc));
            }
        }
Esempio n. 2
0
        private void CheckSignatureStatuses()
        {
            // todo: need thread safety here ?   Will race condition occur? critical section?  Reading all of them, updating existing ones?

            // read all signatures from DB
            List <DataModels.Signature> signatures = _repo.ReadAllSignatures();

            foreach (DataModels.Signature signature in signatures)
            {
                if (signature.Status != "completed" &
                    signature.Status != "declined" &
                    signature.Status != "voided" &
                    signature.Status != "expired")
                {
                    IResponse response;
                    string    envelopeId = signature.EnvelopeId.ToString();
                    _statusBuilder.Build(envelopeId, signature.DocuSignUsername, signature.DocuSignPassword, out response); // get current DocuSign status
                    string currentStatus = ((EnvelopeStatus)response.Data).Status;
                    if (!(string.Compare(currentStatus, signature.Status) == 0))                                            // if status is different
                    {
                        _logger.Debug($"Updating status:  from: {signature.Status} to: {currentStatus} EnvelopeId {envelopeId} ");
                        signature.Status = currentStatus;
                        _repo.UpdateSignature(signature);                               // save current status to database
                    }
                }
            }

            // end critical section ?
        }