Пример #1
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            string Key             = txtKey.Text;
            string PropertyPath    = txtPropertyPath.Text;
            string DestinationPath = txtDestinationPath.Text;
            string ListName        = txtListName.Text;

            IBaseMessage message = MessageHelper.CreateFromString("<testfile/>");

            message.Context.Promote(new ContextProperty(PropertyPath), Key);

            var component = new SharepointLookup()
            {
                Disabled        = false,
                PropertyPath    = PropertyPath,
                DestinationPath = DestinationPath,
                ListName        = ListName,
                ThrowException  = true,
                PromoteProperty = true
            };

            SendPipelineWrapper sendPipeline = PipelineFactory.CreateEmptySendPipeline();

            sendPipeline.AddComponent(component, PipelineStage.PreAssemble);

            IBaseMessage results = sendPipeline.Execute(message);

            string result = (string)results.Context.Read(new ContextProperty(DestinationPath));

            txtResult.Text = result;
        }
Пример #2
0
        public void CanCreateTransaction()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateSendPipeline(typeof(XMLTransmit));

            using (TransactionControl control = pipeline.EnableTransactions())
            {
                // Create the input message to pass through the pipeline
                Stream       stream       = DocLoader.LoadStream("SampleDocument.xml");
                IBaseMessage inputMessage = MessageHelper.CreateFromStream(stream);

                // Add the necessary schemas to the pipeline, so that
                // disassembling works
                pipeline.AddDocSpec(typeof(Schema1_NPP));
                pipeline.AddDocSpec(typeof(Schema2_WPP));

                MessageCollection inputMessages = new MessageCollection();
                inputMessages.Add(inputMessage);

                // Execute the pipeline, and check the output
                IBaseMessage outputMessage = pipeline.Execute(inputMessages);

                Assert.IsNotNull(outputMessage);
                control.SetComplete();
            }
        }
Пример #3
0
        public void ThrowExceptionWhenInputMsgCollectionIsEmpty()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateSendPipeline(typeof(XMLTransmit));

            pipeline.Execute(new MessageCollection());
        }
Пример #4
0
        public void CanExecutePipelineWithMultiInputMsgs()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateSendPipeline(typeof(Env_SendPipeline));

            // Create the input message to pass through the pipeline
            string body =
                @"<o:Body xmlns:o='http://SampleSchemas.SimpleBody'>
               this is a body</o:Body>";

            // Add the necessary schemas to the pipeline, so that
            // assembling works
            pipeline.AddDocSpec(typeof(SimpleBody));
            pipeline.AddDocSpec(typeof(SimpleEnv));

            // original code:
            // MessageCollection inputMessages = new MessageCollection();
            // inputMessages.Add(MessageHelper.CreateFromString(body));
            // inputMessages.Add(MessageHelper.CreateFromString(body));
            // inputMessages.Add(MessageHelper.CreateFromString(body));

            // Execute the pipeline, and check the output
            // we get a single message batched with all the
            // messages grouped into the envelope's body
            IBaseMessage outputMessage = pipeline.Execute(
                MessageHelper.CreateFromString(body),
                MessageHelper.CreateFromString(body),
                MessageHelper.CreateFromString(body)
                );

            Assert.IsNotNull(outputMessage);
        }
Пример #5
0
        public void ThrowExceptionWhenInputMsgIsNull()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateSendPipeline(typeof(XMLTransmit));

            pipeline.Execute((MessageCollection)null);
        }
        public void TestPipeline()
        {
            IBaseMessage msg = MessageHelper.CreateFromString(Resource.GoogleBucketEntry_1);

            rcvpipeline.AddDocSpec(typeof(Schemas.BucketClaimCheck));



            MessageCollection messages = rcvpipeline.Execute(msg);

            IBaseMessage message = messages[0];



            SendPipelineWrapper snddirectpipeline = PipelineFactory.CreateSendPipeline(typeof(Pipelines.ClaimCheckSendPipeline));



            IBaseMessage sendmessage = snddirectpipeline.Execute(messages);



            Diff myDiff = DiffBuilder.Compare(Input.FromString(Resource.GoogleBucketResult))
                          .WithTest(Input.FromStream(sendmessage.BodyPart.Data))
                          .CheckForIdentical().Build();


            Assert.IsFalse(myDiff.HasDifferences());
        }
Пример #7
0
        private static Stream Assemble(Assembler component, Stream inputDocument)
        {
            SendPipelineWrapper pipeline = Pipelines.Send()
                                           .WithAssembler(component);
            IBaseMessage output = pipeline.Execute(
                MessageHelper.CreateFromStream(inputDocument)
                );

            return(output.BodyPart.GetOriginalDataStream());
        }
Пример #8
0
        public void SetFileName_ShouldIncludeSourceFilename()
        {
            var component = new SetFileName()
            {
                IncludeOriginalFilename = true
            };

            pipeline.AddComponent(component, PipelineStage.Encode);

            var result = pipeline.Execute(msg);

            string newFileName = result.Context.Read(receivedFileName.PropertyName,
                                                     receivedFileName.PropertyNamespace).ToString();

            Assert.AreEqual(originalFileName, newFileName);
        }
