private void btnYes_Click(object sender, EventArgs e) { string lh = boxList != null && boxList.Count > 0 ? boxList.First().LH : ""; if (string.IsNullOrEmpty(lh)) { ShowStatusInfo(false, "楼号为空,不能生成交接单"); return; } SapResult result = SAPDataService.GenerateDocInfo( SysConfig.LGNUM, SysConfig.CurrentLoginUser.UserId, lh, boxList.FindAll(i => i.LH == lh && i.PACKRESULT == "S" && i.RESULT == "S").Select(i => i.HU).ToList()); if (result.STATUS == "E") { ShowStatusInfo(false, result.MSG); } else { PackingBoxService.UpdateBoxGenerated(lh); if (OnGenerateSuccess != null) { OnGenerateSuccess(lh); } MetroMessageBox.Show(this, "生成交接单成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } }
/// <summary> /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条 /// </summary> public void Upload() { CUploadData task = null; if (CurrentUploadQueue.Count > 0) { lock (_lockObject) { // 取出任务上传 task = CurrentUploadQueue.Dequeue() as CUploadData; } } if (task != null) { //upload SapResult re = SAPDataService.UploadJianHuoData(task.Data as CJianHuoUpload); if (re.SUCCESS) { SqliteDataService.delUploadFromSqlite(task.Guid); } else { SqliteDataService.updateMsgToSqlite(task.Guid, re.MSG); OnUploaded?.Invoke(task.Data as CJianHuoUpload, re); } } }
private void savingDataThreadFunc() { while (true) { try { if (mCancel) { return; } CUploadData ud = getQueueData(); if (ud != null) { YKBoxInfo upData = ud.Data as YKBoxInfo; if (upData != null) { //upload string uploadRe = ""; string sapMsg = ""; SapResult result = SAPDataService.UploadYKBoxInfo(SysConfig.LGNUM, upData); uploadRe = result.STATUS; sapMsg = result.MSG; if (uploadRe == "E") { SqliteDataService.updateMsgToSqlite(ud.Guid, sapMsg); playSoundWarn(); } else { SqliteDataService.delUploadFromSqlite(ud.Guid); } upData.SapRemark = result.MSG; upData.SapStatus = result.STATUS; //save YKBoxService.SaveBox(upData); if (upData.Status == "S" && uploadRe == "S") { updateBoxList(upData); UpdateTotalInfo(); } updateUploadCount(); updateExpButton(); } } Thread.Sleep(500); } catch (Exception) { //LogHelper.WriteLine(ex.Message + "\r\n" + ex.StackTrace.ToString()); } } }
public SapResult <List <FunctionModel> > GetFunctions(string functionName) { var result = new SapResult <List <FunctionModel> >(); try { using (var conn = new SapConnection(_destinationName)) { // NOTE: https://www.sapdatasheet.org/abap/func/rfc_function_search.html var rfcFunction = conn.Repository.CreateFunction("RFC_FUNCTION_SEARCH"); rfcFunction.SetValue("FUNCNAME", functionName); rfcFunction.SetValue("LANGUAGE", "KO"); rfcFunction.Invoke(conn.Destination); var functions = rfcFunction.GetTable("FUNCTIONS"); foreach (var function in functions) { result.Export.Add(new FunctionModel { Name = function.GetString("FUNCNAME"), Group = function.GetString("GROUPNAME"), Application = function.GetString("APPL"), RemoteHost = function.GetString("HOST"), ShortText = function.GetString("STEXT") }); } } } catch (Exception ex) { result.AddError(ex); } return(result); }
public SapResult <DataTable> GetTable(string tableName, int rowSkips = 0, int rowCount = 0) { var result = new SapResult <DataTable>(); try { using (var conn = new SapConnection(_destinationName)) { // NOTE: https://www.sapdatasheet.org/abap/func/rfc_read_table.html var rfcFunction = conn.Repository.CreateFunction("RFC_READ_TABLE"); rfcFunction.SetValue("QUERY_TABLE", tableName); rfcFunction.SetValue("DELIMITER", DATA_SEPARATOR); rfcFunction.SetValue("ROWSKIPS", rowSkips); rfcFunction.SetValue("ROWCOUNT", rowCount); rfcFunction.Invoke(conn.Destination); var fields = rfcFunction.GetTable("FIELDS"); var datas = rfcFunction.GetTable("DATA"); var table = ToTable(tableName, fields, datas); result.Export = table; } } catch (Exception ex) { result.AddError(ex); } return(result); }
public SapResult <List <ParameterModel> > GetFunctionParameters(string functionName) { var result = new SapResult <List <ParameterModel> >(); try { using (var conn = new SapConnection(_destinationName)) { var parameters = new List <ParameterModel>(); var meta = conn.Repository.GetFunctionMetadata(functionName); for (int i = 0; i < meta.ParameterCount; i++) { StructureModel structureModel = null; if (meta[i].DataType == RfcDataType.STRUCTURE) { string structureName = meta[i].ValueMetadataAsStructureMetadata.Name; structureModel = LoadStructureMetadata(conn.Repository, structureName); } else if (meta[i].DataType == RfcDataType.TABLE) { string structureName = meta[i].ValueMetadataAsTableMetadata.LineType.Name; structureModel = LoadStructureMetadata(conn.Repository, structureName); } var parameter = new ParameterModel() { Name = meta[i].Name, DataType = meta[i].DataType.ToString(), Direction = meta[i].Direction.ToString(), DefaultValue = meta[i].DefaultValue, Optional = meta[i].Optional, Documentation = meta[i].Documentation, Structure = structureModel }; parameters.Add(parameter); } // 정렬순서 var sortOrder = new List <string>() { "IMPORT", "EXPORT", "CHANGING", "TABLES" }; result.Export = parameters.OrderBy(x => sortOrder.IndexOf(x.Direction)).ToList(); } } catch (Exception ex) { result.AddError(ex); } return(result); }
/// <summary> /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条 /// </summary> public void Upload() { lock (_lockObject) { if (isbusy) { return; } else { isbusy = true; } try { if (CurrentUploadQueue.Count > 0) { // 取出任务上传 object o = CurrentUploadQueue.Pop(); if (o.GetType() == typeof(SqliteUploadDataInfo)) { UploadBoxInfo box = (o as SqliteUploadDataInfo).Data; SapResult result = new SapResult(); //if (box.Box.RESULT == "S") //{ result = SAPDataService.UploadPackingBox(box.LGNUM, box.Box.HU, box.EQUIP_HLA, box.Box.RESULT, box.Box.MSG, box.Box.MX, box.LOUCENG, box.SUBUSER, box.Box.Details); //(box.LGNUM, box.Box.HU, box.EQUIP_HLA, box.LOUCENG, box.SUBUSER, box.Box.Details); box.Box.PACKMSG = result.MSG; box.Box.PACKRESULT = result.STATUS; //if (!result.SUCCESS) box.Box.RESULT = "SE"; //if (!result.SUCCESS && OnUploadError != null) OnUploadError(); //} if (result.STATUS == "E") { box.Box.Details.Clear(); } bool xdSaveResult = PackingBoxService.SaveBox(box.Box); SqliteDataService.DeleteUploaded((o as SqliteUploadDataInfo).Guid); if (OnUploaded != null) { OnUploaded(box.Box); } } } } catch (Exception ex) { LogHelper.WriteLine(ex.Message + "\r\n" + ex.StackTrace); } isbusy = false; } }
public void updateSAP(YKBoxInfo uploadData) { CUploadData ud = new CUploadData(); ud.Guid = Guid.NewGuid().ToString(); ud.Data = uploadData; ud.IsUpload = 0; ud.CreateTime = DateTime.Now; SqliteDataService.saveToSqlite(ud); YKBoxInfo upData = ud.Data as YKBoxInfo; if (upData == null) { return; } string uploadRe = ""; string sapMsg = ""; SapResult result = SAPDataService.UploadYKBoxInfo(SysConfig.LGNUM, upData); uploadRe = result.STATUS; sapMsg = result.MSG; if (uploadRe == "E") { SqliteDataService.updateMsgToSqlite(ud.Guid, sapMsg); } else { SqliteDataService.delUploadFromSqlite(ud.Guid); } upData.SapRemark = result.MSG; upData.SapStatus = result.STATUS; //save YKBoxService.SaveBox(upData); if (upData.Status == "S" && uploadRe == "S") { updateBoxList(upData); UpdateTotalInfo(); } }
private void UploadServer_OnUploaded(CJianHuoUpload data, SapResult re) { try { Invoke(new Action(() => { if (!re.SUCCESS) { grid.Rows.Insert(0, mCurBoxNo, mCurJieHuoDan.PICK_LIST, "", "", "", "", "", "", "", "SAP 上传出错:" + re.MSG); grid.Rows[0].DefaultCellStyle.BackColor = Color.OrangeRed; } })); } catch (Exception e) { Log4netHelper.LogError(e); } }
/// <summary> /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条 /// </summary> public void Upload() { lock (_lockObject) { if (isbusy) { return; } else { isbusy = true; } try { if (CurrentUploadQueue.Count > 0) { //取出任务上传 object o = CurrentUploadQueue.Pop(); if (o.GetType() == typeof(SqliteUploadDataInfo)) { YKBoxInfo box = (o as SqliteUploadDataInfo).Data; //if(box.Status == "S") //{ SapResult result = SAPDataService.UploadYKBoxInfo(SysConfig.LGNUM, box); box.SapRemark = result.MSG; box.SapStatus = result.STATUS; bool xdSaveResult = YKBoxService.SaveBox(box); YKBoxSqliteService.SetUploaded((o as SqliteUploadDataInfo).Guid); if (OnUploaded != null) { OnUploaded(box); } //} } } } catch (Exception ex) { LogHelper.WriteLine(ex.Message + "\r\n" + ex.StackTrace); } isbusy = false; } }
/// <summary> /// 取出队列中第一个上传任务,进行上传,上传完成后删除这条 /// </summary> public void Upload() { if (CurrentUploadQueue.Count > 0) { UploadPKBoxInfo box = null; lock (_lockObject) { // 取出任务上传 box = CurrentUploadQueue.Dequeue() as UploadPKBoxInfo; } if (box != null) { SapResult sr = SAPDataService.UploadPKBoxInfo(box); SqliteDataService.DeleteUploaded(box.Guid); if (!sr.SUCCESS && box.InventoryResult) { box.UploadMsg = sr.MSG; SqliteDataService.InsertUploadData(box); } } } }
void uploadSap(YKBoxInfo box) { try { SqliteUploadDataInfo ud = new SqliteUploadDataInfo(); ud.Guid = Guid.NewGuid().ToString(); ud.Data = box; ud.IsUpload = 0; ud.CreateTime = DateTime.Now; YKBoxSqliteService.InsertUploadData(ud); SapResult result = SAPDataService.UploadYKBoxInfo(SysConfig.LGNUM, box); box.SapRemark = result.MSG; box.SapStatus = result.STATUS; bool xdSaveResult = YKBoxService.SaveBox(box); YKBoxSqliteService.SetUploaded(ud.Guid); } catch (Exception e) { Log4netHelper.LogError(e); } }