【问题标题】:Store configurable values in SSO在 SSO 中存储可配置值
【发布时间】:2012-07-31 16:15:30
【问题描述】:

我需要在 SSO 中存储可配置值,并在运行时在自定义管道组件中检索它们

有关此的任何帮助...

【问题讨论】:

    标签: biztalk single-sign-on biztalk-2010 custom-pipeline-component


    【解决方案1】:

    有关在 SSO 中存储值的帮助,请参阅this post

    就在管道组件中检索它们而言,您可以创建一个辅助函数。这样的事情会起作用:

    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);
        }
    }
    

    (如果链接的帖子对您​​有帮助,也请点赞)

    【讨论】:

    • 感谢您的信息..我将开始研究它。我无法投票,因为它需要 15 个声誉..但我一定会稍后投票..
    • 你能帮助我如何在自定义管道组件中写入 sso
    • 你有没有尝试过?喜欢 BizTalk 管道组件向导吗? btsplcw.codeplex.com
    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-16
      • 2018-10-20
      • 1970-01-01
      • 2013-09-04
      • 2017-12-06
      相关资源
      最近更新 更多