예제 #1
0
        private void bW1_DoWork(object sender, DoWorkEventArgs e)
        {
            bW1Arg dArg = e.Argument as bW1Arg;

            List <FileMeta> lst          = MyIO.GetFileMsgFromTo(dArg.MailFolder, dArg.DFrom, dArg.DTo);
            WorkerThread2   workerThread = new WorkerThread2();

            e.Result = workerThread.RunMT(lst, dArg.IsReIndex);
        }
예제 #2
0
        private void BtnFromTo_Click(object sender, EventArgs e)
        {
            InitBackgroundWorker();
            bW1Arg arg = new bW1Arg(DPickerFrom, DPickerTo);

            TxtStatus.Clear();
            TxtStatus.Text = "Program is running. It is very time consuming, Please wait ...";
            bW1.RunWorkerAsync(arg);
        }
예제 #3
0
        private void BtnFromTo_Click(object sender, EventArgs e)
        {
            InitBackgroundWorker();
            bW1Arg arg = new bW1Arg(DPickerFrom, DPickerTo);

            TxtStatus.Clear();
            TxtStatus.Text = "Chuong trinh dang chay, vui long cho ...";
            bW1.RunWorkerAsync(arg);
        }
예제 #4
0
        private void BtnReIndexAll_Click(object sender, EventArgs e)
        {
            InitBackgroundWorker();

            bW1Arg arg = new bW1Arg(true);

            TxtStatus.Clear();
            TxtStatus.Text = "Chuong trinh dang chay, vui long cho ...";
            bW1.RunWorkerAsync(arg);
        }
예제 #5
0
        public WorkerThreadResult RunMT(bW1Arg arg)
        {
            WorkerThreadResult result = new WorkerThreadResult();

            string indexPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "LuceneData");

            Lucene.Net.Store.Directory directory = Lucene.Net.Store.FSDirectory.Open(indexPath);
            Lucene.Net.Analysis.Standard.StandardAnalyzer analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30);

            Worker workerObject = new Worker();

            workerObject.Writer      = new IndexWriter(directory, analyzer, IndexWriter.MaxFieldLength.UNLIMITED);
            workerObject.ConStackLog = ErrLog;
            workerObject.SetRAMBufferSizeMB();

            List <FileMeta> LstMsgFile = MyIO.GetFileMsgFromTo(MyConfig.GetMailFolder(), arg.DFrom, arg.DTo);

            if (arg.IsReIndex)
            {
                workerObject.DeleteAllDocuments();
            }
            else
            {
                //Xoa bo nhung item trung lap giua list moi tao va du lieu da index
                using (Lucene.Net.Search.IndexSearcher searcher = new Lucene.Net.Search.IndexSearcher(directory))
                {
                    for (int i = LstMsgFile.Count - 1; i >= 0; i--)
                    {
                        if (MyLucene.CheckDocExist(searcher, LstMsgFile[i]))
                        {
                            LstMsgFile.RemoveAt(i);
                            result.IncreaseNumDupFiles();
                        }
                    }
                }
            }

            //Chay song song
            ParallelLoopResult pResult = Parallel.ForEach(LstMsgFile, (currentFileMeta) => workerObject.DoWork(currentFileMeta));

            StringBuilder sb = new StringBuilder();

            if (pResult.IsCompleted)
            {
                workerObject.DisposeWriter();
                analyzer.Dispose();
                directory.Dispose();

                result.FileDone = LstMsgFile;

                int i = 0;
                foreach (var a in ErrLog)
                {
                    string item;
                    ErrLog.TryPop(out item);
                    i++;
                    sb.Append(i.ToString());
                    sb.Append(". ");
                    sb.Append(item);
                    sb.Append(Environment.NewLine);
                }
                result.ErrLog = sb.ToString();
            }
            return(result);
        }