Example #1
0
        public void Handle(ThreadEntity CurrentThreadEntity, Page.PageAbstract CurrentPageClass, HTMLContainer ContentContainer)
        {
            _threadEntity = CurrentThreadEntity;
            _threadEntity.ControlIndex += 1;
            _dataBuilder.Init(_tagList);
            _datastring = _dataBuilder.HandleData(CurrentPageClass);

            HTMLContainer _temp = new HTMLContainer(ContentContainer.Encoding);

            if (!_xsltLoaded || _threadEntity.WebSetting.DebugMode) {
                _xsltCache = HandleXSLT();
            }
            _xsltString = _xsltCache;
            _xsltString = _dataBuilder.InsertParameter(_xsltString);
            if (!string.IsNullOrEmpty(_xsltParameter)) {
                _xsltString = InsertParameter(_xsltString, CurrentPageClass);
            }
            _temp.Write(HandleHTML(_datastring, _xsltString));

            if (_enableScript && _temp.Length > 0) {
                Control.ControlAnalyze _controls = new ControlAnalyze(CurrentThreadEntity, this.Map, true);
                _controls.SetContent(_temp.ToArray());
                _controls.Analyze();
                _temp.Clear();
                _controls.Handle(CurrentPageClass, _temp);
            }
            ContentContainer.Write(_temp);
            _threadEntity.ControlIndex -= 1;
        }
Example #2
0
        public void Handle(ThreadEntity CurrentThreadEntity, Page.PageAbstract CurrentPageClass, HTMLContainer ContentContainer)
        {
            _threadEntity = CurrentThreadEntity;
            _threadEntity.ControlIndex += 1;

            _index = Xy.Tools.Control.Tag.TransferValue("PageIndex", _index, CurrentPageClass);
            _size = Xy.Tools.Control.Tag.TransferValue("PageSize", _size, CurrentPageClass);
            _max = Xy.Tools.Control.Tag.TransferValue("PageMax", _max, CurrentPageClass);
            _count = Xy.Tools.Control.Tag.TransferValue("PageCount", _count, CurrentPageClass);

            if (_innerData == null || (!string.IsNullOrEmpty(_xsltstring) && _threadEntity.WebSetting.DebugMode)) {
                if (!string.IsNullOrEmpty(_xsltstring)) {
                    using (System.IO.FileStream fs = new System.IO.FileStream(_threadEntity.WebSetting.XsltDir + _xsltstring, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)) {
                        using (System.IO.StreamReader sr = new System.IO.StreamReader(fs)) {
                            _innerData.Write(sr.ReadToEnd());
                            sr.Close();
                        }
                        fs.Close();
                    }
                }
            }
            HandleData();
            System.Xml.XPath.XPathDocument xpathDoc = new System.Xml.XPath.XPathDocument(new System.IO.StringReader(_datastring));

            System.Xml.Xsl.XslCompiledTransform xsl = HandleXSLT();

            ContentContainer.Write(Xy.Tools.IO.XML.TransfromXmlStringToHtml(xsl, xpathDoc));
            _threadEntity.ControlIndex -= 1;
        }
Example #3
0
        public void Handle(ThreadEntity CurrentThreadEntity, Page.PageAbstract CurrentPageClass, HTMLContainer ContentContainer)
        {
            _threadEntity = CurrentThreadEntity;
            _threadEntity.ControlIndex += 1;
            _dataBuilder.Init(_tagList);
            _datastring = _dataBuilder.HandleData(CurrentPageClass);
            if (!_xsltLoaded || _threadEntity.WebSetting.DebugMode)
            {
                _xsltstring = HandleXSLT();
            }
            HTMLContainer _temp = new HTMLContainer(ContentContainer.Encoding);

            _xsltstring = _dataBuilder.InsertParameter(_xsltstring);
            if (!string.IsNullOrEmpty(_xsltParameter))
            {
                _xsltstring = InsertParameter(_xsltstring, CurrentPageClass);
            }
            _temp.Write(HandleHTML(_datastring, _xsltstring));

            if (_enableScript && _temp.Length > 0)
            {
                Control.ControlAnalyze _controls = new ControlAnalyze(CurrentThreadEntity, this.Map, true);
                _controls.SetContent(_temp.ToArray());
                _controls.Analyze();
                _temp.Clear();
                _controls.Handle(CurrentPageClass, _temp);
            }
            ContentContainer.Write(_temp);
            _threadEntity.ControlIndex -= 1;
        }
        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;
        }
