//检查k号是否存在 //public Boolean checkKno(string Kno) { // string oracleSid = textBox4.Text.Trim(); // string oracleName = textBox5.Text.Trim(); // string oraclePwd = textBox6.Text.Trim(); // string constring = "Data Source=" + oracleSid + ";Persist Security Info=True;User ID=" + oracleName + ";Password="******";Unicode=True"; // DBHelperORACLE doo = new DBHelperORACLE(constring); // string sql = "select count(*) from scene_investigation where INVESTIGATION_NO='"+Kno+"'"; // Object c = doo.execScalar(sql); // int count = int.Parse(c.ToString()); // if (count > 0) // { // return true; // } // else { // return false; // } //} private void button2_Click(object sender, EventArgs e) { if (checkInput()) { //先检查数据库配置是否正确 string inv_no = textBox2.Text.Trim(); //string oracleSid = textBox4.Text.Trim(); //string oracleName = textBox5.Text.Trim(); //string oraclePwd = textBox6.Text.Trim(); // string aa = HttpService.HttpPost("http://localhost:8080/BSINFO/manager/selectKid.do?inv_no=" + inv_no,""); //if (aa=="Yes") //{ //再检查文件是否真实存在并可正确读取 if (File.Exists(textBox1.Text)) { //if (checkCaseInfo(inv_no)) //{ //尝试转换对应的文件 XmlDocument xmldoc = createXml(inv_no, "admin", "456c2e75fe0faa57fd1cfd87117e0963", "52813100500148620140730230647098"); if (xmldoc != null) { //最后将转换后的数据按地址(GPS)为依据逐个作为这个K号的多个记录导入 string path = Application.StartupPath + "\\data.xml"; byte[] data; FileStream fs = File.OpenRead(path); data = new byte[fs.Length]; fs.Read(data, 0, Convert.ToInt32(fs.Length)); fs.Close(); Program.LastError = ""; string checkOraclexml = HttpService.HttpPost1("http://localhost:8080/BSINFO/CheckDB.do"); Console.WriteLine("TTTT" + checkOraclexml); XmlDocument xmlDoc1 = new XmlDocument(); xmlDoc1.LoadXml(checkOraclexml); XmlNode rootNode1 = xmlDoc1.SelectSingleNode("response"); XmlNodeList datas1 = rootNode1.ChildNodes[0].ChildNodes; string checkOracle = datas1[0].InnerText; if (checkOracle == "目标库验证通过") { Console.WriteLine("oracleok"); string xmlStr = HttpService.HttpPost("http://localhost:8080/BSINFO/AddKCT.do", xmldoc); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlStr); XmlNode rootNode = xmlDoc.SelectSingleNode("response"); XmlNodeList datas = rootNode.ChildNodes[0].ChildNodes; string returnMessage = datas[0].InnerText; if (returnMessage == "解密失败") { MessageBox.Show("解密失败"); } else if (returnMessage == "此设备已超出使用范围") { MessageBox.Show("此设备已超出使用范围"); } else if (returnMessage == "用户名或密码错误") { MessageBox.Show("用户名或密码错误!"); } else if (returnMessage == "此设备没有权限") { MessageBox.Show("此设备没有权限"); } else if (returnMessage == "您输入的k号不存在") { MessageBox.Show("您输入的k号不存在"); } else { if (returnMessage == "success") { MessageBox.Show("导入完成!"); } else { MessageBox.Show("导入失败!"); } } } else if (checkOracle == "") { MessageBox.Show(""); } else if (checkOracle == "") { MessageBox.Show(""); } else { } Console.WriteLine("oracle" + checkOracle); } else { MessageBox.Show("XML文件生成失败"); } } else { MessageBox.Show("文件不存在!"); } } }
private void button2_Click(object sender, EventArgs e) { if (checkInput()) { string inv_no = txtKCH.Text.Trim(); string filePath = txtfile.Text.Trim(); string deviceid = txtUUID.Text.Trim(); string xkuser = txtuser.Text.Trim(); string xkpass = Tool.GetMD5(txtpass.Text.Trim()); string xml = "<?xml version=\"1.0\" encoding=\"gb2312\"?>" + @"<REQUEST> <SERVICESKEY> 111 </SERVICESKEY > <APPKEY> 222 </APPKEY > <PARAMS> <KID> " + inv_no + @" </KID> <KCT_UUID> " + deviceid + @" </KCT_UUID> <USERNAME> " + xkuser + @" </USERNAME> <PASSWORD> " + xkpass + @" </PASSWORD> </PARAMS> </REQUEST>"; string checkOraclexml = HttpService.HttpPostXML(Program.ServerRoot + "CheckKCT.do", xml); XmlDocument xmlDoc1 = new XmlDocument(); xmlDoc1.LoadXml(checkOraclexml); XmlNode rootNode1 = xmlDoc1.SelectSingleNode("response"); XmlNodeList datas1 = rootNode1.ChildNodes[0].ChildNodes; string returnMessage = datas1[0].InnerText; if (returnMessage == "解密失败") { MessageBox.Show("解密失败"); return; } else if (returnMessage == "此设备已超出使用范围") { MessageBox.Show("此设备已超出使用范围"); return; } else if (returnMessage == "用户名或密码错误") { MessageBox.Show("用户名或密码错误!"); return; } else if (returnMessage == "此设备没有权限") { MessageBox.Show("此设备没有权限"); return; } else if (returnMessage == "您输入的k号不存在") { MessageBox.Show("您输入的k号不存在"); return; } XmlDocument xmldoc = createXml(inv_no, xkuser, xkpass, deviceid); if (xmldoc != null) { //最后将转换后的数据按地址(GPS)为依据逐个作为这个K号的多个记录导入 string path = Application.StartupPath + "\\data.xml"; xmldoc.Save(path); Program.LastError = ""; string xmlStr = HttpService.HttpPost(Program.ServerRoot + "AddKCT.do", xmldoc); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlStr); XmlNode rootNode = xmlDoc.SelectSingleNode("response"); XmlNodeList datas = rootNode.ChildNodes[0].ChildNodes; returnMessage = datas[0].InnerText; if (returnMessage == "解密失败") { MessageBox.Show("解密失败"); } else if (returnMessage == "此设备已超出使用范围") { MessageBox.Show("此设备已超出使用范围"); } else if (returnMessage == "用户名或密码错误") { MessageBox.Show("用户名或密码错误!"); } else if (returnMessage == "此设备没有权限") { MessageBox.Show("此设备没有权限"); } else if (returnMessage == "您输入的k号不存在") { MessageBox.Show("您输入的k号不存在"); } else { if (returnMessage == "success") { MessageBox.Show("导入完成!"); } else { MessageBox.Show("导入失败!"); } } } else { MessageBox.Show("XML文件生成失败"); } } }