/// <summary> /// Write method helps write configuration data /// </summary> /// <param name="appName">The name of the affiliate application to represent the configuration container to access</param> /// <param name="properties"></param> internal static void Write(string appName, ConfigurationPropertyBag properties) { try { var ssoStore = new SSOConfigStore(); ((ISSOConfigStore)ssoStore).SetConfigInfo(appName, IdenifierGuid, properties); } catch (Exception e) { System.Diagnostics.Trace.WriteLine(e.Message); throw; } }
/// <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 { var ssoStore = new SSOConfigStore(); var appMgmtBag = new ConfigurationPropertyBag(); ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, IdenifierGuid, SSOFlag.SSO_FLAG_RUNTIME, appMgmtBag); object propertyValue; appMgmtBag.Read(propName, out propertyValue, 0); return((string)propertyValue); } catch (Exception e) { System.Diagnostics.Trace.WriteLine(e.Message); throw; } }
/// <summary> /// Write method helps write 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 write</param> /// <param name="propValue">The property value to write</param> public static void Write(string appName, string propName, string propValue) { try { var ssoStore = new SSOConfigStore(); var appMgmtBag = new ConfigurationPropertyBag(); ((ISSOConfigStore)ssoStore).GetConfigInfo(appName, IdenifierGuid, SSOFlag.SSO_FLAG_RUNTIME, appMgmtBag); object tempProp = propValue; appMgmtBag.Remove(propName); appMgmtBag.Write(propName, ref tempProp); ((ISSOConfigStore)ssoStore).SetConfigInfo(appName, IdenifierGuid, appMgmtBag); } catch (Exception e) { System.Diagnostics.Trace.WriteLine(e.Message); throw; } }
/// <summary> /// execute task /// </summary> /// <returns></returns> public override bool Execute() { var fieldNames = CommaDelimitedFieldNames.Split(",".ToCharArray()); var noFields = fieldNames.Length + 1; var appFlags = 0; //bitwise operation for flags appFlags |= SSOFlag.SSO_FLAG_APP_CONFIG_STORE; appFlags |= SSOFlag.SSO_FLAG_SSO_WINDOWS_TO_EXTERNAL; appFlags |= SSOFlag.SSO_FLAG_APP_ALLOW_LOCAL; var admin = new ISSOAdmin(); admin.CreateApplication(ApplicationName, Description, "", UserGroup, AdministratorGroup, appFlags, noFields); const int fieldFlags = 0; admin.CreateFieldInfo(ApplicationName, "Reserved", fieldFlags); foreach (var fieldName in fieldNames) { admin.CreateFieldInfo(ApplicationName, fieldName, fieldFlags); } admin.UpdateApplication(ApplicationName, null, null, null, null, SSOFlag.SSO_FLAG_ENABLED, SSOFlag.SSO_FLAG_ENABLED); var propertiesBag = new ConfigurationPropertyBag(); foreach (var field in fieldNames) { object val = "<empty>"; propertiesBag.Write(field, ref val); } SSOConfiguration.Write(ApplicationName, propertiesBag); return(true); }