Ejemplo n.º 1
0
        public void ThrowExceptionWhenComponentAddedToInvalidStage()
        {
            SendPipelineWrapper pipeline = PipelineFactory.CreateEmptySendPipeline();
            IBaseComponent      encoder  = new MIME_SMIME_Encoder();

            pipeline.AddComponent(encoder, PipelineStage.ResolveParty);
        }
        public void SendHTMLFormattedEmailWithAttachment()
        {
            var pipeline  = PipelineFactory.CreateEmptySendPipeline();
            var component = new EmailCustomizer
            {
                Enabled             = true,
                FileNames           = "BodyPartASFileName.xml",
                XSLTFilePath        = TestFiles.EmailFormatterFilePath,
                ApplyXsltOnBodyPart = true// if it is true the XSLT file be aplied on the
            };

            pipeline.AddComponent(component, PipelineStage.Encode);
            //adding MIME encoder component to the sendpipeline so we can view the structure of the output message.
            var mime = new MIME_SMIME_Encoder();

            pipeline.AddComponent(mime, PipelineStage.Encode);
            //create a message with body part only.
            var message = MessageHelper.Create(System.IO.File.ReadAllText(TestFiles.BodyPart_FilePath),
                                               System.IO.File.ReadAllText(TestFiles.Part1_FilePath),
                                               System.IO.File.ReadAllText(TestFiles.Part2_FilePath));
            var output = pipeline.Execute(message);

            System.IO.StreamReader reader = new System.IO.StreamReader(output.BodyPart.GetOriginalDataStream());
            var ret = reader.ReadToEnd();
        }
Ejemplo n.º 3
0
        public void CanAddComponentToValidStage()
        {
            SendPipelineWrapper pipeline = PipelineFactory.CreateEmptySendPipeline();
            IBaseComponent      encoder  = new MIME_SMIME_Encoder();

            pipeline.AddComponent(encoder, PipelineStage.Encode);
        }
        public void SendPlainTextWithAttachment()
        {
            var pipeline  = PipelineFactory.CreateEmptySendPipeline();
            var component = new EmailCustomizer
            {
                Enabled   = true,
                FileNames = "BodyPart.xml",
                EmailBody = "This is a plain text e-mail with body part as attachment.\nRegards"
            };

            pipeline.AddComponent(component, PipelineStage.Encode);
            //adding MIME encoder component to the sendpipeline so we can view the structure of the output message.
            var mime = new MIME_SMIME_Encoder();

            pipeline.AddComponent(mime, PipelineStage.Encode);
            //create a message with body part only.
            var message = MessageHelper.Create(System.IO.File.ReadAllText(TestFiles.BodyPart_FilePath));
            var output  = pipeline.Execute(message);

            System.IO.StreamReader reader = new System.IO.StreamReader(output.BodyPart.GetOriginalDataStream());
            var ret = reader.ReadToEnd();
        }
Ejemplo n.º 5
0
        public void CanApplyConfigToPipeline()
        {
            XmlTextReader reader = new XmlTextReader(
                DocLoader.LoadStream("PipelineInstanceConfig.xml")
                );
            SendPipelineWrapper pipeline = Pipelines.Xml.Send()
                                           .WithAssembler(Assembler.Xml())
                                           .WithEncoder(new MIME_SMIME_Encoder())
                                           .WithInstanceConfig(reader);

            XmlAsmComp xmlassm = (XmlAsmComp)
                                 pipeline.GetComponent(PipelineStage.Assemble, 0);

            Assert.IsFalse(xmlassm.AddXMLDeclaration);
            Assert.IsFalse(xmlassm.PreserveBom);

            MIME_SMIME_Encoder enc = (MIME_SMIME_Encoder)
                                     pipeline.GetComponent(PipelineStage.Encode, 0);

            Assert.IsTrue(enc.EnableEncryption);
            Assert.AreEqual(MIME_SMIME_Encoder.MIMETransferEncodingType.SevenBit,
                            enc.ContentTransferEncoding);
        }
        public void SendPlainTextAndAttachParts()
        {
            var pipeline  = PipelineFactory.CreateEmptySendPipeline();
            var component = new EmailCustomizer
            {
                Enabled   = true,
                FileNames = "BodyPart.xml||Part2.xml",// string array for parts' filenames separated by |, adding empty text results in skipping the corespondant part from being attached.
                EmailBody = "This is a plain text e-mail with several parts attached.\nRegards"
            };

            pipeline.AddComponent(component, PipelineStage.Encode);
            //adding MIME encoder component to the sendpipeline so we can view the structure of the output message.
            var mime = new MIME_SMIME_Encoder();

            pipeline.AddComponent(mime, PipelineStage.Encode);
            //create a message with body part only.
            var message = MessageHelper.Create(System.IO.File.ReadAllText(TestFiles.BodyPart_FilePath),
                                               System.IO.File.ReadAllText(TestFiles.Part1_FilePath),
                                               System.IO.File.ReadAllText(TestFiles.Part2_FilePath));
            var output = pipeline.Execute(message);

            System.IO.StreamReader reader = new System.IO.StreamReader(output.BodyPart.GetOriginalDataStream());
            var ret = reader.ReadToEnd();
        }
 public void ThrowExceptionWhenComponentAddedToInvalidStage()
 {
    SendPipelineWrapper pipeline = PipelineFactory.CreateEmptySendPipeline();
    IBaseComponent encoder = new MIME_SMIME_Encoder();
    pipeline.AddComponent(encoder, PipelineStage.ResolveParty);
 }
 public void CanAddComponentToValidStage()
 {
    SendPipelineWrapper pipeline = PipelineFactory.CreateEmptySendPipeline();
    IBaseComponent encoder = new MIME_SMIME_Encoder();
    pipeline.AddComponent(encoder, PipelineStage.Encode);
 }
      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);
         }

      }
Ejemplo n.º 10
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);
                }
            }
        }