Exemple #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;
 }
Exemple #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;
 }
Exemple #3
0
 /// <summary>
 /// 实时判断会员是不是客服
 /// </summary>
 /// <param name="_id"></param>
 /// <param name="doh"></param>
 /// <param name="_servicename"></param>
 /// <returns></returns>
 public bool Service(string _id, DbOperHandler doh, ref string _servicename)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         _doh.Reset();
         _doh.SqlCmd = "SELECT [ServiceName] FROM [jcms_normal_user] WHERE [ServiceId]>0 AND [Id]=" + _id;
         DataTable dt = _doh.GetDataTable();
         //_doh.Dispose();
         if (dt.Rows.Count > 0)
         {
             _servicename = dt.Rows[0]["ServiceName"].ToString();
             return true;
         }
         else
             return false;
     }
 }
Exemple #4
0
 /// <summary>
 /// 插入GUID
 /// </summary>
 /// <param name="_id"></param>
 public string InsertGUID(string _id, DbOperHandler doh)
 {
     using (DbOperHandler _doh = new Common().Doh())
     {
         string _guid = "";
         _doh.Reset();
         _doh.SqlCmd = "SELECT [GUID] FROM [jcms_normal_user] WHERE [Id]=" + _id;
         DataTable dt = _doh.GetDataTable();
         if (dt.Rows.Count > 0)
         {
             _guid = dt.Rows[0][0].ToString();
         }
         if (_guid.Length != 36)
         {
             _guid = Guid.NewGuid().ToString();
             _doh.ConditionExpress = "id=" + _id;
             _doh.AddFieldItem("guid", _guid);
             _doh.Update("jcms_normal_user");
         }
         return _guid;
     }
 }
Exemple #5
0
 /// <summary>
 /// 连接到一个Access数据库。
 /// </summary>
 /// <param name="dataBase">数据库名称。</param>
 public void ConnectDb(string dataBase)
 {
     System.Data.OleDb.OleDbConnection oleConn = new System.Data.OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" + this.Server.MapPath(dataBase));
     doh = new JumboTCMS.DBUtility.OleDbOperHandler(oleConn);
 }
Exemple #6
0
 /// <summary>
 /// 连接Sql Server数据库。
 /// </summary>
 /// <param name="serverName">服务器地址。</param>
 /// <param name="userName">用户名。</param>
 /// <param name="password">密码。</param>
 /// <param name="dataBaseName">数据库名称。</param>
 public void ConnectDb(string serverName, string userName, string password, string dataBaseName)
 {
     System.Data.SqlClient.SqlConnection sqlConn = new System.Data.SqlClient.SqlConnection("server='" + serverName + "';uid=" + userName + ";pwd=" + password + ";database=" + dataBaseName);
     doh = new JumboTCMS.DBUtility.SqlDbOperHandler(sqlConn);
 }