Making it more flexible.

Dec 18, 2011 at 9:26 PM

Hi Stuart

A nifty little pipeline component.

However it has some limitations in that it only works for a send/receive port which is a FILE or FTP.

We had the need to archive it both on a Dynamic Send port (going to SMTP) and also a Web Service.  The Dynamic send port was bound to a file receive location (so the property was set on the message) and the webservice message was getting the property set in the Orchestration.

To achieve this I changed

                        switch (TransportType)
                        {
                            case "FILE":
                                FullPath = ProcessFilePropertiesMacros(FullPath, inmsg);
                                break;

                            case "FTP":
                                FullPath = ProcessFTPPropertiesMacros(FullPath, inmsg);
                                break;
                        }
To
            FullPath = ProcessFilePropertiesMacros(FullPath, inmsg);

I Deleted ProcessFTPPopertiesMacros
and changed ProcessFilePopertiesMacros as below.
                ReceivedFileName = Message.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties") as string;
To
                ReceivedFileName = Message.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties") as string;
                if (ReceivedFileName == null)
                {
                    ReceivedFileName = Message.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/ftp-properties") as string;
                }
                if (ReceivedFileName == null)
                {
                    ReceivedFileName = Message.Context.Read("FileName", "http://schemas.microsoft.com/BizTalk/2003/mime-properties") as string;
                }

I also fixed an issue that caused an exception when the file did not have an extension
                Index = ReceivedFileName.LastIndexOf(".");
                Index2 = ReceivedFileName.LastIndexOf("\\") + 1;
                FileNameLength = Index - Index2;

                FileName = ReceivedFileName.Substring(Index2, FileNameLength);
                FileExtension = ReceivedFileName.Substring(Index);
To
                Index = ReceivedFileName.LastIndexOf(".");
                if (Index == -1)
                {
                    Index = ReceivedFileName.Length;
                }
                else
                {
                    FileExtension = ReceivedFileName.Substring(Index);
                }
                Index2 = ReceivedFileName.LastIndexOf("\\") + 1;
                FileNameLength = Index - Index2;

                FileName = ReceivedFileName.Substring(Index2, FileNameLength);

Dec 18, 2011 at 11:15 PM

In fact for the file name & extension why aren't you using?

                FileExtension = Path.GetExtension(ReceivedFileName);
                FileName = Path.GetFileName(ReceivedFileName);
                if (FileExtension != "")
                {
                    FileName = FileName.Replace(FileExtension, "");
                }