C#.net json到数据网格视图过滤器

时间:2016-12-24 00:41:02

标签: c# json filter

我有一个程序将json带到列表并将列表加载到2数据网格视图 我需要过滤视图,尝试在数据源上执行此操作,这是代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using Newtonsoft.Json;


 namespace WindowsFormsApplication1
 {

/// <summary>
/// 
/// </summary>
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    /// <summary>
    /// Set the Auto complete on combobox
    /// load data table for items 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void Form1_Load(object sender, EventArgs e)
    {
        // TODO: This line of code loads data into the 'typeidDataSet.Sheet1' table. You can move, or remove it, as needed.
        // https://esi.tech.ccp.is/dev/markets/10000069/orders/?type_id=34&order_type=all&page=1&datasource=tranquility
        this.sheet1TableAdapter.Fill(this.typeidDataSet.Sheet1);


        comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;
        comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
        comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;


    }
    /// <summary>
    /// Gets system ID base on system pick in combobox
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            label1.Text = comboBox1.SelectedValue.ToString();
        }
        catch
        {

        }
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void button1_Click(object sender, EventArgs e)
    {
        var cheklist = checkedListBox1.CheckedItems;
        var result = new System.Collections.Generic.List<JsonResult>();
        foreach (var sys in cheklist)
        {
            /// <summary>
            /// The next few lines of code help build the URL for the region that have been pick giveing the var pick the system id the are 64 regions 
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            string identifierName = sys.ToString();


            dictionary["Aridia"] = "10000054";
            dictionary["Black Rise"] = "10000069";
            dictionary["Branch"] = "10000055";
            dictionary["Cache"] = "10000007";
            dictionary["Catch"] = "10000014";
            dictionary["Cloud Ring"] = "10000051";
            dictionary["Cobalt Edge"] = "10000053";
            dictionary["Curse"] = "10000012";
            dictionary["Deklein"] = "10000035";
            dictionary["Delve"] = "10000060";
            dictionary["Derelik"] = "10000001";
            dictionary["Detorid"] = "10000005";
            dictionary["Devoid"] = "10000036";
            dictionary["Domain"] = "10000043";
            dictionary["Esoteria"] = "10000039";
            dictionary["Essence"] = "10000064";
            dictionary["Etherium Reach"] = "10000027";
            dictionary["Everyshore"] = "10000037";
            dictionary["Fade"] = "10000046";
            dictionary["Feythabolis"] = "10000056";
            dictionary["Fountain"] = "10000058";
            dictionary["Geminate"] = "10000029";
            dictionary["Genesis"] = "10000067";
            dictionary["Great Wildlands"] = "10000011";
            dictionary["Heimatar"] = "10000030";
            dictionary["Immensea"] = "10000025";
            dictionary["Impass"] = "10000031";
            dictionary["Insmother"] = "10000009";
            dictionary["Kador"] = "10000052";
            dictionary["Khanid"] = "10000049";
            dictionary["Kor-Azor"] = "10000065";
            dictionary["Lonetrek"] = "10000016";
            dictionary["Malpais"] = "10000013";
            dictionary["Metropolis"] = "10000042";
            dictionary["Molden Heath"] = "10000028";
            dictionary["Oasa"] = "10000040";
            dictionary["Omist"] = "10000062";
            dictionary["Outer Passage"] = "10000021";
            dictionary["Outer Ring"] = "10000057";
            dictionary["Paragon Soul"] = "10000059";
            dictionary["Period Basis"] = "10000063";
            dictionary["Perrigen Falls"] = "10000066";
            dictionary["Placid"] = "10000048";
            dictionary["Providence"] = "10000047";
            dictionary["Pure Blind"] = "10000023";
            dictionary["Querious"] = "10000050";
            dictionary["Scalding Pass"] = "10000008";
            dictionary["Sinq Laison"] = "10000032";
            dictionary["Solitude"] = "10000044";
            dictionary["Stain"] = "10000022";
            dictionary["Syndicate"] = "10000041";
            dictionary["Tash-Murkon"] = "10000020";
            dictionary["Tenal"] = "10000045";
            dictionary["Tenerifis"] = "10000061";
            dictionary["The Bleak Lands"] = "10000038";
            dictionary["The Citadel"] = "10000033";
            dictionary["The Forge"] = "10000002";
            dictionary["The Kalevala Expanse"] = "10000034";
            dictionary["The Spire"] = "10000018";
            dictionary["Tribute"] = "10000010";
            dictionary["Vale of the Silent"] = "10000003";
            dictionary["Venal"] = "10000015";
            dictionary["Verge Vendor"] = "10000068";
            dictionary["Wicked Creek"] = "10000006";
            string pick = dictionary[identifierName];

            WebClient wc = new WebClient();
            using (MemoryStream stream = new MemoryStream(wc.DownloadData("https://esi.tech.ccp.is/dev/markets/" + pick + "/orders/?type_id=" + comboBox1.SelectedValue.ToString() + "&order_type=all&page=1&datasource=tranquility")))
            {
                using (var reader = new StreamReader(stream))
                {
                    string input = reader.ReadToEnd();
                    result.AddRange(JsonConvert.DeserializeObject<List<JsonResult>>(input));

                }
            }
        }
        BindingSource source1 = new BindingSource();
        source1.DataSource = result;
        source1.Filter = "is_buy_order LIKE true";
        dataGridView1.DataSource = source1;



        BindingSource source2 = new BindingSource();
        source2.DataSource = result;
        source2.Filter = "is_buy_order == 'false'";
        dataGridView2.DataSource = source2;

    }




}

public class JsonResult
{
    public Int64 order_id { get; set; }
    public int type_id { get; set; }
    public Int64 location_id { get; set; }
    public int volume_total { get; set; }
    public int volume_remain { get; set; }
    public int min_volume { get; set; }
    public decimal price { get; set; }
    public bool   is_buy_order { get; set; }
    public int duration { get; set; }
    public DateTime issued { get; set; }
    public string range { get; set; }
}

}

过滤器根本没有过滤,我得到了漏洞列表这两个时间我缺少什么?

0 个答案:

没有答案