Store configurable values in SSO
-
23-06-2021 - |
Frage
I need to store configurable values in SSO, and at run time, retrieve them in a custom pipeline component
Any help regarding this...
Lösung
You can go to the following links..it has all the information you need
Andere Tipps
For help storing values in SSO please see this post.
As far as retrieving them in a pipeline component you can create a helper function. Something like this will work:
using System;
using System.Collections;
using System.Collections.Specialized;
using Microsoft.BizTalk.SSOClient.Interop;
/// <summary>
/// Contains helper methods for using SSO as a config store.
/// </summary>
public static class SSOConfigHelper
{
/// <summary>
/// Can be set to anything
/// </summary>
private static string idenifierGUID = "ConfigProperties";
/// <summary>
/// Read method helps get configuration data
/// </summary>
/// <param name="appName">The name of the affiliate application to represent the configuration container to access</param>
/// <param name="propName">The property name to read</param>
/// <returns>
/// The value of the property stored in the given affiliate application of this component.
/// </returns>
public static string Read(string appName, string propName)
{
try
{
SSOConfigStore ssoStore = new SSOConfigStore();
ConfigurationPropertyBag appMgmtBag = new ConfigurationPropertyBag();
((ISSOConfigStore)ssoStore).GetConfigInfo(appName, idenifierGUID, SSOFlag.SSO_FLAG_RUNTIME, (IPropertyBag)appMgmtBag);
object propertyValue = null;
appMgmtBag.Read(propName, out propertyValue, 0);
return (string)propertyValue;
}
catch (Exception e)
{
System.Diagnostics.Trace.WriteLine(e.Message);
throw;
}
}
}
// The code above uses this propertybag
public class ConfigurationPropertyBag : IPropertyBag
{
/// <summary>
/// The properties
/// </summary>
private HybridDictionary properties;
/// <summary>
/// Initializes a new instance of the ConfigurationPropertyBag class
/// </summary>
internal ConfigurationPropertyBag()
{
this.properties = new HybridDictionary();
}
#region IPropertyBag Members
/// <summary>
/// Implements IPropertyBag read
/// </summary>
/// <param name="propName">IPropertyBag propName</param>
/// <param name="ptrVar">IPropertyBag ptrVar</param>
/// <param name="errorLog">IPropertyBag errLog</param>
public void Read(string propName, out object ptrVar, int errorLog)
{
ptrVar = this.properties[propName];
}
/// <summary>
/// Implements IPropertyBag write
/// </summary>
/// <param name="propName">IPropertyBag propName</param>
/// <param name="ptrVar">IPropertyBag ptrVar</param>
public void Write(string propName, ref object ptrVar)
{
this.properties.Add(propName, ptrVar);
}
#endregion
/// <summary>
/// Searches for property key
/// </summary>
/// <param name="key">key of kv pair</param>
/// <returns>true if key found</returns>
public bool Contains(string key)
{
return this.properties.Contains(key);
}
/// <summary>
/// Removes property
/// </summary>
/// <param name="key">key of kv pair</param>
public void Remove(string key)
{
this.properties.Remove(key);
}
}
(Please also upvote the linked post if it helps you)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow