Esempio n. 1
0
        public void Init(System.Collections.Specialized.NameValueCollection CreateTag, int Index)
        {
            for (int i = 0; i < CreateTag.Count; i++)
            {
                switch (CreateTag.Keys[i])
                {
                case "File":
                    _file = CreateTag[i];
                    break;

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

                case "Config":
                    _webConfig = Xy.WebSetting.WebSettingCollection.GetWebSetting(CreateTag[i]);
                    break;

                case "ID":
                    _id = CreateTag[i];
                    break;
                }
            }
            if (string.IsNullOrEmpty(ID))
            {
                _id = Xy.Web.Control.ControlFactory.UNNAME + "IncludeControl" + Index;
            }
        }
Esempio n. 2
0
 public void Handle(ThreadEntity CurrentThreadEntity, Page.Page CurrentPageClass)
 {
     _threadEntity = CurrentThreadEntity;
     _threadEntity.ControlIndex += 1;
     Xy.WebSetting.WebSettingItem _tempWebConfig = null;
     if (_webConfig != null)
     {
         _tempWebConfig           = _threadEntity.WebSetting;
         _threadEntity.WebSetting = _webConfig;
     }
     InitSourceHtml();
     //if (_enableScript) {
     //    ControlCollection cc = new Control.ControlAnalyze(ref _innerHtml, _threadEntity).ControlCollection;
     //    cc.Handle(ref _innerHtml, ref _threadEntity);
     //}
     if (_enableScript)
     {
         ControlCollection cc;
         if (_threadEntity.WebSetting.DebugMode)
         {
             cc = new Control.ControlAnalyze(_innerHtml, _threadEntity).ControlCollection;
         }
         else
         {
             cc = _cacheItem._controlCollection;
         }
         cc.Handle(_innerHtml, _threadEntity, CurrentPageClass);
     }
     if (_webConfig != null)
     {
         _threadEntity.WebSetting = _tempWebConfig;
     }
     _threadEntity.ControlIndex -= 1;
 }
Esempio n. 3
0
        public static string GetCacheFilePath(string PageID, string ControlID, Xy.WebSetting.WebSettingItem websetting, Xy.Tools.Web.UrlAnalyzer url, bool cacheUrlParam = false)
        {
            StringBuilder _sb = new StringBuilder();

            _sb.Append(websetting.CacheDir);
            _sb.Append(url.Path.Replace('/', '\\'));
            if (cacheUrlParam)
            {
                _sb.Append(url.Param.Replace('?', '#'));
            }
            //_sb.Append('#');
            //int index = 0;
            //int inindex = 0;
            //int temp = 0;
            //foreach (System.Text.RegularExpressions.Group itemGroup in urlitem.Regex.Match(url.Path).Groups) {
            //    string tempName = urlitem.Regex.GroupNameFromNumber(index++);
            //    if (!int.TryParse(tempName, out temp)) {
            //        if (inindex++ != 0) _sb.Append('&');
            //        _sb.Append(tempName);
            //        _sb.Append('=');
            //        _sb.Append(itemGroup.Value);
            //    }
            //}
            if (!string.IsNullOrEmpty(PageID))
            {
                _sb.Append("-" + PageID);
            }
            if (!string.IsNullOrEmpty(ControlID))
            {
                _sb.Append("-" + ControlID);
            }
            _sb.Append(".cache");
            return(_sb.ToString());
        }
Esempio n. 4
0
 public ThreadEntity(System.Web.HttpContext webApp, WebSetting.WebSettingItem webSetting, URLManage.URLItem urlItem, Xy.Tools.Web.UrlAnalyzer currentURL)
 {
     _webContext = webApp;
     _webSetting = webSetting;
     _urlItem    = urlItem;
     _url        = currentURL;
     _content    = new HTMLContainer(_webSetting.Encoding);
 }
Esempio n. 5
0
 public ThreadEntity(System.Web.HttpContext webApp, WebSetting.WebSettingItem webSetting, URLManage.URLItem urlItem, Xy.Tools.Web.UrlAnalyzer currentURL)
 {
     _webContext = webApp;
     _webSetting = webSetting;
     _urlItem = urlItem;
     _url = currentURL;
     _content = new HTMLContainer(_webSetting.Encoding);
 }
Esempio n. 6
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--;
 }
Esempio n. 7
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;
 }
Esempio n. 8
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;
 }
