public ClientCatch SiteClientCacheGet(string siteName) { Site site = _serverManager.Sites[siteName]; if (site == null) { throw new Exception(string.Format("站点{0}不存在!", siteName)); } Configuration siteConfig = site.GetWebConfiguration(); ConfigurationSection staticContentSection = siteConfig.GetSection("system.webServer/staticContent"); ConfigurationElement clientCacheElement = staticContentSection.GetChildElement("clientCache"); ClientCatch clientCatch = new ClientCatch(); clientCatch.CacheControlMode = (CacheControlMode)clientCacheElement["cacheControlMode"]; clientCatch.HttpExpires = DateTime.Parse(clientCacheElement["httpExpires"].ToString()); return clientCatch; }
public void SiteClientCacheSet(string siteName, ClientCatch clientCatch) { Site site = _serverManager.Sites[siteName]; if (site == null) { throw new Exception(string.Format("站点{0}不存在!", siteName)); } Configuration siteConfig = site.GetWebConfiguration(); ConfigurationSection staticContentSection = siteConfig.GetSection("system.webServer/staticContent"); ConfigurationElement clientCacheElement = staticContentSection.GetChildElement("clientCache"); clientCacheElement["cacheControlMode"] = clientCatch.CacheControlMode.ToString(); clientCacheElement["httpExpires"] = clientCatch.HttpExpires.ToUniversalTime().ToString("r"); _serverManager.CommitChanges(); }
public string SiteClientCacheSet(DeveloperInfo developerInfo, string siteName, int appId, string expires) { ClientCatch clientCatch = new ClientCatch(); clientCatch.CacheControlMode = string.IsNullOrEmpty(expires) ? CacheControlMode.DisableCache : CacheControlMode.UseExpires; if (!string.IsNullOrEmpty(expires)) { clientCatch.HttpExpires = DateTime.Parse(expires); } IISProcess iisProcess = new IISProcess(DeveloperConfig.SystemPhysicalPath, developerInfo.LoginName); iisProcess.SiteClientCacheSet(siteName, clientCatch); DbCommand cmd = _dataBaseAccess.CreateCommand(); cmd.CommandText = "Proc_Apps_SiteClientCache_Update"; DbParameter param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@AppId"; param.DbType = DbType.Int32; param.Value = appId; cmd.Parameters.Add(param); param = _dataBaseAccess.CreateParameter(); param.ParameterName = "@ClientCache"; param.DbType = DbType.String; param.Value = expires; cmd.Parameters.Add(param); _dataBaseAccess.ExecuteCommand(cmd); return string.Empty; }