Ejemplo n.º 1
0
        /// <summary>
        /// 缓存本地txt文件
        /// </summary>
        /// <param name="keyName"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string GetCacheStrByTxt(string keyName, string fileName)
        {
            string chcheKey = "GetCacheStr_" + keyName;
            string result   = CacheCore.Get(chcheKey) as String;

            if (!string.IsNullOrEmpty(result))
            {
                return(result);
            }
            string content = FileCore.ReadTextFileString(fileName);

            CacheCore.Add(chcheKey, content);
            return(content);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 缓存网络字符串
        /// </summary>
        /// <param name="keyName"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string GetCacheStrByUrl(string keyName, string url)
        {
            string chcheKey = "GetCacheStr_" + keyName;
            string result   = CacheCore.Get(chcheKey) as String;

            if (!string.IsNullOrEmpty(result))
            {
                return(result);
            }
            string content = GetHtml(url);

            CacheCore.Add(chcheKey, content);
            return(content);
        }
Ejemplo n.º 3
0
        public static DataSet GetCacheXML(string fileName, string keyName)
        {
            string  key = "GetCacheXml_" + keyName;
            DataSet ds  = CacheCore.Get(key) as DataSet;

            if (ds != null && ds.Tables.Count > 0)
            {
                return(ds);
            }
            ds = new DataSet();
            ds.ReadXml(fileName);
            CacheCore.Add(key, ds);
            return(ds);
        }
Ejemplo n.º 4
0
        public static DataTable GetCacheTable(string tableName, string connStr)
        {
            string key = "GetCacheTable_" + tableName;

            DataTable dt = CacheCore.Get(key) as DataTable;

            if (dt != null)
            {
                return(dt);
            }

            string sql = "select * from [" + tableName + "]";

            dt = SQLCore.ExecuteDatatable(connStr, CommandType.Text, sql, null);

            if (dt == null || dt.Rows.Count == 0)
            {
                return(null);
            }

            CacheCore.Add(key, dt);

            return(dt);
        }