Пример #1
0
 protected void gvNominees_Sorting(object sender, GridViewSortEventArgs e)
 {
     SortDirection =
             (SortDirection == SortDirection.Ascending) ? SortDirection.Descending : SortDirection.Ascending;
     SortColumn = e.SortExpression;
     LoadNominees();
 }
Пример #2
0
 /// <summary>
 /// Sort the returned items
 /// </summary>
 /// <param name="propertyName">Property to sort by</param>
 /// <param name="direction">Sort direction</param>
 /// <returns>current instance</returns>
 public QueryConstraints Sort(string propertyName, SortDirection direction)
 {
     if (propertyName == null) throw new ArgumentNullException("propertyName");
     SortPropertyName = propertyName;
     SortOrder = direction;
     return this;
 }
Пример #3
0
 private string CreatePageLink(string column, SortDirection? direction, string text)
 {
     var builder = new TagBuilder("a");
     builder.SetInnerText(text);
     builder.MergeAttribute("href", urlBuilder(column, direction));
     return builder.ToString(TagRenderMode.Normal);
 }
Пример #4
0
 public virtual ViewResult List(string sortType, SortDirection? sortDirection)
 {
     if (string.IsNullOrEmpty(sortType))
         sortType = "date";
     if (sortDirection == null)
         sortDirection = SortDirection.Descending;
     var viewModel = new FlightLogList();
     viewModel.SortDirection = sortDirection ?? SortDirection.Ascending;
     viewModel.SortType = sortType;
     var flightLogs = flightLogRepository.GetAllFlightLogs();
     var viewModelItems = Mapper.Map<IEnumerable<FlightLog>, IEnumerable<FlightLogListItemViewModel>>(flightLogs.ToList());
     if (viewModel.IsCurrentSortType("date") && viewModel.SortDirection == SortDirection.Ascending)
         viewModelItems = viewModelItems.OrderBy(x => x.LogDate);
     else if (viewModel.IsCurrentSortType("date"))
         viewModelItems = viewModelItems.OrderByDescending(x => x.LogDate);
     if (viewModel.IsCurrentSortType("aircraft") && viewModel.SortDirection == SortDirection.Ascending)
         viewModelItems = viewModelItems.OrderBy(x => x.AircraftMDS);
     else if (viewModel.IsCurrentSortType("aircraft"))
         viewModelItems = viewModelItems.OrderByDescending(x => x.AircraftMDS);
     if (viewModel.IsCurrentSortType("program") && viewModel.SortDirection == SortDirection.Ascending)
         viewModelItems = viewModelItems.OrderBy(x => x.Program);
     else if (viewModel.IsCurrentSortType("program"))
         viewModelItems = viewModelItems.OrderByDescending(x => x.Program);
     if (viewModel.IsCurrentSortType("location") && viewModel.SortDirection == SortDirection.Ascending)
         viewModelItems = viewModelItems.OrderBy(x => x.Location);
     else if (viewModel.IsCurrentSortType("location"))
         viewModelItems = viewModelItems.OrderByDescending(x => x.Location);
     viewModel.Items = viewModelItems.ToList();
     return View(Views.List, viewModel);
 }
Пример #5
0
 public Pagination()
 {
     PageNumber = 1;
     PageSize = 20;
     SortColumn = "CreationDateUtc";
     SortDirection = SortDirection.Descending;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            MasterPage.RequiredPermission = 4400;
            MasterPage.IsSecure = true;
            MasterPage.PageTitle = string.Format("{0}", "Challenges");

            _mStrSortExp = String.Empty;

            if (!IsPostBack)
            {
                SetPageRibbon(StandardModuleRibbons.SetupRibbon());

                _mStrSortExp = String.Empty;
            }
            else
            {
                if (null != ViewState["_SortExp_"])
                {
                    _mStrSortExp = ViewState["_SortExp_"] as String;
                }

                if (null != ViewState["_Direction_"])
                {
                    _mSortDirection = (SortDirection)ViewState["_Direction_"];
                }
            }
        }
Пример #7
0
        public virtual ViewResult List(string sortType, SortDirection? sortDirection, int? page, int? itemsPerPage)
        {
            if (string.IsNullOrEmpty(sortType))
                sortType = "name";
            var viewModel = new SortedListViewModel<PersonnelRecordListViewModel>
            {
                SortDirection = sortDirection ?? SortDirection.Ascending,
                SortType = sortType,
                PagingEnabled = true,
                CurrentPage = page.HasValue ? page.Value : 1,
                ItemsPerPage = itemsPerPage.HasValue ? itemsPerPage.Value : SortedListViewModel<PersonnelRecordListViewModel>.DefaultItemsPerPage,
            };

            IEnumerable<User> users = userRepository.GetAllActiveUsers().ToList();
            var items = Mapper.Map<IEnumerable<User>, IEnumerable<PersonnelRecordListViewModel>>(users);
            if (viewModel.IsCurrentSortType("name") && viewModel.SortDirection == SortDirection.Ascending)
                items = items.OrderBy(x => x.FileByName);
            else if (viewModel.IsCurrentSortType("name"))
                items = items.OrderByDescending(x => x.FileByName);
            if (viewModel.IsCurrentSortType("status") && viewModel.SortDirection == SortDirection.Ascending)
                items = items.OrderBy(x => x.Status);
            else if (viewModel.IsCurrentSortType("status"))
                items = items.OrderByDescending(x => x.Status);
            viewModel.SetItems(items.ToList());

            return View(Views.List, viewModel);
        }
