Beispiel #1
0
        protected override bool VerifyFile(FileActivity activity)
        {
            FileInfo fileInfo = new FileInfo(activity.FilePath);

            if (!fileInfo.Exists)
            {
                activity.Message = "文件不存在";
                return(false);
            }
            if ((fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
            {
                activity.Message = "隐藏文件不参与扫描";
                return(false);
            }

            if (Filter.IndexOf(fileInfo.Extension.ToLower()) < 0)
            {
                activity.Message = "不支持此扩展名的文件";
                return(false);
            }
            if (fileInfo.Length > MaxSize * 1024 * 1024)
            {
                activity.Message = string.Format("不支持大于[{0}m]的文件", MaxSize);
                return(false);
            }

            //判断文件是否变化,没有变化不处理
            if (!FileChanged(activity))
            {
                activity.Message = "文件内容未发生变化";
                return(false);
            }

            //检验是否为简历
            var result = _service.Predict(activity.FilePath, new ExtractOption[] { ExtractOption.Text });

            if (result.Status == OperateStatus.Failure || !result.Data.IsResume)
            {
                activity.Message = result.Description;
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        private void btnDocExt_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;
                btnDocExt.Enabled = false;
                btnClear_Click(null, null);

                Notice(fileDialog.FileName);
                Notice("正在抽取->" + fileDialog.FileName);

                ThreadPool.QueueUserWorkItem((w) =>
                {
                    //抽取文档
                    var result = _service.Predict(fileDialog.FileName, new ExtractOption[] { ExtractOption.Text });
                    Notice("抽取完成->" + fileDialog.FileName);
                    UpdateUI(() =>
                    {
                        if (result.Status == OperateStatus.Failure)
                        {
                            Alert(result.Description);
                        }
                        else
                        {
                            txtTxt.Text = result.Data.Text;
                        }
                        btnDocExt.Enabled = true;
                    });
                });
            }
        }