|
| 1 | + |
| 2 | +namespace POC.BizTalk.PropertyDemotion.PipelineComponent |
| 3 | +{ |
| 4 | + using System; |
| 5 | + using System.Resources; |
| 6 | + using System.Collections; |
| 7 | + using System.Reflection; |
| 8 | + using System.ComponentModel; |
| 9 | + using System.Text; |
| 10 | + using System.IO; |
| 11 | + using Microsoft.BizTalk.Message.Interop; |
| 12 | + using Microsoft.BizTalk.Component.Interop; |
| 13 | + |
| 14 | + |
| 15 | + /// <summary> |
| 16 | + /// Implements custom pipeline component to promote properties. |
| 17 | + /// </summary> |
| 18 | + [ComponentCategory(CategoryTypes.CATID_PipelineComponent)] |
| 19 | + [ComponentCategory(CategoryTypes.CATID_Any)] |
| 20 | + [ComponentCategory(CategoryTypes.CATID_Validate)] |
| 21 | + [System.Runtime.InteropServices.Guid("48BEC85A-20EE-40ad-BFD0-319B59A0DDBA")] |
| 22 | + public class BizTalkPromotion : |
| 23 | + IBaseComponent, |
| 24 | + Microsoft.BizTalk.Component.Interop.IComponent, |
| 25 | + Microsoft.BizTalk.Component.Interop.IPersistPropertyBag, |
| 26 | + IComponentUI |
| 27 | + { |
| 28 | + |
| 29 | + #region IBaseComponent |
| 30 | + |
| 31 | + /// <summary> |
| 32 | + /// Name of the component. |
| 33 | + /// </summary> |
| 34 | + [Browsable(false)] |
| 35 | + public string Name |
| 36 | + { |
| 37 | + get { return "Promotion Component"; } |
| 38 | + } |
| 39 | + |
| 40 | + /// <summary> |
| 41 | + /// Version of the component. |
| 42 | + /// </summary> |
| 43 | + [Browsable(false)] |
| 44 | + public string Version |
| 45 | + { |
| 46 | + get { return "1.0"; } |
| 47 | + } |
| 48 | + |
| 49 | + /// <summary> |
| 50 | + /// Description of the component. |
| 51 | + /// </summary> |
| 52 | + [Browsable(false)] |
| 53 | + public string Description |
| 54 | + { |
| 55 | + get { return "Promotion Pipeline Component"; } |
| 56 | + } |
| 57 | + |
| 58 | + #endregion |
| 59 | + |
| 60 | + #region IComponent |
| 61 | + |
| 62 | + /// <summary> |
| 63 | + /// Implements IComponent.Execute method. |
| 64 | + /// </summary> |
| 65 | + /// <param name="pc">Pipeline context</param> |
| 66 | + /// <param name="inmsg">Input message.</param> |
| 67 | + /// <returns>Processed input message with appended or prepended data.</returns> |
| 68 | + /// <remarks> |
| 69 | + /// IComponent.Execute method is used to initiate |
| 70 | + /// the processing of the message in pipeline component. |
| 71 | + /// </remarks> |
| 72 | + public IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg) |
| 73 | + { |
| 74 | + inmsg.Context.Promote("SubmissionDate", "https://POC.BizTalk.PropertyDemotion.PropertySchema", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszzz")); |
| 75 | + |
| 76 | + return inmsg; |
| 77 | + } |
| 78 | + #endregion |
| 79 | + |
| 80 | + #region IPersistPropertyBag |
| 81 | + |
| 82 | + /// <summary> |
| 83 | + /// Gets class ID of component for usage from unmanaged code. |
| 84 | + /// </summary> |
| 85 | + /// <param name="classid">Class ID of the component.</param> |
| 86 | + public void GetClassID(out Guid classid) |
| 87 | + { |
| 88 | + classid = new System.Guid("48BEC85A-20EE-40ad-BFD0-319B59A0DDBA"); |
| 89 | + } |
| 90 | + |
| 91 | + /// <summary> |
| 92 | + /// Not implemented. |
| 93 | + /// </summary> |
| 94 | + public void InitNew() |
| 95 | + { |
| 96 | + } |
| 97 | + |
| 98 | + /// <summary> |
| 99 | + /// Loads configuration property for component. |
| 100 | + /// </summary> |
| 101 | + /// <param name="pb">Configuration property bag.</param> |
| 102 | + /// <param name="errlog">Error status (not used in this code).</param> |
| 103 | + public void Load(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, Int32 errlog) |
| 104 | + { |
| 105 | + return; |
| 106 | + } |
| 107 | + |
| 108 | + /// <summary> |
| 109 | + /// Saves the current component configuration into the property bag. |
| 110 | + /// </summary> |
| 111 | + /// <param name="pb">Configuration property bag.</param> |
| 112 | + /// <param name="fClearDirty">Not used.</param> |
| 113 | + /// <param name="fSaveAllProperties">Not used.</param> |
| 114 | + public void Save(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, Boolean fClearDirty, Boolean fSaveAllProperties) |
| 115 | + { |
| 116 | + return; |
| 117 | + } |
| 118 | + |
| 119 | + /// <summary> |
| 120 | + /// Reads property value from property bag. |
| 121 | + /// </summary> |
| 122 | + /// <param name="pb">Property bag.</param> |
| 123 | + /// <param name="propName">Name of property.</param> |
| 124 | + /// <returns>Value of the property.</returns> |
| 125 | + private static object ReadPropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName) |
| 126 | + { |
| 127 | + object val = null; |
| 128 | + try |
| 129 | + { |
| 130 | + pb.Read(propName, out val, 0); |
| 131 | + } |
| 132 | + |
| 133 | + catch (ArgumentException) |
| 134 | + { |
| 135 | + return val; |
| 136 | + } |
| 137 | + catch (Exception ex) |
| 138 | + { |
| 139 | + throw new ApplicationException(ex.Message); |
| 140 | + } |
| 141 | + return val; |
| 142 | + } |
| 143 | + |
| 144 | + /// <summary> |
| 145 | + /// Writes property values into a property bag. |
| 146 | + /// </summary> |
| 147 | + /// <param name="pb">Property bag.</param> |
| 148 | + /// <param name="propName">Name of property.</param> |
| 149 | + /// <param name="val">Value of property.</param> |
| 150 | + private static void WritePropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName, object val) |
| 151 | + { |
| 152 | + try |
| 153 | + { |
| 154 | + pb.Write(propName, ref val); |
| 155 | + } |
| 156 | + catch (Exception ex) |
| 157 | + { |
| 158 | + throw new ApplicationException(ex.Message); |
| 159 | + } |
| 160 | + } |
| 161 | + |
| 162 | + |
| 163 | + |
| 164 | + |
| 165 | + #endregion |
| 166 | + |
| 167 | + #region IComponentUI |
| 168 | + |
| 169 | + /// <summary> |
| 170 | + /// Component icon to use in BizTalk Editor. |
| 171 | + /// </summary> |
| 172 | + [Browsable(false)] |
| 173 | + public IntPtr Icon |
| 174 | + { |
| 175 | + get |
| 176 | + { |
| 177 | + return IntPtr.Zero; |
| 178 | + } |
| 179 | + |
| 180 | + } |
| 181 | + |
| 182 | + /// <summary> |
| 183 | + /// The Validate method is called by the BizTalk Editor during the build |
| 184 | + /// of a BizTalk project. |
| 185 | + /// </summary> |
| 186 | + /// <param name="obj">Project system.</param> |
| 187 | + /// <returns> |
| 188 | + /// A list of error and/or warning messages encounter during validation |
| 189 | + /// of this component. |
| 190 | + /// </returns> |
| 191 | + public IEnumerator Validate(object obj) |
| 192 | + { |
| 193 | + IEnumerator enumerator = null; |
| 194 | + |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | + return enumerator; |
| 199 | + } |
| 200 | + |
| 201 | + #endregion |
| 202 | + } |
| 203 | +} |
0 commit comments