首页 > 代码库 > 【基于WPF+OneNote+Oracle的中文图片识别系统阶段总结】之篇四:关于OneNote入库处理以及审核

【基于WPF+OneNote+Oracle的中文图片识别系统阶段总结】之篇四:关于OneNote入库处理以及审核

 篇一:WPF常用知识以及本项目设计总结:http://www.cnblogs.com/baiboy/p/wpf.html

篇二:基于OneNote难点突破和批量识别:http://www.cnblogs.com/baiboy/p/wpf1.html

篇三:批量处理后的txt文件入库处理:http://www.cnblogs.com/baiboy/p/wpf2.html

篇四:关于OneNote入库处理以及审核:http://www.cnblogs.com/baiboy/p/wpf3.html


【小记】:大胆尝试才能突破,某个中医药大学有一批图片需要处理(ORC),然后进行数据挖掘。之前没有接触过ORC这个东西,但是还是应允了。在网上搜索一番,关于中文图片识别,最终敲定为基于微软的OneNote,其识别率相对较高。网上这个技术点的资料真心不多,后来于博客园找到一篇博文,但是那个程序还是bug百出,而且只是单处理。后来经过一番摸索逐个突破,批处理完成。然后进行界面设计,这些零碎工作完成后,便是入库处理。由于OneNote生成的xml文件封装好的,即不可视的。便将其代码处理生成txt文件,再进行Oracle入库处理。入库前需要文件内容审核,并且在WPF开发中数据绑定和分页中做了独特处理。现在经过半个月的工作,本项目做个阶段总结。一则知识总结便于二次开发,尽量保持程序流畅性,核心知识做以梳理;另外,相关WPFOneNote常用技术共享,便于部分园友所需。本人技术有限,欢迎交流。项目还未结束,暂作阶段文章发布,随后相继发布。


篇四:关于OneNote入库处理以及审核

【开篇概述】:文本作为系列文章的最后一篇,主要对页面进行设计布局和审核页面的完善,其中主页面用户可以查询审核通过的信息,浏览详细信息。也可以作为导航到orc页面,对批量图片进行文字处理,处理后的文件,可以通过入库页面对文件信息提取。达到半自动填写表格的状态,由于文件信息不一定符合主观要求或者格式不一致,所以设置了审核页面,也是信息修改页面,信息无误后,选择下面审核通过复选框即可成功入库。后面就是交付做数据挖掘处理了。效果如图所示

主页面:

 

完整代码:

