/// <summary> /// 调用Sap服务器函数 /// (非IDOC) /// </summary> /// <param name="orderCode"></param> /// <returns></returns> /// public SAPLog InvokeRFCFunctionRFID(SAPLog item) { IRfcFunction function = null; string companyID = String.Empty; try { function = _rfcDestination.Repository.CreateFunction("ZMMF_RFID_WS");//调用sap函数 function.SetParameterActive(0, true); function.SetValue("ZSJNO", item.Zsjno); function.SetValue("ZTYPE", item.Ztype); function.SetValue("WERKS", item.Werks.ToUpper()); function.SetValue("ZPLTN", string.IsNullOrEmpty(item.Zpltn) ? item.Zpltn : item.Zpltn.ToUpper()); function.SetValue("ZPOINT", item.Zpoint); function.SetValue("MATNR", item.Matnr); function.SetValue("EXIDV", item.Exidv); function.SetValue("ZLGORT_ORI", item.ZlgortOri); function.SetValue("ZLGORT_TAR", item.ZlgortTar); function.SetValue("ERFMG", item.qty); function.Invoke(_rfcDestination); IRfcTable tb = function.GetTable("GT_OUTPUT"); //获取 ZRFC_JGM_INFO2函数返回的 "E_TAB"表 foreach (IRfcStructure dr in tb) { string ZSJNO = dr.GetValue("ZSJNO").ToString(); //获取表 "E_TAB"结构中 "VBELN" 字段的值 string ZTYPE = dr.GetValue("ZTYPE").ToString(); item.M_TYPE = dr.GetValue("M_TYPE").ToString(); item.M_MESS = dr.GetValue("M_MESS").ToString(); //if (orderNumber.Equals(orderCode)) //{ // companyID = dr.GetValue("KUNNR").ToString(); // break; //} } } catch (RfcAbapMessageException e) { item.M_TYPE = e.AbapMessageType.ToString(); item.M_MESS = e.AbapT100Message; } return(item); }
public ServerMessage DataMethod(RfidCollections rfidKey, ref string action) { var megInfo = new ServerMessage(); string message = string.Empty; var acionGroup = string.Empty; var dataObj = new RfidCollections(); try { //var data = JsonConvert.DeserializeObject<RfidCollections>(jsonData); AbsRfidCollections <RfidCollections> abs = new RunRfidCollections_DAL(rfidKey); dataObj = abs.GetData(); //action = abs.GetAction().ToLower(); acionGroup = this.SqlQueryOne <string>(" select actionGroup from rfidinfo where rfidKey=@rfidKey", new { rfidKey = rfidKey.rfidKey });//查询方法组 if (string.IsNullOrEmpty(acionGroup)) { message = "0,successfully"; } else { if (abs.GetAction().Equals("131")) { message = "0,successfully"; } else { message = RunActionGroup(abs, acionGroup, rfidKey.specialAction); } } if (abs.GetERP() != null && message.StartsWith("0")) { SapncoClient client = new SapncoClient(); client.RegisterRfcDestination(); var sapCreateDate = DateTime.Now; SAPLog sapLog = new SAPLog() { Zsjno = sapCreateDate.ToString("yyyyMMddHHmmss") + abs.GetData().Exidv, Ztype = abs.GetData().ecp, Werks = abs.GetData().plantToStr, Zpltn = abs.GetData().assLine, Zpoint = abs.GetData().linePoint, Matnr = abs.GetData().Matnr, Exidv = abs.GetData().Exidv, ZlgortOri = abs.GetData().stockFromStr, ZlgortTar = abs.GetData().stockToStr, qty = rfidKey.qty.ToString(), Created = sapCreateDate.ToString("yyyy-MM-dd HH:mm:ss") }; SAPLog ret = client.InvokeRFCFunctionRFID(sapLog); sapLogger(ret); if (sapLog.M_TYPE.Contains("E")) { //return new ServerMessage() { Code = 1, Msg = "SAP ERROR" }; } } } catch { megInfo.Code = 1; megInfo.Msg = "Data Error"; } var msg = string.IsNullOrEmpty(message) ? new string[2] { "1", "Data Handle Error" } : message.Split(','); //插入处理记录 var svc = new ServerMessage() { Code = int.Parse(msg[0]), Msg = msg[1] }; dataObj.CodeInt = svc.Code; dataObj.Msg = svc.Msg; var acionArray = acionGroup.Split(',').ToList(); if (!string.IsNullOrEmpty(rfidKey.specialAction)) { if (!acionArray.Contains(rfidKey.specialAction.ToLower())) { dataObj.Action = rfidKey.specialAction.ToUpper(); } } this.SqlExecute <int>("insert into Operation(rfidKey,action,plantTo,stockTo,binTo,plantFrom,stockFrom,binFrom,matnr,exidv,recordTime,processingState,messageHints) values(@Code,@Action,@plantTo,@stockLocTo,@stockBinTo,@plantFrom,@stockLocFrom,@stockBinFrom,@Matnr,@Exidv,now(),@CodeInt,@Msg)", dataObj); return(svc); }
public bool sapLogger(SAPLog log) { return(this.SqlExecute <int>("INSERT INTO sap_log(Zsjno,Ztype,Werks,Zpltn,Zpoint,Matnr,Exidv,ZlgortOri,ZlgortTar,qty,M_TYPE,M_MESS,created) VALUES(@Zsjno,@Ztype,@Werks,@Zpltn,@Zpoint,@Matnr,@Exidv,@ZlgortOri,@ZlgortTar,@qty,@M_TYPE,@M_MESS,@Created)", log) > 0); }