Esempio n. 9
0
 public void Handle(ThreadEntity CurrentThreadEntity, Page.PageAbstract CurrentPageClass)
 {
     _threadEntity = CurrentThreadEntity;
     _innerHTML.Clear();
     _threadEntity.ControlIndex++;
     Xy.Tools.Web.UrlAnalyzer _url = CurrentThreadEntity.URL;
     if (_webSetting == null)
         _webSetting = CurrentPageClass.WebSetting;
     if (_webSetting.AutoUrl) _webSetting.UpdateDomain(CurrentThreadEntity.URL.Site);
     URLManage.URLItem _urlItem = new URLManage.URLItem(_file, _type, _threadEntity.URLItem.Regex.ToString(), _threadEntity.URLItem.Mime, _enableScript, _enableCache, _threadEntity.URLItem.ContentType.ToString(), _threadEntity.URLItem.Age.Minutes);
     ThreadEntity _entity = new ThreadEntity(CurrentThreadEntity.WebContext, _webSetting, _urlItem, _url, true);
     _entity.Handle(_extValues);
     if (_entity.Content.HasContent)
         _innerHTML.Write(_entity.Content);
     _threadEntity.ControlIndex--;
 }
Esempio n. 10
0
        public void Init(System.Collections.Specialized.NameValueCollection CreateTag, 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)
                    {
                        _cached = true;
                    }
                    break;

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

                case "Config":
                    _webSetting = Xy.WebSetting.WebSettingCollection.GetWebSetting(CreateTag[i]);
                    break;
                }
            }
            _map = string.Concat(map, "IncludeControl", index);
        }
Esempio n. 11
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;
        }
Esempio n. 12
0
        public void Handle(ThreadEntity CurrentThreadEntity, Page.PageAbstract CurrentPageClass)
        {
            _threadEntity = CurrentThreadEntity;
            _innerHTML.Clear();
            _threadEntity.ControlIndex++;
            Xy.Tools.Web.UrlAnalyzer _url = CurrentThreadEntity.URL;
            if (_webSetting == null)
            {
                _webSetting = CurrentPageClass.WebSetting;
            }
            if (_webSetting.AutoUrl)
            {
                _webSetting.UpdateDomain(CurrentThreadEntity.URL.Site);
            }
            URLManage.URLItem _urlItem = new URLManage.URLItem(_file, _type, _threadEntity.URLItem.Regex.ToString(), _threadEntity.URLItem.Mime, _enableScript, _enableCache, _threadEntity.URLItem.ContentType.ToString(), _threadEntity.URLItem.Age.Minutes);
            ThreadEntity      _entity  = new ThreadEntity(CurrentThreadEntity.WebContext, _webSetting, _urlItem, _url, true);

            _entity.Handle(_extValues);
            if (_entity.Content.HasContent)
            {
                _innerHTML.Write(_entity.Content);
            }
            _threadEntity.ControlIndex--;
        }
Esempio n. 13
0
        public void Init(System.Collections.Specialized.NameValueCollection createTag, string map, int index)
        {
            for (int i = 0; i < createTag.Count; i++)
            {
                switch (createTag.Keys[i])
                {
                case "Provider":
                    _settingClass = createTag[i];
                    break;

                case "Name":
                    _settingProperty = createTag[i];
                    break;

                case "Default":
                    _defaultValue = createTag[i];
                    break;

                case "EnableScript":
                    _enableScript = string.Compare("true", createTag[i], true) == 0;
                    break;

                case "UseInnerTag":
                    _useInnerTag = string.Compare("true", createTag[i], true) == 0;
                    break;

                case "Mode":
                    switch (createTag[i])
                    {
                    case "Get":
                        _mode = TagMode.Get;
                        break;

                    case "Exist":
                        _mode       = TagMode.Exist;
                        _isNeedData = true;
                        break;

                    case "Compare":
                        _mode       = TagMode.Compare;
                        _isNeedData = true;
                        break;

                    case "NotExist":
                        _mode       = TagMode.NotExist;
                        _isNeedData = true;
                        break;
                    }
                    break;

                case "CompareValue":
                    _compareValue = createTag[i];
                    break;

                case "CompareMethod":
                    switch (createTag[i])
                    {
                    case "Equal":
                    case "=":
                        _compareMode = CompareMode.Equal;
                        break;

                    case "NotEqual":
                    case "!=":
                        _compareMode = CompareMode.NotEqual;
                        break;

                    case "Greater":
                    case ">":
                        _compareMode = CompareMode.Greater;
                        break;

                    case "Lesser":
                    case "<":
                        _compareMode = CompareMode.Lesser;
                        break;

                    case "GreaterAndEqual":
                    case ">=":
                        _compareMode = CompareMode.GreaterAndEqual;
                        break;

                    case "LesserAndEqual":
                    case "<=":
                        _compareMode = CompareMode.LesserAndEqual;
                        break;
                    }
                    break;

                case "Config":
                    _configName = createTag[i];
                    break;
                }
            }
            _map = string.Concat(map, "TagControl", index);
            if (!string.IsNullOrEmpty(_configName))
            {
                _webConfig = Xy.WebSetting.WebSettingCollection.GetWebSetting(_configName);
            }
            _fillContentDelegate = initDelegate();
        }