Пример #8
0
        public List<CUSTOMER> Search(CUSTOMER Customer, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.CUSTOMER.AsQueryable();
            if (Customer != null)
            {
                if (!String.IsNullOrWhiteSpace(Customer.Name))
                {
                    result = result.Where(c => (c.Name + " " + c.Surname).Contains(Customer.Name));
                }

                if (!String.IsNullOrWhiteSpace(Customer.Email))
                {
                    result = result.Where(c => c.Email.ToLower().Contains(Customer.Email.ToLower()));
                }

                if (Customer.Newsletter.HasValue)
                {
                    result = result.Where(c => c.Newsletter == Customer.Newsletter.Value);
                }
            }

            TotalRecords = result.Count();

            GenericSorterCaller<CUSTOMER> sorter = new GenericSorterCaller<CUSTOMER>();
            result = sorter.Sort(result, String.IsNullOrEmpty(OrderExp) ? "ID" : OrderExp, SortDirection);

            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            MasterPage.RequiredPermission = 5100;
            MasterPage.AdditionalRequiredPermission = 5300;
            MasterPage.IsSecure = true;
            if (Session["Curr_Patron"] == null) Response.Redirect("Default.aspx");

            if (!IsPostBack)
            {
                PatronsRibbon.GetByAppContext(this);

                var patron = (Patron)Session["Curr_Patron"];
                MasterPage.PageTitle = string.Format("{0} - {1} {2} ({3})", "Patron Reviews", patron.FirstName, patron.LastName, patron.Username);
            }

            _mStrSortExp = String.Empty;
            if (!IsPostBack)
            {
                _mStrSortExp = String.Empty;
            }
            else
            {
                if (null != ViewState["_SortExp_"])
                {
                    _mStrSortExp = ViewState["_SortExp_"] as String;
                }

                if (null != ViewState["_Direction_"])
                {
                    _mSortDirection = (SortDirection)ViewState["_Direction_"];
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SetPageRibbon(StandardModuleRibbons.SetupRibbon());
                SID.Text = Session["SID"] == null ? "" : Session["SID"].ToString();
                if (SID.Text == "") Response.Redirect("SurveyList.aspx");
                var s = Survey.FetchObject(int.Parse(SID.Text));
                lblSurvey.Text = string.Format("{0} - {1}", s.Name, s.LongName);
                if (s.Status > 1) ReadOnly.Text = "true";
            }

            MasterPage.RequiredPermission = 5200;
            MasterPage.IsSecure = true;
            MasterPage.PageTitle = string.Format("{0}", "Survey/Test Question List");

            _mStrSortExp = String.Empty;
            if (!IsPostBack)
            {
                _mStrSortExp = String.Empty;
            }
            else
            {
                if (null != ViewState["_SortExp_"])
                {
                    _mStrSortExp = ViewState["_SortExp_"] as String;
                }

                if (null != ViewState["_Direction_"])
                {
                    _mSortDirection = (SortDirection)ViewState["_Direction_"];
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            MasterPage.RequiredPermission = 4100;
            MasterPage.IsSecure = true;
            MasterPage.PageTitle = string.Format("{0}", "School and District Crosswalk");

            if (!IsPostBack)
            {
                SetPageRibbon(StandardModuleRibbons.SettingsRibbon());

                //LoadData();

            }

            _mStrSortExp = String.Empty;
            if (!IsPostBack)
            {
                _mStrSortExp = String.Empty;
            }
            else
            {
                if (null != ViewState["_SortExp_"])
                {
                    _mStrSortExp = ViewState["_SortExp_"] as String;
                }

                if (null != ViewState["_Direction_"])
                {
                    _mSortDirection = (SortDirection)ViewState["_Direction_"];
                }
            }

        }
        protected void Page_Load(object sender, EventArgs e) {
            MasterPage.IsSecure = true;
            MasterPage.PageTitle = "SRP User List";

            ControlRoomAccessPermission.CheckControlRoomAccessPermission(1000); // User Security;

            if(!IsPostBack) {
                List<RibbonPanel> moduleRibbonPanels = StandardModuleRibbons.SecurityRibbon();
                foreach(var moduleRibbonPanel in moduleRibbonPanels) {
                    MasterPage.PageRibbon.Add(moduleRibbonPanel);
                }
                MasterPage.PageRibbon.DataBind();
            }


            _mStrSortExp = String.Empty;
            if(!IsPostBack) {
                _mStrSortExp = "Username";
                _mSortDirection = SortDirection.Ascending;
                ViewState["_SortExp_"] = _mStrSortExp;
                ViewState["_Direction_"] = _mSortDirection;
            } else {
                if(null != ViewState["_SortExp_"]) {
                    _mStrSortExp = ViewState["_SortExp_"] as String;
                }

                if(null != ViewState["_Direction_"]) {
                    _mSortDirection = (SortDirection)ViewState["_Direction_"];
                }
            }

            if(!IsPostBack) {
                LoadData();
            }
        }
 public ReportSortOptions(string criterium, SortDirection direction)
     : base(criterium, direction)
 {
     var allowedCriteria = new string[] { "Operator.Name", "CreateDate" };
     if (!allowedCriteria.Contains(criterium))
         throw new ArgumentException("criterium");
 }
Пример #14
0
        public IndexKeyColumn(Column column, SortDirection sortDirection)
        {
            if (column == null) throw new ArgumentNullException("column");

            Column = column;
            SortDirection = sortDirection;
        }
Пример #15
0
    protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
    {
        DataTable dataTable = GridView1.DataSource as DataTable;
        string sortExpression = e.SortExpression;
        string direction = string.Empty;

        if (dataTable != null)
        {
            DataView dataView = new DataView(dataTable);

            if (SortDirection == SortDirection.Descending)
            {
                SortDirection = SortDirection.Ascending;
                direction = " ASC";
            }
            else
            {
                SortDirection = SortDirection.Descending;
                direction = " DESC";
            }

            DataTable table = GridView1.DataSource as DataTable;
            table.DefaultView.Sort = sortExpression + direction;

            GridView1.DataSource = table;
            GridView1.DataBind();

        }
    }
Пример #16
0
 /// <summary>
 /// Creates new instance of OrderByField
 /// </summary>
 /// <param name="OrderField">Field to order by</param>
 /// <param name="Direction">Sort direction</param>
 public OrderByField(Field OrderField, SortDirection Direction)
 {
     if (OrderField == null)
         throw new ArgumentNullException("OrderField");
     this.Field = OrderField;
     this.Direction = Direction;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            MasterPage.RequiredPermission = 4500;
            MasterPage.IsSecure = true;
            MasterPage.PageTitle = string.Format("{0}", "Events List");

            _mStrSortExp = String.Empty;

            if (!IsPostBack)
            {
                SetPageRibbon(StandardModuleRibbons.SetupRibbon());

                //if (WasFiltered())
                //{
                //    GetFilterSessionValues();
                //}

                _mStrSortExp = String.Empty;
            }
            else
            {
                if (null != ViewState["_SortExp_"])
                {
                    _mStrSortExp = ViewState["_SortExp_"] as String;
                }

                if (null != ViewState["_Direction_"])
                {
                    _mSortDirection = (SortDirection)ViewState["_Direction_"];
                }
            }
        }
Пример #18
0
        public void Init(ParsingContext context, ParseTreeNode parseNode)
        {
            if (HasChildNodes(parseNode))
            {
                if (parseNode.ChildNodes[3] != null && HasChildNodes(parseNode.ChildNodes[3]) && parseNode.ChildNodes[3].ChildNodes[0].Term.Name.ToUpper() == "DESC")
                    _OrderDirection = SortDirection.Desc;
                else
                    _OrderDirection = SortDirection.Asc;

                _OrderByAttributeList = new List<OrderByAttributeDefinition>();

                foreach (ParseTreeNode treeNode in parseNode.ChildNodes[2].ChildNodes)
                {
                    if (treeNode.AstNode != null && treeNode.AstNode is IDNode)
                    {

                        _OrderByAttributeList.Add(new OrderByAttributeDefinition(((IDNode)treeNode.AstNode).IDChainDefinition, null));
                    }
                    else
                    {
                        _OrderByAttributeList.Add(new OrderByAttributeDefinition(null, treeNode.Token.ValueString));
                    }
                }

                OrderByDefinition = new OrderByDefinition(_OrderDirection, _OrderByAttributeList);
            }
        }
Пример #19
0
        public static MvcHtmlString SortExpressionLink(
            this HtmlHelper helper,
            string title,
            string sortExpression,
            SortDirection direction = SortDirection.Ascending,
            object htmlAttributes = null)
        {
            var a = new TagBuilder("a");

            if (htmlAttributes != null)
            {
                // get the attributes
                IDictionary<string, object> attributes =
                    HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes)
                        as IDictionary<string, object>;

                // set the attributes
                a.MergeAttributes(attributes);
            }

            var i = new TagBuilder("i");
            i.MergeAttribute("class", "indicator");

            a.AddCssClass("sort-expression-link");

            a.MergeAttribute("title", title);
            a.MergeAttribute("href", "#" + sortExpression);
            a.MergeAttribute("data-sort-expression", sortExpression);
            a.MergeAttribute("data-sort-direction", direction.ToString());
            a.InnerHtml = title + i.ToString(TagRenderMode.Normal);

            return
                MvcHtmlString.Create(a.ToString(TagRenderMode.Normal));
        }
Пример #20
0
        public SortableField(string name, SortDirection sortDirection = SortDirection.Asc)
        {
            Ensure.That(name, "name").IsNotNullOrWhiteSpace();

            Name = name;
            SortDirection = sortDirection;
        }
Пример #21
0
        public static Paging<Plant> PlantsPaging(int start, int limit, string sort, SortDirection dir, string filter)
        {
            List<Plant> plants = Plant.GetPlants();

            if (!string.IsNullOrEmpty(filter) && filter != "*")
            {
                plants.RemoveAll(plant => !plant.Common.ToLower().StartsWith(filter.ToLower()));
            }

            if (!string.IsNullOrEmpty(sort))
            {
                plants.Sort(delegate(Plant x, Plant y)
                {
                    object a;
                    object b;

                    int direction = dir == SortDirection.DESC ? -1 : 1;

                    a = x.GetType().GetProperty(sort).GetValue(x, null);
                    b = y.GetType().GetProperty(sort).GetValue(y, null);

                    return CaseInsensitiveComparer.Default.Compare(a, b) * direction;
                });
            }

            if ((start + limit) > plants.Count)
            {
                limit = plants.Count - start;
            }

            List<Plant> rangePlants = (start < 0 || limit < 0) ? plants : plants.GetRange(start, limit);

            return new Paging<Plant>(rangePlants, plants.Count);
        }
Пример #22
0
 public PagingInfo(
     string sortTitle,
     string sortExpression,
     SortDirection sortDirection)
 {
     AddSortExpression(sortTitle, sortExpression, sortDirection);
 }
Пример #23
0
        private void Initialize(string sortExpression)
        {
            FieldName = string.Empty;
            Direction = SortDirection.Ascending;

            if (string.IsNullOrEmpty(sortExpression))
                return;

            var sortExp = sortExpression.Trim();

            if (sortExp.EndsWith(" DESC"))
            {
                sortExp = sortExp.Remove(sortExp.LastIndexOf(" DESC"));
                this.Direction = SortDirection.Descending;
            }
            else if (sortExp.EndsWith(" ASC"))
            {
                sortExp = sortExp.Remove(sortExp.LastIndexOf(" ASC"));
                this.Direction = SortDirection.Ascending;
            }

            this.FullName = sortExp;

            var separatorIndex = sortExp.IndexOf('.');
            if (separatorIndex >= 0)
                sortExp = sortExp.Substring(separatorIndex + 1);

            this.FieldName = sortExp;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            MasterPage.RequiredPermission = 4400;
            MasterPage.IsSecure = true;
            
            if (!IsPostBack)
            {
                SetPageRibbon(StandardModuleRibbons.SetupRibbon());

                lblPK.Text = Session["BLL"] == null ? "" : Session["BLL"].ToString(); //Session["BLL"]= string.Empty;
                var bl = BookList.FetchObject(int.Parse(lblPK.Text));
                MasterPage.PageTitle = string.Format("Tasks in the \"{0}\" Challenge", bl.AdminName);
             }

            
            _mStrSortExp = String.Empty;
            if (!IsPostBack)
            {
                _mStrSortExp = String.Empty;
            }
            else
            {
                if (null != ViewState["_SortExp_"])
                {
                    _mStrSortExp = ViewState["_SortExp_"] as String;
                }

                if (null != ViewState["_Direction_"])
                {
                    _mSortDirection = (SortDirection)ViewState["_Direction_"];
                }
            }
        }
Пример #25
0
        public List<BRAND> Search(BRAND Brand, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, SortDirection SortDirection)
        {
            var result = Context.BRAND.AsQueryable();
            if (Brand != null)
            {
                if (!String.IsNullOrEmpty(Brand.Name))
                {
                    result = result.Where(b => b.Name.Contains(Brand.Name));
                }

                if (!String.IsNullOrEmpty(Brand.ShowName))
                {
                    result = result.Where(b => b.ShowName.Contains(Brand.ShowName));
                }

                if (!String.IsNullOrEmpty(Brand.Description))
                {
                    result = result.Where(b => b.Description.Contains(Brand.Description));
                }

                if (!String.IsNullOrEmpty(Brand.Email))
                {
                    result = result.Where(b => b.Email.Contains(Brand.Email));
                }
            }
            TotalRecords = result.Count();

            GenericSorterCaller<BRAND> sorter = new GenericSorterCaller<BRAND>();
            result = sorter.Sort(result, string.IsNullOrEmpty(OrderExp) ? DEFAULT_ORDER_EXP : OrderExp, SortDirection);

            // pagination
            return result.Skip(PageIndex * PageSize).Take(PageSize).ToList();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            MasterPage.RequiredPermission = 8000;
            MasterPage.IsSecure = true;
            MasterPage.PageTitle = string.Format("{0}", "Organization List");

            if (!(bool)CRIsMasterTenant)
            {
                Response.Redirect("MyTenantAccount.aspx");
            }

            _mStrSortExp = String.Empty;

            if (!IsPostBack)
            {
                SetPageRibbon(StandardModuleRibbons.MasterTenantRibbon());

                _mStrSortExp = String.Empty;
            }
            else
            {
                if (null != ViewState["_SortExp_"])
                {
                    _mStrSortExp = ViewState["_SortExp_"] as String;
                }
 
                if (null != ViewState["_Direction_"])
                {
                    _mSortDirection = (SortDirection)ViewState["_Direction_"];
                }
            }
        }
        public static IQueryable<Article> Sort(this IQueryable<Article> articleQuery, string orderBy, SortDirection sortDirection)
        {
            orderBy = orderBy.ToUpperInvariant();
            switch (orderBy)
            {
                case "DATECREATED":
                    if (sortDirection == SortDirection.ASC)
                    {
                        articleQuery = articleQuery.OrderBy(a => a.DateCreated);
                    }
                    else
                    {
                        articleQuery = articleQuery.OrderByDescending(a => a.DateCreated);
                    }
                    break;
                case "TITLE":
                    if (sortDirection == SortDirection.ASC)
                    {
                        articleQuery = articleQuery.OrderBy(a => a.Title);
                    }
                    else
                    {
                        articleQuery = articleQuery.OrderByDescending(a => a.Title);
                    }
                    break;
                case "PRICE":
                    if (sortDirection == SortDirection.ASC)
                    {
                        articleQuery = articleQuery.OrderBy(a => a.Price);
                    }
                    else
                    {
                        articleQuery = articleQuery.OrderByDescending(a => a.Price);
                    }
                    break;
                case "LIKESCOUNT":
                    if (sortDirection == SortDirection.ASC)
                    {
                        articleQuery = articleQuery.OrderBy(a => a.LikesCount);
                    }
                    else
                    {
                        articleQuery = articleQuery.OrderByDescending(a => a.LikesCount);
                    }
                    break;
                case "ORDERSCOUNT":
                    if (sortDirection == SortDirection.ASC)
                    {
                        articleQuery = articleQuery.OrderBy(a => a.OrdersCount);
                    }
                    else
                    {
                        articleQuery = articleQuery.OrderByDescending(a => a.OrdersCount);
                    }
                    break;
            }

            return articleQuery;
        }
Пример #28
0
		public SortOrder(SymbolName symbolName, SortDirection sortDirection)
		{
			if ((object)symbolName == null)
				throw new ArgumentNullException(nameof(symbolName));

			this.symbolName = symbolName;
			this.sortDirection = sortDirection;
		}
Пример #29
0
        //
        // GET: /StoreManager/

        public ActionResult Index(SortField sortField = SortField.Name, SortDirection sortDirection = SortDirection.Up)
        {
            var products = db.Products.Include("Category").ToList();

            var sorted = Sort(products, sortField, sortDirection);

            return View(sorted);
        }
Пример #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SortExpression"/> class.
        /// </summary>
        /// <param name="columnName">Name of the column to be sorted by.</param>
        /// <param name="descending">if set to <c>true</c> [descending].</param>
        /// <exception cref="ArgumentException"></exception>
        public SortExpression(string columnName, SortDirection descending)
        {
            if (string.IsNullOrWhiteSpace(columnName))
                throw new ArgumentException($"{nameof(columnName)} is null or empty.", nameof(columnName));

            m_ColumnName = columnName;
            m_Direction = descending;
        }
 public virtual new void Sort(string sortExpression, SortDirection sortDirection)
 {
 }
Пример #32
0
 public override Allors.Extent AddSort(IRoleType roleType, SortDirection direction)
 {
     throw new NotSupportedException();
 }
Пример #33
0
 public DirectionalSortDefinition(FieldDefinition <TDocument> field, SortDirection direction)
 {
     _field     = Ensure.IsNotNull(field, "field");
     _direction = direction;
 }
Пример #34
0
 /// <summary>
 /// Search returning an <see cref="IProductContent"/> collection.
 /// </summary>
 /// <param name="page">
 /// The page.
 /// </param>
 /// <param name="itemsPerPage">
 /// The items per page.
 /// </param>
 /// <param name="sortBy">
 /// The sort by.
 /// </param>
 /// <param name="sortDirection">
 /// The sort direction.
 /// </param>
 /// <returns>
 /// The <see cref="IEnumerable{IProductContent}"/>.
 /// </returns>
 public IEnumerable <IProductContent> TypedProductContentSearch(long page, long itemsPerPage, string sortBy = "name", SortDirection sortDirection = SortDirection.Descending)
 {
     return(TypedProductContentSearchPaged(page, itemsPerPage, sortBy, sortDirection).Items);
 }
Пример #35
0
 /// <summary>
 /// Searches all products for a term
 /// </summary>
 /// <param name="term">
 /// The term.
 /// </param>
 /// <param name="page">
 /// The page.
 /// </param>
 /// <param name="itemsPerPage">
 /// The items per page.
 /// </param>
 /// <param name="sortBy">
 /// The sort by.
 /// </param>
 /// <param name="sortDirection">
 /// The sort direction.
 /// </param>
 /// <returns>
 /// The <see cref="QueryResultDisplay"/>.
 /// </returns>
 public QueryResultDisplay Search(string term, long page, long itemsPerPage, string sortBy = "name", SortDirection sortDirection = SortDirection.Ascending)
 {
     return(GetQueryResultDisplay(_productService.GetPagedKeys(term, page, itemsPerPage, sortBy, sortDirection)));
 }
Пример #36
0
 public static IQueryable <T> SortBy <T>(this IQueryable <T> query, SortDirection sortDirection, IEnumerable <Expression <Func <T, object> > > sortExpressions)
 {
     return(query.SortBy(sortDirection, sortExpressions?.ToArray()));
 }
 /// <summary>
 ///
 /// </summary>
 public virtual TBuilder Group(DataSorterCollection groupers, SortDirection direction)
 {
     this.ToComponent().Group(groupers, direction);
     return(this as TBuilder);
 }
Пример #38
0
        public static SearchProductProjectionsCommand Sort(this SearchProductProjectionsCommand command, Expression <Func <ProductProjection, IComparable> > expression, SortDirection sortDirection = SortDirection.Ascending)
        {
            var p = command.SearchParameters as ProductProjectionSearchParameters;

            p.Sort.Add(new Sort <ProductProjection>(expression, sortDirection).ToString());

            return(command);
        }
Пример #39
0
        public static QueryCommand <T> Sort <T>(this QueryCommand <T> command, Expression <Func <T, IComparable> > expression, SortDirection sortDirection = SortDirection.Ascending)
        {
            command.Sort.Add(new Sort <T>(expression, sortDirection).ToString());

            return(command);
        }
Пример #40
0
 internal OrderedSequence(IEnumerable <TElement> source, Func <TElement, TKey> key_selector, IComparer <TKey> comparer, SortDirection direction) : base(source)
 {
     this.selector  = key_selector;
     this.comparer  = (comparer ?? Comparer <TKey> .Default);
     this.direction = direction;
 }
Пример #41
0
 internal OrderedSequence(OrderedEnumerable <TElement> parent, IEnumerable <TElement> source, Func <TElement, TKey> keySelector, IComparer <TKey> comparer, SortDirection direction) : this(source, keySelector, comparer, direction)
 {
     this.parent = parent;
 }
Пример #42
0
        public async Task <IEnumerable <T> > SearchAsync <T>(string searchQuery, string sortByField = "", SortDirection sortDirection = SortDirection.Ascending, params Expression <Func <T, object> >[] searchFields)
            where T : class
        {
            var res = await SearchAsync(null, null, sortByField, sortDirection, null, searchQuery, searchFields);

            return(res.Documents);
        }
Пример #43
0
        public async Task <ISearchResponse <T> > SearchAsync <T>(int?skip = null, int?take = null, string sortByField = "", SortDirection sortDirection = SortDirection.Ascending, IEnumerable <KeyValuePair <Expression <Func <T, object> >, object> > terms = null, string searchQuery = null, params Expression <Func <T, object> >[] searchFields)
            where T : class
        {
            var res = await Client.SearchAsync <T>(x => BuildSearchDescriptor(x, skip, take, sortByField, sortDirection, terms, searchQuery, searchFields).Index(PrefixIndex + "-" + typeof(T).Name.ToLower()));

            if (!res.IsValid)
            {
                throw new CoreException(res.DebugInformation);
            }
#if DEBUG
            var query = Encoding.UTF8.GetString(res.ApiCall.RequestBodyInBytes);
            Debug.WriteLine(query);
#endif
            return(res);
        }
Пример #44
0
        public async Task <QueryResult <T> > QueryAsync <T>(int skip, int take, string sortByField = "", SortDirection sortDirection = SortDirection.Ascending, IEnumerable <KeyValuePair <Expression <Func <T, object> >, object> > terms = null, string searchQuery = null, params Expression <Func <T, object> >[] searchFields)
            where T : class
        {
            var res = await SearchAsync(skip, take, sortByField, sortDirection, terms, searchQuery, searchFields);

            return(new QueryResult <T>
            {
                Count = res.Total,
                Items = res.Documents
            });
        }
Пример #45
0
        private IList <Ansatt> SortAllAnsatte(IEnumerable <Ansatt> allAnsatte, SortDirection sortDirection, string sortExpression)
        {
            IEnumerable <Ansatt> result = new List <Ansatt>();

            var propertyInfo = typeof(Ansatt).GetProperty(sortExpression);

            if (sortExpression == "Avdeling")
            {
                if (sortDirection == SortDirection.Ascending)
                {
                    result = allAnsatte.OrderBy(ansatt => ansatt.Avdeling != null ? ansatt.Avdeling.Navn : string.Empty).ToList();
                }
                else
                {
                    result = allAnsatte.OrderByDescending(ansatt => ansatt.Avdeling != null ? ansatt.Avdeling.Navn : string.Empty).ToList();
                }
            }
            else if (sortExpression == "StillingsType")
            {
                if (sortDirection == SortDirection.Ascending)
                {
                    result = allAnsatte.OrderBy(ansatt => ansatt.StillingsType != null ? ansatt.StillingsType.Navn : string.Empty).ToList();
                }
                else
                {
                    result = allAnsatte.OrderByDescending(ansatt => ansatt.StillingsType != null ? ansatt.StillingsType.Navn : string.Empty).ToList();
                }
            }
            //else if (sortExpression == "VarslesAvansatt")
            //{
            //    if (sortDirection == SortDirection.Ascending)
            //    {
            //        result = allAnsatte.OrderBy(ansatt => ansatt.VarslesAvAnsatt != null ? ansatt.VarslesAvAnsatt.Navn : string.Empty);
            //    }
            //    else
            //    {
            //        result = allAnsatte.OrderByDescending(ansatt => ansatt.VarslesAvAnsatt != null ? ansatt.VarslesAvAnsatt.Navn : string.Empty);
            //    }
            //}
            else if (sortExpression == "JobberIKlasser")
            {
                if (sortDirection == SortDirection.Ascending)
                {
                    result = allAnsatte.OrderBy(ansatt => ansatt.JobberIKlasser.Count > 0 ? ansatt.JobberIKlasser.First().Navn : string.Empty).ToList();
                }
                else
                {
                    result = allAnsatte.OrderByDescending(ansatt => ansatt.JobberIKlasser.Count > 0 ? ansatt.JobberIKlasser.First().Navn : string.Empty).ToList();
                }
            }
            else if (sortExpression == "JobberISfos")
            {
                if (sortDirection == SortDirection.Ascending)
                {
                    result = allAnsatte.OrderBy(ansatt => ansatt.JobberISfos.Count > 0 ? ansatt.JobberISfos.First().Navn : string.Empty).ToList();
                }
                else
                {
                    result = allAnsatte.OrderByDescending(ansatt => ansatt.JobberISfos.Count > 0 ? ansatt.JobberISfos.First().Navn : string.Empty).ToList();
                }
            }
            //else if (sortExpression == "AvdelingsLederIAvdelinger")
            //{
            //    if (sortDirection == SortDirection.Ascending)
            //    {
            //        result = allAnsatte.OrderBy(ansatt => ansatt.AvdelingsLederIAvdelinger.Count > 0 ? ansatt.AvdelingsLederIAvdelinger.First().Navn : string.Empty);
            //    }
            //    else
            //    {
            //        result = allAnsatte.OrderByDescending(ansatt => ansatt.AvdelingsLederIAvdelinger.Count > 0 ? ansatt.AvdelingsLederIAvdelinger.First().Navn : string.Empty);
            //    }
            //}
            else
            {
                if (sortDirection == SortDirection.Ascending)
                {
                    result = allAnsatte.OrderBy(ansatt => propertyInfo.GetValue(ansatt)).ToList();
                }
                else
                {
                    result = allAnsatte.OrderByDescending(ansatt => propertyInfo.GetValue(ansatt)).ToList();
                }
            }

            return(result.ToList());
        }
Пример #46
0
 public List <ContractFileInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
 {
     return(ContractFileInfo.GetPagedList(pPageIndex, pPageSize, pOrderBy, pSortExpression, out pRecordCount));
 }
Пример #47
0
 internal ExtentSort(Session session, IRoleType roleType, SortDirection direction)
 {
     this.session   = session;
     this.roleType  = roleType;
     this.direction = direction;
 }
Пример #48
0
 public SortingInfo(SortColumn sortColumn, SortDirection sortDirection)
 {
     SortColumn    = sortColumn;
     SortDirection = sortDirection;
 }
Пример #49
0
        /// <summary>
        /// Searches all products for a term
        /// </summary>
        /// <param name="term">
        /// The term.
        /// </param>
        /// <param name="page">
        /// The page.
        /// </param>
        /// <param name="itemsPerPage">
        /// The items per page.
        /// </param>
        /// <param name="sortBy">
        /// The sort by.
        /// </param>
        /// <param name="sortDirection">
        /// The sort direction.
        /// </param>
        /// <returns>
        /// The <see cref="QueryResultDisplay"/>.
        /// </returns>
        public QueryResultDisplay Search(string term, long page, long itemsPerPage, string sortBy = "name", SortDirection sortDirection = SortDirection.Ascending)
        {
            var cacheKey = PagedKeyCache.GetPagedQueryCacheKey <ICachedProductQuery>("Search", page, itemsPerPage, sortBy, sortDirection, new Dictionary <string, string> {
                { "term", term }
            });
            var pagedKeys = PagedKeyCache.GetPageByCacheKey(cacheKey);

            return(GetQueryResultDisplay(
                       pagedKeys ??
                       PagedKeyCache.CachePage(cacheKey, _productService.GetPagedKeys(term, page, itemsPerPage, sortBy, sortDirection))));
        }
        /// <summary>
        /// Touches the job after it is queryable.
        /// </summary>
        /// <param name="job">The job</param>
        async Task CheckJobAsync(Job job, Service service)
        {
            string dummyString;
            //string[] dummyList;
            long     dummyInt;
            bool     dummyBool;
            DateTime dummyDateTime;
            double   dummyDouble;

            dummyDateTime = job.CursorTime;
            //dummyString = job.Delegate;
            dummyInt = job.DiskUsage;
            DispatchState dummyDispatchState = job.DispatchState;

            dummyDouble   = job.DoneProgress;
            dummyInt      = job.DropCount;
            dummyDateTime = job.EarliestTime;
            dummyInt      = job.EventAvailableCount;
            dummyInt      = job.EventCount;
            dummyInt      = job.EventFieldCount;
            dummyBool     = job.EventIsStreaming;
            dummyBool     = job.EventIsTruncated;
            dummyString   = job.EventSearch;
            SortDirection sordirection      = job.EventSorting;
            long          indexEarliestTime = job.IndexEarliestTime;
            long          indexLatestTime   = job.IndexLatestTime;

            dummyString = job.Keywords;
            //dummyString = job.Label;

            ServerInfo serverInfo = await service.Server.GetInfoAsync();

            if (serverInfo.Version.CompareTo(new Version(6, 0)) < 0)
            {
                dummyDateTime = job.LatestTime;
            }

            dummyInt    = job.NumPreviews;
            dummyInt    = job.Priority;
            dummyString = job.RemoteSearch;
            //dummyString = job.ReportSearch;
            dummyInt    = job.ResultCount;
            dummyBool   = job.ResultIsStreaming;
            dummyInt    = job.ResultPreviewCount;
            dummyDouble = job.RunDuration;
            dummyInt    = job.ScanCount;
            dummyString = job.EventSearch;               // Search;
            DateTime jobearliestTime = job.EarliestTime; //SearchEarliestTime;
            DateTime joblatestTime   = job.LatestTime;
            ReadOnlyCollection <string> providers = job.SearchProviders;

            dummyString = job.Sid;
            dummyInt    = job.StatusBuckets;
            dummyInt    = job.Ttl;
            dummyBool   = job.IsDone;
            dummyBool   = job.IsFailed;
            dummyBool   = job.IsFinalized;
            dummyBool   = job.IsPaused;
            dummyBool   = job.IsPreviewEnabled;
            dummyBool   = job.IsRealTimeSearch;
            dummyBool   = job.IsRemoteTimeline;
            dummyBool   = job.IsSaved;
            dummyBool   = job.IsSavedSearch;
            dummyBool   = job.IsZombie;
            Assert.Equal(job.Name, job.Sid);
        }
Пример #51
0
        /// <summary>
        /// Searches all products
        /// </summary>
        /// <param name="page">
        /// The page.
        /// </param>
        /// <param name="itemsPerPage">
        /// The items per page.
        /// </param>
        /// <param name="sortBy">
        /// The sort by.
        /// </param>
        /// <param name="sortDirection">
        /// The sort direction.
        /// </param>
        /// <returns>
        /// The <see cref="QueryResultDisplay"/>.
        /// </returns>
        public QueryResultDisplay Search(long page, long itemsPerPage, string sortBy = "name", SortDirection sortDirection = SortDirection.Descending)
        {
            var cacheKey  = PagedKeyCache.GetPagedQueryCacheKey <ICachedProductQuery>("Search", page, itemsPerPage, sortBy, sortDirection);
            var pagedKeys = PagedKeyCache.GetPageByCacheKey(cacheKey);

            return(GetQueryResultDisplay(
                       pagedKeys ??
                       PagedKeyCache.CachePage(cacheKey, _productService.GetPagedKeys(page, itemsPerPage, sortBy, sortDirection))));
        }
Пример #52
0
 public void SortByColumn(int iColumn, SortDirection dir)
 {
 }
Пример #53
0
 public Sorter(SortField field, SortDirection direction)
 {
     Field     = field;
     Direction = direction;
 }
Пример #54
0
 public Sorter(SortField field)
 {
     Field     = field;
     Direction = SortDirection.Ascending;
 }
Пример #55
0
 public void Sort(SortDirection direction)
 {
     musicFiles.Sort(new YearComparer(direction));
 }
 /// <summary>
 /// The direction in which sorting should be applied when grouping. Defaults to \"ASC\" - the other supported value is \"DESC\"
 /// </summary>
 public virtual TBuilder GroupDir(SortDirection groupDir)
 {
     this.ToComponent().GroupDir = groupDir;
     return(this as TBuilder);
 }
Пример #57
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="path">The path to the resulting member to sort by.</param>
 /// <param name="direction">The direction of the sort.</param>
 public MemberSortPath(IEnumerable <IMember> path, SortDirection direction)
 {
     Path      = path.ToList();
     Direction = direction;
 }
Пример #58
0
        private KeywordQuery CreateKeywordQuery()
        {
            var keywordQuery = new KeywordQuery(ClientContext);

            // Construct query to execute
            var query = "";

            if (!string.IsNullOrEmpty(Query))
            {
                query = Query;
            }

            keywordQuery.QueryText  = query;
            keywordQuery.ClientType = ClientType;
            if (MyInvocation.BoundParameters.ContainsKey("TrimDuplicates"))
            {
                keywordQuery.TrimDuplicates = TrimDuplicates;
            }
            if (MyInvocation.BoundParameters.ContainsKey("Refiners"))
            {
                keywordQuery.Refiners = Refiners;
            }
            if (MyInvocation.BoundParameters.ContainsKey("Culture"))
            {
                keywordQuery.Culture = Culture;
            }
            if (MyInvocation.BoundParameters.ContainsKey("QueryTemplate"))
            {
                keywordQuery.QueryTemplate = QueryTemplate;
            }
            if (MyInvocation.BoundParameters.ContainsKey("RankingModelId"))
            {
                keywordQuery.RankingModelId = RankingModelId;
            }
            if (MyInvocation.BoundParameters.ContainsKey("HiddenConstraints"))
            {
                keywordQuery.HiddenConstraints = HiddenConstraints;
            }
            if (MyInvocation.BoundParameters.ContainsKey("TimeZoneId"))
            {
                keywordQuery.TimeZoneId = TimeZoneId;
            }
            if (MyInvocation.BoundParameters.ContainsKey("EnablePhonetic"))
            {
                keywordQuery.EnablePhonetic = EnablePhonetic;
            }
            if (MyInvocation.BoundParameters.ContainsKey("EnableStemming"))
            {
                keywordQuery.EnableStemming = EnableStemming;
            }
            if (MyInvocation.BoundParameters.ContainsKey("EnableQueryRules"))
            {
                keywordQuery.EnableQueryRules = EnableQueryRules;
            }
            if (MyInvocation.BoundParameters.ContainsKey("SourceId"))
            {
                keywordQuery.SourceId = SourceId;
            }
            if (MyInvocation.BoundParameters.ContainsKey("ProcessBestBets"))
            {
                keywordQuery.ProcessBestBets = ProcessBestBets;
            }
            if (MyInvocation.BoundParameters.ContainsKey("ProcessPersonalFavorites"))
            {
                keywordQuery.ProcessPersonalFavorites = ProcessPersonalFavorites;
            }
            if (MyInvocation.BoundParameters.ContainsKey("CollapseSpecification"))
            {
                keywordQuery.CollapseSpecification = CollapseSpecification;
            }

            if (SortList != null)
            {
                var sortList = keywordQuery.SortList;
                sortList.Clear();
                foreach (string key in SortList.Keys)
                {
                    SortDirection sort = (SortDirection)Enum.Parse(typeof(SortDirection), SortList[key] as string, true);
                    sortList.Add(key, sort);
                }
            }
            if (SelectProperties != null)
            {
                var selectProperties = keywordQuery.SelectProperties;
                selectProperties.Clear();
                foreach (string property in SelectProperties)
                {
                    selectProperties.Add(property);
                }
            }
            if (RefinementFilters != null)
            {
                var refinementFilters = keywordQuery.RefinementFilters;
                refinementFilters.Clear();
                foreach (string property in RefinementFilters)
                {
                    refinementFilters.Add(property);
                }
            }
            if (Properties != null)
            {
                foreach (string key in Properties.Keys)
                {
                    QueryPropertyValue propVal = new QueryPropertyValue();
                    var value = Properties[key];
                    if (value is string)
                    {
                        propVal.StrVal = (string)value;
                        propVal.QueryPropertyValueTypeIndex = 1;
                    }
                    else if (value is int)
                    {
                        propVal.IntVal = (int)value;
                        propVal.QueryPropertyValueTypeIndex = 2;
                    }
                    else if (value is bool)
                    {
                        propVal.BoolVal = (bool)value;
                        propVal.QueryPropertyValueTypeIndex = 3;
                    }
                    else if (value is string[])
                    {
                        propVal.StrArray = (string[])value;
                        propVal.QueryPropertyValueTypeIndex = 4;
                    }
                    keywordQuery.Properties.SetQueryPropertyValue(key, propVal);
                }
            }
            return(keywordQuery);
        }
Пример #59
0
 public YearComparer(SortDirection direction)
 {
     this.m_direction = direction;
 }
 /// <summary>
 ///
 /// </summary>
 public virtual TBuilder Group(string field, SortDirection direction)
 {
     this.ToComponent().Group(field, direction);
     return(this as TBuilder);
 }