Exemplo n.º 1
0
        public static string UpdateConfig(string providerPath, string configFile, Version version, string reason)
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "UpdateConfig:" + version.ToString(3));
            string exceptions = "";
            if (File.Exists(configFile))
            {
                //Create XmlMerge instance from config file source
                StreamReader stream = File.OpenText(configFile);
                try
                {
                    var merge = new XmlMerge(stream, version.ToString(3), reason);

                    //Process merge
                    merge.UpdateConfigs();
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    exceptions += string.Format("Error: {0}{1}", ex.Message + ex.StackTrace, Environment.NewLine);
                    // log the results
                    try
                    {
                        using (StreamWriter streamWriter = File.CreateText(providerPath + Globals.FormatVersion(version) + "_Config.log"))
                        {
                            streamWriter.WriteLine(exceptions);
                            streamWriter.Close();
                        }
                    }
                    catch (Exception exc)
                    {
                        Logger.Error(exc);
                    }
                }
                finally
                {
                    //Close stream
                    stream.Close();
                }
            }
            if (string.IsNullOrEmpty(exceptions))
            {
                DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogEnd", Localization.Localization.GlobalResourceFile) + "UpdateConfig:" + version.ToString(3));
            }
            else
            {
                DnnInstallLogger.InstallLogError(exceptions);
            }
            return exceptions;
        }
Exemplo n.º 2
0
        public static string UpdateConfig(string configFile, Version version, string reason)
        {
            string exceptions = "";
            if (File.Exists(configFile))
            {
                //Create XmlMerge instance from config file source
                StreamReader stream = File.OpenText(configFile);
                try
                {
                    var merge = new XmlMerge(stream, version.ToString(3), reason);

                    //Process merge
                    merge.UpdateConfigs();
                }
                catch (Exception ex)
                {
                    exceptions += String.Format("Error: {0}{1}", ex.Message + ex.StackTrace, Environment.NewLine);
                    Exceptions.Exceptions.LogException(ex);
                }
                finally
                {
                    //Close stream
                    stream.Close();
                }
            }
            return exceptions;
        }