一、首先,CXF的WS实现类由于实现了和Spring的无缝集成,因此可以采用Spring的单元测试来测试基本功能。
代码如下:
[java]
package com.defshare.sy.test.biz;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.UUID;
import javax.annotation.Resource;
import org.apache.commons.io.IOUtils;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.junit.Test;
import com.defshare.sy.ws.ISYWebService;
import com.defshare.sy.ws.po.Clinique;
import com.defshare.sy.ws.po.WorkList;
import com.defshare.sy.ws.po.WorkListPicFile;
public class SyWebServiceTest extends SpringTestTemplate{
@Test
public void testUploadWorkListPicFile(){
//JaxWsProxyFactoryBean proxy = new JaxWsProxyFactoryBean();
//proxy.setAddress("http://localhost:8090/sy/services/SYWebService");
//proxy.setServiceClass(ISYWebService.class);
//ISYWebService clientProxy = (ISYWebService)proxy.create();
//clientProxy.upLoadWorkListPic("", "",null);
WorkListPicFile file = new WorkListPicFile();
String serverFile = UUID.randomUUID().toString()+".DBF";
InputStream is = null;
try {
is = new FileInputStream("d:/QUESCTION.DBF");
file.setFileSize(is.available());
byte[] bytes = new byte[1024 * 1024];
int size=0;
do{
size = is.read(bytes);
if (size <= 0) {
break;
}
byte[] fixedBytes = Arrays.copyOfRange(bytes, 0, size);
file.setBytes(fixedBytes);
file.setServerFile(serverFile);
file.setWorkListId("WL0001");
int resp = syWebService.upLoadWorkListPic("WS访问账户","WS访问密码", file);
System.out.println(resp==0?"本次上传文件块成功":"本次上传文件块异常");
if (resp!=0)
break;
file.setPosition(file.getPosition() + fixedBytes.length);
}while(size>0);
} catch(IOException e) {
e.printStackTrace();
} finally {
if (is!=null)
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
IOUtils.closeQuietly(is);
}
}
@Test
public void testremoveWorkList(){
正常输入数据1 期望结果:成功 实际结果:
syWebService.removeWorkList("WS访问账户", "WS访问密码", "q");
}
@Test
public void testUpdateWorkList(){
WorkList wl = new WorkList();
wl.setGdbh("WL0001");
wl.setFggdbh("hehe-------");
syWebService.updateWorkList("WS访问账户", "WS访问密码", wl);
}
@Test
public void updateClinique(){
Clinique c = new Clinique();
c.setZsid("CL0001");
c.setDq("金牛区-------");
System.out.println("*******"+syWebService.updateClinique("WS访问账户", "WS访问密码", c));
}
@Resource(name="syWebService")
private ISYWebService syWebService;
@Resource(name="syWebService")
public void setSyWebService(ISYWebService syWebService) {
this.syWebService = syWebService;
}
}
二、待单元测试通过后在进行WebService调用测试,这需要发布这个WebService到服务器上:
我的这个WS发布后的WSDL如下:
http://192.168.1.89:92/services/SYWebService?wsdl
[html]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Java的测试客户端如下:
[java]
package com.defshare.sy.test.ws;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.UUID;
import org.apache.commons.io.IOUtils;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.junit.Test;
import com.defshare.sy.po.ToothSpec;
import com.defshare.sy.ws.ISYWebService;
import com.defshare.sy.ws.po.Clinique;
import com.defshare.sy.ws.po.WorkList;
import com.defshare.sy.ws.po.WorkListPicFile;
public class syWebServiceClientTest {
/**
* 图片上传测试
*/
@Test
public void testUpLoadWorkListPic() {
JaxWsProxyFactoryBean proxy = new JaxWsProxyFactoryBean();
proxy.setAddress("http://localhost:8090/sy/services/SYWebService");
proxy.setServiceClass(ISYWebService.class);
ISYWebService clientProxy = (ISYWebService)proxy.create();
WorkListPicFile file = new WorkListPicFile();
String serverFile = UUID.randomUUID().toString()+".rar";
InputStream is = null;
try {
is = new FileInputStream("d:/webtemp.rar");
file.setFileSize(is.available());
file.setServerFile(serverFile);
byte[] bytes = new byte[1024 * 1024];
int size=0;
do{
size = is.read(bytes);
if (size <= 0) {
break;
}
byte[] fixedBytes = Arrays.copyOfRange(bytes, 0, size);
file.setBytes(fixedBytes);
file.setWorkListId("WL0001");
int resp = clientProxy.upLoadWorkListPic("WS访问账户","WS访问密码", file);
System.out.println(resp==0?"本次上传文件块成功"+fixedBytes.length+"字节,已上传"+(file.getPosition()+fixedBytes.length)+"/"+file.getFileSize()+"字节":"本次上传文件块异常");
if (resp!=0)
break;
file.setPosition(file.getPosition() + fixedBytes.length);
}while(size>0);
} catch(IOException e) {
e.printStackTrace();
} finally {
if (is!=null)
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
IOUtils.closeQuietly(is);
}
}
@Test
public void testremoveWorkList(){
JaxWsProxyFactoryBean proxy = new JaxWsProxyFactoryBean();
proxy.setAddress("http://localhost:8080/sy/services/SYWebService");
proxy.setServiceClass(ISYWebService.class);
ISYWebService clientProxy = (ISYWebService)proxy.create();
clientProxy.removeWorkList("WS访问账户", "WS访问密码", "sdfghj");
}
@Test
public void testUpdateWorkList(){
JaxWsProxyFactoryBean proxy = new JaxWsProxyFactoryBean();
proxy.setAddress("http://localhost:8080/sy/services/SYWebService");
proxy.setServiceClass(ISYWebService.class);
ISYWebService clientProxy = (ISYWebService)proxy.create();
WorkList ws = new WorkList();
com.defshare.sy.ws.po.ToothSpec[] tt=new com.defshare.sy.ws.po.ToothSpec[2];
com.defshare.sy.ws.po.ToothSpec t=new com.defshare.sy.ws.po.ToothSpec();
ws.setGdbh("WL0001");
ws.setZsid("CL0001");
ws.setYsxm("王医生");
ws.setBrxm("张发亏");
// ws.setJjrq("2012-09-12");
t.setToothSpecId("sx001");
t.setGdbh("WL0005");
t.setYclx("进口烤瓷牙1111");
t.setYw("A1-B6");
t.setYs("A2");
t.setSl(2);
t.setAddsl(0);
t.setDx("大");
t.setZl("smsm");
t.setGx("接单中·····");
tt[0]=t;
com.defshare.sy.ws.po.ToothSpec ts=new com.defshare.sy.ws.po.ToothSpec();
ts.setGdbh("WL0001");
ts.setToothSpecId("sx002");
ts.setYclx("进口烤瓷牙22222");
ts.setYw("A1-B6");
ts.setYs("A2");
ts.setSl(2);
ts.setAddsl(0);
ts.setDx("大");
tt[1]=ts;
ws.setToothSpecs(tt);
System.out.println(clientProxy.updateWorkList("WS访问账户", "WS访问密码", ws));
}
@Test
public void upLoadClinique(){
JaxWsProxyFactoryBean proxy = new JaxWsProxyFactoryBean();
proxy.setAddress("http://localhost:8090/sy/services/SYWebService");
proxy.setServiceClass(ISYWebService.class);
ISYWebService clientProxy = (ISYWebService)proxy.create();
Clinique[] cliniques = new Clinique[3];
cliniques[0] = new Clinique();
cliniques[0].setZsid("ZS004");
cliniques[0].setDq("成都区");
cliniques[0].setDqbh("1");
cliniques[0].setDxts(10);
cliniques[0].setLxdh("13699451030");
cliniques[0].setYsxm("蒋医生");
cliniques[0].setYwjl("黄经理");
cliniques[0].setYwy("小明");
cliniques[0].setZsdz("成都金牛区");
cliniques[0].setZsjx("asdf");
cliniques[0].setZsmc("中西医院");
cliniques[0].setZsmm("123456");
cliniques[1] = new Clinique();
cliniques[1].setZsid("ZS005");
cliniques[1].setDq("绵阳区");
cliniques[1].setDqbh("2");
cliniques[1].setDxts(15);
cliniques[1].setLxdh("15015157972");
cliniques[1].setYsxm("董医生");
cliniques[1].setYwjl("胡经理");
cliniques[1].setYwy("小强");
cliniques[1].setZsdz("成都金牛区");
cliniques[1].setZsjx("asdf");
cliniques[1].setZsmc("中西医院");
cliniques[1].setZsmm("123456");
cliniques[2] = new Clinique();
cliniques[2].setZsid("ZS006");
cliniques[2].setDq("湖北区");
cliniques[2].setDqbh("3");
cliniques[2].setDxts(10);
cliniques[2].setLxdh("13699451030");
cliniques[2].setYsxm("顾医生");
cliniques[2].setYwjl("赵经理");
cliniques[2].setYwy("小黄");
cliniques[2].setZsdz("成都金牛区");
cliniques[2].setZsjx("asdf");
cliniques[2].setZsmc("中西医院");
cliniques[2].setZsmm("123456");
clientProxy.upLoadClinique("WS访问账户", "WS访问密码", cliniques);
}
@Test
public void upLoadWorkList(){
JaxWsProxyFactoryBean proxy = new JaxWsProxyFactoryBean();
proxy.setAddress("http://localhost:8080/sy/services/SYWebService");
proxy.setServiceClass(ISYWebService.class);
ISYWebService clientProxy = (ISYWebService)proxy.create();
WorkList[] workList = new WorkList[2];
workList[0] = new WorkList();
workList[0].setBrxm("小强哥");
workList[0].setCjr("某某");
workList[0].setCjrq("2012-12-12 13:10:00");
workList[0].setFggdbh("001");
workList[0].setFgyy("工单打回");
workList[0].setGdbh("w9527");
workList[0].setJjrq("2012-12-12 13:10:00");
workList[0].setJzrq("2012-12-12 13:10:00");
workList[0].setLuz("张山");
workList[0].setPics("asdfsadf.jsp");
workList[0].setSsdq("成都");
workList[0].setXgcs("1");
workList[0].setXgrq("2012-12-12 13:10:00");
workList[0].setYsxm("蒋医生");
workList[0].setYwy("李四");
workList[0].setZsid("ZS003");
workList[1] = new WorkList();
workList[1].setBrxm("王哥");
workList[1].setCjr("某某");
workList[1].setCjrq("2012-12-12 13:10:00");
workList[1].setFggdbh("002");
workList[1].setFgyy("工单打回");
workList[1].setGdbh("w9528");
workList[1].setJjrq("2012-12-12 13:10:00");
workList[1].setJzrq("2012-12-12 13:10:00");
workList[1].setLuz("张山");
workList[1].setPics("asdfsadf.jsp");
workList[1].setSsdq("成都");
workList[1].setXgcs("2");
workList[1].setXgrq("2012-12-12 13:10:00");
workList[1].setYsxm("蒋医生");
workList[1].setYwy("李四");
workList[1].setZsid("ZS003");
com.defshare.sy.ws.po.ToothSpec[] tt=new com.defshare.sy.ws.po.ToothSpec[2];
com.defshare.sy.ws.po.ToothSpec t=new com.defshare.sy.ws.po.ToothSpec();
// ws.setJjrq("2012-09-12");
t.setGdbh("WL0005");
t.setYclx("进口烤瓷牙");
t.setYw("A1-B6");
t.setYs("A2");
t.setSl(2);
t.setAddsl(0);
t.setDx("大");
tt[0]=t;
com.defshare.sy.ws.po.ToothSpec ts=new com.defshare.sy.ws.po.ToothSpec();
ts.setGdbh("WL0001");
ts.setYclx("进口烤瓷牙");
ts.setYw("A1-B6");
ts.setYs("A2");
ts.setSl(2);
ts.setAddsl(0);
ts.setDx("大");
tt[1]=ts;
workList[1].setToothSpecs(tt);
int result = clientProxy.upLoadWorkList("WS访问账户", "WS访问密码", workList);
System.out.println(result);
}
@Test
public void updateToothSpecGX(){
JaxWsProxyFactoryBean proxy = new JaxWsProxyFactoryBean();
proxy.setAddress("http://localhost:8080/sy/services/SYWebService");
proxy.setServiceClass(ISYWebService.class);
ISYWebService clientProxy = (ISYWebService)proxy.create();
int result = clientProxy.updateToothSpecGX("sx001", "11111");
System.out.println(result);
}
}
三、.NET测试客户端如下:
实现代码如下:
[csharp]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SYWSClient.ServiceRef;
using System.IO;
namespace SYWSClient
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
/**
* 上传诊所
**/
private void btnsyloadzs_Click(object sender, EventArgs e)
{
Clinique clinique = new Clinique();
if (this.txtzsid.Text == "")
{
MessageBox.Show("诊所编号不能为空.....");
return;
}
if (this.txtzsmc.Text == "")
{
MessageBox.Show("诊所名称不能为空.....");
return;
}
if (this.txtzsmm.Text == "")
{
MessageBox.Show("诊所密码不能为空.....");
return;
}
if (this.txtysmc.Text == "")
{
MessageBox.Show("诊所医生不能为空.....");
return;
}
//封装诊所的信息
clinique.zsid = this.txtzsid.Text;
clinique.zsmm = this.txtzsmm.Text;
clinique.zsmc = this.txtzsmc.Text;
clinique.ysxm = this.txtysmc.Text;
clinique.lxdh = this.txtlxdh.Text;
clinique.zsjx = this.txtzsjx.Text;
clinique.zsdz = this.txtzsdz.Text;
clinique.dq = this.txtzsdq.Text;
clinique.dqbh = this.txtdqbh.Text;
clinique.ywy = this.txtywy.Text;
clinique.ywjl = this.txtywjl.Text;
//实例webserverce客户端
SYWebServiceClient client = new SYWebServiceClient();
int flag = client.upLoadClinique("WS访问访问账户", "WS访问密码", new Clinique[] { clinique });
switch (flag)
{
case 0:
MessageBox.Show("上传诊所信息成功!");
break;
case 1:
MessageBox.Show("工单编号为空");
break;
case 2:
MessageBox.Show("诊所编号为空");
break;
case 3:
MessageBox.Show("没有文件信息上传");
break;
case 4:
MessageBox.Show("没有工单信息可以上传");
break;
case 5:
MessageBox.Show("没有工单图片文件可以上传");
break;
case 6:
MessageBox.Show("没有诊所信息可以上传");
break;
case 7:
MessageBox.Show("没有诊所信息可以上传");
break;
case 8:
MessageBox.Show("没有诊所信息可以更新");
break;
case 9:
MessageBox.Show("不安全的调用");
break;
case 10:
MessageBox.Show("不存在的工单[上传工单图片时检查]");
break;
case 11:
MessageBox.Show("输入输出异常");
break;
case 12:
MessageBox.Show("录入数据失败[存在重复数据]");
break;
case 13:
MessageBox.Show("应用程序异常");
break;
case 14:
MessageBox.Show("数据库异常");
break;
}
}
private void btnsyupdatezs_Click(object sender, EventArgs e)
{
Clinique clinique = new Clinique();
if (this.txtzsid.Text == "")
{
MessageBox.Show("诊所编号不能为空.....");
return;
}
if (this.txtzsmc.Text == "")
{
MessageBox.Show("诊所名称不能为空.....");
return;
}
if (this.txtzsmm.Text == "")
{
MessageBox.Show("诊所密码不能为空.....");
return;
}
if (this.txtysmc.Text == "")
{
MessageBox.Show("诊所医生不能为空.....");
return;
}
//封装诊所的信息
clinique.zsid = this.txtzsid.Text;
clinique.zsmm = this.txtzsmm.Text;
clinique.zsmc = this.txtzsmc.Text;
clinique.ysxm = this.txtysmc.Text;
clinique.lxdh = this.txtlxdh.Text;
clinique.zsjx = this.txtzsjx.Text;
clinique.zsdz = this.txtzsdz.Text;
clinique.dq = this.txtzsdq.Text;
clinique.dqbh = this.txtdqbh.Text;
clinique.ywy = this.txtywy.Text;
clinique.ywjl = this.txtywjl.Text;
ServiceRef.SYWebServiceClient c = new ServiceRef.SYWebServiceClient();
int flag = c.updateClinique("WS访问访问账户", "WS访问密码", clinique);
switch (flag)
{
case 0:
MessageBox.Show("修改诊所信息成功!");
break;
case 1:
MessageBox.Show("工单编号为空");
break;
case 2:
MessageBox.Show("诊所编号为空");
break;
case 3:
MessageBox.Show("没有文件信息上传");
break;
case 4:
MessageBox.Show("没有工单信息可以上传");
break;
case 5:
MessageBox.Show("没有工单图片文件可以上传");
break;
case 6:
MessageBox.Show("没有诊所信息可以上传");
break;
case 7:
MessageBox.Show("没有诊所信息可以上传");
break;
case 8:
MessageBox.Show("没有诊所信息可以更新");
break;
case 9:
MessageBox.Show("不安全的调用");
break;
case 10:
MessageBox.Show("不存在的工单[上传工单图片时检查]");
break;
case 11:
MessageBox.Show("输入输出异常");
break;
case 12:
MessageBox.Show("录入数据失败[存在重复数据]");
break;
case 13:
MessageBox.Show("应用程序异常");
break;
case 14:
MessageBox.Show("数据库异常");
break;
}
}
///
/// 上传工单
///
///
///
private void btnUploadWorkList_Click(object sender, EventArgs e)
{
WorkList w = new WorkList();
if (txtgdbh.Text == "")
{
MessageBox.Show("工单编号不能为空");
return;
}
w.gdbh = txtgdbh.Text;
if (txtfggdbh.Text == "")
{
MessageBox.Show("返工原单号不能为空!");
return;
}
w.fggdbh = txtfggdbh.Text;
if (txtzsidwokelist.Text == "")
{
MessageBox.Show("诊所编号不能为空");
return;
}
w.zsid = txtzsidwokelist.Text;
if (txtysxm.Text == "")
{
MessageBox.Show("医生姓名不能为空");
return;
}
w.ysxm = txtysxm.Text;
if (txtbrxm.Text == "")
{
MessageBox.Show("病人姓名不能为空");
return;
}
w.brxm = txtbrxm.Text;
if (textBox7.Text == "")
{
MessageBox.Show("业务员不能为空");
return;
}
w.ywy = textBox7.Text;
if (txtssdq.Text == "")
{
MessageBox.Show("所属地区不能为空");
return;
}
w.ssdq = txtssdq.Text;
if (txtfgyy.Text == "")
{
MessageBox.Show("返工原因不能为空");
}
//格式化日期
w.jjrq = ftpjjrq.Value.ToString("yyyy-mm-dd hh:mm:ss");
w.cjrq = ftpcjrq.Value.ToString("yyyy-mm-dd hh:mm:ss");
w.jzrq = dtpjzrq.Value.ToString("yyyy-mm-dd hh:mm:ss");
w.xgrq = dtpxgrq.Value.ToString("yyyy-mm-dd hh:mm:ss");
if (txtluz.Text == "")
{
MessageBox.Show("录入人不能为空");
return;
}
w.luz = txtcjr.Text;
ToothSpec ts = new ToothSpec();
if (txttoothSpecId.Text == "")
{
MessageBox.Show("规格编号不能为空");
return;
}
ts.toothSpecId = txttoothSpecId.Text;
if (txtlx.Text == "")
{
MessageBox.Show("牙齿类型不能为空");
return;
}
ts.yclx = txtlx.Text;
if (texzl.Text == "")
{
MessageBox.Show("牙齿总类不能为空");
return;
}
ts.zl = texzl.Text;
if (txtys.Text == "")
{
MessageBox.Show("牙齿颜色不能为空");
return;
}
ts.ys = txtys.Text;
if (txxjg.Text == "")
{
MessageBox.Show("JG不能为空");
return;
}
ts.jg = int.Parse(txxjg.Text);
if (textyw.Text == "")
{
MessageBox.Show("牙位不能为空");
return;
}
ts.yw = textyw.Text;
if (txtdx.Text == "")
{
MessageBox.Show("牙齿大小不能为空");
return;
}
ts.dx = txtdx.Text;
if (textsl.Text == "")
{
MessageBox.Show("数量1不能为空");
return;
}
ts.sl = int.Parse(textsl.Text);
if (textaddsl.Text == "")
{
MessageBox.Show("数量2不能为空");
return;
}
ts.addsl = int.Parse(textaddsl.Text);
if (txthbhid.Text == "")
{
MessageBox.Show("hbhid不能为空");
return;
}
ts.hbhid = txthbhid.Text;
if (txtgx.Text == "")
{
MessageBox.Show("工序不能为空");
return;
}
ts.gx = txthbhid.Text;
w.toothSpecs = new ToothSpec[] { ts };
SYWebServiceClient webService = new SYWebServiceClient();
int flag = webService.upLoadWorkList("WS访问访问账户", "WS访问密码", new WorkList[] { w });
switch (flag)
{
case 0:
MessageBox.Show("上传工单成功!");
break;
case 1:
MessageBox.Show("工单编号为空");
break;
case 2:
MessageBox.Show("诊所编号为空");
break;
case 3:
MessageBox.Show("没有文件信息上传");
break;
case 4:
MessageBox.Show("没有工单信息可以上传");
break;
case 5:
MessageBox.Show("没有工单图片文件可以上传");
break;
case 6:
MessageBox.Show("没有诊所信息可以上传");
break;
case 7:
MessageBox.Show("没有诊所信息可以上传");
break;
case 8:
MessageBox.Show("没有诊所信息可以更新");
break;
case 9:
MessageBox.Show("不安全的调用");
break;
case 10:
MessageBox.Show("不存在的工单[上传工单图片时检查]");
break;
case 11:
MessageBox.Show("输入输出异常");
break;
case 12:
MessageBox.Show("录入数据失败[存在重复数据]");
break;
case 13:
MessageBox.Show("应用程序异常");
break;
case 14:
MessageBox.Show("数据库异常");
break;
}
}
///
/// 更新工单
///
///
///
private void btnUpdateWorkList_Click(object sender, EventArgs e)
{
WorkList w = new WorkList();
if (txtgdbh.Text == "")
{
MessageBox.Show("工单编号不能为空");
return;
}
w.gdbh = txtgdbh.Text;
if (txtfggdbh.Text == "")
{
MessageBox.Show("返工原单号不能为空!");
return;
}
w.fggdbh = txtfggdbh.Text;
if (txtzsidwokelist.Text == "")
{
MessageBox.Show("诊所编号不能为空");
return;
}
w.zsid = txtzsidwokelist.Text;
if (txtysxm.Text == "")
{
MessageBox.Show("医生姓名不能为空");
return;
}
w.ysxm = txtysxm.Text;
if (txtbrxm.Text == "")
{
MessageBox.Show("病人姓名不能为空");
return;
}
w.brxm = txtbrxm.Text;
if (textBox7.Text == "")
{
MessageBox.Show("业务员不能为空");
return;
}
w.ywy = textBox7.Text;
if (txtssdq.Text == "")
{
MessageBox.Show("所属地区不能为空");
return;
}
w.ssdq = txtssdq.Text;
if (txtfgyy.Text == "")
{
MessageBox.Show("返工原因不能为空");
}
w.cjrq = ftpcjrq.Value.ToString("yyyy-mm-dd hh:mm:ss");
w.jzrq = dtpjzrq.Value.ToString("yyyy-mm-dd hh:mm:ss");
w.xgrq = dtpxgrq.Value.ToString("yyyy-mm-dd hh:mm:ss");
ToothSpec ts = new ToothSpec();
if (txttoothSpecId.Text == "") {
MessageBox.Show("规格编号不能为空");
return;
}
ts.toothSpecId = txttoothSpecId.Text;
if (txtluz.Text == "")
{
MessageBox.Show("录入人不能为空");
return;
}
w.luz = txtcjr.Text;
if (txtlx.Text == "")
{
MessageBox.Show("牙齿类型不能为空");
return;
}
ts.yclx = txtlx.Text;
if (texzl.Text == "")
{
MessageBox.Show("牙齿总类不能为空");
return;
}
ts.zl = texzl.Text;
if (txtys.Text == "")
{
MessageBox.Show("牙齿颜色不能为空");
return;
}
ts.ys = txtys.Text;
if (txxjg.Text == "")
{
MessageBox.Show("JG不能为空");
return;
}
ts.jg = int.Parse(txxjg.Text);
if (textyw.Text == "")
{
MessageBox.Show("牙位不能为空");
return;
}
ts.yw = textyw.Text;
if (txtdx.Text == "")
{
MessageBox.Show("牙齿大小不能为空");
return;
}
ts.dx = txtdx.Text;
if (textsl.Text == "")
{
MessageBox.Show("数量1不能为空");
return;
}
ts.sl = int.Parse(textsl.Text);
if (textaddsl.Text == "")
{
MessageBox.Show("数量2不能为空");
return;
}
ts.addsl = int.Parse(textaddsl.Text);
if (txthbhid.Text == "")
{
MessageBox.Show("hbhid不能为空");
return;
}
ts.hbhid = txthbhid.Text;
if (txtgx.Text == "")
{
MessageBox.Show("工序不能为空");
return;
}
ts.gx = txthbhid.Text;
w.toothSpecs = new ToothSpec[] { ts };
SYWebServiceClient webService = new SYWebServiceClient();
int flag = webService.updateWorkList("WS访问访问账户", "WS访问密码", w);
switch (flag)
{
case 0:
MessageBox.Show("更新工单成功!");
break;
case 1:
MessageBox.Show("工单编号为空");
break;
case 2:
MessageBox.Show("诊所编号为空");
break;
case 3:
MessageBox.Show("没有文件信息上传");
break;
case 4:
MessageBox.Show("没有工单信息可以上传");
break;
case 5:
MessageBox.Show("没有工单图片文件可以上传");
break;
case 6:
MessageBox.Show("没有诊所信息可以上传");
break;
case 7:
MessageBox.Show("没有诊所信息可以上传");
break;
case 8:
MessageBox.Show("没有诊所信息可以更新");
break;
case 9:
MessageBox.Show("不安全的调用");
break;
case 10:
MessageBox.Show("不存在的工单[上传工单图片时检查]");
break;
case 11:
MessageBox.Show("输入输出异常");
break;
case 12:
MessageBox.Show("录入数据失败[存在重复数据]");
break;
case 13:
MessageBox.Show("应用程序异常");
break;
case 14:
MessageBox.Show("数据库异常");
break;
}
}
///
/// 删除工单
///
///
///
private void btnRemoveWorklist_Click(object sender, EventArgs e)
{
if (txtgdbh.Text == "")
{
MessageBox.Show("要删除的工单编号不能为空");
return;
}
SYWebServiceClient webService = new SYWebServiceClient();
int flag = webService.removeWorkList("WS访问访问账户", "WS访问密码", txtgdbh.Text);
switch (flag)
{
case 0:
MessageBox.Show("删除工单成功!");
break;
case 1:
MessageBox.Show("工单编号为空");
break;
case 2:
MessageBox.Show("诊所编号为空");
break;
case 3:
MessageBox.Show("没有文件信息上传");
break;
case 4:
MessageBox.Show("没有工单信息可以上传");
break;
case 5:
MessageBox.Show("没有工单图片文件可以上传");
break;
case 6:
MessageBox.Show("没有诊所信息可以上传");
break;
case 7:
MessageBox.Show("没有诊所信息可以上传");
break;
case 8:
MessageBox.Show("没有诊所信息可以更新");
break;
case 9:
MessageBox.Show("不安全的调用");
break;
case 10:
MessageBox.Show("不存在的工单[上传工单图片时检查]");
break;
case 11:
MessageBox.Show("输入输出异常");
break;
case 12:
MessageBox.Show("录入数据失败[存在重复数据]");
break;
case 13:
MessageBox.Show("应用程序异常");
break;
case 14:
MessageBox.Show("数据库异常");
break;
}
}
///
/// 上传工单图片
///
///
///
private void btnUpload_Click(object sender, EventArgs e)
{
if (txtpicwokelistid.Text == "")
{
MessageBox.Show("请输入工单编号");
return;
}
SYWebServiceClient webService = new SYWebServiceClient();
OpenFileDialog openFile = new OpenFileDialog();
openFile.ShowDialog();
WorkListPicFile file = new WorkListPicFile();
//获得唯一图片名字
String saveFile = Guid.NewGuid().ToString() + openFile.FileName.Substring(openFile.FileName.Length - 4, 4);
Console.WriteLine("图片名称:" + saveFile);
FileStream fs = null;
int filg = -1;
try
{
fs = new FileStream(openFile.FileName, FileMode.Open);
file.serverFile = saveFile;
file.fileSize = fs.Length;
Console.WriteLine("开始上传图片,文件总共大小为:" + fs.Length);
byte[] bytes = new byte[1024 * 1024];
int size = 0;
do
{
size = fs.Read(bytes, 0, 1024 * 1024);
if (size <= 0)
{
break;
}
byte[] fixedBytes = new byte[size];
Array.Copy(bytes, fixedBytes, size);
file.bytes = fixedBytes;
file.workListId = txtpicwokelistid.Text;
filg = webService.upLoadWorkListPic("WS访问访问账户", "WS访问密码", file);
if (filg != 0)
{
break;
}
file.position = (file.position + fixedBytes.Length);
Console.WriteLine("上传成功,已上传" + file.position + "字节");
} while (size > 0);
}
catch (Exception exce)
{
MessageBox.Show(exce.Message);
}
finally
{
if (null != fs)
{
fs.Close();
}
switch (filg)
{
case 0:
MessageBox.Show("上传工单图片成功!");
break;
case 1:
MessageBox.Show("工单编号为空");
break;
case 2:
MessageBox.Show("诊所编号为空");
break;
case 3:
MessageBox.Show("没有文件信息上传");
break;
case 4:
MessageBox.Show("没有工单信息可以上传");
break;
case 5:
MessageBox.Show("没有工单图片文件可以上传");
break;
case 6:
MessageBox.Show("没有诊所信息可以上传");
break;
case 7:
MessageBox.Show("没有诊所信息可以上传");
break;
case 8:
MessageBox.Show("没有诊所信息可以更新");
break;
case 9:
MessageBox.Show("不安全的调用");
break;
case 10:
MessageBox.Show("不存在的工单[上传工单图片时检查]");
break;
case 11:
MessageBox.Show("输入输出异常");
break;
case 12:
MessageBox.Show("录入数据失败[存在重复数据]");
break;
case 13:
MessageBox.Show("应用程序异常");
break;
case 14:
MessageBox.Show("数据库异常");
break;
}
}
}
///
/// 修改牙齿工s序
///
///
///
private void btnUpdate_Click(object sender, EventArgs e)
{
if (txtycbh.Text == "")
{
MessageBox.Show("请输入牙齿编号");
return;
}
if (txtycgx.Text == "")
{
MessageBox.Show("请输入工序");
return;
}
SYWebServiceClient webService = new SYWebServiceClient();
int filg = webService.updateToothSpecGX(txtycbh.Text, txtycgx.Text);
Console.WriteLine("修改状态:"+filg);
switch (filg)
{
case 0:
MessageBox.Show("修改牙齿工序成功!");
break;
case 1:
MessageBox.Show("工单编号为空");
break;
case 2:
MessageBox.Show("诊所编号为空");
break;
case 3:
MessageBox.Show("没有文件信息上传");
break;
case 4:
MessageBox.Show("没有工单信息可以上传");
break;
case 5:
MessageBox.Show("没有工单图片文件可以上传");
break;
case 6:
MessageBox.Show("没有诊所信息可以上传");
break;
case 7:
MessageBox.Show("没有诊所信息可以上传");
break;
case 8:
MessageBox.Show("没有诊所信息可以更新");
break;
case 9:
MessageBox.Show("不安全的调用");
break;
case 10:
MessageBox.Show("不存在的工单[上传工单图片时检查]");
break;
case 11:
MessageBox.Show("输入输出异常");
break;
case 12:
MessageBox.Show("录入数据失败[存在重复数据]");
break;
case 13:
MessageBox.Show("应用程序异常");
break;
case 14:
MessageBox.Show("数据库异常");
break;
}
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
}
}