Example #1
0
        /// <summary>
        /// Called when a menu item has been selected
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            bool handled = false;

            int id = item.ItemId;

            // Let the main command router have a look first
            if (CommandRouter.HandleCommand(id) == true)
            {
                handled = true;
            }
            // Pass on a collapse request to the adapter
            else if (id == Resource.Id.action_collapse)
            {
                Adapter.OnCollapseRequest();
                handled = true;
            }
            else if (id == Resource.Id.filter)
            {
                FilterSelector?.SelectFilter();
            }

            if (handled == false)
            {
                handled = base.OnOptionsItemSelected(item);
            }

            return(handled);
        }
 public ViewGroups(User Student) : this()
 {
     FilterSelector.Hide();
     FilterSelector.ApplyFilter(Filters.Group.HasStudent, Student.ID.ToString());
     LoadResults();
     label_Title.Text = String.Format("Showing Groups That {0} Belongs To", Student.FName + " " + Student.LName[0] + ".");
 }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the FilterContainer class
        /// </summary>
        /// <param name="owningSelector">The view that will own this FilterContainer</param>
        /// <param name="filter">The filter to hold on this FilterContainer</param>
        public FilterContainer(FilterSelector owningSelector, FilterControl filter)
        {
            InitializeComponent();

            _containerState = FilterContainerState.Expanded;
            _mouseDown      = false;
            _owningSelector = owningSelector;
            _filterEnabled  = true;

            LoadFilter(filter);
        }
Example #4
0
        public void AddCondition(String groupId, FilterSelector groupSelector, Int64 fieldId, String fieldName, DataType dataType, String text, FilterConditionType conditionType, FilterSelector selector)
        {
            FilterGroup g = filter_groups.Find(g1 => (g1.GroupId == groupId));

            if (g == null)
            {
                g = new FilterGroup(groupId, groupSelector);
                filter_groups.Add(g);
            }

            g.AddFilter(fieldId, fieldName, dataType, text, conditionType, selector);
        }
Example #5
0
        /// <summary>
        /// Add fragment specific menu items to the main toolbar
        /// </summary>
        /// <param name="menu"></param>
        /// <param name="inflater"></param>
        public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater)
        {
            // Inflate the menu for this fragment
            inflater.Inflate(Menu, menu);

            // Show or hide the collapse icon
            collapseItem = menu.FindItem(Resource.Id.action_collapse);
            collapseItem?.SetVisible(expandedGroupCount > 0);

            // If there is a filter selector then bind to it
            FilterSelector?.BindToMenu(menu.FindItem(Resource.Id.filter));

            // Bind the SortSelector
            BaseModel.SortSelector.BindToMenu(menu.FindItem(Resource.Id.sort), Context, this);
        }
        private List <Breakpoint> Filter <T>(List <Breakpoint> input, T[] filter, FilterSelector <T> selector)
        {
            List <Breakpoint> list = new List <Breakpoint>();

            for (int i = 0; i < input.Count; i++)
            {
                for (int j = 0; j < filter.Length; j++)
                {
                    if (selector(input[i], filter[j]))
                    {
                        list.Add(input[i]);
                        break;
                    }
                }
            }
            return(list);
        }
Example #7
0
    // void BackButtonPress() {
    //     HideFilterMenu();
    // }

    void PopulateFilterSelectors()
    {
        ClearFilterSelectors();
        for (int i = 0; i < filteredItems.Count; i++)
        {
            GameObject filterSelectorGo = (GameObject)Instantiate(filterSelectorPrefab);
            filterSelectorGo.transform.SetParent(filterSelectorParent, false);
            FilterSelector filterSelector = filterSelectorGo.GetComponent <FilterSelector> ();
            filterSelectors.Add(filterSelector);
            bool active = false;
            foreach (ActiveFilter af in activeFilters)
            {
                if (af.id == filteredItems[i].id)
                {
                    active = true;
                }
            }
            filterSelector.SetUp(filteredItems[i].id, filteredItems[i].label, active);
        }
    }
