1.基础数据类型
1.NameObject:名称对象
2.RevsionedObject:带版本的对象
3.Service:服务
4.SubEntity,SubEntityList:子实体 子实体集合
5.NamedSubEntityList :带名称的子实体集合
6.Query:查询
开发环境依赖
Dotnet framework引用camstar安装服务器上C:Program Files (x86)CamstarInSite XML Client 目录下的InSiteXMLClient.dll
Dotnet Core引用我自己封装的nutget包InSiteXmlClient4Core https://github.com/307209239/InSiteXmlClient4Core
dotnetFramework开发请参考官方文档,下面只介绍dotnetcore下的调用camstar API的开发步骤
1.创建连接实例,链接到camstar服务器 var common = new CamstarCommon(“192.168.1.168”,2881,“admin”,“admin”);
2.创建服务 common.CreateService(“LotStart”);
3.创建服务输入对象 var inputdata = common.InputData();
4. 赋值输入对象(根据服务desinger建模数据) 例如:inputdata.DataField(“AutoPrepare”).SetValue(false);
5. 提交并返回结果 同步: return await common.ExecuteResult(); 异步:return await common.ExecuteResultAsync(); 返回值为元组,status:状态true 成功,false 失败,Message:信息
开发实例 NemeObject
每一个NameObject都有对应的服务,服务名称一般都是名称+Maint(例如: LossReason,服务为LossReasonMaint )
//添加 var common=new CamstarCommon("192.168.1.167",2881,"CamstarAdmin","camstarAdmin"); common.CreateService("LossReasonMaint"); common.Perform(CamstarCommon.PerformType.New); var inputData = common.InputData(); var objectChanges = inputData.NamedObjectField("ObjectChanges"); objectChanges.DataField(“Name”).SetValue(“测试”); return common.ExecuteResult(); //更新 var common = new CamstarCommon("192.168.1.167", 2881, "CamstarAdmin", "camstarAdmin"); common.CreateService("LossReasonMaint"); var inputData = common.InputData(); inputData.NamedObjectField("ObjectToChange").SetRef("测试"); common.Perform(CamstarCommon.PerformType.Change); var inputData1 = common.InputData(); var objectChanges = inputData1.NamedObjectField("ObjectChanges"); objectChanges.DataField("Description").SetValue("更新"); return common.ExecuteResult(); //删除 var common = new CamstarCommon("192.168.1.167", 2881, "CamstarAdmin", "camstarAdmin"); common.CreateService("LossReasonMaint"); var inputData = common.InputData(); inputData.NamedObjectField("ObjectToChange").SetRef("测试"); common.Perform(CamstarCommon.PerformType.Delete); return common.ExecuteResult();
开发实例RevsionedObject
每一个RevsionedObject都有对应的服务,服务名称一般都是名称+Maint(例如: ERPRoute,服务为ERPRouteMaint )
//添加 var common=new CamstarCommon("192.168.1.167",2881,"CamstarAdmin","camstarAdmin"); common.CreateService("ERPRouteMaint"); common.Perform(CamstarCommon.PerformType.New); var inputData = common.InputData(); var objectChanges = inputData.RevisionedObjectField("ObjectChanges"); objectChanges.DataField("Name").SetValue("测试"); objectChanges.DataField("Revision").SetValue("1"); objectChanges.DataField("IsRevofRcd").SetValue(true);//默认版本 return common.ExecuteResult(); //更新 var common = new CamstarCommon("192.168.1.167", 2881, "CamstarAdmin", "camstarAdmin"); common.CreateService("ERPRouteMaint"); var inputData = common.InputData(); inputData.RevisionedObjectField("ObjectToChange").SetRef("测试", "1", false); common.Perform(CamstarCommon.PerformType.Change); var inputData1 = common.InputData(); var objectChanges = inputData1.RevisionedObjectField("ObjectChanges"); objectChanges.DataField("Description").SetValue("更新"); return common.ExecuteResult(); //添加新版本 var common = new CamstarCommon("192.168.1.167", 2881, "CamstarAdmin", "camstarAdmin"); common.CreateService("ERPRouteMaint"); var inputData = common.InputData(); inputData.RevisionedObjectField("ObjectToChange").SetRef("测试", "1", false); common.Perform(CamstarCommon.PerformType.NewRev); var inputData1 = common.InputData(); var objectChanges = inputData1.RevisionedObjectField("ObjectChanges"); objectChanges.DataField("Revision").SetValue("2"); objectChanges.DataField("IsRevofRcd").SetValue(true);//默认版本 return common.ExecuteResult(); //删除指定版本 var common = new CamstarCommon("192.168.1.167", 2881, "CamstarAdmin", "camstarAdmin"); common.CreateService("LossReasonMaint"); var inputData = common.InputData(); inputData.NamedObjectField("ObjectToChange").SetRef("测试"); common.Perform(CamstarCommon.PerformType.Delete); return common.ExecuteResult(); //删除所有版本 var common = new CamstarCommon("192.168.1.167", 2881, "CamstarAdmin", "camstarAdmin"); common.CreateService("ERPRouteMaint"); var inputData = common.InputData(); inputData.RevisionedObjectField("ObjectToChange").SetRef("测试", null, true); common.Perform("DeleteAllRevisions"); return common.ExecuteResult();
开发实例SubEntity
var entity= objectChanges.Subentity(“Entrie”);//实例化 item.DataField(“Qty”).SetValue(2);//新项字段赋值
开发实例SubEntityList
var list= objectChanges.SubentityList(“Entries”);//实例化 var item=list.AppendItem();//添加新项 item.DataField(“__name”).SetValue(“测试”);//新项字段赋值
开发实例NamedSubEntityList
var list= objectChanges.NamedSubentityList(“Entries”);//实例化 var item=list.AppendItem();//添加新项 item.DataField(“Name”).SetValue(“测试”);//新项Name字段赋值(必须)