namespace OnenoteOCRDemo{    /// <summary>    /// Index.xaml 的交互逻辑    /// </summary>    public partial class Index : Window    {        public Index()        {            InitializeComponent();            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);        }        page page1 = new page();        void MainWindow_Loaded(object sender, RoutedEventArgs e)        {            this.c1.Children.Add(page1);            this.Loaded += delegate            {                InitData();            };            dataGrid1.LoadingRow += new EventHandler<DataGridRowEventArgs>(dataGrid1_LoadingRow);        }        void dataGrid1_LoadingRow(object sender, DataGridRowEventArgs e)        {            e.Row.Header = e.Row.GetIndex() + 1;    //设置行表头的内容值           }        //查询        private void InitData()        {            string sql = "select * from T_TCM_THESIS where auditflag=1  order by ID desc";            DataSet ds = MYHelper.SQLHelper.GetOrlData(sql);            if (ds.Tables[0].Rows.Count > 0)            {                page1.ShowPages(this.dataGrid1, ds, 10);            }            else            {                System.Windows.Forms.MessageBox.Show("Erroy");            }        }        private void Window_Loaded(object sender, RoutedEventArgs e)        {            InitData();        }        private void hlorc_Click(object sender, RoutedEventArgs e)        {            Main m = new Main();            m.Show();        }        private void hltext_Click(object sender, RoutedEventArgs e)        {            TextData td = new TextData();            td.Show();        }        //刷新        private void hlnew_Click(object sender, RoutedEventArgs e)        {            InitData();        }        private void hyper2_Click(object sender, RoutedEventArgs e)        {            this.Hide();            DataRowView mySelectedElement = (DataRowView)dataGrid1.SelectedItem;            int ID = Convert.ToInt32((mySelectedElement.Row[0]));  //获取该行的FID              falg f = new falg(ID,0);            f.Show();        }        }}
View Code

审核页面:

完整代码:

namespace OnenoteOCRDemo{    /// <summary>    /// falg.xaml 的交互逻辑    /// </summary>    public partial class falg : Window    {        int i;        public falg(int id,int n)        {            InitializeComponent();            txt.Text = id.ToString();            THESIS(id);            i = n;            if (i == 0)            {                btnupdate.Visibility = System.Windows.Visibility.Hidden;                cbflag.Visibility = System.Windows.Visibility.Hidden;                txtflag.Text="审核通过";            }        }        private void THESIS(int id)        {            string sql = "select * from T_TCM_THESIS where id="+id;            DataTable dt = MYHelper.SQLHelper.GetTabOrlData(sql);            if (dt.Rows.Count>0)            {                txtdocname.Text = dt.Rows[0]["docname"].ToString();                txtauthor.Text = dt.Rows[0]["author"].ToString();                txtcompany.Text = dt.Rows[0]["authorcompany"].ToString();                txtcontent.Text = dt.Rows[0]["content"].ToString();                txtdigest.Text = dt.Rows[0]["digest"].ToString();                txtdisease.Text = dt.Rows[0]["disease"].ToString();                txtdoctype.Text = dt.Rows[0]["doctype"].ToString();                txtenglishtitle.Text = dt.Rows[0]["englishtitle"].ToString();                txtkeyword.Text = dt.Rows[0]["keyword"].ToString();                txtmemo.Text = dt.Rows[0]["memo"].ToString();                txtpath.Text = dt.Rows[0]["path"].ToString();                txtsource.Text = dt.Rows[0]["source"].ToString();                txtsourcetype.Text = dt.Rows[0]["sourcetype"].ToString();                txtsummary.Text = dt.Rows[0]["summary"].ToString();                txttitle.Text = dt.Rows[0]["title"].ToString();                txtyears.Text = dt.Rows[0]["years"].ToString();                int flag =Convert.ToInt32(dt.Rows[0]["auditflag"].ToString());                if (flag == 1)                {                    cbflag.IsChecked = true;                }                else                {                    cbflag.IsChecked = false;                }            }        }        public void TextIsNull()        {            txtdocname.Text = "";            txtyears.Text = "";            txtdoctype.Text = "";            txtsummary.Text = "";            txtauthor.Text = "";            txtsource.Text = "";            txtsourcetype.Text = "";            txtmemo.Text = "";            txttitle.Text = "";            txtenglishtitle.Text = "";            txtcompany.Text = "";            txtkeyword.Text = "";            txtcontent.Text = "";            txtdigest.Text = "";            txtpath.Text = "";            txtdisease.Text = "";            cbflag.IsChecked = false;        }        //审核信息(更新信息)        private void btnupdate_Click(object sender, RoutedEventArgs e)        {            int id=Convert.ToInt32( txt.Text);            string docname = txtdocname.Text.ToString();            string years = txtyears.Text.ToString();            string doctype = txtdoctype.Text.ToString();            string summary = txtsummary.Text.ToString();            string author = txtauthor.Text.ToString();            string source = txtsource.Text.ToString();            string sourcetype = txtsourcetype.Text.ToString();            string memo = txtmemo.Text.ToString();            string title = txttitle.Text.ToString();            string englishtitle = txtenglishtitle.Text.ToString();            string authorcompany = txtcompany.Text.ToString();            string keyword = txtkeyword.Text.ToString();            string content = txtcontent.Text.ToString().Trim();            string digest = txtdigest.Text.ToString();            string path = txtpath.Text.ToString();            string disease = txtdisease.Text.ToString();            int auditflag;            if (cbflag.IsChecked == true)            {                auditflag = 1;            }            else            {                auditflag =0;            }            try            {                string sql = "update T_TCM_THESIS set docname=‘" + docname + "‘,years=‘" + years + "‘,doctype=‘" + doctype + "‘,summary=‘" + summary + "‘,";                sql += "author=‘" + author + "‘,source=‘" + source + "‘,sourcetype=‘" + sourcetype + "‘,memo=‘" + memo + "‘,title=‘" + title + "‘,";                sql += "englishtitle=‘" + englishtitle + "‘,authorcompany=‘" + authorcompany + "‘,keyword=‘" + keyword + "‘,content=‘" + content + "‘,digest=‘" + digest + "‘,";                sql += "path=‘" + path + "‘,disease=‘" + disease + "‘,auditflag=" + auditflag + " where ID= "+id;                int i = SQLHelper.OrlExecuteQuery(sql);                if (i > 0)                {                    System.Windows.Forms.MessageBox.Show("审核通过", "审核信息");                    TextIsNull();                    this.Close();                    TextData td = new TextData();                    td.Show();                }                else                {                    System.Windows.Forms.MessageBox.Show("审核失败", "审核信息");                }            }            catch (Exception ex)            {                System.Windows.Forms.MessageBox.Show(ex.Message);            }        }        private void btnback_Click(object sender, RoutedEventArgs e)        {            this.Close();            if (i == 1)            {                TextData td = new TextData();                td.Show();            }            else {                Index index = new Index();                index.Show();            }        }    }}
View Code

 


【功能以及操作描述】

