public void Handle(ThreadEntity CurrentThreadEntity, Page.PageAbstract CurrentPageClass, HTMLContainer ContentContainer) { _threadEntity = CurrentThreadEntity; _threadEntity.ControlIndex += 1; HTMLContainer _innerHTML = new HTMLContainer(ContentContainer.Encoding); if (CurrentPageClass is Page.UserPage) { Page.UserPage up = (Page.UserPage)CurrentPageClass; if (up.CurrentUser != null) { if ((_hasPowerIndex > 0 && up.CurrentUser.HasPower(_hasPowerIndex)) || (!string.IsNullOrEmpty(_hasPowerKey) && up.CurrentUser.HasPower(_hasPowerKey))) { if (_inGroupIndex > 0 || !string.IsNullOrEmpty(_inGroupKey)) { if (up.CurrentUser.InGroup(_inGroupIndex) || up.CurrentUser.InGroup(_inGroupKey)) { _innerHTML.Write(_innerData); } } else { _innerHTML.Write(_innerData); } } else if ((_inGroupIndex > 0 && up.CurrentUser.InGroup(_inGroupIndex)) || (!string.IsNullOrEmpty(_hasPowerKey) && up.CurrentUser.InGroup(_inGroupKey))) { _innerHTML.Write(_innerData); } } } if (_innerHTML.Length == 0 && !string.IsNullOrEmpty(_noPowerMessage)) { ContentContainer.Write(_noPowerMessage); } else { if (_enableScript) { Control.ControlAnalyze _controls = Cache.PageAnalyze.GetInstance(CurrentThreadEntity, CurrentPageClass, this.Map); if (!_controls.IsHandled || CurrentPageClass.WebSetting.DebugMode) { _controls.SetContent(_innerHTML.ToArray()); _controls.Analyze(); } _controls.Handle(CurrentPageClass, ContentContainer); } else { ContentContainer.Write(_innerHTML); } } _threadEntity.ControlIndex -= 1; }
public void Handle(ThreadEntity CurrentThreadEntity, Page.PageAbstract CurrentPageClass, HTMLContainer ContentContainer) { _threadEntity = CurrentThreadEntity; _threadEntity.ControlIndex += 1; string _content = string.Empty; if (_preEnableScript && _innerData.Length > 0) { Control.ControlAnalyze _controls = Cache.PageAnalyze.GetInstance(CurrentThreadEntity, CurrentPageClass, this.Map); if (!_controls.IsHandled || CurrentPageClass.WebSetting.DebugMode) { _controls.SetContent(_innerData.ToArray()); _controls.Analyze(); } HTMLContainer _temp = new HTMLContainer(_innerData.Encoding); _controls.Handle(CurrentPageClass, _temp); _content = _temp.ToString(); } else { _content = _innerData.ToString(); } if (_append) { string _originalContent = string.Empty; if (CurrentPageClass.PageData[_dataName] != null) { _originalContent = CurrentPageClass.PageData[_dataName].GetDataString(); } CurrentPageClass.PageData.Add(_dataName, _originalContent + _content); } else { CurrentPageClass.PageData.Add(_dataName, _content); } _threadEntity.ControlIndex -= 1; }
public void Handle(string map, string filePath, bool enableScript, bool isIncludePage) { #if DEBUG Xy.Tools.Debug.Log.WriteEventLog("start page:" + map); #endif string _staticCacheDir = string.Empty, _staticCacheFile = string.Empty, _staticCachePath = string.Empty; if (_threadEntity.URLItem.EnableCache && !isIncludePage) { _staticCacheDir = WebSetting.CacheDir + "PageCache\\" + _threadEntity.URL.Dir.Replace('/', '\\'); _staticCacheFile = filePath + (_threadEntity.URL.HasParam ? _threadEntity.URL.Param.Replace('?', '#') : string.Empty); _staticCachePath = _staticCacheDir + _staticCacheFile + ".xycache"; if (!UpdateCache(_staticCachePath, DateTime.Now)) { if (System.IO.File.Exists(_staticCachePath)) { DateTime _modifiedTime = System.IO.File.GetLastWriteTime(_staticCachePath); if (Xy.Tools.IO.File.IsClientCached(_request.Headers["If-Modified-Since"], _modifiedTime) && !_webSetting.DebugMode) { _response.StatusCode = 304; _response.SuppressContent = true; } else { _response.Cache.SetLastModified(DateTime.Now); if (_threadEntity.URLItem.Age.TotalMinutes > 0) { _response.Cache.SetMaxAge(_threadEntity.URLItem.Age); _response.Cache.SetExpires(DateTime.Now.Add(_threadEntity.URLItem.Age)); _response.Expires = Convert.ToInt32(_threadEntity.URLItem.Age.TotalMinutes); _response.ExpiresAbsolute = DateTime.Now.Add(_threadEntity.URLItem.Age); _response.AddHeader("Cache-Control", "max-age=" + _threadEntity.URLItem.Age.TotalMinutes); } _htmlContainer.Write(System.IO.File.ReadAllBytes(_staticCachePath)); } return; } } } onGetRequest(); #if DEBUG Xy.Tools.Debug.Log.WriteEventLog(map + " page process:onGetRequest finished"); #endif Validate(); #if DEBUG Xy.Tools.Debug.Log.WriteEventLog(map + " page process:Validate finished"); #endif string _sourcefile = string.Empty; if (!string.IsNullOrEmpty(filePath)) { _sourcefile = LoadSourceFile((isIncludePage ? _webSetting.IncludeDir : _webSetting.PageDir) + filePath); #if DEBUG Xy.Tools.Debug.Log.WriteEventLog(map + " page process:LoadSourceFile finished"); #endif } Control.ControlAnalyze _controls = Cache.PageAnalyze.GetInstance(_threadEntity, this, map); if (!_controls.IsHandled || WebSetting.DebugMode) { if (!string.IsNullOrEmpty(_sourcefile)) { _content = System.IO.File.ReadAllBytes(_sourcefile); _controls.SetContent(_content); } } if (_contentChanged) { _controls.SetContent(_content); } if (enableScript) { if (!_controls.IsHandled) { _controls.Analyze(); } HandleControl(_controls.ControlCollection); } #if DEBUG Xy.Tools.Debug.Log.WriteEventLog(map + " page process:HandleControl finished"); #endif _controls.Handle(this, _htmlContainer); #if DEBUG Xy.Tools.Debug.Log.WriteEventLog(map + " controls handled"); #endif OutputHtml(_htmlContainer); #if DEBUG Xy.Tools.Debug.Log.WriteEventLog(map + " page process:OutputHtml finished"); #endif if (_threadEntity.URLItem.EnableCache && !isIncludePage) { Xy.Tools.IO.File.ifNotExistsThenCreate(_staticCachePath); using (System.IO.FileStream fs = new System.IO.FileStream(_staticCachePath, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read)) { using (System.IO.StreamWriter sw = new System.IO.StreamWriter(fs)) { try { sw.Write(_htmlContainer.ToString()); sw.Flush(); } finally { sw.Close(); fs.Close(); } } } #if DEBUG Xy.Tools.Debug.Log.WriteEventLog(map + " page cache writed"); #endif } #if DEBUG Xy.Tools.Debug.Log.WriteEventLog(map + " end"); #endif }