Example #5
0
 public void Handle(ThreadEntity CurrentThreadEntity, Page.PageAbstract CurrentPageClass, HTMLContainer ContentContainer)
 {
     _threadEntity = CurrentThreadEntity;
     _threadEntity.ControlIndex++;
     if (_webSetting == null) _webSetting = CurrentPageClass.WebSetting;
     HTMLContainer _container = new HTMLContainer(_webSetting.Encoding);
     Xy.Web.Page.PageAbstract _page;
     if (string.IsNullOrEmpty(_type)) _type = "Xy.Web,Xy.Web.Page.EmptyPage";
     _page = Runtime.Web.PageClassLibrary.Get(_type);
     _page.Init(CurrentPageClass, _webSetting, _container);
     if (_extValues != null) {
         for (int i = 0; i < _extValues.Count; i++) {
             if (_page.Request.Values[_extValues.Keys[i]] != null) {
                 _page.Request.Values[_extValues.Keys[i]] = _extValues[i];
             } else {
                 _page.Request.Values.Add(_extValues.Keys[i], _extValues[i]);
             }
         }
     }
     string _staticCacheDir = string.Empty, _staticCacheFile = string.Empty, _staticCachePath = string.Empty;
     if (_cached) {
         _staticCacheDir = _webSetting.CacheDir + "IncludeCache\\" + _threadEntity.URL.Dir.Replace('/', '\\');
         _staticCacheFile = _file + _valueString;
         _staticCachePath = _staticCacheDir + _staticCacheFile + ".xycache";
         if (!_page.UpdateCache(_staticCachePath, DateTime.Now)) {
             if (System.IO.File.Exists(_staticCachePath)) {
                 ContentContainer.Write(System.IO.File.ReadAllBytes(_staticCachePath));
                 return;
             }
         }
     }
     if (_innerData != null && _innerData.HasContent) {
         _page.SetContent(_innerData);
     }
     _page.Handle(_map, _file, _enableScript, true);
     if (_cached) {
         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(_container.ToString());
                     sw.Flush();
                 } finally {
                     sw.Close();
                     fs.Close();
                 }
             }
         }
     }
     ContentContainer.Write(_container);
     //ContentContainer.Write(_page.HTMLContainer);
     _threadEntity.ControlIndex--;
 }
Example #6
0
 public void Init(ThreadEntity threadEntity, WebSetting.WebSettingItem webSetting)
 {
     _threadEntity     = threadEntity;
     _htmlContainer    = new HTMLContainer(_threadEntity.WebSetting.Encoding);
     _server           = _threadEntity.WebContext.Server;
     _url              = threadEntity.URL;
     _updateLocalCache = false;
     _response         = new PageResponse(_threadEntity, _htmlContainer);
     _request          = new PageRequest(_threadEntity);
     _pageData         = new PageData();
     _pageSession      = PageSessionCollection.GetInstance().GetSession(_threadEntity);
     _webSetting       = webSetting;
 }
Example #7
0
 public void Init(PageAbstract page, WebSetting.WebSettingItem webSetting, HTMLContainer container)
 {
     _threadEntity     = page._threadEntity;
     _server           = page._server;
     _updateLocalCache = page._updateLocalCache;
     _request          = page._request;
     _pageData         = page._pageData;
     _pageSession      = page._pageSession;
     _url        = page._url;
     _webSetting = webSetting;
     _response   = page._response;
     _response.SetNewContainer(container);
     _htmlContainer = container;
 }
Example #8
0
        public void Init(System.Collections.Specialized.NameValueCollection CreateTag, HTMLContainer content, string map, int Index)
        {
            for (int i = 0; i < CreateTag.Count; i++)
            {
                switch (CreateTag.Keys[i])
                {
                case "File":
                    _file = CreateTag[i];
                    break;

                case "Type":
                    _type = CreateTag[i];
                    break;

                case "EnableScript":
                    if (string.Compare(CreateTag[i], "true", true) == 0)
                    {
                        _enableScript = true;
                    }
                    break;

                case "EnableCache":
                    if (string.Compare(CreateTag[i], "true", true) == 0)
                    {
                        _enableCache = true;
                    }
                    break;

                case "Value":
                    _extValues = Xy.Tools.Control.Tag.Decode(CreateTag[i]);
                    break;

                case "Config":
                    _webSetting = Xy.WebSetting.WebSettingCollection.GetWebSetting(CreateTag[i]);
                    break;
                }
            }
            _map       = map + "PageControl" + Index;
            _innerHTML = content;
        }
Example #9
0
        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;
        }
Example #10
0
 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;
 }
