Ejemplo n.º 1
0
        private static void CreatSchoolModle(string schoolType, string[] strContents, string villageID, string cityIDByArea, Village village)
        {
            //解析txt所得到学校信息处理
            string[] schoolNames = UtilsHelper.GetSchoolsInfo(strContents[1]);

            int j = AcessDBUser.Instance.ReadMaxShcoolID(villageID);

            foreach (string schoolName in schoolNames)
            {
                try
                {
                    //删除特殊符号
                    string dealSchoolName = UtilsHelper.HandleSpecialSymbol(schoolName).Trim();

                    if (string.IsNullOrEmpty(dealSchoolName)) continue;
                    j++;
                    string shcoolID = string.Format("{0}{1}", villageID, j.ToString().PadLeft(3, '0'));   // 如 : 安徽蚌埠美佛儿国际学校 340305012

                    School school = new School(shcoolID, villageID, cityIDByArea, dealSchoolName, schoolType, string.Empty);

                    //直接插入插入,因为判断的话太耗时了
                    village.Schools.Add(school);
                }
                catch (System.Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                   throw ex;
                }
            }
        }
Ejemplo n.º 2
0
        private static void CreateVillageModle(string strProvinceData, string schoolType, bool isMuitCity, string[] strContents, string[] areaList, out string cityNameByArea, out string cityIDByArea, out Village village)
        {
            //解析txt所得到区域级别处理
            string villageName = areaList[areaList.Length - 1].Split('>')[1].Replace(" ", string.Empty);    // 荔湾区
            string villageID = UtilsHelper.GetAreaID(strContents[0]);  //解析txt所得到的ID 如 : 东城区 110101

            //解析txt所得到市级信息处理,用于匹配
            cityNameByArea = areaList[1];
            cityIDByArea = UtilsHelper.GetCityID(strProvinceData, cityNameByArea);   //取出来三级目录中的市名称,再匹配二级目录的id就是市级id

            //根据城市的id和区域的名称去数据库中找区域的名称
            if (isMuitCity)
            {
                UtilsHelper.DealMuitCityArea(villageName, ref cityNameByArea, ref cityIDByArea);
            }

            //从数据库中获取villiageid,找不到则插入
            string vID = AcessDBUser.Instance.QureyIDFromVillageDS(villageName, cityIDByArea, isMuitCity);

            if (!string.IsNullOrEmpty(vID))  //找到的话,赋值给areaID
            {
                villageID = vID;
            }
            else //找不到,说明数据库中没有此城市对应的区域
            {
                //那么,将更新数据库区域列表:将此条区域记录加入数据库中
                AcessDBUser.Instance.InsertVillageInfoToDB(villageID, villageName, cityIDByArea);

                AcessDBUser.Instance.ClearVillageDS();
            }

            village = new Village() { VillageID = villageID, VillageName = villageName, DistrictID = cityIDByArea };

            #region 学校信息处理

            CreatSchoolModle(schoolType, strContents, villageID, cityIDByArea, village);
            #endregion
        }