private void GoPath(string path, int pageIndex) { var catalogueLogic = new CatalogueLogic(); catalogueLogic.SetPath(path); catalogueLogic.PageNum = pageIndex; var localTagID = ((CityLocalTagEntity)clbStoreTag.SelectedItem).LocalTagID; var cityLocalTagBll = new Maticsoft.BLL.CityLocalTag(); var cityLocalTag = cityLocalTagBll.GetModel(localTagID); if (cityLocalTag != null) { catalogueLogic.CircleId = int.Parse(cityLocalTag.Circleid); } var catalogueList = catalogueLogic.GetStoreInfo(pageIndex); #region GoPathDelegate goPathDelegate = (s, index, cList) => { catalogueListBox.Items.Clear(); if (catalogueList != null) { catalogueListBox.Items.AddRange(catalogueList.ToArray()); } for (int i = 0; i < catalogueListBox.Items.Count; i++) { catalogueListBox.SetItemChecked(i, ((Maticsoft.Model.Catalogue)catalogueListBox.Items[i]).IsRead); } labPage.Text = catalogueLogic.PageNum.ToString(CultureInfo.InvariantCulture); btnNextPage.Enabled = catalogueLogic.IflastPage == 0; }; #endregion this.Invoke(goPathDelegate, path, pageIndex, catalogueList); }
private void GoPath(string path, int pageIndex) { try { var catalogueLogic = new CollectionLogic.CatalogueLogic(cbbSiteType.SelectedItem.ToString()); catalogueLogic.SetPath(path); catalogueLogic.PageNum = pageIndex; var localTagID = ((CityLocalTagEntity)clbStoreTag.SelectedItem).LocalTagID; var cityLocalTagBll = new Maticsoft.BLL.CityLocalTag(); var cityLocalTag = cityLocalTagBll.GetModel(localTagID); if (cityLocalTag != null) { catalogueLogic.CircleId = int.Parse(cityLocalTag.Circleid); } var catalogueList = catalogueLogic.GetStoreInfo(pageIndex); #region GoPathDelegate goPathDelegate = (nextPage, beforePage, pageNum, cList) => { catalogueListBox.Items.Clear(); if (catalogueList != null) { catalogueListBox.Items.AddRange(cList.ToArray()); } for (int i = 0; i < catalogueListBox.Items.Count; i++) { catalogueListBox.SetItemChecked(i, ((Maticsoft.Model.Catalogue)catalogueListBox.Items[i]).IsRead); } labPage.Text = pageNum.ToString(CultureInfo.InvariantCulture); btnNextPage.Enabled = !string.IsNullOrEmpty(nextPage); btnNextPage.Tag = nextPage; if (pageIndex > 1) { btnBeforePage.Enabled = !string.IsNullOrEmpty(beforePage); btnBeforePage.Tag = beforePage; } else { btnBeforePage.Enabled = false; btnBeforePage.Tag = string.Empty; } }; #endregion this.Invoke(goPathDelegate, catalogueLogic.NextPage, catalogueLogic.BeforePage, catalogueLogic.PageNum, catalogueList); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
private void button1_Click_1(object sender, EventArgs e) { //http://www.fanqie.com/restaurant/circle var pageUrl = @"http://www.fanqie.com/restaurant/circle"; var cityID = ((Maticsoft.Model.City)cbBoxCity.SelectedItem).CityID; if (string.IsNullOrWhiteSpace(pageUrl)) { return; } try { var dictionary = new Dictionary<string, string>(); var headDictionary = new Dictionary<string, string>(); headDictionary.Add("city", "1"); var jsonStr = PostHttpResponse.PostData(pageUrl, dictionary, headDictionary); if (jsonStr == null) { return; } var anonymous = JsonHelper.JsonToObj<Anonymous>(jsonStr); var districtBll = new District(); var cityLocalTagBll = new CityLocalTagBll(); var districtTableBll = new DistrictTable(); var cityLocalTagSampleBll = new CityLocalTag(); var districtList = new List<Maticsoft.Model.District>(); var districtOldList = districtBll.GetModelList(string.Format("cityID = '{0}'", cityID)) ?? new List<Maticsoft.Model.District>(); var cityLocalTagList = cityLocalTagBll.GetModelList(string.Format("CityID='{0}'", cityID)) ?? new List<CityLocalTagEntity>(); var districtTableList = districtTableBll.GetModelList(string.Format("CityID='{0}'", cityID)) ?? new List<Maticsoft.Model.DistrictTable>(); var cityLocalTagSampleList = cityLocalTagSampleBll.GetModelList(string.Format("CityID='{0}'", cityID)) ?? new List<Maticsoft.Model.CityLocalTag>(); foreach (var areaInfo in anonymous.Arealist) { var olddistrict = districtOldList.Find(x => x.DistrictName.Trim() == areaInfo.AreaName.Trim()); if (olddistrict == null) { olddistrict = new Maticsoft.Model.District { DistrictID = Guid.NewGuid().ToString(), DistrictName = areaInfo.AreaName, CityID = cityID }; districtBll.Add(olddistrict); } var districtTable = districtTableList.Find(x => x.DistrictName.Trim() == areaInfo.AreaName.Trim()); if (districtTable == null) { districtTable = new Maticsoft.Model.DistrictTable(); districtTable.CityID = cityID; districtTable.DistrictID = olddistrict.DistrictID; districtTable.SiteID = areaInfo.AreaId; districtTable.DistrictName = areaInfo.AreaName; districtTableBll.Add(districtTable); } districtList.Add(olddistrict); foreach (var circle in areaInfo.CircleList) { var cityLocalTag = cityLocalTagList.Find(x => x.TagName.Trim() == circle.CircleName.Trim()); if (cityLocalTag == null) { cityLocalTag = new CityLocalTagEntity { LocalTagID = Guid.NewGuid().ToString(), TagName = circle.CircleName, DistrictID = olddistrict.DistrictID, CityID = cityID, TagGrade = 10 }; cityLocalTagBll.Add(cityLocalTag); } var cityLocalTagSample = cityLocalTagSampleList.Find(x => x.TagName.Trim() == circle.CircleName.Trim()); if (cityLocalTagSample == null) { cityLocalTagSample = new Maticsoft.Model.CityLocalTag(); cityLocalTagSample.Circleid = circle.Circleid; cityLocalTagSample.TagName = circle.CircleName; cityLocalTagSample.CityID = cityID; cityLocalTagSample.LocalTagID = cityLocalTag.LocalTagID; cityLocalTagSampleBll.Add(cityLocalTagSample); } } } MessageBox.Show("OK"); } catch { } }