Esempio n. 1
0
        private void ParseUrl(bool throwException)
        {
            Match match = _regex.Match(Url);

            UserControl         = "";
            IsDataControl       = false;
            NavigateTo          = false;
            ShowHistory         = false;
            IsSelect            = false;
            ShowFilter          = false;
            IsMultipleSelect    = false;
            IsNew               = false;
            IsRead              = false;
            IsDownload          = false;
            IsExecute           = false;
            IsFilterWindow      = false;
            IsCustomUserControl = false;
            QueryParameters.Clear();
            ParameterConverter.Clear();
            ControlFilterParameters.Clear();
            SelectParameters = null;
            BackUrl          = "";
            Query            = "";
            SelectedValues   = "";
            FilterQuery      = null;
            if (!match.Success)
            {
                match = _regex2.Match(Url);
                if (!match.Success)
                {
                    return;
                }
            }

            Page    = match.Groups["page"].Value;
            PageExt = match.Groups["pageExt"].Value;
            if (match.Groups["type"].Success)
            {
                if (match.Groups["type"].Value.Equals("data/"))
                {
                    IsDataControl = true;
                }
                else if (match.Groups["type"].Value.Equals("navigateto/"))
                {
                    NavigateTo = true;
                }
                else if (match.Groups["type"].Value.Equals("download/"))
                {
                    IsDownload = true;
                }
                else if (match.Groups["type"].Value.Equals("execute/"))
                {
                    IsExecute = true;
                }
                else if (match.Groups["type"].Value.Equals("custom/"))
                {
                    IsCustomUserControl = true;
                }
            }

            if ((IsDataControl || NavigateTo) && !match.Groups["usercontrol"].Success)
            {
                if (throwException)
                {
                    throw new Exception("Not set UserControls in url");
                }
                IsDataControl = false;
                NavigateTo    = false;
                return;
            }

            if (match.Groups["usercontrol"].Success)
            {
                var setUC = true;
                if (!match.Groups["type"].Success)
                {
                    if (match.Groups["usercontrol"].Value.Equals("download"))
                    {
                        IsDownload = true;
                        setUC      = false;
                    }
                    else if (match.Groups["usercontrol"].Value.Equals("execute"))
                    {
                        IsExecute = true;
                        setUC     = false;
                    }
                }

                if (setUC)
                {
                    UserControl = HttpUtility.UrlDecode(match.Groups["usercontrol"].Value);
                }
            }

            var dic = new Dictionary <string, string>();

            if (IsCustomUserControl)
            {
                UserControl += match.Groups["param1"].Success ? HttpUtility.UrlDecode(match.Groups["param1"].Value) : "";
            }
            else
            {
                AddParam(match, dic, "param1");
            }

            AddParam(match, dic, "param2");
            AddParam(match, dic, "param3");
            AddParam(match, dic, "param4");
            AddParam(match, dic, "param5");

            ShowHistory      = dic.ContainsKey("showhistory");
            IsMultipleSelect = dic.ContainsKey("multipleselect");
            IsSelect         = dic.ContainsKey("select") || IsMultipleSelect;
            ShowFilter       = dic.ContainsKey("showfilter");
            IsNew            = dic.ContainsKey("new");
            IsRead           = dic.ContainsKey("read");
            IsFilterWindow   = dic.ContainsKey("filter");

            if (match.Groups["query"].Success)
            {
                Query = match.Groups["query"].Value;
                ParseQuery();
            }
        }