Exemple #1
0
        public void DoWork(object obj) //chay Parallel.ForEach
        {
            if (obj == null)
            {
                return;
            }
            FileMeta fileMeta = (FileMeta)obj;

            if (string.IsNullOrEmpty(fileMeta.FullName))
            {
                return;
            }

            string sPath = MyConfig.GetMailFolder();

            try
            {
                using (var msg = new MsgReader.Outlook.Storage.Message(fileMeta.FullName))
                {
                    //msg.Type == MsgReader.Outlook.MessageType.Email
                    //msg.Type == MsgReader.Outlook.MessageType.AppointmentRequest
                    //msg.Type == MsgReader.Outlook.MessageType.EmailNonDeliveryReport
                    // etc
                    Document doc = new Document();

                    doc.Add(new Field("SentOn", msg.GetSentOnEx(), Field.Store.YES, Field.Index.NOT_ANALYZED));
                    doc.Add(new Field("ReceivedOn", msg.GetReceivedOnEx(), Field.Store.YES, Field.Index.NOT_ANALYZED));

                    doc.Add(new Field("Subject", msg.Subject.EmptyIfNullEx(), Field.Store.YES, Field.Index.ANALYZED));
                    doc.Add(new Field("Body", msg.BodyText.EmptyIfNullEx(), Field.Store.YES, Field.Index.ANALYZED));

                    doc.Add(new Field("SenderEmailAddress", msg.Sender.Email.EmptyIfNullEx(), Field.Store.YES, Field.Index.ANALYZED));
                    doc.Add(new Field("SenderName", msg.Sender.DisplayName.EmptyIfNullEx(), Field.Store.YES, Field.Index.ANALYZED));

                    doc.Add(new Field("To", msg.GetEmailToEx(), Field.Store.YES, Field.Index.ANALYZED));
                    doc.Add(new Field("CC", msg.GetEmailCcEx(), Field.Store.YES, Field.Index.ANALYZED));

                    doc.Add(new Field("Categories", msg.GetCategoryEx(), Field.Store.YES, Field.Index.ANALYZED));

                    doc.Add(new Field("FlagRequest", msg.GetFlagEx(), Field.Store.YES, Field.Index.NOT_ANALYZED));

                    doc.Add(new Field("Importance", msg.GetImportanceEx(), Field.Store.YES, Field.Index.NOT_ANALYZED));

                    doc.Add(new Field("AttachmentNames", msg.GetAttachmentNames().EmptyIfNullEx(), Field.Store.YES, Field.Index.ANALYZED));

                    doc.Add(new Field("FullFileName", fileMeta.FileNameWithoutPath, Field.Store.YES, Field.Index.NOT_ANALYZED));
                    doc.Add(new Field("LastWriteTime", fileMeta.LastWriteTime, Field.Store.YES, Field.Index.NOT_ANALYZED));

                    Writer.AddDocument(doc);
                    //  ConStackLog.Push(msg.Subject);
                }
            }
            catch (Exception ex)
            {
                ConStackLog.Push(ex.Message + "|" + fileMeta.FullName);
            }
        }
Exemple #2
0
 public bW1Arg(System.Windows.Forms.DateTimePicker DPickerFrom, System.Windows.Forms.DateTimePicker DPickerTo)
 {
     IsReIndex    = false;
     DFromNaN     = DPickerFrom.Value;
     DFromChecked = DPickerFrom.Checked;
     DToNaN       = DPickerTo.Value;
     DToChecked   = DPickerTo.Checked;
     MailFolder   = MyConfig.GetMailFolder();
 }
Exemple #3
0
        private void BtnPath_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            if (folderBrowserDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            MyConfig.SaveSetting("MailFolder", folderBrowserDialog.SelectedPath);
            TxtPath.Text = MyConfig.GetMailFolder();
        }
Exemple #4
0
 public TabIndex()
 {
     InitializeComponent();
     TxtPath.Text = MyConfig.GetMailFolder();
 }
Exemple #5
0
 public TabMailView(MailData mail)
 {
     InitializeComponent();
     webBrowser1.DocumentText = mail.ToHtml(MyConfig.GetMailFolder());
 }
Exemple #6
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);
        }
 public TabAbout()
 {
     InitializeComponent();
     LblVersion.Text = string.Format("version {0}, @2020.04", MyConfig.GetVersion());
 }
Exemple #8
0
 public bW1Arg(bool bReIndex)
 {
     IsReIndex  = bReIndex;
     MailFolder = MyConfig.GetMailFolder();
 }