版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.HandleUpload.ashx页面<% WebHandler Language="C#" Class="Handler" %>using System;using System.Web;using System.IO;using System.Data;using System.Xml;using KqFormEngineLibrary3;using KqFormEngineLibrary3.Common;using System.Data.SqlClient;using Microsoft.Practices.EnterpriseLi
2、brary.Data;using System.Data.Common;using System.Data.OleDb;using Oracle.DataAccess.Types;using Oracle.DataAccess.Client;using KqFormEngineLibrary3;public class Handler : IHttpHandler public void ProcessRequest (HttpContext context) context.Response.ContentType = "text/html" string method=
3、 context.Request.QueryString"method" switch (method) case "upload": UploadText(context); break; case "getJson": context.Response.Write( getDate(context); context.Response.End(); break; public void UploadText(HttpContext context) string serverPath = "" string f
4、ileName = "" string destPath="" string json = "" try if (context.Request.Files.Count > 0) if (context.Request.Files0.ContentLength > 0) HttpPostedFile postedFile = context.Request.Files0; serverPath = context.Server.MapPath("./Upload");/上?传?路·径? fil
5、eName = Path.GetFileName(postedFile.FileName); destPath = Path.Combine(serverPath, fileName); postedFile.SaveAs(destPath); if (File.Exists(destPath) / readXmlToDatabase(postedFile); json = "success:true,message:'上?传?成é功|'" UpdateTable(destPath); / ConvertXMLFileToDataSet(destP
6、ath); / UpdateDatabase(destPath); / UpdateDatabaseTest(destPath); else json = "success:false,message:'添加ó上?传?文?件t'" else json = "success:false,message:'添加ó文?件t'" catch(Exception err) json="success:false,message:'"+err.Message+"'&qu
7、ot; context.Response.Write(json); context.Response.End(); public string getDate(HttpContext context) string json = "totalProperty:'10',root: " string serverPath = context.Server.MapPath("./Upload");/上?传?路·径? DirectoryInfo dir = new DirectoryInfo(serverPath); int i =
8、1; foreach (FileInfo dChild in dir.GetFiles("*.xml") string pathName = context.Server.UrlEncode(dChild.Name); json += "id:'" + i + "', dd:'" + dChild.Name + "',path:'" + pathName + "'," i+; json=json.Substring(0, json.Length -
9、 1) + "" return json; public void ConvertXMLFileToDataSet(string xmlFile) StringReader stream = null; XmlTextReader reader = null; try XmlDocument xmld = new XmlDocument(); xmld.Load(xmlFile); DataSet xmlDS = new DataSet(); stream = new StringReader(xmld.InnerXml); /从洙畇tream装痢载?到?XmlTextRe
10、ader reader = new XmlTextReader(stream); xmlDS.ReadXml(reader); foreach (DataTable dt in xmlDS.Tables) foreach (DataRow row in dt.Rows) bool b = IsCunZai(row"ZCBM".ToString(); if (b) continue; else int SLID = int.Parse(row"SLID".ToString(); int RECNO = int.Parse(row"RECNO&qu
11、ot;.ToString(); string ZCBM = row"ZCBM".ToString(); string ZCMC = row"ZCMC".ToString(); string LBMC = row"LBMC".ToString(); string GGXH = row"GGXH".ToString(); string CFDD = row"CFDD".ToString(); string SYBM = row"SYBM".ToString(); string S
12、YR = row"SYR".ToString(); string PDJG = row"PDJG".ToString(); string PDZT = row"PDZT".ToString(); string JSM = row"JSM".ToString(); string YBYZ = row"YBYZ".ToString(); string YJTYF = row"YJTYF".ToString(); string SYZK = row"SYZK".
13、ToString(); string PDRQ = row"PDRQ".ToString(); string strSql = "insert into KQD130129918_copy (SLID,RECNO,ZCBM,ZCMC,LBMC,GGXH,CFDD,SYBM,SYR,PDJG,PDZT,JSM,YBYZ,YJTYF,SYZK,PDRQ) values(" + SLID + "," + RECNO + ",'" + ZCBM + "','" + ZCMC +
14、"','" + LBMC + "','" + GGXH + "','" + CFDD + "','" + SYBM + "','" + SYR + "','" + PDJG + "','" + PDZT + "','" + JSM + "','" + YBYZ + "
15、;','" + YJTYF + "','" + SYZK + "',to_date('" + PDRQ + "','YYYY-mm-dd hh24:mi:ss')" / strSql += strSql; int resCount = KqDbOperationLibary.DBOperateHelper.GetDBInstence(KqDbOperationLibary.atomic.DB_INSTANCE.MISDataSouce.ToString(
16、).SendToExecute(strSql); catch (System.Exception ex) throw ex; / finally / / if (reader != null) / reader.Close(); / public void UpdateDatabase(string xmlFile) StringReader stream = null; XmlTextReader reader = null; try XmlDocument xmld = new XmlDocument(); xmld.Load(xmlFile); DataSet xmlDS = new D
17、ataSet(); stream = new StringReader(xmld.InnerXml); /从洙畇tream装痢载?到?XmlTextReader reader = new XmlTextReader(stream); xmlDS.ReadXml(reader); DataTable dt = xmlDS.Tables"b" DataSet dstemp=new DataSet(); string str = "" foreach (DataRow row in dt.Rows) str += "'" + row
18、"ZCBM".ToString() + "'," str=str.Substring(0, str.Length - 1); string cmdSqlDel = "delete KQD130129918_copy where zcbm in (" + str + ")" / string cmdSqlInser = "insert into KQD130129918_copy (SLID,RECNO,ZCBM,ZCMC,LBMC,GGXH,CFDD,SYBM,SYR,PDJG,PDZT,JSM,
19、YBYZ,YJTYF,SYZK,PDRQ) values(SLID ,RECNO , ZCBM , ZCMC,LBMC,GGXH,CFDD,SYBM,SYR,PDJG,PDZT,JSM,YBYZ,YJTYF,SYZK,to_date(PDRQ,'YYYY-mm-dd hh24:mi:ss')" string cmdSqlInser = "insert into KQD130129918_copy (SLID,RECNO,ZCBM,ZCMC,LBMC,GGXH,CFDD,SYBM,SYR,PDJG,PDZT,JSM,YBYZ,YJTYF,SYZK,PDRQ)
20、values(:SLID ,:RECNO,:ZCBM,:ZCMC,:LBMC,:GGXH,:CFDD,:SYBM,:SYR,:PDJG,:PDZT,:JSM,:YBYZ,:YJTYF,:SYZK,to_date(:PDRQ,'YYYY-mm-dd hh24:mi:ss')" / string cmdSqlYS = "select SLID,RECNO,ZCBM,ZCMC,LBMC,GGXH,CFDD,SYBM,SYR,PDJG,PDZT,JSM,YBYZ,YJTYF,SYZK,PDRQ from KQD130129918_copy" / DbCom
21、mand db = new DbCommand(); / db.CommandText = cmdSql; Database db = KqDbOperationLibary.DBOperateHelper.GetDBInstence(KqDbOperationLibary.atomic.DB_INSTANCE.MISDataSouce.ToString().getDatabase(); using (DbConnection conn = db.CreateConnection() DbCommand dbcommandDel = db.GetSqlStringCommand(cmdSqlD
22、el); DbCommand dbcommandIns = db.GetSqlStringCommand(cmdSqlInser); dbcommandIns.Connection = conn; conn.Open(); DbTransaction transe = conn.BeginTransaction(); try DbDataAdapter adapter = db.GetDataAdapter(); IDbDataAdapter iadapter = adapter; / if (deleteCommand != null) / / PrepareCommand(deleteCo
23、mmand, transe); / iadapter.DeleteCommand = deleteCommand; db.ExecuteNonQuery(dbcommandDel, transe); / / if (insertCommand != null) / / PrepareCommand(insertCommand, transe); / iadapter.InsertCommand = insertCommand; / / dbcommandIns.Parameters / iadapter.Fill(dstemp);, OracleParameter op = null; op=
24、new OracleParameter(":SLID", OracleDbType.Int32); op.IsNullable = true; op.SourceColumn = "SLID" dbcommandIns.Parameters.Add(op); op = new OracleParameter(":RECNO", OracleDbType.Int32); op.IsNullable = true; op.SourceColumn = "RECNO" dbcommandIns.Parameters.Ad
25、d(op); op = new OracleParameter(":ZCBM", OracleDbType.Varchar2); op.IsNullable = true; op.SourceColumn = "ZCBM" dbcommandIns.Parameters.Add(op); op = new OracleParameter(":ZCMC", OracleDbType.Varchar2); op.IsNullable = true; op.SourceColumn = "ZCMC" dbcommandI
26、ns.Parameters.Add(op); op = new OracleParameter(":LBMC", OracleDbType.Varchar2); op.IsNullable = true; op.SourceColumn = "LBMC" dbcommandIns.Parameters.Add(op); op = new OracleParameter(":GGXH", OracleDbType.Varchar2); op.IsNullable = true; op.SourceColumn = "GGXH&
27、quot; dbcommandIns.Parameters.Add(op); op = new OracleParameter(":CFDD", OracleDbType.Varchar2); op.IsNullable = true; op.SourceColumn = "CFDD" dbcommandIns.Parameters.Add(op); op = new OracleParameter(":SYBM", OracleDbType.Varchar2); op.IsNullable = true; op.SourceColu
28、mn = "SYBM" dbcommandIns.Parameters.Add(op); op = new OracleParameter(":SYR", OracleDbType.Varchar2); op.IsNullable = true; op.SourceColumn = "SYR" dbcommandIns.Parameters.Add(op); op = new OracleParameter(":PDJG", OracleDbType.Varchar2); op.IsNullable = true;
29、 op.SourceColumn = "PDJG" dbcommandIns.Parameters.Add(op); op = new OracleParameter(":PDZT", OracleDbType.Varchar2); op.IsNullable = true; op.SourceColumn = "PDZT" dbcommandIns.Parameters.Add(op); op = new OracleParameter(":JSM", OracleDbType.Varchar2); op.IsN
30、ullable = true; op.SourceColumn = "JSM" dbcommandIns.Parameters.Add(op); op = new OracleParameter(":YBYZ", OracleDbType.Varchar2); op.IsNullable = true; op.SourceColumn = "YBYZ" dbcommandIns.Parameters.Add(op); op = new OracleParameter(":YJTYF", OracleDbType.V
31、archar2); op.IsNullable = true; op.SourceColumn = "YJTYF" dbcommandIns.Parameters.Add(op); op = new OracleParameter(":SYZK", OracleDbType.Varchar2); op.IsNullable = true; op.SourceColumn = "SYZK" dbcommandIns.Parameters.Add(op); op = new OracleParameter(":PDRQ"
32、;, OracleDbType.Varchar2); op.IsNullable = true; op.SourceColumn = "PDRQ" dbcommandIns.Parameters.Add(op); iadapter.InsertCommand = dbcommandIns; adapter.Update(dt); transe.Commit(); catch (Exception ex) transe.Rollback(); conn.Close(); /将?异皑常入?库a StaticResource.ErrorEnqueue(Error_Code.err
33、or_noerror, "批ú量?更ü新?异皑常", ex); / return false; conn.Close(); /foreach (DataTable dt in xmlDS.Tables) / / DbHelper.UpdateDataSet(); /foreach (DataRow row in dt.Rows) / / bool b = IsCunZai(row"ZCBM".ToString(); / if (b) / / continue; / / else / / int SLID = int.Parse(row
34、"SLID".ToString(); / int RECNO = int.Parse(row"RECNO".ToString(); / string ZCBM = row"ZCBM".ToString(); / string ZCMC = row"ZCMC".ToString(); / string LBMC = row"LBMC".ToString(); / string GGXH = row"GGXH".ToString(); / string CFDD = row&qu
35、ot;CFDD".ToString(); / string SYBM = row"SYBM".ToString(); / string SYR = row"SYR".ToString(); / string PDJG = row"PDJG".ToString(); / string PDZT = row"PDZT".ToString(); / string JSM = row"JSM".ToString(); / string YBYZ = row"YBYZ".To
36、String(); / string YJTYF = row"YJTYF".ToString(); / string SYZK = row"SYZK".ToString(); / string PDRQ = row"PDRQ".ToString(); / string strSql = "insert into KQD130129918_copy (SLID,RECNO,ZCBM,ZCMC,LBMC,GGXH,CFDD,SYBM,SYR,PDJG,PDZT,JSM,YBYZ,YJTYF,SYZK,PDRQ) values(&
37、quot; + SLID + "," + RECNO + ",'" + ZCBM + "','" + ZCMC + "','" + LBMC + "','" + GGXH + "','" + CFDD + "','" + SYBM + "','" + SYR + "','" + PDJG + &qu
38、ot;','" + PDZT + "','" + JSM + "','" + YBYZ + "','" + YJTYF + "','" + SYZK + "',to_date('" + PDRQ + "','YYYY-mm-dd hh24:mi:ss')" / int resCount = KqDbOperationLibary.DBOperate
39、Helper.GetDBInstence(KqDbOperationLibary.atomic.DB_INSTANCE.MISDataSouce.ToString().SendToExecute(strSql); / / / catch (System.Exception ex) throw ex; / finally / / if (reader != null) / reader.Close(); / public void UpdateTable(string xmlFile) StringReader stream = null; XmlTextReader reader = null
40、; try XmlDocument xmld = new XmlDocument(); xmld.Load(xmlFile); DataSet xmlDS = new DataSet(); stream = new StringReader(xmld.InnerXml); /从洙畇tream装痢载?到?XmlTextReader reader = new XmlTextReader(stream); xmlDS.ReadXml(reader); DataTable dt = xmlDS.Tables"b" string str = "" foreach
41、(DataRow row in dt.Rows) str += "'" + row"ZCBM".ToString() + "'," str = str.Substring(0, str.Length - 1); string cmdSqlDel = "delete KQD130129918_copy where zcbm in (" + str + ")" string cmdSqlInser = "insert into KQD130129918_copy (SLID
42、,RECNO,ZCBM,ZCMC,LBMC,GGXH,CFDD,SYBM,SYR,PDJG,PDZT,JSM,YBYZ,YJTYF,SYZK,PDRQ) values(:SLID ,:RECNO,:ZCBM,:ZCMC,:LBMC,:GGXH,:CFDD,:SYBM,:SYR,:PDJG,:PDZT,:JSM,:YBYZ,:YJTYF,:SYZK,to_date(:PDRQ,'YYYY-mm-dd hh24:mi:ss')" DbCommand dbcommandDel = new OracleCommand(cmdSqlDel); DbCommand dbcomma
43、ndIns = new OracleCommand(cmdSqlInser); dbcommandIns = getDbCommand(dbcommandIns, dt); string dbsign = KqDbOperationLibary.atomic.DB_INSTANCE.MISDataSouce.ToString(); KqFormEngineLibrary3.DbHelper.UpdateDataSet(dt, dbcommandDel, dbcommandIns, dbsign); catch (System.Exception ex) public DbCommand get
44、DbCommand(DbCommand dbcommandIns,DataTable dt) OracleParameter op = null; string colName="" foreach (DataColumn col in dt.Columns) colName=col.ColumnName.ToString(); if (colName = "SLID" | colName = "RECNO") op = new OracleParameter(":" + col.ColumnName.ToString(), OracleDbType.Int32); else op = new OracleParameter(":" + c
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 教案 分数的意义
- 建筑工程技术资料管理教案
- 100句励志经典语录
- 智能家居安全的可靠防护方案设计和实施
- 数据终端设备账务处理实例-记账实操
- 猫和老鼠课件
- 2024年粮油加工机械项目评估分析报告
- 2024年航空运输辅助服务项目成效分析报告
- 2019湘美版 高中美术 选择性必修3 雕塑《第三单元 雕塑的探索与展望》大单元整体教学设计2020课标
- 菜鸟驿站转让合同协议书范本
- ICH指南指导原则Q8(R2)药品研发
- 2022玻璃栈道工程技术规程
- 幼儿园课件小小银行家
- 离婚登记申请受理回执单
- 初高中数学衔接讲座
- SAPO-34沸石分子筛的合成课件
- 华北电网调度管理规程
- 鸟类系统分类课件
- 肿瘤科运用PDCA循环降低癌痛患者爆发性疼痛发生率品管圈成果汇报
- 比亚迪唐DM-i说明书
- 肠道准备指南解读
评论
0/150
提交评论