Exemplo n.º 1
0
 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);
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        private void RebuildCache()
        {
            if (!Directory.Exists("./cache"))
            {
                Directory.CreateDirectory("./cache");
            }

            if (string.IsNullOrEmpty(excelPath))
            {
                return;
            }
            var files = Directory.GetFiles(excelPath);


            List <string> toConvertList  = new List <string>();
            var           fileModifyDict = FileAccessTimeManager.FileModifyDict;

            foreach (var file in files)
            {
                var fileInfo = new FileInfo(file);
                if (file.EndsWith(".xlsx") && !fileInfo.Name.StartsWith("~"))
                {
                    if (!fileModifyDict.ContainsKey(fileInfo.Name) || fileModifyDict[fileInfo.Name] < TimeTool.DateTimeToUnixTime(fileInfo.LastWriteTime))
                    {
                        toConvertList.Add(file);
                    }
                }
            }

            if (toConvertList.Count > 0)
            {
                UpdateStatueBarTextSafe("开始重建缓存");
                var total = toConvertList.Count;
                int done  = 0;
                SetProgressSafe(0);
                foreach (var file in toConvertList)
                {
                    var fileInfo = new FileInfo(file);
                    Excel2Csv.Convert(file, string.Format("./cache/{0}.txt", fileInfo.Name.Substring(0, fileInfo.Name.Length - 5)));
                    fileModifyDict[fileInfo.Name] = TimeTool.DateTimeToUnixTime(fileInfo.LastWriteTime);
                    done++;
                    SetProgressSafe((float)done / total);
                }
                FileAccessTimeManager.Save();
                SetProgressSafe(1);
                UpdateTextboxSourceSafe(KeywordManager.Get());
                UpdateStatueBarTextSafe("重建缓存完成");
            }
        }
Exemplo n.º 3
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();
            }
        }
Exemplo n.º 4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            FileAccessTimeManager.Load();
            if (File.Exists("config"))
            {
                using (var sr = new StreamReader("config"))
                {
                    excelPath = sr.ReadLine();
                }
            }
            KeywordManager.Init();
            textBox1.AutoCompleteCustomSource = KeywordManager.Get();

            rebuildThread = new Thread(CheckRebuild);
            rebuildThread.IsBackground = true;
            rebuildThread.Start();
            //richTextBoxEx1.SelectedText = "	2000	";
            //richTextBoxEx1.InsertLink("荆轲");
            //richTextBoxEx1.SelectedText = @"1	1	0	ProfilePictureTemporary	Character	ZhuJueHead	Character	{1,}	不详		Train/0000_train_data	2001			2001_YingZheng	2001_a	2001_a_prefab_weapon	黯然销魂刀	{100002,}	100002	20	{[0]={10,},[1]={20, }, [2]={30, }, [3]={40, }, [4]={50, }, [5]={60, }, }	{[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,}	{}	{}	{}	{}	{}		{[0] = {[100002] = 10,},[1] = {[100002] = 10,},[2] = {[100002] = 10,},[3] = {[100002] = 10,},[4] = {[100002] = 10,},[5] = {[100002] = 10,},[6] = {[100002] = 10,},}	100002	{1,1}	100003";
        }