public void RemoveNestedOperator()
        {
            var unaryOperator = new UnaryOperator(UnaryOperatorType.IsNull, "prop2");
            CriteriaOperator groupOperator = new GroupOperator(new BinaryOperator("pro1", 1), unaryOperator);

            var binaryOperatorExtractor = new CriteriaOperatorExtractor();

            binaryOperatorExtractor.Remove(ref groupOperator, unaryOperator.ToString());

            Assert.AreEqual(new BinaryOperator("pro1", 1).ToString(), groupOperator.ToString());
        }
        private void ApplyFilter()
        {
            if (gridView1.Columns["Date"] == null)
            {
                return;
            }

            CriteriaOperator binaryFilter = new GroupOperator(GroupOperatorType.And,
                                                              new BinaryOperator("Date", FromDate, BinaryOperatorType.GreaterOrEqual),
                                                              new BinaryOperator("Date", ToDate, BinaryOperatorType.Less));


            CriteriaOperator simplifiedFilter = (new OperandProperty("Date") >= new OperandValue(FromDate)) & (new OperandProperty("Date") < new OperandValue(ToDate));

            string           filterDisplayText = String.Format("Date is between {0:d} and {1:d}", FromDate, ToDate);
            ColumnFilterInfo dateFilter        = new ColumnFilterInfo(binaryFilter.ToString(), filterDisplayText);

            gridView1.Columns["Date"].FilterInfo = dateFilter;
        }
    private string GetFilterExpression()
    {
        string res_str = string.Empty;
        List <CriteriaOperator> lst_operator = new List <CriteriaOperator>();

        if (!string.IsNullOrEmpty(txtFirstName.Text))
        {
            lst_operator.Add(new BinaryOperator("FirstName", string.Format("%{0}%", txtFirstName.Text), BinaryOperatorType.Like));
        }

        if (!string.IsNullOrEmpty(txtLastName.Text))
        {
            lst_operator.Add(new BinaryOperator("LastName", string.Format("%{0}%", txtLastName.Text), BinaryOperatorType.Like));
        }

        if (deHDFrom.Value != null)
        {
            lst_operator.Add(new BinaryOperator("HireDate", deHDFrom.Date, BinaryOperatorType.GreaterOrEqual));
        }

        if (deHDTo.Value != null)
        {
            lst_operator.Add(new BinaryOperator("HireDate", deHDTo.Date, BinaryOperatorType.LessOrEqual));
        }

        if (lst_operator.Count > 0)
        {
            CriteriaOperator[] op = new CriteriaOperator[lst_operator.Count];
            for (int i = 0; i < lst_operator.Count; i++)
            {
                op[i] = lst_operator[i];
            }
            CriteriaOperator res_operator = new GroupOperator(GroupOperatorType.And, op);
            res_str = res_operator.ToString();
        }

        return(res_str);
    }
        public void RemoveNestedOperator()
        {
            var unaryOperator = new UnaryOperator(UnaryOperatorType.IsNull, "prop2");
            CriteriaOperator groupOperator = new GroupOperator(new BinaryOperator("pro1", 1), unaryOperator);

            var binaryOperatorExtractor = new CriteriaOperatorExtractor();
            binaryOperatorExtractor.Remove(ref groupOperator, unaryOperator.ToString());

            Assert.AreEqual(new BinaryOperator("pro1", 1).ToString(), groupOperator.ToString());
        }
예제 #5
0
    protected void MailGrid_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
    {
        if (string.IsNullOrEmpty(e.Parameters))
        {
            return;
        }
        var args = e.Parameters.Split('|');

        if (args[0] == "FolderChanged")
        {
            MailGrid.FilterExpression = "";
            BindGrid();
            MailGrid.ExpandAll();
        }
        if (args[0] == "Search")
        {
            if (string.IsNullOrEmpty(SearchText))
            {
                MailGrid.FilterExpression = "";
            }
            CriteriaOperator criteria = new GroupOperator(GroupOperatorType.Or,
                                                          new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty(ShowToColumn() ? "To" : "From"), SearchText),
                                                          new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty("Subject"), SearchText)
                                                          );
            MailGrid.FilterExpression = criteria.ToString();

            BindGrid();
            MailGrid.ExpandAll();
        }
        if (args[0] == "SendMail" || args[0] == "SaveMail")
        {
            var    subject     = SubjectEditor.Text;
            var    to          = ToEditor.Text;
            string messageText = MailEditor.Html.Length <= 10000 ? MailEditor.Html : MailEditor.Html.Substring(0, 10000);
            string folder      = args[0] == "SendMail" ? "Sent Items" : "Drafts";
            int    id;
            if (args.Length == 2 && int.TryParse(args[1], out id))
            {
                MessageBL bl = new MessageBL();
                bl.UpdateMessage(id, subject, to, messageText, folder);
            }
            else
            {
                MessageBL bl      = new MessageBL();
                bool      IsReply = false;
                if (Session["CurrentReplyEmailID"] != null)
                {
                    IsReply = true;
                }
                bl.AddMessage(subject, User.Identity.Name, to, messageText, folder, IsReply);
            }

            Session["CurrentReplyEmailID"] = null;
            BindGrid();
        }
        if (args[0] == "Delete" && args.Length > 1)
        {
            int[] keys = null;
            if (!TryParseKeyValues(args.Skip(1), out keys))
            {
                return;
            }

            MessageBL bl = new MessageBL();

            bl.DeleteMessages(keys);
            BindGrid();
        }
    }