private void btnResumeParse_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.InitialDirectory = InitialDirectory; fileDialog.Filter = MimeType; fileDialog.FilterIndex = 2; fileDialog.RestoreDirectory = true; if (fileDialog.ShowDialog() == DialogResult.OK) { _currentFile = fileDialog.FileName; btnResumeParse.Enabled = false; btnClear_Click(null, null); Notice("正在解析->" + fileDialog.FileName); ThreadPool.QueueUserWorkItem((w) => { //解析简历 var result = _service.Parse(fileDialog.FileName, new ExtractOption[] { ExtractOption.Text }); FileHandleCallBack(new FileActivity(fileDialog.FileName), result); UpdateUI(() => { btnResumeParse.Enabled = true; }); }); } }
/// <summary> /// 处理事件(核心功能,解析文件存储,监听文件,回调) /// </summary> /// <param name="activity"></param> /// <returns></returns> protected override bool HandleActivity(FileActivity activity) { activity.HashCode = activity.FilePath.MD5(); RecordFileInfo(activity); var result = _service.Parse(activity.FilePath, new ExtractOption[] { ExtractOption.Text }); if (result.Status == OperateStatus.Success) { _storage.Save(activity, result.Data); WatchFile(activity); } _handleCallback(activity, result); return(true); }