Exemplo n.º 1
0
    protected override void OnInit(EventArgs e)
    {
		if (!this.BXUser.IsCanOperate(BXRoleOperation.Operations.UpdateSystem))
			BXAuthentication.AuthenticationRequired();

        base.OnInit(e);
        MasterTitle = "Marketplace";
		try
		{
			query = new BXMarketplaceQuery
			{
				ModuleId = "-"
			}
			.Execute();
		}
		catch(Exception ex)
		{
			ErrorMessage.AddErrorText(ex.Message);
			query = new BXMarketplaceQueryResult();
		}

		CategoryFilter.Values.Clear();
		CategoryFilter.Values.Add(new ListItem(GetMessageRaw("Kernel.All"), ""));
		CategoryFilter.Values.AddRange(query.Categories.ConvertAll(x => new ListItem(x.Title, x.Id.ToString())).ToArray());

		TypeFilter.Values.Clear();
		TypeFilter.Values.Add(new ListItem(GetMessageRaw("Kernel.All"), ""));
		TypeFilter.Values.AddRange(query.Types.ConvertAll(x => new ListItem(x.Title, x.Id.ToString())).ToArray());

		
    }
Exemplo n.º 2
0
	protected void GridView_Select(object sender, BXSelectEventArgs e)
	{
		var query = BuildQuery();

		Match m;
		if ((m = Regex.Match(e.SortExpression ?? "", @"^(\w+)(?:\s+(ASC|DESC))?$", RegexOptions.IgnoreCase)).Success)
		{
			try
			{
				query.OrderBy = (BXMarketplaceQueryOrderBy)Enum.Parse(typeof(BXMarketplaceQueryOrderBy), m.Groups[1].Value, true);
				query.OrderByAsc = !string.Equals(m.Groups[2].Value, "DESC", StringComparison.OrdinalIgnoreCase);
			}
			catch
			{

			}
		}
		
		BXMarketplaceQueryResult r;
		try
		{
			r = query.Execute();
		}
		catch(Exception ex)
		{
			ErrorMessage.AddErrorText(ex.Message);
			r = new BXMarketplaceQueryResult();
		}

		var q = r.Modules.Skip(e.PagingOptions.startRowIndex);
		if (e.PagingOptions.maximumRows > 0)
			q = q.Take(e.PagingOptions.maximumRows);
		e.Data = q.ToList();
	}