Ejemplo n.º 1
0
        private void AddDocumentsToContext(NodeDocument[] documents)
        {
            this.SetMustUnderstand();
            SoapContext requestSoapContext = this.requestor.RequestSoapContext;
            Hashtable   hashtable          = new Hashtable();

            this.RaiseRequestorEvent("Parsing Documents");
            for (int i = 0; i < documents.Length; i++)
            {
                DimeAttachment attachment = new DimeAttachment();
                attachment.TypeFormat = TypeFormatEnum.MediaType;
                attachment.Type       = "application/octet-stream";
                attachment.Id         = string.Format("Document-{0}", i);
                attachment.Stream     = new MemoryStream(documents[i].content);
                requestSoapContext.Attachments.Add(attachment);
                hashtable.Add(documents[i].name, attachment.Id);
                this.RaiseRequestorEvent("Document Parsed");
            }
            requestSoapContext.Add("hrefs", hashtable);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Download
        /// </summary>
        /// <param name="securityToken"></param>
        /// <param name="transactionId"></param>
        /// <param name="dataflow"></param>
        /// <param name="documents"></param>
        void INetworkNodeBinding.Download(string securityToken, string transactionId, string dataflow, ref NodeDocument[] documents)
        {
            Init();
            LOG.Debug("Download");

            if (string.IsNullOrEmpty(transactionId))
            {
                throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ENExceptionCodeType.E_InvalidParameter,
                                                                "NULL Transaction Id");
            }

            try
            {
                SoapContext res = HttpSoapContext.ResponseContext;

                LOG.Debug("Getting visit");
                NamedEndpointVisit visit = _service11Provider.VisitProvider.GetVisit(securityToken);

                ComplexContent content = new ComplexContent();
                if (!string.IsNullOrEmpty(dataflow))
                {
                    content.Flow = new OperationDataFlow(dataflow);
                }
                content.Transaction = new SimpleId(transactionId);

                LOG.Debug("Submitting: " + content);
                IList <Document> wnosDocs = _service11Provider.ContentService.Download(content, visit);


                List <NodeDocument> wsdlDocList = new List <NodeDocument>();

                if (!CollectionUtils.IsNullOrEmpty(wnosDocs))
                {
                    Dictionary <string, string> docIdList = new Dictionary <string, string>();

                    LOG.Debug("Spooling documents");
                    foreach (Document wnosDoc in wnosDocs)
                    {
                        NodeDocument doc = new NodeDocument();

                        doc.content = wnosDoc.Content;
                        doc.type    = CommonContentAndFormatProvider.ConvertTo11Enum(wnosDoc.Type);
                        doc.name    = wnosDoc.DocumentName;
                        LOG.Debug("   doc:" + doc);

                        DimeAttachment attachment = new DimeAttachment();
                        attachment.Stream     = new MemoryStream(doc.content);
                        attachment.TypeFormat = TypeFormatEnum.MediaType;
                        attachment.Type       = "application/x-gzip";
                        attachment.Id         = Guid.NewGuid().ToString();

                        //Add to the the xref filter collection
                        docIdList.Add(doc.name, attachment.Id);

                        res.Attachments.Add(attachment);
                        wsdlDocList.Add(doc);
                    }
                    //Output filter specific
                    res.Add("hrefs", docIdList);
                }

                documents = wsdlDocList.ToArray();
            }
            catch (Exception ex)
            {
                LOG.Error("Error while downloading", ex);
                throw _service11Provider.FaultProvider.GetFault(EndpointVersionType.EN11, ex);
            }
        }