Exemplo n.º 1
0
        /// <summary>
        /// 详情页面
        /// </summary>
        public QgglModel QGXiangQing(string userId)
        {
            QgglModel model        = new QgglModel();
            string    url          = $"https://www.biomart.cn/japi/agency/enquiry/{userId}?_csrf=4c546c75-02af-4342-a3e4-4c7e4375fd9e&action=GetDetail&id={userId}";
            var       httpResponse = Util.WebRequestConstruct(url);

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                Console.WriteLine(result);
                if (!string.IsNullOrEmpty(result))
                {
                    var dynamicObject = JsonConvert.DeserializeObject <dynamic>(result);
                    if ((bool)dynamicObject.success)
                    {
                        model.phone     = dynamicObject.results.phone != null ? dynamicObject.results.phone : "";
                        model.email     = dynamicObject.results.email != null ? dynamicObject.results.email : "";
                        model.searchLog = dynamicObject.results.searchLog != null?dynamicObject.results.searchLog.ToString().TrimEnd(']').TrimStart('[') : "";

                        model.productLog = dynamicObject.results.productLog != null?dynamicObject.results.productLog.ToString().TrimEnd(']').TrimStart('[') : "";

                        model.fullAddress = dynamicObject.results.fullAddress != null ? dynamicObject.results.fullAddress : "";
                        return(model);
                    }
                    else
                    {
                        return(model);
                    }
                }
                else
                {
                    //  MessageBox.Show("没有获取到数据");
                    return(model);
                }
            }
        }
Exemplo n.º 2
0
        public void GetQGGL()
        {
            button1.Enabled = false;

            for (int i = 1; i <= pageCount; i++)
            {
                string url = $"https://www.biomart.cn/i/opt.do?_csrf=4c546c75-02af-4342-a3e4-4c7e4375fd9e&page_index={i}&items_per_page=20&cate=0&action=List&sortBy=&order=";

                var httpResponse = Util.WebRequestConstruct(url);
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                    Console.WriteLine(result);
                    if (!string.IsNullOrEmpty(result))
                    {
                        var dynamicObject = JsonConvert.DeserializeObject <dynamic>(result);
                        if (dynamicObject != null)
                        {
                            if (totalCount == 1 && pageCount == 1)
                            {
                                totalCount = dynamicObject.data.total_items;
                                pageSize   = dynamicObject.data.items_per_page;
                                pageCount  = dynamicObject.data.total_pages;

                                this.ztBand(pageCount, totalCount);
                            }
                            var datas = dynamicObject.data.items;



                            foreach (var item in datas)
                            {
                                tempCount += 1;
                                //GridViewBind(this.dataGridView1);

                                //Task task = new Task(() =>
                                //{

                                string uid = GXXingQingUserId((String)item.demand_id);


                                QgglModel qgglModel = new QgglModel();
                                if (!string.IsNullOrEmpty(uid))
                                {
                                    qgglModel = QGXiangQing(uid);
                                }

                                qgglModel.cate         = item.cate;
                                qgglModel.city         = item.city;
                                qgglModel.name         = item.name;
                                qgglModel.id           = item.id;
                                qgglModel.release_time = item.release_time;


                                qgglModels.Add(qgglModel);
                                //});

                                //数据写入
                                //if (this.InvokeRequired)
                                //{
                                //    this.Invoke(new DelegateGridViewDataListBand(dataGirdViewListBind), new object[] { (String)item.id, (String)item.projuctName, (String)item.contactName, (String)item.creator, (String)item.modifyTime });
                                //}
                                //else
                                //{
                                //    dataGirdViewListBind((String)item.id, (String)item.projuctName, (String)item.contactName, (String)item.creator, (String)item.modifyTime);
                                //}
                            }
                            //  ViewDataBind(datas);
                        }
                        else
                        {
                            MessageBox.Show(dynamicObject.success);
                        }
                    }
                    else
                    {
                        MessageBox.Show("没有获取到数据");
                    }
                }

                thisPageCount++;
            }

            button1.Enabled = true;
        }