Example #1
0
 private void HydrateDocuments()
 {
     using (var context = DNAContextFactory.CreateDNAContext())
     {
         List <Document> docs = new List <Document>();
         context.Documents.Where(d => d.RequestedBy == this.CurrentUser).OrderByDescending(d => d.RequestedDate).ToList().ForEach(d => docs.Add(d));
         this.Documents = docs;
     }
 }
Example #2
0
        public static byte[] GetDocumentByEnvelopeId(string envelopeId)
        {
            byte[] doc = new byte[] { };

            using (var context = DNAContextFactory.CreateDNAContext())
            {
                var document = context.Documents.Where(d => d.DocuSignEnvelopId == envelopeId).FirstOrDefault();
                if (document != null)
                {
                    doc = document.DocumentPDF;
                }
            }

            return(doc);
        }
Example #3
0
 private void PersistDocumentToQueue(string envelopeId, string status)
 {
     using (var context = DNAContextFactory.CreateDNAContext())
     {
         var doc = new Document()
         {
             DocumentName      = this.FileName,
             DocuSignEnvelopId = envelopeId,
             DocumentPDF       = this.Document,
             RequestedBy       = this.CurrentUser,
             RequestedDate     = DateTime.Now,
             SentToEmail       = this.SendToEmail,
             SentToName        = this.SendToName,
             Status            = status
         };
         context.Documents.Add(doc);
         context.SaveChanges();
     }
     this.HydrateDocuments();
 }
Example #4
0
 public virtual void DeleteDocument(string envelopeId)
 {
     using (var context = DNAContextFactory.CreateDNAContext())
     {
         var doc = context.Documents.Where(d => d.DocuSignEnvelopId == envelopeId).FirstOrDefault();
         if (doc != null)
         {
             context.Documents.Remove(doc);
             context.SaveChanges();
         }
     }
     if (this.Documents != null)
     {
         var doc = this.Documents.Where(d => d.DocuSignEnvelopId == envelopeId).FirstOrDefault();
         if (doc != null)
         {
             (this.Documents as List <Document>).Remove(doc);
         }
     }
 }
Example #5
0
        private IEnumerable <Document> getStatusUpdate(IEnumerable <Document> listOfDocumentsToCheck, string statusToCheck)
        {
            List <Document> documents = listOfDocumentsToCheck.Where(d => d.Status.ToUpper() == statusToCheck.ToUpper()).ToList();

            if (documents != null && documents.Any())
            {
                DateTime minDateTime   = documents.Min(d => d.RequestedDate);
                string   formattedDate = HttpUtility.UrlEncode(minDateTime.ToString("MM/dd/yyyy")).Replace("+", "%20");
                string   url           = this.DocuSignURL + string.Format("accounts/{0}/envelopes?from_date={1}&from_to_status={2}", this.DocuSignAccountId, formattedDate, statusToCheck.ToLower());
                dynamic  jsonResponse  = this.GetJSONRestResponse(url);

                using (var context = DNAContextFactory.CreateDNAContext())
                {
                    foreach (var item in jsonResponse.envelopes)
                    {
                        string envelopeId = item.envelopeId.ToString();
                        var    doc        = listOfDocumentsToCheck.Where(d => d.DocuSignEnvelopId == envelopeId).FirstOrDefault();
                        if (doc != null)
                        {
                            if (doc.Status.ToUpper() != item.status.ToString().ToUpper())
                            {
                                doc.Status = item.status.ToString().ToUpper();
                                var dbDoc = context.Documents.Where(d => d.DocuSignEnvelopId == envelopeId).FirstOrDefault();
                                if (dbDoc != null)
                                {
                                    dbDoc.Status      = item.status.ToString().ToUpper();
                                    dbDoc.DocumentPDF = this.GetDocument(envelopeId);
                                    doc.DocumentPDF   = dbDoc.DocumentPDF;
                                }
                            }
                        }
                    }
                    context.SaveChanges();
                }
            }
            return(listOfDocumentsToCheck);
        }