Ejemplo n.º 1
0
        public string SendSubDOManifestToBizTalk(HttpPostedFileBase manifestFile, string uCode, string cCode, string centerCode, string billType)
        {
            var response = string.Empty;
            IWebClientHelper    helper = new WebClientHelper();
            SubmitSubDOManifest subDOManifestRequest = new SubmitSubDOManifest();
            SubDOMF             manifest             = new SubDOMF();
            SubDOMFHeader       header = new SubDOMFHeader();
            SubDOMFBody         body   = new SubDOMFBody();

            byte[] fileBytes;
            using (Stream inputStream = manifestFile.InputStream)
            {
                MemoryStream memoryStream = inputStream as MemoryStream;
                if (memoryStream == null)
                {
                    memoryStream = new MemoryStream();
                    inputStream.CopyTo(memoryStream);
                }
                fileBytes = memoryStream.ToArray();
            }

            header.DocumentReference = Guid.NewGuid().ToString();
            header.Sender            = "Mamar";
            header.Receiver          = "Customs";
            header.MessageType       = "SubmitManifest";

            body.CenterCode     = centerCode;
            body.UserCode       = uCode;
            body.CompanyCode    = cCode;
            body.ManifestBase64 = fileBytes;
            body.BillType       = billType;

            manifest.Header = header;
            manifest.Body   = body;

            subDOManifestRequest.SubmitManifest = manifest;

            response = helper.SendSubDOManifestToBizTalk(subDOManifestRequest, header.DocumentReference);

            return(response);
        }