public static void Init()
 {
     if (!Directory.Exists("./cache/"))
     {
         return;
     }
     foreach (var file in Directory.GetFiles("./cache/"))
     {
         if (file.EndsWith(".txt"))
         {
             using (StreamReader sr = new StreamReader(file, Encoding.UTF8))
             {
                 string line;
                 while ((line = sr.ReadLine()) != null)
                 {
                     var dts = line.Split('\t');
                     int c;
                     foreach (var dt in dts)
                     {
                         if (!int.TryParse(dt, out c) && dt.Length > 1 && dt.Length <= 5)
                         {
                             //数字不要,字符长度大于5的不要
                             KeywordManager.SetKeyword(dt);
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 2
0
        private static void WriteSheet(ExcelWorksheet sheetIn, StreamWriter sw)
        {
            if (sheetIn.Name.StartsWith("~") || sheetIn.Dimension == null)
            {
                return;
            }

            int colCount = sheetIn.Dimension.End.Column;

            for (int col = 2; col <= colCount; col++)
            {
                var dt = sheetIn.GetValue(9, col);
                if (dt == null)
                {
                    colCount = col;
                    break;
                }
            }
            for (int row = 14; row <= sheetIn.Dimension.End.Row; row++)
            {
                if (sheetIn.GetValue(row, 2) == null)
                {
                    break;
                }
                for (int col = 1; col <= colCount; col++)
                {
                    var cell = sheetIn.GetValue(row, col);
                    var r    = "\t";
                    if (cell != null)
                    {
                        r = cell.ToString().Replace("\n", "");
                        int c;
                        if (!int.TryParse(r, out c) && r.Length > 1 && r.Length <= 5)
                        {
                            //数字不要,字符长度大于5的不要
                            KeywordManager.SetKeyword(r);
                        }
                        r += "\t";
                    }

                    sw.Write(r);
                }

                sw.WriteLine();
            }
        }