Close

Custom Functoid: SSOConfigReader

Yet another example that can be useful. A custom functoid to read configuration data from SSO.

using System;
using System.Reflection;
using Microsoft.BizTalk.BaseFunctoids;

namespace Rfs.Integration.BizTalk.Library.Functoids
{
public class SSOConfigReader : BaseFunctoid
{
public SSOConfigReader()
: base()
{
this.ID = Constants.SSOConfigReader;

// set up the resource assembly to our own assembly
SetupResourceAssembly(Constants.functoidsResourcesPath, Assembly.GetExecutingAssembly());

SetName(“SSOCONFIGREADER_NAME”);
SetTooltip(“SSOCONFIGREADER_TOOLTIP”);
SetDescription(“SSOCONFIGREADER_DESCRIPTION”);
SetBitmap(“SSOCONFIGREADER_BITMAP”);

this.SetMinParams(2);
this.SetMaxParams(2);

SetExternalFunctionName(GetType().Assembly.FullName, Constants.functoidsNamespace + “.SSOConfigReader”, “SSOConfigHelper_Read”);

this.Category = FunctoidCategory.DatabaseLookup;
this.OutputConnectionType = ConnectionType.AllExceptRecord;

// Parameter
AddInputConnectionType(ConnectionType.AllExceptRecord);
}

public string SSOConfigHelper_Read(String applicationName, String propertyName)
{
return SSOSettingsFileManager.SSOSettingsFileReader.ReadString(applicationName, propertyName);
}
}
}

The SSOSettingsFileReader is part of the ESB Toolkit and can be added to the SharedReferences folder. To test the functoid the unit test below can be used:

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Rfs.Integration.BizTalk.Library.Tests
{
[TestClass] public class SSOConfigReader
{
[TestMethod] public void SSOConfigReaderTest()
{
var functoid = new Functoids.SSOConfigReader();
string app = “Rfs.Integration.BizTalk.Library”;
ReadSSOConfig(app, “LOCUS-DV”, “RFS.LOC.DED”);
ReadSSOConfig(app, “LOCUS”, “RFS.LOC.MAU”);
ReadSSOConfig(app, “UBLVersionID”, “2.1”);
ReadSSOConfig(app, “CustomizationID”, “1.0”);
ReadSSOConfig(app, “ProfileID”, “rid”);
ReadSSOConfig(app, “PartyID.DAX”, “RFS.DAX”);
ReadSSOConfig(app, “MasterOwnerCode”, “WEH”);
}

private void ReadSSOConfig(string application, string key, string expectedValue)
{
var functoid = new Functoids.SSOConfigReader();
string result = functoid.SSOConfigHelper_Read(application, key);
Assert.AreEqual(expectedValue, result);
functoid = null;
}

}
}

Leave a Reply

Your email address will not be published. Required fields are marked *