Пример #1
0
        /// <summary>
        /// 获取远程XML
        /// </summary>
        /// <param name="key"></param>
        /// <param name="xmlUrl"></param>
        /// <returns></returns>
        public static DataSet GetUrlXmlByCache(string key, string xmlUrl)
        {
            DataSet ds = CacheCore.Get("GetCacheXml_" + key) as DataSet;

            if (ds == null)
            {
                string       xmlContent = GetHtml(xmlUrl);
                byte[]       bt         = System.Text.Encoding.UTF8.GetBytes(xmlContent);
                MemoryStream ms         = new MemoryStream(bt);
                ds = CacheCore.GetCacheXML(ms, key);
            }
            return(ds);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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);
        }