Example #1
0
 private static void LoadAccountBlock()
 {
     try
     {
         string key = "ACCOUNTBLOCK_FILE";
         if (BicCache.ReadCache(key) == null)
         {
             XDocument xmldoc         = XDocument.Load(ACCOUNTBLOCK_FILE);
             IEnumerable <XElement> q = from xe in xmldoc.Descendants("key") select xe;
             var dt = new DataTable();
             dt.Columns.Add("key");
             dt.Columns.Add("name");
             dt.Columns.Add("accountid");
             dt.Columns.Add("reasonblock");
             dt.Columns.Add("namereasonblock");
             dt.Columns.Add("typeblock");
             dt.Columns.Add("endtimeblock");
             dt.Columns.Add("createDate");
             foreach (XElement xe in q)
             {
                 DataRow row = dt.NewRow();
                 row[0] = xe.Attribute("key").Value;
                 row[1] = xe.Attribute("name").Value;
                 row[2] = xe.Attribute("accountid").Value;
                 row[3] = xe.Attribute("reasonblock").Value;
                 row[4] = xe.Attribute("namereasonblock").Value;
                 row[5] = xe.Attribute("typeblock").Value;
                 row[6] = xe.Attribute("endtimeblock").Value;
                 row[7] = xe.Attribute("createDate").Value;
                 dt.Rows.Add(row); // Thêm dòng mới vào dtb
             }
             List <ListAccountBlock> Data = ListAccountBlock = dt.AsEnumerable().Select(m => new ListAccountBlock()
             {
                 key             = m.Field <string>("key"),
                 name            = m.Field <string>("name"),
                 accountid       = m.Field <string>("accountid"),
                 reasonblock     = m.Field <string>("reasonblock"),
                 namereasonblock = m.Field <string>("namereasonblock"),
                 typeblock       = m.Field <string>("typeblock"),
                 endtimeblock    = m.Field <string>("endtimeblock"),
                 createDate      = m.Field <string>("createDate")
             }).ToList();
             BicCache.CacheData(key, Data);
         }
         else
         {
             ListAccountBlock = (List <ListAccountBlock>)BicCache.ReadCache(key);
         }
     }
     catch (Exception ex)
     {
         NLogManager.LogMessage(">> Ex LoadAccountBlock:" + ex.Message);
     }
 }
Example #2
0
 private static void DeleteAccountBlock(string key)
 {
     try
     {
         XDocument xmldoc     = XDocument.Load(ACCOUNTBLOCK_FILE);
         XElement  xmlelement = xmldoc.Element("AccountBlock").Elements("key").Single(x => (string)x.Attribute("key") == key);
         xmlelement.Remove();
         xmldoc.Save(ACCOUNTBLOCK_FILE);
         BicCache.Remove("ACCOUNTBLOCK_FILE");
         LoadAccountBlock();
     }
     catch (Exception ex)
     { }
 }
Example #3
0
 private static void LoadKeywordReplace()
 {
     try
     {
         string key = "KEYWORDREPLACE_FILE";
         if (BicCache.ReadCache(key) == null)
         {
             XDocument xmldoc         = XDocument.Load(KEYWORDREPLACE_FILE);
             IEnumerable <XElement> q = from xe in xmldoc.Descendants("key") select xe;
             var dt = new DataTable();
             dt.Columns.Add("text");
             dt.Columns.Add("replace");
             foreach (XElement xe in q)
             {
                 DataRow row = dt.NewRow();
                 row[0] = xe.Attribute("text").Value;
                 row[1] = xe.Attribute("replace").Value;
                 dt.Rows.Add(row); // Thêm dòng mới vào dtb
             }
             List <ObjKeywordReplace> Data = dt.AsEnumerable().Select(m => new ObjKeywordReplace()
             {
                 text    = m.Field <string>("text"),
                 replace = m.Field <string>("replace"),
             }).ToList();
             KeywordReplace = Data;
             BicCache.CacheData(key, KeywordReplace);
         }
         else
         {
             KeywordReplace = (List <ObjKeywordReplace>)BicCache.ReadCache(key);
         }
     }
     catch (Exception ex)
     {
         NLogManager.PublishException(ex);
     }
 }
Example #4
0
        private static void LoadBlackList()
        {
            string key = "BLACKLIST_FILE";

            if (BicCache.ReadCache(key) == null)
            {
                XDocument xmldoc         = XDocument.Load(BLACKLIST_FILE);
                IEnumerable <XElement> q = from xe in xmldoc.Descendants("key") select xe;
                var dt = new DataTable();
                dt.Columns.Add("text");
                foreach (XElement xe in q)
                {
                    DataRow row = dt.NewRow();
                    row[0] = xe.Attribute("text").Value;
                    dt.Rows.Add(row); // Thêm dòng mới vào dtb
                }
                BadWords = dt.AsEnumerable().Select(r => r.Field <string>("text")).ToList();
                BicCache.CacheData(key, BadWords);
            }
            else
            {
                BadWords = (List <string>)BicCache.ReadCache(key);
            }
        }