public override void Install()
 {
     try
     {
         if (string.IsNullOrEmpty(_FileName))
         {
             Util.BackupFile(TargetFile, PhysicalSitePath, Log);
             _TargetConfig = new XmlDocument();
             TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));
             XmlMerge merge = new XmlMerge(new StringReader(InstallConfig), this.Package.Version.ToString(), this.Package.Name);
             merge.UpdateConfig(TargetConfig);
             Completed = true;
             Log.AddInfo(Util.CONFIG_Updated + " - " + TargetFile.Name);
         }
         else
         {
             string strConfigFile = Path.Combine(this.Package.InstallerInfo.TempInstallFolder, _FileName);
             if (File.Exists(strConfigFile))
             {
                 StreamReader stream = File.OpenText(strConfigFile);
                 XmlMerge merge = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " Install");
                 merge.UpdateConfigs();
                 stream.Close();
                 Completed = true;
                 Log.AddInfo(Util.CONFIG_Updated);
             }
         }
     }
     catch (Exception ex)
     {
         Log.AddFailure(Util.EXCEPTION + " - " + ex.Message);
     }
 }
Ejemplo n.º 2
0
 public override void UnInstall()
 {
     if (string.IsNullOrEmpty(_UninstallFileName))
     {
         _TargetConfig = new XmlDocument();
         TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));
         XmlMerge merge = new XmlMerge(new StringReader(UnInstallConfig), this.Package.Version.ToString(), this.Package.Name);
         merge.UpdateConfig(TargetConfig, TargetFile.FullName);
     }
     else
     {
         string strConfigFile = Path.Combine(this.Package.InstallerInfo.TempInstallFolder, _UninstallFileName);
         if (File.Exists(strConfigFile))
         {
             StreamReader stream = File.OpenText(strConfigFile);
             XmlMerge     merge  = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " UnInstall");
             merge.UpdateConfigs();
             stream.Close();
         }
     }
 }
Ejemplo n.º 3
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The UnInstall method uninstalls the config component
        /// </summary>
        /// -----------------------------------------------------------------------------
        public override void UnInstall()
        {
            if (string.IsNullOrEmpty(_UninstallFileName))
            {
                if (!string.IsNullOrEmpty(UnInstallConfig))
                {
                    //Create an XmlDocument for the config file
                    _TargetConfig = new XmlDocument {
                        XmlResolver = null
                    };
                    TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));

                    //Create XmlMerge instance from UnInstallConfig source
                    var merge = new XmlMerge(new StringReader(UnInstallConfig), Package.Version.ToString(), Package.Name);

                    //Update the Config file - Note that this method does save the file
                    merge.UpdateConfig(TargetConfig, TargetFile.FullName);
                }
            }
            else
            {
                //Process external file
                string strConfigFile = Path.Combine(Package.InstallerInfo.TempInstallFolder, _UninstallFileName);
                if (File.Exists(strConfigFile))
                {
                    //Create XmlMerge instance from config file source
                    StreamReader stream = File.OpenText(strConfigFile);
                    var          merge  = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " UnInstall");

                    //Process merge
                    merge.UpdateConfigs();

                    //Close stream
                    stream.Close();
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Adds the standard URL configuration.
        /// </summary>
        public static void AddStandardUrlConfiguration()
        {
            try
            {
                string configString = "";
                using (var stream = new StreamReader(Path.Combine(HttpContext.Current.Server.MapPath("~"),
                                                                  "DesktopModules/InspectorIT/VanityUrls/Includes/StandardProvider.add.config"))
                       )
                {
                    configString = stream.ReadToEnd();
                }

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

                var merge = new XmlMerge(new StringReader(configString), "", "");
                merge.UpdateConfig(targetConfig);
                Config.Save(targetConfig, "web.config");
            }
            catch (Exception ex)
            {
                DotNetNuke.Services.Exceptions.Exceptions.LogException(ex);
            }
        }
Ejemplo n.º 5
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The UnInstall method uninstalls the config component
        /// </summary>
        /// <history>
        /// 	[cnurse]	08/04/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void UnInstall()
        {
            if (string.IsNullOrEmpty(_UninstallFileName))
            {
				//Create an XmlDocument for the config file
                _TargetConfig = new XmlDocument();
                TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));

                //Create XmlMerge instance from UnInstallConfig source
                var merge = new XmlMerge(new StringReader(UnInstallConfig), Package.Version.ToString(), Package.Name);

                //Update the Config file - Note that this method does save the file
                merge.UpdateConfig(TargetConfig, TargetFile.FullName);
            }
            else
            {
				//Process external file
                string strConfigFile = Path.Combine(Package.InstallerInfo.TempInstallFolder, _UninstallFileName);
                if (File.Exists(strConfigFile))
                {
					//Create XmlMerge instance from config file source
                    StreamReader stream = File.OpenText(strConfigFile);
                    var merge = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " UnInstall");

                    //Process merge
                    merge.UpdateConfigs();

                    //Close stream
                    stream.Close();
                }
            }
        }
Ejemplo n.º 6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The Install method installs the config component
        /// </summary>
        /// <history>
        /// 	[cnurse]	08/04/2007  created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void Install()
        {
            try
            {
                if (string.IsNullOrEmpty(_FileName))
                {
					//First backup the config file
                    Util.BackupFile(TargetFile, PhysicalSitePath, Log);

                    //Create an XmlDocument for the config file
                    _TargetConfig = new XmlDocument();
                    TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));

                    //Create XmlMerge instance from InstallConfig source
                    var merge = new XmlMerge(new StringReader(InstallConfig), Package.Version.ToString(), Package.Name);

                    //Update the Config file - Note that this method does not save the file - we will save it in Commit
                    merge.UpdateConfig(TargetConfig);
                    Completed = true;
                    Log.AddInfo(Util.CONFIG_Updated + " - " + TargetFile.Name);
                }
                else
                {
					//Process external file
                    string strConfigFile = Path.Combine(Package.InstallerInfo.TempInstallFolder, _FileName);
                    if (File.Exists(strConfigFile))
                    {
						//Create XmlMerge instance from config file source
                        using (var stream = File.OpenText(strConfigFile))
                        {
                            _xmlMerge = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " Install");

                            //Process merge
                            _xmlMerge.UpdateConfigs(false);
                        }

                        Completed = true;
                        Log.AddInfo(Util.CONFIG_Updated);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.AddFailure(Util.EXCEPTION + " - " + ex.Message);
            }
        }
 public override void UnInstall()
 {
     if (string.IsNullOrEmpty(_UninstallFileName))
     {
         _TargetConfig = new XmlDocument();
         TargetConfig.Load(Path.Combine(PhysicalSitePath, TargetFile.FullName));
         XmlMerge merge = new XmlMerge(new StringReader(UnInstallConfig), this.Package.Version.ToString(), this.Package.Name);
         merge.UpdateConfig(TargetConfig, TargetFile.FullName);
     }
     else
     {
         string strConfigFile = Path.Combine(this.Package.InstallerInfo.TempInstallFolder, _UninstallFileName);
         if (File.Exists(strConfigFile))
         {
             StreamReader stream = File.OpenText(strConfigFile);
             XmlMerge merge = new XmlMerge(stream, Package.Version.ToString(3), Package.Name + " UnInstall");
             merge.UpdateConfigs();
             stream.Close();
         }
     }
 }