public static bool SplitQty(string Username, string Password, string Container, int splitQty,int plateQty,ref List<string> childList,ref string Msg) { string SessionID = Guid.NewGuid().ToString(); csiClient Client = new csiClient(); csiConnection Connection = Client.createConnection(Constants.CAMSTAR_HOST, Constants.CAMSTAR_PORT); Connection.setConnectionTimeout(600000); csiSession Session = Connection.createSession(Username, Password, SessionID); try { csiDocument Document = Session.createDocument("SplitDoc"); csiService Service = Document.createService("Split"); csiObject InputData = Service.inputData(); InputData.containerField("Container").setRef(Container, ""); InputData.dataField("AutoNumber").setValue("True"); InputData.dataField("CloseWhenEmpty").setValue("False"); InputData.namedObjectField("AutoNumberRule").setRef("SplitRule"); InputData.dataField("ES_SNDetail").setValue("1"); csiSubentityList Details = InputData.subentityList("ToContainerDetails"); for(int i=1;i<=plateQty;i++) { csiSubentity Detail = Details.appendItem(); Detail.dataField("Qty").setValue(splitQty.ToString()); } Service.setExecute(); Service.requestData().requestField("CompletionMsg"); Service.requestData().requestField("ToContainerDetails"); Service.requestData().requestField("ChildContainers"); csiDocument ResponseDocument = Document.submit(); if (ResponseDocument.checkErrors())//提交失败 { csiExceptionData csiexceptiondata = ResponseDocument.exceptionData(); Msg = csiexceptiondata.getDescription(); return false; } else//提交成功 { csiService RespService = ResponseDocument.getService(); var xxxxx = RespService.responseData(); csiField CompletionMsg = RespService.responseData().getResponseFieldByName("CompletionMsg"); csiField details = RespService.responseData().getResponseFieldByName("ToContainerDetails"); //需要解析XML csiSubentityList list = details.asSubentityList(); for (int i = 0; i < plateQty; i++) { csiSubentity item = list.getItemByIndex(i); var a = item.getField("ToContainerName"); var sn=a.asDataField().getValue(); childList.Add(sn); } Msg = CompletionMsg.asDataField().getValue(); return true; } } catch (Exception e) { Msg = e.Message; return false; } finally { if (Session != null) Session.removeDocument("SplitDoc"); if (Connection != null) Connection.removeSession(SessionID); if (Client != null) Client.removeConnection(Constants.CAMSTAR_HOST, Constants.CAMSTAR_PORT); } }
标签:setValue,Container,string,Camstar,int,获取,Connection,回参,InputData From: https://www.cnblogs.com/CarryYou-lky/p/16857917.html