Beispiel #1
0
        public static void uploadDocument(IDictionary <string, string> localParams, string envelopeId, string documentId, DocumentOptions options, string docClass, string docType)
        {
            Log.Info("Environment : " + localParams[EnvelopeMetaFields.Environment] + " - Account Id : " + localParams[EnvelopeMetaFields.AccountId] + " - Envelope Id : " + envelopeId + " - document Id : " + documentId + " - Option : " + options);

            //Now retrieve the documents for the given envelope from the accountId hosted in environment as combined
            MemoryStream docStream = DocuSignService.GetDocument(localParams[EnvelopeMetaFields.Environment],
                                                                 localParams[EnvelopeMetaFields.AccountId],
                                                                 envelopeId,
                                                                 documentId,
                                                                 options);

            // Now upload the bytes for the document that we just retrieved in cm
            byte[] buffer = ServiceUtil.ReadFully(docStream);

            string exFolderUri = exFolderUri = ConfigurationManager.AppSettings["exFolderUri"];

            AuthenticationData authData = CMWebServiceClient.setupAuthData();

            MTOMAttachment[] mtomAttachment = CMWebServiceClient.setupAttachments(new string[, ] {
                { "doc", "application/pdf" }
            }, buffer);

            //check for cach
            //check for  hangfire flag
            ObjectCache cache        = MemoryCache.Default;
            string      cacheItemUri = cache["cacheItemUri"] as string;
            string      itemUri      = null;

            if (cacheItemUri == null)
            {
                CacheItemPolicy policy = new CacheItemPolicy();
                policy.AbsoluteExpiration = DateTime.Now.AddHours(36);
                itemUri      = CMWebServiceClient.createItem(authData, mtomAttachment, docClass, docType, localParams[EnvelopeMetaFields.EID], localParams[EnvelopeMetaFields.FirstName], localParams[EnvelopeMetaFields.LastName]);
                cacheItemUri = itemUri;
                cache.Set("cacheItemUrl", cacheItemUri, policy);
                Log.Info("Cache Value for : " + envelopeId + " is : " + cacheItemUri);
            }
            //setcach
            //set a hangfire flag
            Log.Info("The Following CM Item was Created. Item Uri :: " + itemUri);
            string folderUri = CMWebServiceClient.getItemUri(authData, "HrEmpFolder", localParams[EnvelopeMetaFields.EID]);

            if (folderUri == null)
            {
                CMWebServiceClient.addItemToFolder(authData, exFolderUri, itemUri);
                Log.Info("No Folder Matching the Employee ID was found. Item was placed in the following Exception Folder - Folder URI :: " + folderUri);
            }
            else
            {
                CMWebServiceClient.addItemToFolder(authData, folderUri, itemUri);
                Log.Info("Item was placed in the following Folder - Folder URI ::" + folderUri);
            }
        }
Beispiel #2
0
        public static void uploadDocument(IDictionary <string, string> localParams,
                                          string envelopeId, string documentId, DocumentOptions options)
        {
            //Now retrieve the documents for the given envelope from the accountId hosted in environment as combined
            MemoryStream docStream = DocuSignService.GetDocument(localParams[EnvelopeMetaFields.Environment],
                                                                 localParams[EnvelopeMetaFields.AccountId],
                                                                 envelopeId,
                                                                 documentId,
                                                                 options);


            // Now upload the bytes for teh document that we just retrieved in Documentum
            byte[] buffer   = ServiceUtil.ReadFully(docStream);
            var    response = DocumentumService.uploadDocument(localParams, buffer);

            Log.Debug("Properties created: ");
        }