当前位置: 首页>>代码示例>>C#>>正文


C# Connection.Query方法代码示例

本文整理汇总了C#中System.Net.Connection.Query方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.Query方法的具体用法?C# Connection.Query怎么用?C# Connection.Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.Connection的用法示例。


在下文中一共展示了Connection.Query方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: fetchInformation

        //Fetches information from 'VNDB.org'
        private int fetchInformation(bool Update)
        {
            //This basically fetches information from vndb using the API
            //First it establishes a connection and logs in
            //using the entered LoginName or a random loginname

            //Then it request basic vn information
            //and deserializes the jsonresponse
            //After that it displays the reponse in
            //the matching textboxes

            //Now it requets detailed information
            //deserializes it again....
            //and stores information in matching controls

            //Now it requests tags
            //deserializes them
            //and stores them in txtTags-Textbox
            //mind you: The tags are all in int format(only ID's)!

            //Now we read our tags-dump
            //deserialize them
            //and change our int tags to the matching string tags

            //That's it.

            Connection conn = new Connection();
            string nice = " ";
            int id = 0, vns_number = 0;
            Random rnd = new Random();

            int error = 0;

            int login_id = rnd.Next(1000);

            conn.Open();

            if (txtLoginName.Text != "")
                error = conn.Login(txtLoginName.Text);
            else
                error = conn.Login(Convert.ToString("asd" + login_id));

            if (error == 1)
            {
                MessageBox.Show("Error while logging in. Response: " + conn.jsonresponse, "Login Error", MessageBoxButtons.OK);
                return 0;
            }

            if (Update == false)
                error = conn.Query("get vn basic (id = " + txtID.Text + " )"); //request basic information
            else
            {
                foreach (Visual_Novel novel in VNS)
                {
                    if (novel.englishName == lbVN.SelectedItem.ToString().Trim())
                    {
                        id = novel.id;
                        error = conn.Query("get vn basic (id = " + id + " )");
                        break;
                    }
                    vns_number++;
                }
            }

            if (error == 1)
            {
                MessageBox.Show("Error while requesting information. Response: " + conn.jsonresponse, "Query Error", MessageBoxButtons.OK);
                return 0;
            }

            BasicRootObject basic_information = Newtonsoft.Json.JsonConvert.DeserializeObject<BasicRootObject>(conn.jsonresponse); //deserialize it
            List<BasicItem> basic_item = basic_information.items;

            if (Update == false)
            {
                txtName.Text = basic_item[0].title;
                txtOriginalName.Text = basic_item[0].original;
                txtVNID.Text = Convert.ToString(basic_item[0].id);
                txtTags.Text = "";
            }
            else
            {
                VNS[vns_number].englishName = basic_item[0].title;
                VNS[vns_number].originalName = basic_item[0].original;
                VNS[vns_number].id = basic_item[0].id;
            }

            if (Update == false)
                error = conn.Query("get vn details (id = " + txtID.Text + " )");
            else
            {
                error = conn.Query("get vn details (id = " + id + " )");
            }

            if (error == 1)
            {
                MessageBox.Show("Error while requesting information. Response: " + conn.jsonresponse, "Query Error", MessageBoxButtons.OK);
                return 0;
            }
//.........这里部分代码省略.........
开发者ID:Onkelsam,项目名称:VN-Database-Program,代码行数:101,代码来源:Form1.cs


注:本文中的System.Net.Connection.Query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。