首页 > 代码库 > 【基于WPF+OneNote+Oracle的中文图片识别系统阶段总结】之篇三:批量处理后的txt文件入库处理
【基于WPF+OneNote+Oracle的中文图片识别系统阶段总结】之篇三:批量处理后的txt文件入库处理
篇一: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开发中数据绑定和分页中做了独特处理。现在经过半个月的工作,本项目做个阶段总结。一则知识总结便于二次开发,尽量保持程序流畅性,核心知识做以梳理;另外,相关WPF和OneNote常用技术共享,便于部分园友所需。本人技术有限,欢迎交流。项目还未结束,暂作阶段文章发布,随后相继发布。
篇三:批量处理后的txt文件入库处理
【开篇概述】:本文继上述文章再做深度剖析,本篇主要介绍txt入库(oracle)和wpf分页,在此篇涉及的页面设计前篇已经细述不再概说。里面涉及到oracle 64位系统安装处理问题,以前oracle的表,序列,触发器,自增种子等基本操作。外加文件操作和利用用户控件分页等技术。大致效果图如下,其次粘贴完整代码,其后就一一概说本文核心要点和难点突破,最后梳理技术知识点,使其一则保持完整性,二则梳理整理知识点便于随时取用。(本篇暂做效果图如下,至于最终效果图和审核界面,待终篇。)
效果图:
完整代码:
namespace OnenoteOCRDemo{ /// <summary> /// TextData.xaml 的交互逻辑 /// </summary> public partial class TextData : Window { public TextData() { InitializeComponent(); this.Loaded += new RoutedEventHandler(MainWindow_Loaded); } void MainWindow_Loaded(object sender, RoutedEventArgs e) { 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 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(); } //批量删除 List<int> selectFID = new List<int>(); private void CheckBox_Click(object sender, RoutedEventArgs e) { System.Windows.Controls.CheckBox dg = sender as System.Windows.Controls.CheckBox; int FID = int.Parse(dg.Tag.ToString()); //获取该行的FID var bl = dg.IsChecked; if (bl == true) { selectFID.Add(FID); //如果选中就保存FID } else { selectFID.Remove(FID); //如果选中取消就删除里面的FID } } private void btnDelete_Click(object sender, RoutedEventArgs e) { foreach (int FID in selectFID) { string sql = "delete T_TCM_THESIS where id=" + FID; int i = SQLHelper.OrlExecuteQuery(sql); if (i > 0) { System.Windows.Forms.MessageBox.Show("success!!!"); } else { System.Windows.Forms.MessageBox.Show("Erroy!!!"); } InitData(); } } 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 = ""; } private void btnAdd_Click(object sender, RoutedEventArgs e) { 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 = 1; try { string sql = "INSERT INTO T_TCM_THESIS(docname,years,doctype,summary,author,source,sourcetype,memo,title,englishtitle,"; sql += "authorcompany,keyword,content,digest,path,disease,auditflag) Values(‘" + docname + "‘,‘" + years + "‘,‘" + doctype + "‘,‘" + summary + "‘,"; sql += "‘" + author + "‘,‘" + source + "‘,‘" + sourcetype + "‘,‘" + memo + "‘,‘" + title + "‘,‘" + englishtitle + "‘,‘" + authorcompany + "‘,‘" + keyword + "‘,"; sql += "‘" + content + "