static WebConfigUtils() { string physicalApplicationPath; var applicationPath = string.Empty; if (HttpContext.Current != null) { physicalApplicationPath = HttpContext.Current.Request.PhysicalApplicationPath; applicationPath = HttpContext.Current.Request.ApplicationPath; } else { physicalApplicationPath = Environment.CurrentDirectory; } if (string.IsNullOrEmpty(applicationPath)) { applicationPath = "/"; } PhysicalApplicationPath = physicalApplicationPath; ApplicationPath = applicationPath; var isProtectData = false; var databaseType = string.Empty; var connectionString = string.Empty; try { var doc = new XmlDocument(); var configFile = PathUtils.Combine(PhysicalApplicationPath, "web.config"); 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, NameIsProtectData)) { var attrValue = setting.Attributes["value"]; if (attrValue != null) { isProtectData = TranslateUtils.ToBool(attrValue.Value); } } else if (StringUtils.EqualsIgnoreCase(attrKey.Value, NameDatabaseType)) { var attrValue = setting.Attributes["value"]; if (attrValue != null) { databaseType = attrValue.Value; } } else if (StringUtils.EqualsIgnoreCase(attrKey.Value, NameConnectionString)) { var attrValue = setting.Attributes["value"]; if (attrValue != null) { connectionString = attrValue.Value; } } } } } if (isProtectData) { databaseType = TranslateUtils.DecryptStringBySecretKey(databaseType); connectionString = TranslateUtils.DecryptStringBySecretKey(connectionString); } } } catch { // ignored } IsMySql = StringUtils.EqualsIgnoreCase(databaseType, "MySql"); ConnectionString = connectionString; }
public static string GetPath(params string[] paths) { return(PathUtils.Combine(PathUtils.PhysicalSiteServerPath, DirectoryName, PathUtils.Combine(paths))); }
public static string GetPath(params string[] paths) => PathUtils.GetSiteFilesPath("assets", PathUtils.Combine(paths));
public static string GetCacheFilePath(string cacheFileName) { return(PathUtils.Combine(WebConfigUtils.PhysicalApplicationPath, DirectoryUtils.SiteFiles.DirectoryName, DirectoryUtils.SiteFiles.TemporaryFiles, cacheFileName)); }