Esempio n. 1
0
 /// <summary>
 /// IP转CityCode
 /// </summary>
 /// <param name="IP"></param>
 /// <returns></returns>
 public string IP2CityCode(string IP, DbOperHandler _doh)
 {
     string _defaultcode = "101010100";//默认北京市
     string citycode = "";
     string areaname = (JumboTCMS.Utils.IPSearchHelp.SearchIndex.GetIPLocation(IP).Split(' ')[0]).Trim();
     JumboTCMS.Utils.IPSearchHelp.Location location = new JumboTCMS.Utils.IPSearchHelp.Location(areaname);
     if (location.AreaType < 4)
     {
         if (location.AreaType == 0 || location.AreaType == 2)
         {
             _doh.Reset();
             _doh.ConditionExpress = "cityname='" + location.Captical + "' and len(cityid)=2";
             string capticalid = _doh.GetField("weather_city", "cityid").ToString();
             _doh.Reset();
             _doh.ConditionExpress = "left(cityid,2)='" + capticalid + "' AND [CityName]='" + location.City + "' and len(cityid)=6";
             citycode = _doh.GetField("weather_city", "citycode").ToString();
             if (citycode == "")
             {
                 _doh.Reset();
                 _doh.ConditionExpress = "cityname='" + location.Captical + "' and len(cityid)=6";
                 citycode = _doh.GetField("weather_city", "citycode").ToString();
                 if (citycode == "")
                     return _defaultcode;
             }
         }
         else
         {
             _doh.Reset();
             _doh.ConditionExpress = "cityname='" + location.Captical + "' and len(cityid)=6";
             citycode = _doh.GetField("weather_city", "citycode").ToString();
         }
     }
     if (citycode.Length < 9)
         return _defaultcode;//默认北京市
     return citycode;
 }
Esempio n. 2
0
 private JumboTCMS.Entity.Normal_ClassTree getTree(DbOperHandler _doh, string _channelid, string _classid, bool _includechild)
 {
     JumboTCMS.Entity.Normal_ClassTree _tree = new JumboTCMS.Entity.Normal_ClassTree();
     JumboTCMS.Entity.Normal_Channel _channel = new JumboTCMS.DAL.Normal_ChannelDAL().GetEntity(_channelid);
     bool _channelishtml = site.IsHtml && _channel.IsHtml;
     if (_classid == "0")//表示从根节点开始
     {
         _tree.Id = _channel.Id;
         _tree.Name = _channel.Title;
         _tree.Link = Go2Channel(site.IsHtml, _channelid, false);
         _tree.RssUrl = "";
     }
     else
     {
         JumboTCMS.Entity.Normal_Class _class = new JumboTCMS.DAL.Normal_ClassDAL().GetEntity(_classid);
         _tree.Id = _classid;
         _tree.Name = _class.Title;
         _tree.Link = Go2Class(1, _channelishtml, _channelid, _classid, false);
         _tree.RssUrl = Go2Rss(1, false, _channelid, _classid);
     }
     _tree.HasChild = HasChild(_channelid, _classid);
     List<JumboTCMS.Entity.Normal_ClassTree> subtree = new List<JumboTCMS.Entity.Normal_ClassTree>();
     if (_includechild)
     {
         _doh.Reset();
         _doh.SqlCmd = "SELECT Id FROM [jcms_normal_class] WHERE [ChannelId]=" + _channelid + " AND [ParentId]=" + _classid + " order by code";
         DataTable dtClass = _doh.GetDataTable();
         for (int i = 0; i < dtClass.Rows.Count; i++)
         {
             string _subclassid = dtClass.Rows[i]["Id"].ToString();
             subtree.Add(getTree(_doh, _channelid, _subclassid, _includechild));
         }
         dtClass.Clear();
         dtClass.Dispose();
     }
     _tree.SubChild = subtree;
     return _tree;
 }