Example #8
0
        /// <summary>
        /// Called when the fragment is destroyed
        /// Release any resources help by the fragment
        /// </summary>
        public sealed override void OnDestroyView()
        {
            FragmentView             = null;
            commandCallback.Callback = null;
            FilterSelector?.BindToMenu(null);

            // Turn off the timer
            userInteractionTimer.Change(Timeout.Infinite, Timeout.Infinite);

            // Some BaseModel resources

            // Remove this object from the sort selector
            BaseModel.SortSelector.Reporter = null;

            // Save the scroll position
            BaseModel.ListViewState = ListView.OnSaveInstanceState();

            // Allow derived fragments to release their own resources
            ReleaseResources();
            base.OnDestroyView();
        }
Example #9
0
        public string ToSqlString()
        {
            String ret = "";

            FilterSelector lastSelector = FilterSelector.AND;

            if (filter_rules != null)
            {
                foreach (FilterCondition f in filter_rules)
                {
                    if (ret != "")
                    {
                        ret += " " + lastSelector.ToString() + " ";
                    }
                    ret         += f.ToSqlString();
                    lastSelector = f.Selector;
                }
            }

            return((ret != "" ? "(" : "") + ret + (ret != "" ? ")" : ""));
        }
Example #10
0
        public string ToSqlString()
        {
            String ret = "";

            FilterSelector lastSelector = FilterSelector.OR;

            if (filter_groups != null)
            {
                foreach (FilterGroup g in filter_groups)
                {
                    if (ret != "")
                    {
                        ret += " " + lastSelector.ToString().ToLower() + " ";
                    }
                    ret         += g.ToSqlString().ToLower();
                    lastSelector = g.Selector;
                }
            }

            return(ret);
        }
Example #11
0
        public override string ToString()
        {
            String ret = "";

            FilterSelector lastSelector = FilterSelector.AND;

            if (filter_rules != null)
            {
                foreach (FilterCondition f in filter_rules)
                {
                    if (ret != "")
                    {
                        ret += " " + MessageResource.GetMessage(lastSelector.ToString().ToLower(), lastSelector.ToString()).ToLower() + " ";
                    }
                    ret         += f.ToString();
                    lastSelector = f.Selector;
                }
            }

            return((ret != "" ? "(" : "") + ret + (ret != "" ? ")" : ""));
        }
Example #12
0
        public override string ToString()
        {
            String ret = "";

            FilterSelector lastSelector = FilterSelector.OR;

            if (filter_groups != null)
            {
                foreach (FilterGroup g in filter_groups)
                {
                    if (ret != "")
                    {
                        ret += " " + MessageResource.GetMessage(lastSelector.ToString().ToLower(), lastSelector.ToString()).ToLower() + " ";
                    }

                    ret         += g.ToString();
                    lastSelector = g.Selector;
                }
            }

            return(ret);
        }
