Exemplo n.º 1
0
        private UrlManager(IDataBase db)
        {
            if (this._excludeStartsUrls == null)
            {
                _excludeStartsUrls = new List<string>();
                _excludeStartsUrls.Add("img/");
                _excludeStartsUrls.Add("gimg/");
                _excludeStartsUrls.Add("css/");
                _excludeStartsUrls.Add("js/");
            }

            if (this._excludeContainsUrls == null)
            {
                _excludeContainsUrls = new List<string>();
                _excludeContainsUrls.Add(".axd");
                _excludeContainsUrls.Add(".ico");
                _excludeContainsUrls.Add("404.aspx");
                _excludeContainsUrls.Add("500.aspx");
                _excludeContainsUrls.Add(".asmx");
            }

            if (this._u301 == null)
            {
                this._u301 = new List<IUrlItem>();
                db.ClearParams();
                db.SetStoredProcedure("WebSite.Get301Urls");
                DataTable src = db.GetDataTable();

                if (src != null && src.Rows.Count > 0)
                {
                    foreach (DataRow dr in src.Rows)
                    {
                        IUrlItem uit = new UrlItem();
                        uit.initValues(
                            0
                            , dr["url"].ToString().ToLower()
                            , 0
                            , dr["url301"].ToString().ToLower()
                            , ""
                            , 0
                            , 0
                            );

                        this._u301.Add(uit);
                    }
                }
            }

            if (this._urls == null)
            {
                this._urls = new List<IUrlItem>();

                db.ClearParams();
                db.SetStoredProcedure("WebSite.GetRedirectUrl");
                DataTable src = db.GetDataTable();

                if (src != null && src.Rows.Count > 0)
                {
                    foreach (DataRow dr in src.Rows)
                    {
                        IUrlItem uit = new UrlItem();
                        uit.initValues(
                            int.Parse(dr["id"].ToString())
                            , dr["url_name"].ToString().ToLower()
                            , int.Parse(dr["ctype_id"].ToString())
                                        , ""
                            , dr["params"].ToString().ToLower()
                            , byte.Parse(dr["filter_map"].ToString())
                            , byte.Parse(dr["url_kind"].ToString())
                            );

                        this._urls.Add(uit);
                    }
                }
            }
        }