コード例 #1
0
        /// <summary>
        /// read json file to list
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public List <BarNameEntity> getJsonContent(string filepath)
        {
            List <BarNameEntity> listkeyWorldEntity = new List <BarNameEntity>();

            try
            {
                if (string.IsNullOrEmpty(filepath))
                {
                    return(null);
                }
                IOFileHelper   iOFileHelper   = new IOFileHelper();
                var            strContext     = iOFileHelper.ReadTxtFile(filepath);
                var            byteData       = strContext.Split('-');
                UrlCodeConvert urlCodeConvert = new UrlCodeConvert();
                foreach (var item in byteData)
                {
                    BarNameEntity barNameEntity = new BarNameEntity();
                    barNameEntity.BarName = item.Trim();
                    barNameEntity.Url     = urlCodeConvert.EncodeUrl(item.Trim());
                    listkeyWorldEntity.Add(barNameEntity);
                }
                return(listkeyWorldEntity);
            }
            catch
            {
                Debug.WriteLine("KeyWorldService");
            }
            return(listkeyWorldEntity);
        }
コード例 #2
0
        /// java服务端编写 不安全方法 Visiable修改好
        /// <summary>
        /// 给mysql查询贴吧名称列表
        /// </summary>
        /// <param name="brNameEntity"></param>
        /// <returns></returns>
        public List <BarNameEntity> SelectTBName(string token = null)
        {
            ISQLConnection       iSQLConnection    = new MySqlConn();
            var                  sqlconn           = iSQLConnection.GetMysqlConn();
            List <BarNameEntity> listBarNameEntity = new List <BarNameEntity>();

            try
            {
                string       sql = @"SELECT BarName,Url,Type,Hot FROM homefood.bd_bar_name WHERE  Visiable=1";
                MySqlCommand cmd = new MySqlCommand(sql, sqlconn);
                sqlconn.Open();
                MySqlDataReader DataReader = cmd.ExecuteReader();
                DataTable       dataTable  = new DataTable();
                dataTable.Load(DataReader);
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    BarNameEntity barNameEntity = new BarNameEntity();
                    barNameEntity.BarName = Convert.ToString(dataRow["BarName"]);
                    barNameEntity.Url     = Convert.ToString(dataRow["Url"]);
                    barNameEntity.Type    = Convert.ToString(dataRow["Type"]);
                    barNameEntity.Hot     = Convert.ToInt32(dataRow["Hot"]);
                    listBarNameEntity.Add(barNameEntity);
                }
                return(listBarNameEntity);
            }
            catch (Exception e)
            {
                Debug.WriteLine("-------TBKeywordDAL error--------" + e);
            }
            return(listBarNameEntity);
        }