private String readAppSettings(GSBApplicationConfigManager gcm, String key) { String appSettingValue = gcm.GetNodeValue(String.Format("/configuration/appSettings/add[@key='{0}']", key)); if (String.IsNullOrEmpty(appSettingValue)) { return(String.Empty); } else { return(appSettingValue.Trim()); } }
public void SaveConfigurationsToFile(string webConfigFilePath, bool isInstaller) { GSBApplicationConfigManager gcm = new GSBApplicationConfigManager(); gcm.LoadXML(webConfigFilePath); gcm.EnsureParentNodesForGSAParameters(); //ensure that all the nodes are in place //else create them gcm.ModifyNode("/configuration/appSettings", "siteCollection", SiteCollection); gcm.ModifyNode("/configuration/appSettings", "GSALocation", ApplianceLocation); gcm.ModifyNode("/configuration/appSettings", "frontEnd", FrontEnd); gcm.ModifyNode("/configuration/appSettings", "verbose", EnableLogging); gcm.ModifyNode("/configuration/appSettings", "GSAStyle", UseGsaStyling); //for custom stylesheet gcm.ModifyNode("/configuration/appSettings", "accesslevel", AccessLevel); //for 'public' or 'public and secure' search with GSBS gcm.ModifyNode("/configuration/appSettings", "omitSecureCookie", OmitSecureCookie); // Included for the BoA secure cookie issue. Will decide whether to process the cookie or discard the same. /* * Denotes the default search type used. Value "publicAndSecure" denotes the default search type will be 'public and secure', * and value "public" denotes the default search type will be 'public' search. */ gcm.ModifyNode("/configuration/appSettings", "defaultSearchType", DefaultSearchType); // Denotes the name for the help file for search tips gcm.ModifyNode("/configuration/appSettings", "SearchTipsHTMLFileName", SearchTipsHTMLFileName); // Code for enabling Session State on SharePoint Web Application gcm.ModifyNodeForHttpModule("//httpModules", "//modules", "Session", SessionStateModule); gcm.ModifyNode("/configuration/appSettings", "EnableEmbeddedMode", EnableEmbeddedMode.ToString().ToLower()); // UseContainerTheme configuartion parameter value should be same as EnableEmbeddedMode gcm.ModifyNode("/configuration/appSettings", "UseContainerTheme", EnableEmbeddedMode.ToString().ToLower()); gcm.ModifyNode("/configuration/appSettings", "UseSamlPost", UseSamlPost.ToString().ToLower()); gcm.ModifyNode("/configuration/appSettings", "assertion_consumer", artifactConsumer); gcm.ModifyNode("/configuration/appSettings", "certificate_friendly_name", CertificateName); gcm.ModifyNode("/configuration/appSettings", "idp_entity_id", IDPEntityID); gcm.ModifyNode("/configuration/appSettings", "trust_duration", TrustDuration.ToString()); //this needs to be saved only during installation. should be unchnaged otherwise if (isInstaller == true) { gcm.ModifyNode("/configuration/appSettings", "xslGSA2SP", GsaToSpStyle); //for custom stylesheet gcm.ModifyNode("/configuration/appSettings", "xslSP2result", SpToResultStyle); //for custom stylesheet //add for logging gcm.ModifyNode("/configuration/appSettings", "logLocation", logLocation);//for custom stylesheet // Setting filterParameter to "p" only during initial deployment. gcm.ModifyNode("/configuration/appSettings", "filterParameter", "p"); // ShowScope and ShowSearchTips parameters to True only during initial deployment gcm.ModifyNode("/configuration/appSettings", "showScope", "true"); gcm.ModifyNode("/configuration/appSettings", "showSearchTips", "true"); } else { #region Scenario and Sample /* * Consider scenario: new web app created or user has clicked cancel on the "configuration wizard form" while putting the GSA parameters * -E.g. user has clicked cancel while saving the configuration * -so as a result the custom stylesheet #1 and #2 location is not getting saved. * Note: we can get the location while installation (as per folder location chosen by user). */ //Steps to ResolveEventArgs it: //1. Read the respective nodes form the web.config of as given web ApplicationException. //2. if ValueType = blank or null put value, get current dir and put the values accordingly //sample values //<add key="xslGSA2SP" value="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GSA2SP.xsl" /> //<add key="xslSP2result" value="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\SP_Actual.xsl" /> #endregion Scenario and Sample string StylesheetPath = ""; string CurrentDir = Directory.GetCurrentDirectory();//Get the current Directory value (common for all) //read style#1 StylesheetPath = gcm.GetNodeValue("/configuration/appSettings/add[@key='xslGSA2SP']"); if ((null == StylesheetPath) || (StylesheetPath.Trim().Equals(""))) { StylesheetPath = CurrentDir + "\\GSA2SP.xsl"; //Get the value from web.config gcm.ModifyNode("/configuration/appSettings", "xslGSA2SP", StylesheetPath); //modify node } //read style#2 StylesheetPath = gcm.GetNodeValue("/configuration/appSettings/add[@key='xslSP2result']"); if ((null == StylesheetPath) || (StylesheetPath.Trim().Equals(""))) { StylesheetPath = CurrentDir + "\\SP_Actual.xsl"; //Get the value from web.config gcm.ModifyNode("/configuration/appSettings", "xslSP2result", StylesheetPath); //modify node } } gcm.SaveXML();//finally save the resultant modified values }
public void SaveConfigurationsToFile(string webConfigFilePath,bool isInstaller) { GSBApplicationConfigManager gcm = new GSBApplicationConfigManager(); gcm.LoadXML(webConfigFilePath); gcm.EnsureParentNodesForGSAParameters();//ensure that all the nodes are in place //else create them gcm.ModifyNode("/configuration/appSettings", "siteCollection", SiteCollection); gcm.ModifyNode("/configuration/appSettings", "GSALocation", ApplianceLocation); gcm.ModifyNode("/configuration/appSettings", "frontEnd", FrontEnd); gcm.ModifyNode("/configuration/appSettings", "verbose", EnableLogging); gcm.ModifyNode("/configuration/appSettings", "GSAStyle", UseGsaStyling);//for custom stylesheet gcm.ModifyNode("/configuration/appSettings", "accesslevel", AccessLevel);//for 'public' or 'public and secure' search with GSBS gcm.ModifyNode("/configuration/appSettings", "omitSecureCookie", OmitSecureCookie);// Included for the BoA secure cookie issue. Will decide whether to process the cookie or discard the same. /* * Denotes the default search type used. Value "publicAndSecure" denotes the default search type will be 'public and secure', * and value "public" denotes the default search type will be 'public' search. */ gcm.ModifyNode("/configuration/appSettings", "defaultSearchType", DefaultSearchType); // Denotes the name for the help file for search tips gcm.ModifyNode("/configuration/appSettings", "SearchTipsHTMLFileName", SearchTipsHTMLFileName); // Code for enabling Session State on SharePoint Web Application gcm.ModifyNodeForHttpModule("//httpModules", "Session", SessionStateModule); gcm.ModifyNode("/configuration/appSettings", "EnableEmbeddedMode", EnableEmbeddedMode.ToString().ToLower()); // UseContainerTheme configuartion parameter value should be same as EnableEmbeddedMode gcm.ModifyNode("/configuration/appSettings", "UseContainerTheme", EnableEmbeddedMode.ToString().ToLower()); gcm.ModifyNode("/configuration/appSettings", "UseSamlPost", UseSamlPost.ToString().ToLower()); gcm.ModifyNode("/configuration/appSettings", "assertion_consumer", artifactConsumer); gcm.ModifyNode("/configuration/appSettings", "certificate_friendly_name", CertificateName); gcm.ModifyNode("/configuration/appSettings", "idp_entity_id", IDPEntityID); gcm.ModifyNode("/configuration/appSettings", "trust_duration", TrustDuration.ToString()); //this needs to be saved only during installation. should be unchnaged otherwise if (isInstaller == true) { gcm.ModifyNode("/configuration/appSettings", "xslGSA2SP", GsaToSpStyle);//for custom stylesheet gcm.ModifyNode("/configuration/appSettings", "xslSP2result", SpToResultStyle);//for custom stylesheet //add for logging gcm.ModifyNode("/configuration/appSettings", "logLocation", logLocation);//for custom stylesheet // Setting filterParameter to "p" only during initial deployment. gcm.ModifyNode("/configuration/appSettings", "filterParameter", "p"); // ShowScope and ShowSearchTips parameters to True only during initial deployment gcm.ModifyNode("/configuration/appSettings", "showScope", "true"); gcm.ModifyNode("/configuration/appSettings", "showSearchTips", "true"); } else { #region Scenario and Sample /* Consider scenario: new web app created or user has clicked cancel on the "configuration wizard form" while putting the GSA parameters -E.g. user has clicked cancel while saving the configuration -so as a result the custom stylesheet #1 and #2 location is not getting saved. Note: we can get the location while installation (as per folder location chosen by user). */ //Steps to ResolveEventArgs it: //1. Read the respective nodes form the web.config of as given web ApplicationException. //2. if ValueType = blank or null put value, get current dir and put the values accordingly //sample values //<add key="xslGSA2SP" value="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GSA2SP.xsl" /> //<add key="xslSP2result" value="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\SP_Actual.xsl" /> #endregion Scenario and Sample string StylesheetPath= ""; string CurrentDir = Directory.GetCurrentDirectory();//Get the current Directory value (common for all) //read style#1 StylesheetPath = gcm.GetNodeValue("/configuration/appSettings/add[@key='xslGSA2SP']"); if ((null == StylesheetPath) || (StylesheetPath.Trim().Equals(""))) { StylesheetPath = CurrentDir + "\\GSA2SP.xsl";//Get the value from web.config gcm.ModifyNode("/configuration/appSettings", "xslGSA2SP", StylesheetPath);//modify node } //read style#2 StylesheetPath = gcm.GetNodeValue("/configuration/appSettings/add[@key='xslSP2result']"); if ((null == StylesheetPath) || (StylesheetPath.Trim().Equals(""))) { StylesheetPath = CurrentDir + "\\SP_Actual.xsl";//Get the value from web.config gcm.ModifyNode("/configuration/appSettings", "xslSP2result", StylesheetPath);//modify node } } gcm.SaveXML();//finally save the resultant modified values }
private String readAppSettings(GSBApplicationConfigManager gcm, String key) { String appSettingValue = gcm.GetNodeValue(String.Format("/configuration/appSettings/add[@key='{0}']", key)); if (String.IsNullOrEmpty(appSettingValue)) { return String.Empty; } else { return appSettingValue.Trim(); } }