Пример #9
0
        public void CanReadXmlAssemblerStream()
        {
            SendPipelineWrapper pipeline = Pipelines.Xml.Send()
                                           .WithSpec <Schema3_FF>();
            IBaseMessage input = MessageHelper.CreateFromStream(
                DocLoader.LoadStream("CSV_XML_SendInput.xml")
                );
            IBaseMessage output = pipeline.Execute(input);

            Assert.IsNotNull(output);
            // doc should load fine
            XmlDocument doc = new XmlDocument();

            doc.Load(output.BodyPart.Data);
            XmlNodeList fields = doc.SelectNodes("//*[local-name()='Field3']");

            Assert.Greater(fields.Count, 0);
        }
Пример #10
0
        public void CanExecuteEmptyPipeline()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateEmptySendPipeline();

            // Create the input message to pass through the pipeline
            Stream       stream       = DocLoader.LoadStream("SampleDocument.xml");
            IBaseMessage inputMessage = MessageHelper.CreateFromStream(stream);

            MessageCollection inputMessages = new MessageCollection();

            inputMessages.Add(inputMessage);

            // Execute the pipeline, and check the output
            IBaseMessage outputMessage = pipeline.Execute(inputMessages);

            Assert.IsNotNull(outputMessage);
        }
Пример #11
0
        public void Test()
        {
            var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            if (config.AppSettings.Settings["SharePointSite"] == null)
            {
                config.AppSettings.Settings.Add("SharePointSite", "https://TestUrl.org");
            }
            else
            {
                config.AppSettings.Settings["SharePointSite"].Value = "https://TestUrl.org";
            }

            string Key             = "274";
            string DestinationPath = "https://Test.Schemas.PropertySchema#Destination";

            IBaseMessage message = MessageHelper.CreateFromString("<Test/>");

            message.Context.Write("Key", "https://Test.Schemas.PropertySchema", Key);
            message.Context.Write("DestinationPath", "https://Test.Schemas.PropertySchema", DestinationPath);

            var component = new SharepointLookup()
            {
                Disabled        = false,
                PropertyPath    = "https://Test.Schemas.PropertySchema#Key",
                DestinationPath = "https://Test.Schemas.PropertySchema#DestinationPath",
                ListName        = "TestList",
                ThrowException  = true,
                PromoteProperty = true
            };

            SendPipelineWrapper sendPipeline = PipelineFactory.CreateEmptySendPipeline();

            sendPipeline.AddComponent(component, PipelineStage.PreAssemble);

            IBaseMessage results = sendPipeline.Execute(message);

            Assert.AreEqual(Key, results.Context.Read("StoreId", "https://Test.Schemas.PropertySchema"));

            Assert.IsTrue(results.Context.IsPromoted("DestinationPath", "https://Test.Schemas.PropertySchema"));
        }
        public void TestGoogleBucket()
        {
            IBaseMessage msg = MessageHelper.CreateFromString(Resource.GoogleBucketEntry_1);

            rcvpipeline.AddDocSpec(typeof(Schemas.BucketClaimCheck));



            MessageCollection messages = rcvpipeline.Execute(msg);

            IBaseMessage message = messages[0];



            ClaimCheckPipelineComponent claimCheckPipelineComponent = new ClaimCheckPipelineComponent();

            claimCheckPipelineComponent.Enabled            = true;
            claimCheckPipelineComponent.ClientId           = "111382948100122064143";
            claimCheckPipelineComponent.ServiceAccountName = "*****@*****.**";
            FileInfo credentials  = new FileInfo(googlecredentials);
            var      jsonfilepath = credentials.FullName;

            claimCheckPipelineComponent.ServiceAccountKey = jsonfilepath;



            sndpipeline.AddComponent(claimCheckPipelineComponent, PipelineStage.Encode);

            IBaseMessage sendmessage = sndpipeline.Execute(messages);



            Diff myDiff = DiffBuilder.Compare(Input.FromString(Resource.GoogleBucketResult))
                          .WithTest(Input.FromStream(sendmessage.BodyPart.Data))
                          .CheckForIdentical().Build();


            Assert.IsFalse(myDiff.HasDifferences());
        }
Пример #13
0
        public void Send_FullPipeline()
        {
            XmlAssembler xml = XmlAssembler.Xml()
                               .WithDocumentSpec <SimpleBody>()
                               .WithEnvelopeSpec <SimpleEnv>();
            SendPipelineWrapper pipeline = Pipelines.Send()
                                           .WithAssembler(xml)
                                           .WithEncoder(new MIME_SMIME_Encoder());

            // Create the input message to pass through the pipeline
            string body =
                @"<o:Body xmlns:o='http://SampleSchemas.SimpleBody'>
               this is a body</o:Body>";
            // Execute the pipeline, and check the output
            // we get a single message batched with all the
            // messages grouped into the envelope's body
            IBaseMessage outputMessage = pipeline.Execute(
                MessageHelper.CreateFromString(body),
                MessageHelper.CreateFromString(body),
                MessageHelper.CreateFromString(body)
                );

            Assert.IsNotNull(outputMessage);
        }