Example #13
0
        public FilterCondition(Int64 fieldId, String fieldName, DataType dataType, Object data, FilterConditionType conditionType, FilterSelector selector)
        {
            this.field_id       = fieldId;
            this.field_name     = fieldName;
            this.condition_type = conditionType;
            this.selector_type  = selector;
            this.data_type      = dataType;

            try
            {
                switch (this.data_type)
                {
                case Filters.DataType.DateTime:
                    try
                    {
                        this.data = (DateTime)data;
                    }
                    catch
                    {
                        this.data = DateTime.Parse(data.ToString());
                    }
                    break;

                case Filters.DataType.Numeric:
                    try
                    {
                        this.data = (Int64)data;
                    }
                    catch
                    {
                        this.data = Int64.Parse(data.ToString());
                    }
                    break;

                default:
                    this.data = (String)data;
                    break;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Invalid cast of data '" + data + "' to type '" + dataType.ToString() + "'", ex);
            }

            switch (this.data_type)
            {
            case Filters.DataType.DateTime:
                switch (this.condition_type)
                {
                case FilterConditionType.NotEqual:
                case FilterConditionType.Greater:
                case FilterConditionType.Less:
                case FilterConditionType.GreaterOrEqual:
                case FilterConditionType.LessOrEqual:
                case FilterConditionType.Equal:
                    break;

                default:
                    throw new Exception("Invalid condition (" + this.condition_type.ToString() + ") of data type (" + this.data_type.ToString() + ")");
                    break;
                }
                break;

            case Filters.DataType.Numeric:
                switch (condition_type)
                {
                case FilterConditionType.Equal:
                case FilterConditionType.NotEqual:
                case FilterConditionType.Greater:
                case FilterConditionType.Less:
                case FilterConditionType.GreaterOrEqual:
                case FilterConditionType.LessOrEqual:
                    break;

                default:
                    throw new Exception("Invalid condition (" + this.condition_type.ToString() + ") of data type (" + this.data_type.ToString() + ")");
                    break;
                }
                break;

            default:
                switch (condition_type)
                {
                case FilterConditionType.Contains:
                case FilterConditionType.EndWith:
                case FilterConditionType.NotContains:
                case FilterConditionType.NotEqual:
                case FilterConditionType.StartWith:
                case FilterConditionType.Equal:
                    break;

                default:
                    throw new Exception("Invalid condition (" + this.condition_type.ToString() + ") of data type (" + this.data_type.ToString() + ")");
                    break;
                }
                break;
            }
        }
Example #14
0
 public FilterGroup(String groupId, FilterSelector groupSelector)
 {
     this.group_id      = groupId;
     this.selector_type = groupSelector;
     this.filter_rules  = new List <FilterCondition>();
 }
 public void LoadResults()
 {
     ResultGrid.DataSource = FilterSelector.GetTable();
     ResultGrid.AutoResizeColumns();
 }
Example #16
0
        public void AddCondition(String groupId, String groupSelector, Int64 fieldId, String fieldName, String dataType, String text, String conditionType, String selector)
        {
            FilterSelector gs = FilterSelector.OR;

            switch (groupSelector.ToLower())
            {
            case "and":
                gs = FilterSelector.AND;
                break;

            case "or":
                gs = FilterSelector.OR;
                break;
            }

            FilterSelector s = FilterSelector.OR;

            switch (selector.ToLower())
            {
            case "and":
                s = FilterSelector.AND;
                break;

            case "or":
                s = FilterSelector.OR;
                break;
            }


            FilterConditionType c = FilterConditionType.Equal;

            switch (conditionType.ToLower())
            {
            case "contains":
                c = FilterConditionType.Contains;
                break;

            case "endwith":
                c = FilterConditionType.EndWith;
                break;

            case "equal":
                c = FilterConditionType.Equal;
                break;

            case "notcontains":
                c = FilterConditionType.NotContains;
                break;

            case "notequal":
                c = FilterConditionType.NotEqual;
                break;

            case "startwith":
                c = FilterConditionType.StartWith;
                break;

            case "greater":
                c = FilterConditionType.Greater;
                break;

            case "less":
                c = FilterConditionType.Less;
                break;

            case "greaterorequal":
                c = FilterConditionType.GreaterOrEqual;
                break;

            case "lessorequal":
                c = FilterConditionType.LessOrEqual;
                break;
            }

            DataType dt = DataType.Text;

            switch (dataType.ToLower())
            {
            case "datetime":
            case "date":
                dt = DataType.DateTime;
                break;

            case "numeric":
                dt = DataType.Numeric;
                break;

            default:
                dt = DataType.Text;
                break;
            }


            AddCondition(groupId, gs, fieldId, fieldName, dt, text, c, s);
        }
Example #17
0
        public FilterMatchCollection Matches()
        {
            FilterMatchCollection col = new FilterMatchCollection();

            foreach (FilterRule r1 in filters)
            {
                /*
                 * if (this.check_data.Select(r1.ToSqlString()).Length > 0)
                 *  col.AddMatch(new FilterMatch(true, r1));*/

                //Novo método
                if (r1.FilterGroups != null)
                {
                    String exp = "";

                    FilterSelector groupLastSelector = FilterSelector.OR;

                    foreach (FilterGroup g in r1.FilterGroups)
                    {
                        if (g.FilterRules != null)
                        {
                            String exp1 = "";

                            FilterSelector lastSelector = FilterSelector.AND;

                            foreach (FilterCondition f in g.FilterRules)
                            {
                                if (exp1 != "")
                                {
                                    exp1 += " " + lastSelector.ToString() + " ";
                                }
                                if (this.check_data.Select(f.ToSqlString()).Length > 0)
                                {
                                    exp1 += " true ";
                                }
                                else
                                {
                                    exp1 += " false ";
                                }

                                lastSelector = f.Selector;
                            }

                            if (exp != "" && exp1 != "")
                            {
                                exp += " " + groupLastSelector.ToString().ToLower() + " ";
                            }
                            exp += (exp1 != "" ? "(" : "") + exp1 + (exp1 != "" ? ")" : "");

                            groupLastSelector = g.Selector;
                        }
                    }

                    if (ExecExpression(exp))
                    {
                        col.AddMatch(new FilterMatch(true, r1));
                    }
                }
            }

            return(col);
        }
Example #18
0
 public void AddFilter(Int64 fieldId, String fieldName, DataType dataType, String text, FilterConditionType conditionType, FilterSelector selector)
 {
     AddFilter(new FilterCondition(fieldId, fieldName, dataType, text, conditionType, selector));
 }
        protected override void ProcessRecord()
        {
            FilterSelector <string> selector    = null;
            List <Breakpoint>       breakpoints = base.Context.Debugger.GetBreakpoints();

            if (!base.ParameterSetName.Equals("Script", StringComparison.OrdinalIgnoreCase))
            {
                if (base.ParameterSetName.Equals("Id", StringComparison.OrdinalIgnoreCase))
                {
                    breakpoints = this.Filter <int>(breakpoints, this._id, (breakpoint, id) => breakpoint.Id == id);
                }
                else if (base.ParameterSetName.Equals("Command", StringComparison.OrdinalIgnoreCase))
                {
                    breakpoints = this.Filter <string>(breakpoints, this._command, delegate(Breakpoint breakpoint, string command) {
                        CommandBreakpoint breakpoint2 = breakpoint as CommandBreakpoint;
                        if (breakpoint2 == null)
                        {
                            return(false);
                        }
                        return(breakpoint2.Command.Equals(command, StringComparison.OrdinalIgnoreCase));
                    });
                }
                else if (base.ParameterSetName.Equals("Variable", StringComparison.OrdinalIgnoreCase))
                {
                    breakpoints = this.Filter <string>(breakpoints, this._variable, delegate(Breakpoint breakpoint, string variable) {
                        VariableBreakpoint breakpoint2 = breakpoint as VariableBreakpoint;
                        if (breakpoint2 == null)
                        {
                            return(false);
                        }
                        return(breakpoint2.Variable.Equals(variable, StringComparison.OrdinalIgnoreCase));
                    });
                }
                else if (base.ParameterSetName.Equals("Type", StringComparison.OrdinalIgnoreCase))
                {
                    breakpoints = this.Filter <BreakpointType>(breakpoints, this._type, delegate(Breakpoint breakpoint, BreakpointType type) {
                        switch (type)
                        {
                        case BreakpointType.Line:
                            if (breakpoint is LineBreakpoint)
                            {
                                return(true);
                            }
                            break;

                        case BreakpointType.Variable:
                            if (breakpoint is VariableBreakpoint)
                            {
                                return(true);
                            }
                            break;

                        case BreakpointType.Command:
                            if (breakpoint is CommandBreakpoint)
                            {
                                return(true);
                            }
                            break;
                        }
                        return(false);
                    });
                }
            }
            if (this._script != null)
            {
                if (selector == null)
                {
                    selector = delegate(Breakpoint breakpoint, string script) {
                        if (breakpoint.Script == null)
                        {
                            return(false);
                        }
                        return(string.Compare(base.SessionState.Path.GetUnresolvedProviderPathFromPSPath(breakpoint.Script), base.SessionState.Path.GetUnresolvedProviderPathFromPSPath(script), StringComparison.OrdinalIgnoreCase) == 0);
                    };
                }
                breakpoints = this.Filter <string>(breakpoints, this._script, selector);
            }
            foreach (Breakpoint breakpoint in breakpoints)
            {
                base.WriteObject(breakpoint);
            }
        }
Example #20
0
        private FilterRule GetFilterByForm(out WebJsonResponse contentRet)
        {
            contentRet = null;

            String name = Request.Form["filter_name"];

            if (String.IsNullOrEmpty(name))
            {
                contentRet = new WebJsonResponse("", MessageResource.GetMessage("invalid_name"), 3000, true);
                return(null);
            }

            String filters = Request.Form["filter_name"];

            if (String.IsNullOrEmpty(name))
            {
                contentRet = new WebJsonResponse("", MessageResource.GetMessage("invalid_name"), 3000, true);
                return(null);
            }

            //Verifica e trata as regras

            if (String.IsNullOrEmpty(Request.Form["filter_id"]))
            {
                contentRet = new WebJsonResponse("", MessageResource.GetMessage("conditions_is_empty"), 3000, true);
                return(null);
            }

            String rData = JSON.Serialize2(new
            {
                jsonrpc    = "1.0",
                method     = "field.list",
                parameters = new
                {
                    page_size = Int32.MaxValue
                },
                id = 1
            });
            //SqlConnection //conn = DB.GetConnection();
            String jData = "";

            try
            {
                using (IAMDatabase database = new IAMDatabase(IAMDatabase.GetWebConnectionString())) jData = WebPageAPI.ExecuteLocal(database, this, rData);
            }
            finally
            {
            }

            List <FieldData> fieldList = new List <FieldData>();
            FieldListResult  flR       = JSON.Deserialize <FieldListResult>(jData);

            if ((flR != null) && (flR.error == null) && (flR.result != null))
            {
                fieldList = flR.result;
            }

            if (fieldList.Count == 0)
            {
                contentRet = new WebJsonResponse("", MessageResource.GetMessage("field_not_found"), 3000, true);
                return(null);
            }

            FilterRule newItem = new FilterRule(name);


            String[] fIds = Request.Form["filter_id"].Split(",".ToCharArray());
            foreach (String fid in fIds)
            {
                if (String.IsNullOrEmpty(Request.Form["filter_" + fid + "_group"]))
                {
                    contentRet = new WebJsonResponse("", "Grupo não localizado na condição " + fid, 3000, true);
                    break;
                }

                if (String.IsNullOrEmpty(Request.Form["filter_" + fid + "_field_id"]))
                {
                    contentRet = new WebJsonResponse("", "ID do campo não localizado na condição " + fid, 3000, true);
                    break;
                }

                String fGroup = Request.Form["filter_" + fid + "_group"].Split(",".ToCharArray())[0];

                FieldData fieldData = null;
                try
                {
                    Int64 tmp = Int64.Parse(Request.Form["filter_" + fid + "_field_id"].Split(",".ToCharArray())[0]);
                    foreach (FieldData fd in fieldList)
                    {
                        if (fd.field_id == tmp)
                        {
                            fieldData = fd;
                        }
                    }

                    if (fieldData == null)
                    {
                        throw new Exception();
                    }
                }
                catch
                {
                    contentRet = new WebJsonResponse("", "ID do campo inválido na condição " + fid, 3000, true);
                    break;
                }

                FilterSelector filterSelector = FilterSelector.AND;

                if (!String.IsNullOrEmpty(Request.Form["filter_" + fid + "_selector"]))
                {
                    switch (Request.Form["filter_" + fid + "_selector"].Split(",".ToCharArray())[0].ToLower())
                    {
                    case "or":
                        filterSelector = FilterSelector.OR;
                        break;

                    default:
                        filterSelector = FilterSelector.AND;
                        break;
                    }
                }

                FilterConditionType condition = FilterConditionType.Equal;
                switch (fieldData.data_type)
                {
                case "numeric":
                    if (String.IsNullOrEmpty(Request.Form["filter_" + fid + "_condition_numeric"]))
                    {
                        contentRet = new WebJsonResponse("", "Condição de comparação não localizada na condição " + fid, 3000, true);
                        break;
                    }

                    if (String.IsNullOrEmpty(Request.Form["filter_" + fid + "_text_numeric"]))
                    {
                        contentRet = new WebJsonResponse("", "Valor não localizado na condição " + fid, 3000, true);
                        break;
                    }

                    Int64 nValue = 0;
                    try
                    {
                        nValue = Int64.Parse(Request.Form["filter_" + fid + "_text_numeric"].Split(",".ToCharArray())[0]);
                    }
                    catch
                    {
                        contentRet = new WebJsonResponse("", "Valor inválido na condição " + fid, 3000, true);
                        break;
                    }

                    String c1 = Request.Form["filter_" + fid + "_condition_numeric"].Split(",".ToCharArray())[0].ToLower();
                    foreach (FilterConditionType ft in IAM.Filters.FilterCondition.ConditionByDataType(DataType.Numeric))
                    {
                        if (c1 == ft.ToString().ToLower())
                        {
                            condition = ft;
                        }
                    }

                    newItem.AddCondition(fGroup, FilterSelector.AND, fieldData.field_id, "", DataType.Numeric, nValue.ToString(), condition, filterSelector);

                    break;

                case "datetime":
                    if (String.IsNullOrEmpty(Request.Form["filter_" + fid + "_condition_datetime"]))
                    {
                        contentRet = new WebJsonResponse("", "Condição de comparação não localizada na condição " + fid, 3000, true);
                        break;
                    }

                    if (String.IsNullOrEmpty(Request.Form["filter_" + fid + "_text_date"]))
                    {
                        contentRet = new WebJsonResponse("", "Valor de data não localizado na condição " + fid, 3000, true);
                        break;
                    }

                    if (String.IsNullOrEmpty(Request.Form["filter_" + fid + "_text_time"]))
                    {
                        contentRet = new WebJsonResponse("", "Valor de hora não localizado na condição " + fid, 3000, true);
                        break;
                    }

                    String dtValue = "";
                    try
                    {
                        if (Request.Form["filter_" + fid + "_text_date"].Split(",".ToCharArray())[0].ToLower() == "now")
                        {
                            dtValue = "now";
                        }
                        else
                        {
                            DateTime tmp = DateTime.Parse(Request.Form["filter_" + fid + "_text_date"].Split(",".ToCharArray())[0] + " " + Request.Form["filter_" + fid + "_text_time"].Split(",".ToCharArray())[0]);
                            dtValue = tmp.ToString("o");
                        }
                    }
                    catch
                    {
                        contentRet = new WebJsonResponse("", "Valor de data e hora inválidos na condição " + fid, 3000, true);
                        break;
                    }

                    String c2 = Request.Form["filter_" + fid + "_condition_datetime"].Split(",".ToCharArray())[0].ToLower();
                    foreach (FilterConditionType ft in IAM.Filters.FilterCondition.ConditionByDataType(DataType.DateTime))
                    {
                        if (c2 == ft.ToString().ToLower())
                        {
                            condition = ft;
                        }
                    }

                    newItem.AddCondition(fGroup, FilterSelector.AND, fieldData.field_id, "", DataType.DateTime, dtValue, condition, filterSelector);

                    break;

                default:
                    if (String.IsNullOrEmpty(Request.Form["filter_" + fid + "_condition_string"]))
                    {
                        contentRet = new WebJsonResponse("", "Condição de comparação não localizada na condição " + fid, 3000, true);
                        break;
                    }

                    if (String.IsNullOrEmpty(Request.Form["filter_" + fid + "_text_string"]))
                    {
                        contentRet = new WebJsonResponse("", "Valor não localizado na condição " + fid, 3000, true);
                        break;
                    }


                    String c3 = Request.Form["filter_" + fid + "_condition_string"].Split(",".ToCharArray())[0].ToLower();
                    foreach (FilterConditionType ft in IAM.Filters.FilterCondition.ConditionByDataType(DataType.Text))
                    {
                        if (c3 == ft.ToString().ToLower())
                        {
                            condition = ft;
                        }
                    }

                    newItem.AddCondition(fGroup, FilterSelector.AND, fieldData.field_id, "", DataType.Text, Request.Form["filter_" + fid + "_text_string"].Split(",".ToCharArray())[0], condition, filterSelector);
                    break;
                }
            }

            //Atualiza os seletores dos grupos caso haja mais de 1 grupo
            if (newItem.FilterGroups.Count > 1)
            {
                foreach (FilterGroup g in newItem.FilterGroups)
                {
                    if (!String.IsNullOrEmpty(Request.Form["group_" + g.GroupId + "_selector"]))
                    {
                        switch (Request.Form["group_" + g.GroupId + "_selector"].Split(",".ToCharArray())[0].ToLower())
                        {
                        case "and":
                            g.Selector = FilterSelector.AND;
                            break;

                        default:
                            g.Selector = FilterSelector.OR;
                            break;
                        }
                    }
                }
            }

            return(newItem);
        }