public static string GetPath(params string[] paths) => PathUtils.GetSiteFilesPath("assets", PathUtils.Combine(paths));
public static void ResetWebConfig() { var configPath = PathUtils.Combine(PhysicalApplicationPath, WebConfigFileName); ResetWebConfig(configPath); }
public static void Load(string physicalApplicationPath, string webConfigFileName) { PhysicalApplicationPath = physicalApplicationPath; var isProtectData = false; var databaseType = string.Empty; var connectionString = string.Empty; try { var doc = new XmlDocument(); var configFile = PathUtils.Combine(PhysicalApplicationPath, webConfigFileName); doc.Load(configFile); var appSettings = doc.SelectSingleNode("configuration/appSettings"); if (appSettings != null) { foreach (XmlNode setting in appSettings) { if (setting.Name == "add") { var attrKey = setting.Attributes?["key"]; if (attrKey != null) { if (StringUtils.EqualsIgnoreCase(attrKey.Value, nameof(IsProtectData))) { var attrValue = setting.Attributes["value"]; if (attrValue != null) { isProtectData = TranslateUtils.ToBool(attrValue.Value); } } else if (StringUtils.EqualsIgnoreCase(attrKey.Value, nameof(DatabaseType))) { var attrValue = setting.Attributes["value"]; if (attrValue != null) { databaseType = attrValue.Value; } } else if (StringUtils.EqualsIgnoreCase(attrKey.Value, nameof(ConnectionString))) { var attrValue = setting.Attributes["value"]; if (attrValue != null) { connectionString = attrValue.Value; } } else if (StringUtils.EqualsIgnoreCase(attrKey.Value, nameof(AdminDirectory))) { var attrValue = setting.Attributes["value"]; if (attrValue != null) { AdminDirectory = attrValue.Value; } } else if (StringUtils.EqualsIgnoreCase(attrKey.Value, nameof(SecretKey))) { var attrValue = setting.Attributes["value"]; if (attrValue != null) { SecretKey = attrValue.Value; } } else if (StringUtils.EqualsIgnoreCase(attrKey.Value, nameof(IsNightlyUpdate))) { var attrValue = setting.Attributes["value"]; if (attrValue != null) { IsNightlyUpdate = TranslateUtils.ToBool(attrValue.Value); } } } } } if (isProtectData) { databaseType = TranslateUtils.DecryptStringBySecretKey(databaseType); connectionString = TranslateUtils.DecryptStringBySecretKey(connectionString); } } } catch { // ignored } IsProtectData = isProtectData; DatabaseType = DatabaseTypeUtils.GetEnumType(databaseType); ConnectionString = SqlUtils.GetConnectionString(DatabaseType, connectionString); if (string.IsNullOrEmpty(AdminDirectory)) { AdminDirectory = "siteserver"; } if (string.IsNullOrEmpty(SecretKey)) { SecretKey = StringUtils.GetShortGuid(); //SecretKey = "vEnfkn16t8aeaZKG3a4Gl9UUlzf4vgqU9xwh8ZV5"; } }
public static string GetPath(params string[] paths) { return(PathUtils.Combine(PathUtils.PhysicalSiteServerPath, DirectoryName, PathUtils.Combine(paths))); }