  1. 打开主页面可以看到,每条信息前序号的生成,通过后台对事件重写完成,代码如下。
            void MainWindow_Loaded(object sender, RoutedEventArgs e)        {            this.c1.Children.Add(page1);            this.Loaded += delegate            {                InitData();            };            dataGrid1.LoadingRow += new EventHandler<DataGridRowEventArgs>(dataGrid1_LoadingRow);        }        void dataGrid1_LoadingRow(object sender, DataGridRowEventArgs e)        {            e.Row.Header = e.Row.GetIndex() + 1;    //设置行表头的内容值           }
    View Code

     

      
  2. 页面自动显示为分页显示,通过用户控件进行分页,然后对数据控件进行绑定,详细操作见系列二文章。本功能代码如下:
     //查询        private void InitData()        {            string sql = "select * from T_TCM_THESIS where auditflag=1  order by ID desc";            DataSet ds = MYHelper.SQLHelper.GetOrlData(sql);            if (ds.Tables[0].Rows.Count > 0)            {                page1.ShowPages(this.dataGrid1, ds, 10);            }            else            {                System.Windows.Forms.MessageBox.Show("Erroy");            }        }
    View Code

     

  3. 点击详细信息按钮,跳转的详细信息页面。如何获取DataGrid主键是关键,具体实现为:
                this.Hide();            DataRowView mySelectedElement = (DataRowView)dataGrid1.SelectedItem;            int ID = Convert.ToInt32((mySelectedElement.Row[0]));  //获取该行的FID              falg f = new falg(ID,0);            f.Show();

     

  4. 在目标页面,通过页面接受页面传值,显示到详细信息。
     private void THESIS(int id)        {            string sql = "select * from T_TCM_THESIS where id="+id;            DataTable dt = MYHelper.SQLHelper.GetTabOrlData(sql);            if (dt.Rows.Count>0)            {                txtdocname.Text = dt.Rows[0]["docname"].ToString();                txtauthor.Text = dt.Rows[0]["author"].ToString();                txtcompany.Text = dt.Rows[0]["authorcompany"].ToString();                txtcontent.Text = dt.Rows[0]["content"].ToString();                txtdigest.Text = dt.Rows[0]["digest"].ToString();                txtdisease.Text = dt.Rows[0]["disease"].ToString();                txtdoctype.Text = dt.Rows[0]["doctype"].ToString();                txtenglishtitle.Text = dt.Rows[0]["englishtitle"].ToString();                txtkeyword.Text = dt.Rows[0]["keyword"].ToString();                txtmemo.Text = dt.Rows[0]["memo"].ToString();                txtpath.Text = dt.Rows[0]["path"].ToString();                txtsource.Text = dt.Rows[0]["source"].ToString();                txtsourcetype.Text = dt.Rows[0]["sourcetype"].ToString();                txtsummary.Text = dt.Rows[0]["summary"].ToString();                txttitle.Text = dt.Rows[0]["title"].ToString();                txtyears.Text = dt.Rows[0]["years"].ToString();                int flag =Convert.ToInt32(dt.Rows[0]["auditflag"].ToString());                if (flag == 1)                {                    cbflag.IsChecked = true;                }                else                {                    cbflag.IsChecked = false;                }            }        }
    View Code

     

  5. 审核页面的具体操作也是类似, 不同之处在于对传值页面进行逻辑判断,如果是审核则允许页面信息的更新,如果查看详细信息,则更新按钮隐藏。

 


 【篇末】:截止到此,本程序完全结束,本章涉及页面传值和数据绑定等基本信息,这方面大体与winfrom操作一致。本程序采用讲涉及的知识点数十个,均一一列出整理。数据库sql文件在项目的db文件夹中,附上完整源码如下:

 

 源码:http://i.cnblogs.com/Files.aspx/OnenoteOCR3.0.zip