public override void FeatureActivated(SPFeatureReceiverProperties properties) { try { SPWebApplication webApp = properties.Feature.Parent as SPWebApplication; XmlDocument configSettingFile = new XmlDocument(); string templateFolderPath = string.Empty; string webConfigsettingFilePath = SPUtility.GetGenericSetupPath(@"template\layouts\macros.core\WebConfigSettings.xml"); configSettingFile.Load(webConfigsettingFilePath); XmlNodeList nodeList = configSettingFile.SelectNodes("WebConfigDeployments/Deployment"); WebConfigInstaller configInstaller = new WebConfigInstaller() { WebApplicationId = webApp.Id, Nodes = nodeList }; configInstaller.Deploy(WebConfigInstaller.DeploymentType.Deploy, properties.Feature.DefinitionId); } catch (Exception ex) { if (!EventLog.SourceExists("MacrosSP")) { EventLog.CreateEventSource("MacrosSP", "Application"); } EventLog.WriteEntry("MacrosSP", "JavaScript Inject Module Activation : " + ex.Message + ex.StackTrace, EventLogEntryType.Error, 2000); } }
public override void Install(IDictionary stateSaver) { base.Install(stateSaver); // /url="[URL]" /title="[TITLE]" /login="******" /password="******" /targetdir="[TARGETDIR]\" string url = Context.Parameters["url"]; string title = Context.Parameters["title"]; string login = Context.Parameters["login"]; string password = Context.Parameters["password"]; string targetdir = Context.Parameters["targetdir"]; List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >(); values.Add(new KeyValuePair <string, string>("TargetProcessPath", url)); values.Add(new KeyValuePair <string, string>("Title", title)); values.Add(new KeyValuePair <string, string>("AdminLogin", login)); values.Add(new KeyValuePair <string, string>("AdminPassword", password)); WebConfigInstaller.SetAppSettingsValue(targetdir, values); }