|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
×
/[查询生产订单]调用示例
//如果是非门户的独立进程,请将U8SOFT\ufcomsql目录中的U8Login.dll替换为Debug版的Login。
//添加对Interop.U8Login.dll引用(在U8SOFT\Interop目录)
//添加对Interop.MSXML2.dll引用(在U8SOFT\Interop目录)
//添加对U8API框架三个类库引用(在U8SOFT\UFMOM\U8APIFramework目录):
//UFIDA.U8.U8APIFramework.dll
//UFIDA.U8.MomServiceCommon.dll
//UFIDA.U8.U8MOMAPIFramework.dll
//声明命名空间
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
//需要添加以下命名空间
using UFIDA.U8.MomServiceCommon;
using UFIDA.U8.U8MOMAPIFramework;
using UFIDA.U8.U8APIFramework;
using UFIDA.U8.U8APIFramework.Meta;
using UFIDA.U8.U8APIFramework.Parameter;
using MSXML2;
namespace U8APITest
{
class Program
{
static void Main(string[] args)
{
//第一步:构造u8login对象并登陆(引用U8API类库中的Interop.U8Login.dll)
//如果当前环境中有login对象则可以省去第一步
U8Login.clsLogin u8Login = new U8Login.clsLogin();
String sSubId = "AS";
String sAccID = "(default)@999";
String sYear = "2015";
String sUserID = "demo";
String sPassword = "DEMO";
String sDate = "2015-3-22";
String sServer = "localhost";
String sSerial = "";
if (!u8Login.Login(ref sSubId, ref sAccID, ref sYear, ref sUserID, ref sPassword, ref sDate, ref sServer, ref sSerial))
{
Console.WriteLine("登陆失败,原因:" + u8Login.ShareString);
Marshal.FinalReleaseComObject(u8Login);
return;
}
//第二步:构造环境上下文对象,传入login,并按需设置其它上下文参数
U8EnvContext envContext = new U8EnvContext();
envContext.U8Login = u8Login;
//第三步:设置API地址标识(Url)
//当前API:查询生产订单的地址标识为:U8API/MOrder/MOrderLoad
U8ApiAddress myApiAddress = new U8ApiAddress("U8API/MOrder/MOrderLoad");
//第四步:构造APIBroker
U8ApiBroker broker = new U8ApiBroker(myApiAddress, envContext);
//第五步:API参数赋值
//给普通参数mocode赋值。此参数的数据类型为System.String,此参数按值传递,表示生产订单编号
//string Mocode = "0000000002";
broker.AssignNormalValue("Mocode", "0000000012");
//第六步:调用API
if (!broker.Invoke())
{
//错误处理
Exception apiEx = broker.GetException();
if (apiEx != null)
{
if (apiEx is MomSysException)
{
MomSysException sysEx = apiEx as MomSysException;
Console.WriteLine("系统异常:" + sysEx.Message);
//todo:异常处理
}
else if (apiEx is MomBizException)
{
MomBizException bizEx = apiEx as MomBizException;
Console.WriteLine("API异常:" + bizEx.Message);
//todo:异常处理
}
//异常原因
String exReason = broker.GetExceptionString();
if (exReason.Length != 0)
{
Console.WriteLine("异常原因:" + exReason);
}
}
//结束本次调用,释放API资源
broker.Release();
return;
}
|
|