Example #11
0
        public void Handle(Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
        {
            if (!_isHandled)
            {
                contentContainer.Write(_content);
                return;
            }
            for (int i = 0; i < _analyzeResultCollection.Count; i++)
            {
//                if (_isHandled && _controlCollection[i].Cached) {
//                    continue;
//                }
//                try {
//#if DEBUG
//                    Xy.Tools.Debug.Log.WriteEventLog(_controlCollection[i].Map + " control handle start");
//#endif
//                    _controlCollection[i].Handle(_currentThreadEntity, currentPageClass);
//#if DEBUG
//                    Xy.Tools.Debug.Log.WriteEventLog(_controlCollection[i].Map + " control handle end");
//#endif
//                } catch (Exception ex) {
//                    throw new Exception("meet a error on handle control: " + _controlCollection[i].Map, ex);
//                }
                try {
#if DEBUG
                    Xy.Tools.Debug.Log.WriteEventLog(_analyzeResultCollection[i].Map + " control handle start");
#endif
                    _analyzeResultCollection[i].Handle(currentPageClass.ThreadEntity, currentPageClass, contentContainer);
#if DEBUG
                    Xy.Tools.Debug.Log.WriteEventLog(_analyzeResultCollection[i].Map + " control handle end");
#endif
                } catch (Exception ex) {
                    throw new Exception("meet an error on handle content: " + _analyzeResultCollection[i].Map, ex);
                }
            }
        }
Example #12
0
 private void delegate_Config_ScriptPath(string name, ThreadEntity currentThreadEntity, Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
 {
     contentContainer.Write(_webConfig.ScriptPath);
 }
Example #13
0
 private void delegate_App_ScriptPath(string name, ThreadEntity currentThreadEntity, Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
 {
     contentContainer.Write(string.Concat(currentPageClass.URL.BasePath, _webConfig.ScriptPath));
 }
Example #14
0
 public void SetContent(HTMLContainer content)
 {
     _content = content.ToArray();
     _contentChanged = true;
 }
Example #15
0
 internal void SetNewContainer(HTMLContainer content)
 {
     _content = content;
 }
Example #16
0
 private void delegate_Theme_Name(string name, ThreadEntity currentThreadEntity, Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
 {
     contentContainer.Write(_webConfig.Theme);
 }
Example #17
0
        private void delegate_Session(string name, ThreadEntity currentThreadEntity, Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
        {
            string temp = Convert.ToString(currentPageClass.Session[name]);

            if (!string.IsNullOrEmpty(temp))
            {
                contentContainer.Write(temp);
            }
        }
Example #18
0
 public void SetContent(HTMLContainer content)
 {
     _content        = content.ToArray();
     _contentChanged = true;
 }
Example #19
0
        public void Handle(ThreadEntity CurrentThreadEntity, Page.PageAbstract CurrentPageClass, HTMLContainer ContentContainer)
        {
            _threadEntity = CurrentThreadEntity;
            _threadEntity.ControlIndex++;
            if (_webSetting == null)
            {
                _webSetting = CurrentPageClass.WebSetting;
            }
            HTMLContainer _container = new HTMLContainer(_webSetting.Encoding);

            Xy.Web.Page.PageAbstract _page;
            if (string.IsNullOrEmpty(_type))
            {
                _type = "Xy.Web,Xy.Web.Page.EmptyPage";
            }
            _page = Runtime.Web.PageClassLibrary.Get(_type);
            _page.Init(CurrentPageClass, _webSetting, _container);
            if (_extValues != null)
            {
                for (int i = 0; i < _extValues.Count; i++)
                {
                    if (_page.Request.Values[_extValues.Keys[i]] != null)
                    {
                        _page.Request.Values[_extValues.Keys[i]] = _extValues[i];
                    }
                    else
                    {
                        _page.Request.Values.Add(_extValues.Keys[i], _extValues[i]);
                    }
                }
            }
            string _staticCacheDir = string.Empty, _staticCacheFile = string.Empty, _staticCachePath = string.Empty;

            if (_cached)
            {
                _staticCacheDir  = _webSetting.CacheDir + "IncludeCache\\" + _threadEntity.URL.Dir.Replace('/', '\\');
                _staticCacheFile = _file + _valueString;
                _staticCachePath = _staticCacheDir + _staticCacheFile + ".xycache";
                if (!_page.UpdateCache(_staticCachePath, DateTime.Now))
                {
                    if (System.IO.File.Exists(_staticCachePath))
                    {
                        ContentContainer.Write(System.IO.File.ReadAllBytes(_staticCachePath));
                        return;
                    }
                }
            }
            if (_innerData != null && _innerData.HasContent)
            {
                _page.SetContent(_innerData);
            }
            _page.Handle(_map, _file, _enableScript, true);
            if (_cached)
            {
                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(_container.ToString());
                            sw.Flush();
                        } finally {
                            sw.Close();
                            fs.Close();
                        }
                    }
                }
            }
            ContentContainer.Write(_container);
            //ContentContainer.Write(_page.HTMLContainer);
            _threadEntity.ControlIndex--;
        }
Example #20
0
 internal void SetNewContainer(HTMLContainer content)
 {
     _content = content;
 }
Example #21
0
 public virtual HTMLContainer OutputHtml(HTMLContainer HTMLContainer)
 {
     return(HTMLContainer);
 }
Example #22
0
 public void Write(HTMLContainer html)
 {
     _content.Write(html);
 }
Example #23
0
 internal PageResponse(ThreadEntity entity, HTMLContainer content)
 {
     _innerResponse = entity.WebContext.Response;
     _content = content;
     _entity = entity;
 }
Example #24
0
        public void Analyze()
        {
            if (_content.Length == 0)
            {
                return;
            }
#if DEBUG
            Xy.Tools.Debug.Log.WriteEventLog(_map + " start control analyze");
#endif
            int           _controlStartPoint   = 0;
            int           _controlEndPoint     = 0;
            int           _controlDeep         = 0;
            int           _lastPoint           = _point;
            int           _controlEndPointHold = 0;
            IControl      _controlHold         = null;
            string        _controlCreateString;
            byte[]        _tempBytes;
            HTMLContainer _container;

            while ((_controlStartPoint = findNextStartTag()) > 0 && _lastPoint < _content.Length)
            {
                _controlEndPoint = findNextEndTag();
                if (_controlEndPoint == -1)
                {
                    throw new Exception("Unclosed tag");
                }
                _tempBytes = new byte[_controlEndPoint - _controlStartPoint];
                Buffer.BlockCopy(_content, _controlStartPoint, _tempBytes, 0, _tempBytes.Length);
                _controlCreateString = _currentThreadEntity.WebSetting.Encoding.GetString(_tempBytes).Trim();
                if (_controlDeep > 0)
                {
                    if (_controlCreateString.IndexOf("@End") == 0)
                    {
                        _controlDeep--;
                        if (_controlDeep == 0)
                        {
                            _tempBytes = new byte[_controlStartPoint - 2 - _controlEndPointHold];
                            Buffer.BlockCopy(_content, _controlEndPointHold, _tempBytes, 0, _tempBytes.Length);
                            _container = new HTMLContainer(_currentThreadEntity.WebSetting.Encoding);
                            _container.Write(_tempBytes);
                            _controlHold.InnerData = _container;
                        }
                    }
                    else
                    {
                        if (CreateControl(_controlCreateString, true).IsNeedData)
                        {
                            _controlDeep++;
                        }
                    }
                }
                else
                {
                    _container = new HTMLContainer(_currentThreadEntity.WebSetting.Encoding);
                    _tempBytes = new byte[_controlStartPoint - 2 - _lastPoint];
                    Buffer.BlockCopy(_content, _lastPoint, _tempBytes, 0, _tempBytes.Length);
                    _container.Write(_tempBytes);
                    _analyzeResultCollection.Add(new AnalyzeResult()
                    {
                        Type     = AnalyzeResultType.PureHTML,
                        PureHTML = _container,
                        Map      = _map + ".PurlHTML" + _lastPoint + "_" + (_controlStartPoint - 2)
                    });
                    //_contentList.Add(_container);

                    //_container = new HTMLContainer(_currentThreadEntity.WebSetting.Encoding);
                    //_contentList.Add(_container);
                    _controlHold = CreateControl(_controlCreateString);
                    if (_controlHold.IsNeedData)
                    {
                        _controlDeep++; _controlEndPointHold = _controlEndPoint + 2;
                    }
                    _controlCollection.Add(_controlHold);
                    _analyzeResultCollection.Add(new AnalyzeResult()
                    {
                        Type    = AnalyzeResultType.Control,
                        Control = _controlHold,
                        Map     = _controlHold.Map
                    });
                }
                _lastPoint = _controlEndPoint + 2;
            }
            if (_lastPoint < _content.Length)
            {
                _container = new HTMLContainer(_currentThreadEntity.WebSetting.Encoding);
                _tempBytes = new byte[_content.Length - _lastPoint];
                Buffer.BlockCopy(_content, _lastPoint, _tempBytes, 0, _tempBytes.Length);
                _container.Write(_tempBytes);
                //_contentList.Add(_container);
                _analyzeResultCollection.Add(new AnalyzeResult()
                {
                    Type     = AnalyzeResultType.PureHTML,
                    PureHTML = _container,
                    Map      = _map + "PurlHTML" + _lastPoint + "_" + _content.Length
                });
            }
            _isHandled = true;
#if DEBUG
            Xy.Tools.Debug.Log.WriteEventLog(_map + " finish control analyze");
#endif
        }
Example #25
0
 private void delegate_Config_DebugMode(string name, ThreadEntity currentThreadEntity, Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
 {
     contentContainer.Write(_webConfig.DebugMode ? "True" : "False");
 }
Example #26
0
        private void delegate_Group(string name, ThreadEntity currentThreadEntity, Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
        {
            string temp = currentPageClass.Request.GroupString[name];

            if (!string.IsNullOrEmpty(temp))
            {
                contentContainer.Write(temp);
            }
        }
Example #27
0
        private void delegate_Translate(string name, ThreadEntity currentThreadEntity, Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
        {
            string temp = _webConfig.Translate[name];

            if (!string.IsNullOrEmpty(temp))
            {
                contentContainer.Write(temp);
            }
        }
Example #28
0
        public void Handle(ThreadEntity CurrentThreadEntity, Page.PageAbstract CurrentPageClass, HTMLContainer ContentContainer)
        {
            _threadEntity = CurrentThreadEntity;
            if (_webConfig == null)
            {
                _webConfig = CurrentPageClass.WebSetting;
            }
            _threadEntity.ControlIndex += 1;
            HTMLContainer _innerHTML = new HTMLContainer(ContentContainer.Encoding);

            _fillContentDelegate(_settingProperty, CurrentThreadEntity, CurrentPageClass, _innerHTML);

            switch (_mode)
            {
            case TagMode.Get:
                break;

            case TagMode.Compare:
                bool   _passed    = false;
                string _dataValue = _innerHTML.ToString();
                _innerHTML.Clear();
                switch (_compareMode)
                {
                case CompareMode.Equal:
                    if (string.Compare(_dataValue, _compareValue) == 0)
                    {
                        _passed = true;
                    }
                    break;

                case CompareMode.NotEqual:
                    if (string.Compare(_dataValue, _compareValue) != 0)
                    {
                        _passed = true;
                    }
                    break;

                case CompareMode.Greater:
                    if (string.Compare(_dataValue, _compareValue) > 0)
                    {
                        _passed = true;
                    }
                    break;

                case CompareMode.Lesser:
                    if (string.Compare(_dataValue, _compareValue) < 0)
                    {
                        _passed = true;
                    }
                    break;

                case CompareMode.GreaterAndEqual:
                    if (string.Compare(_dataValue, _compareValue) >= 0)
                    {
                        _passed = true;
                    }
                    break;

                case CompareMode.LesserAndEqual:
                    if (string.Compare(_dataValue, _compareValue) <= 0)
                    {
                        _passed = true;
                    }
                    break;
                }
                if (_passed)
                {
                    _innerHTML.Write(_innerData);
                }
                break;

            case TagMode.Exist:
                if (_innerHTML.Length > 0)
                {
                    _innerHTML.Clear();
                    _innerHTML.Write(_innerData);
                }
                break;

            case TagMode.NotExist:
                if (_innerHTML.Length > 0)
                {
                    _innerHTML.Clear();
                }
                else
                {
                    _innerHTML.Write(_innerData);
                }
                break;
            }

            if (_innerHTML.Length == 0 && !string.IsNullOrEmpty(_defaultValue))
            {
                ContentContainer.Write(_defaultValue);
            }
            else
            {
                if (_enableScript)
                {
                    Control.ControlAnalyze _controls = new ControlAnalyze(CurrentThreadEntity, this.Map, _useInnerTag);
                    _controls.SetContent(_innerHTML.ToArray());
                    _controls.Analyze();
                    _controls.Handle(CurrentPageClass, ContentContainer);
                }
                else
                {
                    ContentContainer.Write(_innerHTML);
                }
            }
            _threadEntity.ControlIndex -= 1;
        }
Example #29
0
 private void delegate_Theme_Template(string name, ThreadEntity currentThreadEntity, Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
 {
     contentContainer.Write(currentThreadEntity.URLItem.PagePath);
 }
Example #30
0
 public void Write(HTMLContainer html)
 {
     _content.Write(html);
 }
Example #31
0
 private void delegate_Url_Dir(string name, ThreadEntity currentThreadEntity, Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
 {
     contentContainer.Write(currentPageClass.URL.Dir);
 }
Example #32
0
        public virtual void onGetError(Exception ex)
        {
            StringBuilder _errorString = new StringBuilder();
            Exception exception = ex;
            PageData.Add("WrongTime", DateTime.Now.ToString());
            _errorString.Append("WrongTime:").AppendLine(DateTime.Now.ToString());
            PageData.Add("ClientIP", Request.UserHostAddress);
            _errorString.Append("ClientIP:").AppendLine(Request.UserHostAddress);
            PageData.Add("ClientBrowser", string.Format("{0} | {1}", Request.Browser.Type, Request.Browser.Browser));
            _errorString.Append("ClientBrowser:").AppendLine(string.Format("{0} | {1}", Request.Browser.Type, Request.Browser.Browser));
            PageData.Add("UserAgent", Request.UserAgent);
            _errorString.Append("UserAgent:").AppendLine(Request.UserAgent);
            PageData.Add("URL", Request.Url.ToString());
            _errorString.Append("URL:").AppendLine(Request.Url.ToString());
            PageData.Add("Message", exception.Message);
            _errorString.Append("Message:").AppendLine(exception.Message);

            Exception inex = exception;
            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("Message");
            dt.Columns.Add("Source");
            dt.Columns.Add("TargetSite");
            dt.Columns.Add("Data");
            dt.Columns.Add("StackTrace");
            int i = 1;
            while (inex != null) {
                System.Data.DataRow dr = dt.NewRow();
                _errorString.AppendLine("=============================Exception No." + i++ + "=============================");
                dr["Message"] = string.IsNullOrEmpty(inex.Message) ? "None" : inex.Message.Replace("\r\n", "<br />");
                _errorString.AppendLine("Message:" + inex.Message);
                dr["Source"] = string.IsNullOrEmpty(inex.Source) ? "None" : inex.Source.Replace("\r\n", "<br />");
                _errorString.AppendLine("Source:" + inex.Source);
                dr["TargetSite"] = inex.TargetSite == null ? "None" : inex.TargetSite.ToString();
                _errorString.AppendLine("TargetSite:" + inex.TargetSite);

                StringBuilder _tsb = new StringBuilder();
                if (inex.Data != null) {
                    foreach (object _entry in inex.Data.Keys) {
                        _tsb.Append(string.Format("{0}:{1}<br />", _entry.ToString(), inex.Data[_entry]));
                    }
                    _errorString.AppendLine("Data:" + _tsb.ToString());
                    dr["Data"] = _tsb.Length == 0 ? "None" : _tsb.ToString();
                }

                dr["StackTrace"] = string.IsNullOrEmpty(inex.StackTrace) ? "None" : inex.StackTrace.Replace("\r\n", "<br />");
                _errorString.AppendLine("StackTrace:" + inex.StackTrace);
                dt.Rows.Add(dr);
                inex = inex.InnerException;
            }
            PageData.Add("Error", dt);
            Xy.Tools.Debug.Log.WriteErrorLog(_errorString.ToString());
            Response.StatusCode = 404;

            if (string.IsNullOrEmpty(ThreadEntity.URLItem.PagePath)) {
                HTMLContainer _errTemplate = new HTMLContainer(WebSetting.Encoding);
                _errTemplate.Write(_errorTemplate);
                SetContent(_errTemplate);
            }
        }
Example #33
0
 private void delegate_Data(string name, ThreadEntity currentThreadEntity, Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
 {
     Page.PageDataItem pdi = currentPageClass.PageData[name];
     if (pdi != null)
     {
         contentContainer.Write(pdi.GetDataString());
     }
 }
Example #34
0
 public void Handle(Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
 {
     if (!_isHandled) {
         contentContainer.Write(_content);
         return;
     }
     for (int i = 0; i < _analyzeResultCollection.Count; i++) {
     //                if (_isHandled && _controlCollection[i].Cached) {
     //                    continue;
     //                }
     //                try {
     //#if DEBUG
     //                    Xy.Tools.Debug.Log.WriteEventLog(_controlCollection[i].Map + " control handle start");
     //#endif
     //                    _controlCollection[i].Handle(_currentThreadEntity, currentPageClass);
     //#if DEBUG
     //                    Xy.Tools.Debug.Log.WriteEventLog(_controlCollection[i].Map + " control handle end");
     //#endif
     //                } catch (Exception ex) {
     //                    throw new Exception("meet a error on handle control: " + _controlCollection[i].Map, ex);
     //                }
         try {
     #if DEBUG
             Xy.Tools.Debug.Log.WriteEventLog(_analyzeResultCollection[i].Map + " control handle start");
     #endif
             _analyzeResultCollection[i].Handle(currentPageClass.ThreadEntity, currentPageClass, contentContainer);
     #if DEBUG
             Xy.Tools.Debug.Log.WriteEventLog(_analyzeResultCollection[i].Map + " control handle end");
     #endif
         } catch (Exception ex) {
             throw new Exception("meet an error on handle content: " + _analyzeResultCollection[i].Map, ex);
         }
     }
 }
        public void Handle(ThreadEntity CurrentThreadEntity, Page.PageAbstract CurrentPageClass, HTMLContainer ContentContainer)
        {
            _threadEntity = CurrentThreadEntity;
            _threadEntity.ControlIndex += 1;

            _index = Xy.Tools.Control.Tag.TransferValue("PageIndex", _index, CurrentPageClass);
            _size  = Xy.Tools.Control.Tag.TransferValue("PageSize", _size, CurrentPageClass);
            _max   = Xy.Tools.Control.Tag.TransferValue("PageMax", _max, CurrentPageClass);
            _count = Xy.Tools.Control.Tag.TransferValue("PageCount", _count, CurrentPageClass);

            if (_innerData == null || (!string.IsNullOrEmpty(_xsltstring) && _threadEntity.WebSetting.DebugMode))
            {
                if (!string.IsNullOrEmpty(_xsltstring))
                {
                    using (System.IO.FileStream fs = new System.IO.FileStream(_threadEntity.WebSetting.XsltDir + _xsltstring, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)) {
                        using (System.IO.StreamReader sr = new System.IO.StreamReader(fs)) {
                            _innerData.Write(sr.ReadToEnd());
                            sr.Close();
                        }
                        fs.Close();
                    }
                }
            }
            HandleData();
            System.Xml.XPath.XPathDocument xpathDoc = new System.Xml.XPath.XPathDocument(new System.IO.StringReader(_datastring));

            System.Xml.Xsl.XslCompiledTransform xsl = HandleXSLT();

            ContentContainer.Write(Xy.Tools.IO.XML.TransfromXmlStringToHtml(xsl, xpathDoc));
            _threadEntity.ControlIndex -= 1;
        }
Example #36
0
        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;
        }
Example #37
0
        public virtual void onGetError(Exception ex)
        {
            StringBuilder _errorString = new StringBuilder();
            Exception     exception    = ex;

            PageData.Add("WrongTime", DateTime.Now.ToString());
            _errorString.Append("WrongTime:").AppendLine(DateTime.Now.ToString());
            PageData.Add("ClientIP", Request.UserHostAddress);
            _errorString.Append("ClientIP:").AppendLine(Request.UserHostAddress);
            PageData.Add("ClientBrowser", string.Format("{0} | {1}", Request.Browser.Type, Request.Browser.Browser));
            _errorString.Append("ClientBrowser:").AppendLine(string.Format("{0} | {1}", Request.Browser.Type, Request.Browser.Browser));
            PageData.Add("UserAgent", Request.UserAgent);
            _errorString.Append("UserAgent:").AppendLine(Request.UserAgent);
            PageData.Add("URL", Request.Url.ToString());
            _errorString.Append("URL:").AppendLine(Request.Url.ToString());
            PageData.Add("Message", exception.Message);
            _errorString.Append("Message:").AppendLine(exception.Message);

            Exception inex = exception;

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("Message");
            dt.Columns.Add("Source");
            dt.Columns.Add("TargetSite");
            dt.Columns.Add("Data");
            dt.Columns.Add("StackTrace");
            int i = 1;

            while (inex != null)
            {
                System.Data.DataRow dr = dt.NewRow();
                _errorString.AppendLine("=============================Exception No." + i++ + "=============================");
                dr["Message"] = string.IsNullOrEmpty(inex.Message) ? "None" : inex.Message.Replace("\r\n", "<br />");
                _errorString.AppendLine("Message:" + inex.Message);
                dr["Source"] = string.IsNullOrEmpty(inex.Source) ? "None" : inex.Source.Replace("\r\n", "<br />");
                _errorString.AppendLine("Source:" + inex.Source);
                dr["TargetSite"] = inex.TargetSite == null ? "None" : inex.TargetSite.ToString();
                _errorString.AppendLine("TargetSite:" + inex.TargetSite);

                StringBuilder _tsb = new StringBuilder();
                if (inex.Data != null)
                {
                    foreach (object _entry in inex.Data.Keys)
                    {
                        _tsb.Append(string.Format("{0}:{1}<br />", _entry.ToString(), inex.Data[_entry]));
                    }
                    _errorString.AppendLine("Data:" + _tsb.ToString());
                    dr["Data"] = _tsb.Length == 0 ? "None" : _tsb.ToString();
                }

                dr["StackTrace"] = string.IsNullOrEmpty(inex.StackTrace) ? "None" : inex.StackTrace.Replace("\r\n", "<br />");
                _errorString.AppendLine("StackTrace:" + inex.StackTrace);
                dt.Rows.Add(dr);
                inex = inex.InnerException;
            }
            PageData.Add("Error", dt);
            Xy.Tools.Debug.Log.WriteErrorLog(_errorString.ToString());
            Response.StatusCode = 404;

            if (string.IsNullOrEmpty(ThreadEntity.URLItem.PagePath))
            {
                HTMLContainer _errTemplate = new HTMLContainer(WebSetting.Encoding);
                _errTemplate.Write(_errorTemplate);
                SetContent(_errTemplate);
            }
        }
Example #38
0
 internal PageResponse(ThreadEntity entity, HTMLContainer content)
 {
     _innerResponse = entity.WebContext.Response;
     _content       = content;
     _entity        = entity;
 }
Example #39
0
        internal void Handle(ThreadEntity currentThreadEntity, Page.PageAbstract currentPageClass, HTMLContainer contentContainer)
        {
            switch (Type)
            {
            case AnalyzeResultType.PureHTML:
                contentContainer.Write(PureHTML);
                break;

            case AnalyzeResultType.Control:
                Control.Handle(currentThreadEntity, currentPageClass, contentContainer);
                break;
            }
        }
Example #40
0
 public void Init(ThreadEntity threadEntity, WebSetting.WebSettingItem webSetting)
 {
     _threadEntity = threadEntity;
     _htmlContainer = new HTMLContainer(_threadEntity.WebSetting.Encoding);
     _server = _threadEntity.WebContext.Server;
     _url = threadEntity.URL;
     _updateLocalCache = false;
     _response = new PageResponse(_threadEntity, _htmlContainer);
     _request = new PageRequest(_threadEntity);
     _pageData = new PageData();
     _pageSession = PageSessionCollection.GetInstance().GetSession(_threadEntity);
     _webSetting = webSetting;
 }
Example #41
0
        public void Analyze()
        {
            if (_content.Length == 0) return;
            #if DEBUG
            Xy.Tools.Debug.Log.WriteEventLog(_map + " start control analyze");
            #endif
            int _controlStartPoint = 0;
            int _controlEndPoint = 0;
            int _controlDeep = 0;
            int _lastPoint = _point;
            int _controlEndPointHold = 0;
            IControl _controlHold = null;
            string _controlCreateString;
            byte[] _tempBytes;
            HTMLContainer _container;

            while ((_controlStartPoint = findNextStartTag()) > 0 && _lastPoint < _content.Length) {
                _controlEndPoint = findNextEndTag();
                if (_controlEndPoint == -1) throw new Exception("Unclosed tag");
                _tempBytes = new byte[_controlEndPoint - _controlStartPoint];
                Buffer.BlockCopy(_content, _controlStartPoint, _tempBytes, 0, _tempBytes.Length);
                _controlCreateString = _currentThreadEntity.WebSetting.Encoding.GetString(_tempBytes).Trim();
                if (_controlDeep > 0) {
                    if (_controlCreateString.IndexOf("@End") == 0) {
                        _controlDeep--;
                        if (_controlDeep == 0) {
                            _tempBytes = new byte[_controlStartPoint - 2 - _controlEndPointHold];
                            Buffer.BlockCopy(_content, _controlEndPointHold, _tempBytes, 0, _tempBytes.Length);
                            _container = new HTMLContainer(_currentThreadEntity.WebSetting.Encoding);
                            _container.Write(_tempBytes);
                            _controlHold.InnerData = _container;
                        }
                    } else {
                        if (CreateControl(_controlCreateString, true).IsNeedData) _controlDeep++;
                    }
                } else {
                    _container = new HTMLContainer(_currentThreadEntity.WebSetting.Encoding);
                    _tempBytes = new byte[_controlStartPoint - 2 - _lastPoint];
                    Buffer.BlockCopy(_content, _lastPoint, _tempBytes, 0, _tempBytes.Length);
                    _container.Write(_tempBytes);
                    _analyzeResultCollection.Add(new AnalyzeResult() {
                        Type = AnalyzeResultType.PureHTML,
                        PureHTML = _container,
                        Map = _map + ".PurlHTML" + _lastPoint + "_" + (_controlStartPoint - 2)
                    });
                    //_contentList.Add(_container);

                    //_container = new HTMLContainer(_currentThreadEntity.WebSetting.Encoding);
                    //_contentList.Add(_container);
                    _controlHold = CreateControl(_controlCreateString);
                    if (_controlHold.IsNeedData) { _controlDeep++; _controlEndPointHold = _controlEndPoint + 2; }
                    _controlCollection.Add(_controlHold);
                    _analyzeResultCollection.Add(new AnalyzeResult() {
                        Type = AnalyzeResultType.Control,
                        Control = _controlHold,
                        Map = _controlHold.Map
                    });
                }
                _lastPoint = _controlEndPoint + 2;
            }
            if (_lastPoint < _content.Length) {
                _container = new HTMLContainer(_currentThreadEntity.WebSetting.Encoding);
                _tempBytes = new byte[_content.Length - _lastPoint];
                Buffer.BlockCopy(_content, _lastPoint, _tempBytes, 0, _tempBytes.Length);
                _container.Write(_tempBytes);
                //_contentList.Add(_container);
                _analyzeResultCollection.Add(new AnalyzeResult() {
                    Type = AnalyzeResultType.PureHTML,
                    PureHTML = _container,
                    Map = _map + "PurlHTML" + _lastPoint + "_" + _content.Length
                });
            }
            _isHandled = true;
            #if DEBUG
            Xy.Tools.Debug.Log.WriteEventLog(_map + " finish control analyze");
            #endif
        }
Example #42
0
 public void Init(PageAbstract page, WebSetting.WebSettingItem webSetting, HTMLContainer container)
 {
     _threadEntity = page._threadEntity;
     _server = page._server;
     _updateLocalCache = page._updateLocalCache;
     _request = page._request;
     _pageData = page._pageData;
     _pageSession = page._pageSession;
     _url = page._url;
     _webSetting = webSetting;
     _response = page._response;
     _response.SetNewContainer(container);
     _htmlContainer = container;
 }
Example #43
0
 public void Init(System.Collections.Specialized.NameValueCollection CreateTag, HTMLContainer content,string map, int Index)
 {
     for (int i = 0; i < CreateTag.Count; i++) {
         switch (CreateTag.Keys[i]) {
             case "File":
                 _file = CreateTag[i];
                 break;
             case "Type":
                 _type = CreateTag[i];
                 break;
             case "EnableScript":
                 if (string.Compare(CreateTag[i], "true", true) == 0) {
                     _enableScript = true;
                 }
                 break;
             case "EnableCache":
                 if (string.Compare(CreateTag[i], "true", true) == 0) {
                     _enableCache = true;
                 }
                 break;
             case "Value":
                 _extValues = Xy.Tools.Control.Tag.Decode(CreateTag[i]);
                 break;
             case "Config":
                 _webSetting = Xy.WebSetting.WebSettingCollection.GetWebSetting(CreateTag[i]);
                 break;
         }
     }
     _map = map + "PageControl" + Index;
     _innerHTML = content;
 }
Example #44
0
 public virtual HTMLContainer OutputHtml(HTMLContainer HTMLContainer)
 {
     return HTMLContainer;
 }