Exemple #1
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("重建缓存完成");
            }
        }
Exemple #2
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";
        }