Ejemplo n.º 1
0
        /// <summary>
        /// 配置文件名称返回tabid
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, Dimention> GetBigTableId(string filename)
        {
            string CacheKey = filename;
            Dictionary <string, Dimention> TABList = new Dictionary <string, Dimention>();
            object objModel = DataCache.GetCache(CacheKey);

            if (objModel == null)
            {
                DataCache.SetCache(CacheKey, TABList, DateTime.Now.AddMinutes(180), TimeSpan.Zero);
                string   filepath = AppDomain.CurrentDomain.BaseDirectory + "xmldb\\";//获取基目录
                FileInfo file     = new FileInfo(filepath + filename + ".config");

                Report tempreport = (Report)XmlSerializHelper.Deserialize <Report>(file.FullName);
                foreach (Dimention dimention in tempreport.TABList)
                {
                    Dimention tempdimention = dimention;
                    TABList.Add(tempdimention.TabId, tempdimention);
                }

                DataCache.SetCache(CacheKey, TABList, DateTime.Now.AddMinutes(180), TimeSpan.Zero);
            }
            else
            {
                TABList = (Dictionary <string, Dimention>)DataCache.GetCache(CacheKey);
            }
            return(TABList);
        }
Ejemplo n.º 2
0
        public static Dictionary <string, Dimention> GetReport()
        {
            string CacheKey = "report";
            Dictionary <string, Dimention> TABList = new Dictionary <string, Dimention>();
            object objModel = DataCache.GetCache(CacheKey);

            if (objModel == null || ((Dictionary <string, Dimention>)objModel).Count == 0)
            {
                DataCache.SetCache(CacheKey, TABList, DateTime.Now.AddMinutes(180), TimeSpan.Zero);
                string        filepath = AppDomain.CurrentDomain.BaseDirectory + "xmldb\\";//获取基目录
                DirectoryInfo di       = new DirectoryInfo(filepath);
                FileInfo[]    files    = di.GetFiles();
                foreach (FileInfo file in files)
                {
                    Report tempreport = (Report)XmlSerializHelper.Deserialize <Report>(file.FullName);
                    foreach (Dimention dimention in tempreport.TABList)
                    {
                        Dimention tempdimention = dimention;
                        TABList.Add(tempdimention.TabId, tempdimention);
                    }
                }
                DataCache.SetCache(CacheKey, TABList, DateTime.Now.AddMinutes(180), TimeSpan.Zero);
            }
            else
            {
                TABList = (Dictionary <string, Dimention>)DataCache.GetCache(CacheKey);
            }
            return(TABList);
        }