コード例 #1
0
        public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            string errorMessage;

            if (!Validate(out errorMessage))
            {
                throw new ArgumentException(errorMessage);
            }

            var outMsg = pContext.GetMessageFactory().CreateMessage();

            outMsg.Context = pInMsg.Context;
            var bodyPart = pContext.GetMessageFactory().CreateMessagePart();

            using (var compressionUtil = new CompressionUtil())
            {
                for (var i = 0; i < pInMsg.PartCount; i++)
                {
                    string partName;
                    var    part = pInMsg.GetPartByIndex(i, out partName);


                    var fileName = GetFileName(part);

                    compressionUtil.AddMessage(part.GetOriginalDataStream(), fileName);
                }

                bodyPart.Data = compressionUtil.GetZip();
                pContext.ResourceTracker.AddResource(bodyPart.Data);
                bodyPart.Charset     = "utf-8";
                bodyPart.ContentType = "application/zip";
            }

            outMsg.AddPart("Body", bodyPart, true);

            return(outMsg);
        }