Esempio n. 14
0
 public void Init(System.Collections.Specialized.NameValueCollection CreateTag, int Index)
 {
     for (int i = 0; i < CreateTag.Count; i++) {
         switch (CreateTag.Keys[i]) {
             case "File":
                 _file = CreateTag[i];
                 break;
             case "EnableScript":
                 if (string.Compare(CreateTag[i], "true", true) == 0) {
                     _enableScript = true;
                 }
                 break;
             case "Config":
                 _webConfig = Xy.WebSetting.WebSettingCollection.GetWebSetting(CreateTag[i]);
                 break;
             case "ID":
                 _id = CreateTag[i];
                 break;
         }
     }
     if (string.IsNullOrEmpty(ID)) _id = Xy.Web.Control.ControlFactory.UNNAME + "IncludeControl" + Index;
 }
Esempio n. 15
0
 protected void ChangeConfig(string name)
 {
     _webSetting = Xy.WebSetting.WebSettingCollection.GetWebSetting(name);
 }
Esempio n. 16
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;
        }
Esempio n. 17
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;
 }
Esempio n. 18
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;
 }
Esempio n. 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--;
        }
Esempio n. 20
0
        private void context_Error(object sender, EventArgs e)
        {
            HttpApplication _application = sender as HttpApplication;
            Exception       exception    = _application.Context.Server.GetLastError();

            _application.Context.Server.ClearError();
            Xy.WebSetting.WebSettingItem _webSetting = null;
            try {
                Xy.Tools.Web.UrlAnalyzer _url           = new Xy.Tools.Web.UrlAnalyzer(_application.Context.Request.Url.ToString());
                URLManage.URLCollection  _urlCollection = URLManage.URLManager.GetInstance().GetUrlItemCollection(_url);
                if (_urlCollection != null)
                {
                    URLManage.URLItem _urlItem  = null;
                    string            _errorURL = _url.Dir.TrimEnd('/');
                    do
                    {
                        _urlItem = _urlCollection.GetUrlItem(_errorURL + "/error.aspx");
                        if (_urlItem != null)
                        {
                            break;
                        }
                        _errorURL = _errorURL.Substring(0, Math.Max(0, _errorURL.LastIndexOf('/')));
                    } while (_errorURL.Length > 0);
                    if (_urlItem != null)
                    {
                        if (_urlItem.ContentType != URLManage.URLType.Prohibit)
                        {
                            _webSetting = Xy.WebSetting.WebSettingCollection.GetWebSetting(_urlCollection.WebConfigName);
                            ThreadEntity _entity = new ThreadEntity(_application.Context, _webSetting, _urlItem, _url);
                            //_entity.Handle();
                            _application.Response.ContentType = _urlItem.Mime;
                            Xy.Web.Page.ErrorPage _errpage = Runtime.Web.PageClassLibrary.Get(_urlItem.PageClassName) as Xy.Web.Page.ErrorPage;
                            if (_errpage != null)
                            {
                                _errpage.setError(exception);
                                _errpage.Init(_entity, _webSetting);
                                _errpage.Handle("@PageDir:" + _urlItem.PagePath, _urlItem.PagePath, _urlItem.EnableScript, false);
                                if (_errpage.HTMLContainer.HasContent)
                                {
                                    _application.Response.BinaryWrite(_errpage.HTMLContainer.ToArray());
                                    _application.Context.Response.End();
                                    return;
                                }
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                exception = new Exception("Error page class exception:" + ex.Message, exception);
            }
            StringBuilder errorsb = new StringBuilder();

            errorsb.AppendLine(@"<!DOCTYPE HTML><html><head><meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" /><title>Error Page</title></head><body>");
            errorsb.AppendLine("<strong>Wrong Time:</strong>" + DateTime.Now.ToString());
            errorsb.AppendLine("<strong>Client IP:</strong>" + _application.Context.Request.UserHostAddress);
            errorsb.AppendLine("<strong>Browser:</strong>" + _application.Context.Request.Browser.Browser);
            errorsb.AppendLine("<strong>Offending URL:</strong> " + _application.Request.Url.ToString());
            Exception inex = exception;
            int       i    = 1;

            while (inex != null)
            {
                errorsb.AppendLine("=============================Exception No." + i + ": " + inex.Message.Replace(Environment.NewLine, string.Empty) + "=============================");
                if (_webSetting != null && _webSetting.DebugMode)
                {
                    errorsb.AppendLine("<strong>Source: </strong>" + inex.Source);
                    if (inex.TargetSite != null)
                    {
                        errorsb.AppendLine("<strong>TargetMethod: </strong>" + inex.TargetSite.ToString());
                    }
                    errorsb.AppendLine("<strong>Data: </strong>" + inex.Data.ToString());
                    errorsb.AppendLine("<strong>StackTrace: </strong>" + inex.StackTrace);
                    errorsb.AppendLine();
                }
                inex = inex.InnerException; i++;
            }
            errorsb.Append(@"</body></html>");
            _application.Context.Response.BinaryWrite(_application.Context.Request.ContentEncoding.GetBytes(errorsb.ToString().Replace(Environment.NewLine, "<br />" + Environment.NewLine)));
            _application.Context.Response.End();
        }
Esempio n. 21
0
 public static void ClearCache(string PageID, string ControlID, Xy.WebSetting.WebSettingItem websetting, Xy.Tools.Web.UrlAnalyzer url, bool cacheUrlParam = true)
 {
     ClearCache(GetCacheFilePath(PageID, ControlID, websetting, url, cacheUrlParam));
 }
Esempio n. 22
0
        private void context_BeginRequest(object sender, EventArgs e)
        {
            global.RequestStart(sender, e);
            HttpApplication _application = sender as HttpApplication;

#if DEBUG
            Xy.Tools.Debug.Log.StartWorkflowLog();
            Xy.Tools.Debug.Log.WriteEventLog("start " + _application.Context.Request.Url.ToString());
#endif
            Xy.Tools.Web.UrlAnalyzer _url = new Tools.Web.UrlAnalyzer(_application.Context.Request.Url.ToString());

            URLManage.URLCollection _urlCollection = _urlManager.GetUrlItemCollection(_url);
            if (_urlCollection == null)
            {
                throw new Exception(string.Format("can not found URL collection: {0}", _url.ToString()));
            }
            else
            {
#if DEBUG
                Xy.Tools.Debug.Log.WriteEventLog("get url collection.");
#endif
                Xy.WebSetting.WebSettingItem _webSetting = _urlCollection.WebConfig;
                if (!string.IsNullOrEmpty(_webSetting.Root))
                {
                    _url.SetRoot(_webSetting.Root);
                }
                if (!string.IsNullOrEmpty(_webSetting.Port))
                {
                    _url.SetPort(_webSetting.Port);
                }
#if DEBUG
                Xy.Tools.Debug.Log.WriteEventLog("get websetting item.");
#endif
                URLManage.URLItem _urlItem = _urlCollection.GetUrlItem(_url.Path);
                if (_urlItem == null)
                {
                    if (!_webSetting.Compatible)
                    {
                        throw new Exception(string.Format("can not found URL item: {0}", _url.ToString()));
                    }
                }
                else
                {
#if DEBUG
                    Xy.Tools.Debug.Log.WriteEventLog("get url item.");
#endif
                    ThreadEntity _entity = new ThreadEntity(_application.Context, _webSetting, _urlItem, _url);
                    global.HandleStart(_entity);
#if DEBUG
                    Xy.Tools.Debug.Log.WriteEventLog("created thread entity");
#endif
                    _entity.Handle();
#if DEBUG
                    Xy.Tools.Debug.Log.WriteEventLog("thread entity handled");
#endif
                    if (_entity.Content.HasContent)
                    {
                        _application.Response.BinaryWrite(_entity.Content.ToArray());
                    }
                    global.HandleEnd(_entity);
#if DEBUG
                    Xy.Tools.Debug.Log.WriteEventLog("content outputed");
                    Xy.Tools.Debug.Log.EndWorkflowLog();
#endif
                    _application.Context.Response.End();
                }
            }
        }
Esempio n. 23
0
 public void Init(System.Collections.Specialized.NameValueCollection CreateTag,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) {
                     _cached = true;
                 }
                 break;
             case "Value":
                 _valueString = CreateTag[i];
                 _extValues = Xy.Tools.Control.Tag.Decode(_valueString);
                 break;
             case "Config":
                 _webSetting = Xy.WebSetting.WebSettingCollection.GetWebSetting(CreateTag[i]);
                 break;
         }
     }
     _map = string.Concat(map, "IncludeControl", index);
 }
Esempio n. 24
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;
 }
Esempio n. 25
0
 protected void ChangeConfig(string name)
 {
     _webSetting = Xy.WebSetting.WebSettingCollection.GetWebSetting(name);
 }