Пример #14
0
        public void Test()
        {
            IBaseMessage message = MessageHelper.CreateFromString("<test/>");

            message.Context.Write("property1", "namespace1", "filename1.txt");
            message.Context.Write("property2", "namespace2", "123");

            var component = new SetHttpHeaders()
            {
                Disabled        = false,
                DestinationPath = "MyNamespace#HttpHeaders",
                HeaderNames     = "FileName;StoreID",
                PromoteProperty = true,
                PropertyPaths   = "namespace1#property1;namespace2#property2"
            };

            SendPipelineWrapper SendPipeline = PipelineFactory.CreateEmptySendPipeline();

            SendPipeline.AddComponent(component, PipelineStage.PreAssemble);

            IBaseMessage results = SendPipeline.Execute(message);

            Assert.AreEqual("FileName:filename1.txt StoreID:123", results.Context.Read("HttpHeaders", "MyNamespace"));
        }
Пример #15
0
        public void CanExecutePipelineWithFlatFile()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateSendPipeline(typeof(CSV_FF_SendPipeline));

            // Create the input message to pass through the pipeline
            Stream       stream       = DocLoader.LoadStream("CSV_XML_SendInput.xml");
            IBaseMessage inputMessage = MessageHelper.CreateFromStream(stream);

            inputMessage.BodyPart.Charset = "UTF-8";

            // Add the necessary schemas to the pipeline, so that
            // assembling works
            pipeline.AddDocSpec(typeof(Schema3_FF));

            MessageCollection inputMessages = new MessageCollection();

            inputMessages.Add(inputMessage);

            // Execute the pipeline, and check the output
            IBaseMessage outputMessage = pipeline.Execute(inputMessages);

            Assert.IsNotNull(outputMessage);
        }
Пример #16
0
        public void CanExecuteBtfAssembler()
        {
            SendPipelineWrapper pipeline =
                PipelineFactory.CreateEmptySendPipeline();

            pipeline.GroupSigningCertificate = "9302859B216AB1E97A2EB4F94E894A128E4A3B6E";

            MIME_SMIME_Encoder mime = new MIME_SMIME_Encoder();

            mime.SignatureType            = MIME_SMIME_Encoder.SMIME_SignatureType.BlobSign;
            mime.SendBodyPartAsAttachment = true;
            mime.AddSigningCertToMessage  = true;
            mime.EnableEncryption         = false;
            mime.ContentTransferEncoding  = MIME_SMIME_Encoder.MIMETransferEncodingType.SevenBit;
            pipeline.AddComponent(mime, PipelineStage.Encode);

            BTFAsmComp asm = new BTFAsmComp();

            asm.DesignProp_epsFromAddress                     = "asdasd";
            asm.DesignProp_epsFromAddressType                 = "asdad";
            asm.DesignProp_epsToAddress                       = "eweww";
            asm.DesignProp_epsToAddressType                   = " asdd";
            asm.DesignProp_isReliable                         = true;
            asm.DesignProp_propTopic                          = "wewew";
            asm.DesignProp_svcDeliveryRctRqtSendBy            = 4;
            asm.DesignProp_svcDeliveryRctRqtSendToAddress     = "ddd";
            asm.DesignProp_svcDeliveryRctRqtSendToAddressType = "sss";

            pipeline.AddComponent(asm, PipelineStage.Assemble);
            pipeline.AddDocSpec(typeof(BTF2Schemas.btf2_endpoints_header));
            pipeline.AddDocSpec(typeof(BTF2Schemas.btf2_envelope));
            pipeline.AddDocSpec(typeof(BTF2Schemas.btf2_manifest_header));
            pipeline.AddDocSpec(typeof(BTF2Schemas.btf2_process_header));
            pipeline.AddDocSpec(typeof(BTF2Schemas.btf2_receipt_header));
            pipeline.AddDocSpec(typeof(BTF2Schemas.btf2_services_header));
            pipeline.AddDocSpec(typeof(SampleSchemas.SimpleBody));

            string body =
                @"<o:Body xmlns:o='http://SampleSchemas.SimpleBody'>
               this is a body</o:Body>";
            MessageCollection inputMessages = new MessageCollection();
            IBaseMessage      inputMsg      = MessageHelper.CreateFromString(body);

            inputMsg.Context.Write("PassThroughBTF", "http://schemas.microsoft.com/BizTalk/2003/mime-properties", false);
            inputMessages.Add(inputMsg);
            inputMsg.BodyPart.PartProperties.Write("ContentTransferEncoding", "http://schemas.microsoft.com/BizTalk/2003/mime-properties", "7bit");
            IBaseMessage output = pipeline.Execute(inputMessages);

            byte[] buffer = new byte[64 * 1024];
            Stream input  = output.BodyPart.Data;
            int    bytesRead;

            Stream outputs = new FileStream("c:\\temp\\t.xml",
                                            FileMode.Truncate, FileAccess.Write);

            using ( outputs )
            {
                while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0)
                {
                    outputs.Write(buffer, 0, bytesRead);
                }
            }
        }