using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Text; using Microsoft.BizTalk.Component.Interop; using Microsoft.BizTalk.Message.Interop; namespace Paulb.BizTalk { /// /// Custom pipeline component to change the received filename, /// to something usefull. /// [ComponentCategory(CategoryTypes.CATID_PipelineComponent)] [ComponentCategory(CategoryTypes.CATID_Decoder)] [System.Runtime.InteropServices.Guid(FixFileName.ClassID)] public class FixFileName : Microsoft.BizTalk.Component.Interop.IBaseComponent, Microsoft.BizTalk.Component.Interop.IComponent, Microsoft.BizTalk.Component.Interop.IPersistPropertyBag, Microsoft.BizTalk.Component.Interop.IComponentUI { /// /// Default empty constructor. /// public FixFileName() { // ... } #region IComponent Members IBaseMessage IComponent.Execute(IPipelineContext pContext, IBaseMessage pInMsg) { // make sure we have something to work with if (pInMsg == null) { return pInMsg; } string receivedFileName = pInMsg.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties") as string; if (string.IsNullOrEmpty(receivedFileName)) { // nothing we can do return pInMsg; } string newFileName = Path.GetFileNameWithoutExtension(receivedFileName); pInMsg.Context.Promote("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties", newFileName); return pInMsg; } #endregion #region IPersistPropertyBag Members void IPersistPropertyBag.GetClassID(out Guid classID) { classID = new Guid(ClassID); } void IPersistPropertyBag.InitNew() { // no propertybag, so not implemented } void IPersistPropertyBag.Load(IPropertyBag propertyBag, int errorLog) { // no propertybag, so not implemented } void IPersistPropertyBag.Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties) { // no propertybag, so not implemented } #endregion #region IComponentUI Members [System.ComponentModel.Browsable(false)] IntPtr IComponentUI.Icon { get { // no fancy icon return IntPtr.Zero; } } IEnumerator IComponentUI.Validate(object projectSystem) { // no properties to validate return ((IEnumerable)(new string[0])).GetEnumerator(); } #endregion #region IBaseComponent Members /// /// Gets the description. /// [System.ComponentModel.Browsable(false)] string IBaseComponent.Description { get { return "FixFileName Pipeline Component"; } } /// /// Gets the name. /// [System.ComponentModel.Browsable(false)] string IBaseComponent.Name { get { return "FixFileName Component"; } } /// /// Gets the version. /// [System.ComponentModel.Browsable(false)] string IBaseComponent.Version { get { return "1.0.0.0"; } } #endregion internal const string ClassID = "5C9DFEEC-D344-42ce-A087-98A4E5C6A91C"; } }