예제 #1
0
        /// <summary>
        /// Gets document stream of latest version of given document ID.
        /// If version ID is null, it retrieves latest version of requested document ID.
        /// </summary>
        /// <param name="getDocumentStreamRequest">Request parameters.</param>
        /// <returns>Response for stream of latest version of requested document.</returns>
        public async Task <GetDocumentStreamResponse> GetDocumentStreamAsync(GetDocumentStreamRequest getDocumentStreamRequest)
        {
            String versionId = getDocumentStreamRequest.VersionId;

            if (versionId == null)
            {
                GetDocumentRequest getDocumentRequest = new GetDocumentRequest()
                {
                    DocumentId          = getDocumentStreamRequest.DocumentId,
                    AuthenticationToken = authenticationToken
                };

                GetDocumentResponse response = await client.GetDocumentAsync(getDocumentRequest).ConfigureAwait(false);

                versionId = response.Metadata.LatestVersionMetadata.Id;
            }

            Stream documentVersionStream = await GetDocumentVersionStreamAsync(getDocumentStreamRequest.DocumentId, versionId).ConfigureAwait(false);

            GetDocumentStreamResponse getDocumentStreamResponse = new GetDocumentStreamResponse(getDocumentStreamRequest)
            {
                Stream = documentVersionStream
            };

            return(getDocumentStreamResponse);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetDocumentResponse response = new GetDocumentResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("CustomMetadata", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
                    response.CustomMetadata = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Metadata", targetDepth))
                {
                    var unmarshaller = DocumentMetadataUnmarshaller.Instance;
                    response.Metadata = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
예제 #3
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetDocumentResponse response = new GetDocumentResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Content", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Content = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Name", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Name = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
예제 #4
0
        private DocumentView GetDocumentView(string id)
        {
            GetRequest request = new GetRequest();

            request.ID = Guid.Parse(id);

            GetDocumentResponse response = this._documentService.GetDocument(request);

            return(response.DocumentView);
        }
예제 #5
0
        public async Task <GetDocumentResponse> Upload(byte[] fileBytes, CreateDocumentRequest request)
        {
            GetDocumentResponse response = new GetDocumentResponse();

            if (fileBytes.Length > 0)
            {
                var pandaDocHelper = new PandaDocHelper();
                var docresponse    = await pandaDocHelper.CreateDocument(fileBytes, request);

                response = docresponse;
            }
            return(response);
        }
예제 #6
0
        internal static async Task Execute(Client client)
        {
            string documentReference = Guid.NewGuid().ToString();

            GetDocumentResponse result = await client.PurchaseInvoices.GetDocumentDetailsAsync(documentReference);

            Console.WriteLine($"Reference: ", result.Reference);

            var xmlResult = await client.PurchaseInvoices.Xml(documentReference);

            string xml = xmlResult.Content.ToString();

            Console.WriteLine($"Xml: ", xml);
        }
예제 #7
0
        public async Task <GetDocumentResponse> Upload(IFormFile file, CreateDocumentRequest request)
        {
            byte[] fileContent;
            GetDocumentResponse response = new GetDocumentResponse();

            if (file.Length > 0)
            {
                using (var ms = new MemoryStream())
                {
                    file.CopyTo(ms);
                    fileContent = ms.ToArray();
                }
                var pandaDocHelper = new PandaDocHelper();
                var docresponse    = await pandaDocHelper.CreateDocument(fileContent, request);

                response = docresponse;
            }
            return(response);
        }
예제 #8
0
 private static void ReplaceToc(string tocString)
 {
     string[] targetTocs = { "toc.json" };
     foreach (var toc in targetTocs)
     {
         CancellationToken   cancellationToken = new CancellationToken();
         GetDocumentResponse document          = Client.GetDocument(newDepotName, toc, "en-us", 0, "master", false, null, cancellationToken).Result;
         if (toc.Split('/').Length > 1)
         {
             var json = JsonConvert.DeserializeObject <JArray>(tocString);
             Traverse(json, null);
             tocString = JsonConvert.SerializeObject(json);
         }
         Client.PutDocument(newDepotName, toc, "en-us", 0, "master", new PutDocumentRequest
         {
             Metadata         = document.Metadata,
             ContentSourceUri = GetBlobUrlByCreatingOne(tocString)
         }, null, cancellationToken).Wait();
     }
 }
예제 #9
0
        public async Task <GetDocumentResponse> Upload()
        {
            byte[] fileContent;
            GetDocumentResponse response = new GetDocumentResponse();

            if (HttpContext.Current.Request.Files.Count == 1)
            {
                using (var fs = HttpContext.Current.Request.Files[0].InputStream)
                {
                    BinaryReader br = new BinaryReader(fs);
                    fileContent = br.ReadBytes((int)fs.Length);
                }
                var pandaDocHelper            = new PandaDocHelper();
                CreateDocumentRequest request = CreateDocumentRequest();
                var docresponse = await pandaDocHelper.CreateDocument(fileContent, request);

                response = docresponse.Value;
            }
            return(response);
        }
예제 #10
0
        public GetDocumentResponse GetDocument(GetRequest request)
        {
            GetDocumentResponse response = new GetDocumentResponse();

            try
            {
                Document     document     = new Document();
                DocumentView documentView = document.ConvertToDocumentView();

                document = _documentRepository.FindBy(request.ID);
                if (document != null)
                {
                    documentView = document.ConvertToDocumentView();
                }

                response.DocumentView = documentView;
            }
            catch (Exception ex)
            {
            }

            return(response);
        }
예제 #11
0
        private bool MapDocumentToEfolder(Loan loan, BlendDocReturned document, TrackedDocument eFolder)
        {
            string docId = document.Id;

            try
            {
                var url = WcmSettings.GetDocumentFromBlendUri;


                GetDocumentResponse docResponse = BlendUtility.GetDocumentFromBlendPortal(docId, url);

                var data = new EllieMae.Encompass.BusinessObjects.DataObject(docResponse.DocumentData);
                EllieMae.Encompass.BusinessObjects.Loans.Attachment attachment = loan.Attachments.AddObject(data, ".pdf");
                attachment.Title = $"{document.Name}";

                eFolder.Attach(attachment);

                // once attached go update the export status

                var uri           = WcmSettings.UpdateDocExportStatusBlendUri;
                var updateRequest = new UpdateDocumentExportStatusRequest()
                {
                    BlendDocumentId       = docId,
                    UtcDocumentExportTime = DateTime.UtcNow.ToShortDateString()
                };
                var requestTest    = Newtonsoft.Json.JsonConvert.SerializeObject(updateRequest);
                var updateResponse = BlendUtility.PostDocumentExportStatusUpdate(updateRequest, uri);
            }
            catch (Exception ex)
            {
                Macro.Alert($"Error mapping {document.Name} to eFolder. Please submit a Help Desk Ticket." + Environment.NewLine + $"Error Message: {ex.Message}");
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetDocumentResponse response = new GetDocumentResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("AttachmentsContent", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <AttachmentContent, AttachmentContentUnmarshaller>(AttachmentContentUnmarshaller.Instance);
                    response.AttachmentsContent = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Content", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Content = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("DocumentFormat", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.DocumentFormat = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("DocumentType", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.DocumentType = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("DocumentVersion", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.DocumentVersion = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Name", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Name = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Requires", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <DocumentRequires, DocumentRequiresUnmarshaller>(DocumentRequiresUnmarshaller.Instance);
                    response.Requires = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Status", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Status = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("StatusInformation", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.StatusInformation = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("VersionName", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.VersionName = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        public override GetDocumentResponse <T> ReadJson(JsonReader reader, Type objectType, GetDocumentResponse <T> existingValue,
                                                         bool hasExistingValue, JsonSerializer serializer)
        {
            JObject jObject = JObject.Load(reader);

            return(new GetDocumentResponse <T>(jObject.ToObject <T>()));
        }
 public override void WriteJson(JsonWriter writer, GetDocumentResponse <T> value, JsonSerializer serializer)
 {
     throw new NotImplementedException();
 }