public GreatWallForm()
        {
            InitializeComponent();

            var provinces = new Maticsoft.BLL.Provinces();
            var provincesList = provinces.GetModelList(string.Empty);
            cbBoxProvinces.DataSource = provincesList;
            cbBoxProvinces.ValueMember = "ProvincesName";
            var provincesInfo = provincesList.FirstOrDefault();
            var cityBll = new Maticsoft.BLL.City();
            var cityList = cityBll.GetModelList(string.Empty);
            cityList = cityList.FindAll(x => provincesInfo != null && x.ProvincesID == provincesInfo.ProvincesID);
            cbBoxCity.DataSource = cityList;
            cbBoxCity.DisplayMember = "CityName";
            var cityInfo = cityList.FirstOrDefault();
            var districtBll = new Maticsoft.BLL.District();
            var districtList = districtBll.GetModelList(String.Empty);
            cbbDistrict.DataSource = districtList.FindAll(x => cityInfo != null && x.CityID == cityInfo.CityID);
            cbbDistrict.DisplayMember = "DistrictName";

            var specialTagBll = new Maticsoft.BLL.SpecialTag();
            chlBoxSpecialTag.DataSource = specialTagBll.GetModelList(string.Empty);
            chlBoxSpecialTag.DisplayMember = "TagName";

            var cookingStylesBll = new Maticsoft.BLL.CookingStyles();
            chbCookingStyles.DataSource =
                cookingStylesBll.GetModelList(String.Empty).OrderBy(x => x.CookingStyleName).ToList();
            chbCookingStyles.DisplayMember = "CookingStyleName";

            var cityLocalTagBll = new Maticsoft.BLL.CityLocalTagBll();
            clbStoreTag.DataSource = cityLocalTagBll.GetModelList(string.Empty).OrderBy(x => x.TagName).ToList();
            clbStoreTag.DisplayMember = "TagName";
        }
        //private OpenFileDialog file = new OpenFileDialog();
        public AnalysisForm()
        {
            InitializeComponent();

            var provinces = new Maticsoft.BLL.Provinces();
            var provincesList = provinces.GetModelList(string.Empty);
            cbBoxProvinces.DataSource = provincesList;
            cbBoxProvinces.ValueMember = "ProvincesName";

            var cityBll = new Maticsoft.BLL.City();
            var cityList = cityBll.GetModelList(string.Empty);
            cbBoxCity.DataSource = cityList;
            cbBoxCity.DisplayMember = "CityName";

            var districtBll = new Maticsoft.BLL.District();
            var districtList = districtBll.GetModelList(String.Empty);
            cbbDistrict.DataSource = districtList;
            cbbDistrict.DisplayMember = "DistrictName";

            var specialTagBll = new Maticsoft.BLL.SpecialTag();
            chlBoxSpecialTag.DataSource = specialTagBll.GetModelList(string.Empty);
            chlBoxSpecialTag.DisplayMember = "TagName";

            var cookingStylesBll = new Maticsoft.BLL.CookingStyles();
            chbCookingStyles.DataSource =
                cookingStylesBll.GetModelList(String.Empty).OrderBy(x => x.CookingStyleName).ToList();
            chbCookingStyles.DisplayMember = "CookingStyleName";

            var cityLocalTagBll = new Maticsoft.BLL.CityLocalTagBll();
            clbStoreTag.DataSource = cityLocalTagBll.GetModelList(string.Empty).OrderBy(x => x.TagName).ToList();
            clbStoreTag.DisplayMember = "TagName";

            btnNextPage.Enabled = false;
            btnBeforePage.Enabled = false;
        }
 private void InitializeCheckBox()
 {
     var provinces = new Maticsoft.BLL.Provinces();
     var provincesList = provinces.GetModelList(string.Empty);
     cbBoxProvinces.DataSource = provincesList;
     cbBoxProvinces.ValueMember = "ProvincesName";
     var provincesInfo = provincesList.FirstOrDefault();
     var cityBll = new Maticsoft.BLL.City();
     var cityList = cityBll.GetModelList(string.Empty);
     cityList = cityList.FindAll(x => provincesInfo != null && x.ProvincesID == provincesInfo.ProvincesID);
     cbBoxCity.DataSource = cityList;
     cbBoxCity.DisplayMember = "CityName";
     var cityInfo = cityList.FirstOrDefault();
     var districtBll = new Maticsoft.BLL.District();
     var districtList = districtBll.GetModelList(String.Empty);
     cbbDistrict.DataSource = districtList.FindAll(x => cityInfo != null && x.CityID == cityInfo.CityID);
     cbbDistrict.DisplayMember = "DistrictName";
 }
        private void cbBoxCity_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                var cityList = cbBoxCity.DataSource as List<Maticsoft.Model.City>;
                if (cityList == null)
                {
                    return;
                }
                var cityInfo = cityList[cbBoxCity.SelectedIndex];

                var districtBll = new Maticsoft.BLL.District();
                var districtList = districtBll.GetModelList(String.Empty);
                cbbDistrict.DataSource = districtList.FindAll(x => x.CityID == cityInfo.CityID);

                cbbDistrict.DisplayMember = "DistrictName";
                cbbDistrict.ValueMember = "DistrictID";

                var cookingStylesBll = new Maticsoft.BLL.CookingStyles();
                chbCookingStyles.DataSource =
                    cookingStylesBll.GetModelList(string.Empty)
                        .OrderBy(x => x.CookingStyleName)
                        .ToList();
                chbCookingStyles.DisplayMember = "CookingStyleName";

                var cityLocalTagBll = new Maticsoft.BLL.CityLocalTagBll();
                clbStoreTag.DataSource =
                    cityLocalTagBll.GetModelList(string.Format("CityID = '{0}'", cityInfo.CityID))
                        .OrderBy(x => x.TagName)
                        .ToList();
                clbStoreTag.DisplayMember = "TagName";
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var pageUrl = textBox1.Text;
            var cityID = ((Maticsoft.Model.City)cbBoxCity.SelectedItem).CityID;
            if (string.IsNullOrWhiteSpace(pageUrl))
            {
                return;
            }
            var htmlWeb = new HtmlWeb();
            var htmlDoc = htmlWeb.Load(pageUrl);
            var nodeDetail =
                htmlDoc.DocumentNode.SelectSingleNode(
                    ".//div[@class='constr']/div[@class='constr_in']/div[@class='constr_bg mt10']/div[@class='pt30 pl30 pr30 pb28 lh22']");
            if (nodeDetail == null)
            {
                return;
            }

            var nodeNext = nodeDetail.SelectSingleNode("/div[@class='region']").NextSibling;
            var nodeList = nodeNext.SelectNodes(@".//a[class='g3']");

            var districtBll = new District();
            var districtList = new List<Maticsoft.Model.District>();
            foreach (var nodeInfo in nodeList)
            {
                var district = new Maticsoft.Model.District();
                district.DistrictID = Guid.NewGuid().ToString();
                district.DistrictName = nodeInfo.InnerText;
                district.CityID = cityID;
                districtBll.Add(district);
                districtList.Add(district);
            }
            var node = nodeDetail.SelectSingleNode("./div[@class='group']");
            while (true)
            {
                nodeNext = node.NextSibling;
                if (!string.IsNullOrEmpty(nodeNext.Id))
                {
                    break;
                }
                var nodeDistrict = nodeNext.SelectSingleNode("./strong[@class='w100 l']").InnerText;
                var district = districtList.Find(x => x.DistrictName == nodeDistrict);
                nodeList = nodeNext.SelectNodes(@".//a[class='g3']");

                var cityLocalTagBll = new CityLocalTagBll();
                foreach (var nodeInfo in nodeList)
                {
                    var cityLocalTagEntity = new Maticsoft.Model.CityLocalTagEntity();
                    cityLocalTagEntity.LocalTagID = Guid.NewGuid().ToString();
                    cityLocalTagEntity.TagName = nodeInfo.InnerText;
                    cityLocalTagEntity.DistrictID = district.DistrictID;
                    cityLocalTagEntity.CityID = cityID;
                    cityLocalTagEntity.TagGrade = 20;
                    cityLocalTagBll.Add(cityLocalTagEntity);
                }
            }

            node = nodeDetail.SelectSingleNode("./div[@class='position']");
            while (true)
            {
                nodeNext = node.NextSibling;
                if (!string.IsNullOrEmpty(nodeNext.Id))
                {
                    break;
                }
                var nodeDistrict = nodeNext.SelectSingleNode("./strong[@class='w100 l']").InnerText;
                var district = districtList.Find(x => x.DistrictName == nodeDistrict);
                nodeList = nodeNext.SelectNodes(@".//a[class='g3']");

                var cityLocalTagBll = new CityLocalTagBll();
                foreach (var nodeInfo in nodeList)
                {
                    var cityLocalTagEntity = new Maticsoft.Model.CityLocalTagEntity
                    {
                        LocalTagID = Guid.NewGuid().ToString(),
                        TagName = nodeInfo.InnerText,
                        DistrictID = district.DistrictID,
                        CityID = cityID,
                        TagGrade = 10
                    };
                    cityLocalTagBll.Add(cityLocalTagEntity);
                }
            }
        }
        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
            {
            }
        }