Exemplo n.º 1
0
        /// <summary>
        /// Adds the ifinity URL configuration.
        /// </summary>
        public static void AddIfinityUrlConfiguration()
        {
            try
            {

                var targetConfig = new XmlDocument();
                targetConfig.Load(Path.Combine(HttpContext.Current.Server.MapPath("~"), "web.config"));

                string configString = "";

                using (var stream = new StreamReader(Path.Combine(HttpContext.Current.Server.MapPath("~"),
                                                     "DesktopModules/InspectorIT/VanityUrls/Includes/iFinityProvider.add.config"))
                    )
                {
                    configString = stream.ReadToEnd();
                }

                var merge = new XmlMerge(new StringReader(configString), "", "");
                merge.UpdateConfig(targetConfig);
                Config.Save(targetConfig, "web.config");

            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        public static void AddFriendlyUrlHttpModule()
        {
            try
            {
                const string configString = "<configuration>" +
                                            "<nodes configfile=\"web.config\">" +
                                            "<node path=\"/configuration/system.web/httpModules/add[@name='RequestFilter']\" action=\"insertbefore\" key=\"name\" collision=\"ignore\">" +
                                            "<add name=\"DNNQAUrlRewrite\" type=\"GB.SlideShow.Components.Modules.UrlModule, DotNetNuke.Modules.DNNQA\" />" +
                                            "</node>" +
                                            "<node path=\"/configuration/system.webServer/modules/add[@name='RequestFilter']\" action=\"insertbefore\" key=\"name\" collision=\"ignore\">" +
                                            "<add name=\"DNNQAUrlRewrite\" type=\"GB.SlideShow.Components.Modules.UrlModule, DotNetNuke.Modules.DNNQA\" preCondition=\"managedHandler\" />" +
                                            "</node>" +
                                            "</nodes>" +
                                            "</configuration>";

                var targetConfig = new XmlDocument();
                targetConfig.Load(Path.Combine(HttpContext.Current.Server.MapPath("~"), "web.config"));

                if (targetConfig.SelectSingleNode("/configuration/system.webServer/modules/add[@name='DNNQAUrlRewrite']") == null)
                {
                    var merge = new XmlMerge(new StringReader(configString), "", "");
                    merge.UpdateConfig(targetConfig);
                    Config.Save(targetConfig, "web.config");
                }

            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Updates the web.config file to drop emails to a local folder.
 /// </summary>
 /// <param name="mailDropPath">The path to the mailDrop.xml file that contains the xml for the mail dump.</param>
 /// <param name="emailPath">The path that emails will be sent to.</param>
 public static void UpdateConfigForMailDrop(string mailDropPath, string emailPath)
 {
     var physicalPath = GetWebPath(); 
     var mailDropFragment = XDocument.Load(Path.Combine(mailDropPath, "mailDrop.xml"));
     var specifiedPickupDirectory = mailDropFragment.XPathSelectElement("configuration/nodes/node/system.net/mailSettings/smtp/specifiedPickupDirectory");
     specifiedPickupDirectory.Attribute("pickupDirectoryLocation").Value = emailPath;
     mailDropFragment.Save(Path.Combine(physicalPath, "UpdatedMailDrop.xml"));
     var mailDrop = new FileStream(Path.Combine(physicalPath, "UpdatedMailDrop.xml"), FileMode.Open, FileAccess.Read);
     try
     {
         var fileName = string.Format("{0}\\web.config", physicalPath);
         var targetDocument = new XmlDocument();
         targetDocument.Load(fileName);
         var mailNodes = (from mail in targetDocument.DocumentElement.ChildNodes.Cast<XmlNode>()
                          where mail.Name == "system.net"
                          select mail).ToList();
         if (mailNodes.Count == 0)
         {
             var merge = new XmlMerge(mailDrop, String.Empty, String.Empty);
             merge.UpdateConfig(targetDocument);
             targetDocument.Save(fileName);
         }
     }
     finally
     {
         mailDrop.Close();
     }
 }