private void BgWait_DoWork(object sender, DoWorkEventArgs e) { BgWait.ReportProgress(PubConstant.WaitMessageStatus.START); try { switch (e.Argument.ToString()) { case "SearchRFID": using (var QZclient = new SRQZData.QZDataServiceClient()) { var ret = QZclient.GetQZRFIDCodeData(context.SessionID, RFIDCodeTextEdit.Text); var Newret = QZclient.GetNewQZRFIDCodeData(context.SessionID, RFIDCodeTextEdit.Text); if (Newret != null && Newret.Rows.Count > 0) { //该位置应存储过磅单号,RFID卡号,配方编号,配方名称,合计重量 //vw_DurmsUpFeedingModel.RFIDCode = ret.Rows[0][0].ToString(); //vw_DurmsUpFeedingModel.FormulaName = ret.Rows[0][9].ToString(); //vw_DurmsUpFeedingModel.MaterialVouchCode = ret.Rows[0][10].ToString(); //vw_DurmsUpFeedingModel.InputWeight = Decimal.Parse(ret.Rows[0][2].ToString()); NewCraftsName.Text = "上料"; vw_DurmsUpFeedingModel.RFIDCode = Newret.Rows[0]["RFID卡号"].ToString(); vw_DurmsUpFeedingModel.FormulaName = Newret.Rows[0]["配方名称"].ToString(); vw_DurmsUpFeedingModel.ProPlanNum = Newret.Rows[0]["参数表编码"].ToString(); vw_DurmsUpFeedingModel.MaterialVouchCode = Newret.Rows[0]["过磅单号"].ToString(); vw_DurmsUpFeedingModel.FormulaCode = Newret.Rows[0]["配方单号"].ToString(); vw_DurmsUpFeedingModel.InputWeight = Decimal.Parse(Newret.Rows[0]["每鼓合计重量"].ToString()); } else { ClsMsg.ShowErrMsg("没有该卡号信息,请重新刷卡"); BgWait.ReportProgress(PubConstant.WaitMessageStatus.END); return; } } using (var MESclient = new SRCfPExecute.CfPExecuteServiceClient()) { // GetCfPExecuteByArrangedVouchCode WorkbrachName var ArrRet = MESclient.GetCfPExecuteByArrangedVouchCode(context.SessionID, vw_DurmsUpFeedingModel.ArrangedVouchCode); vw_DurmsUpFeedingModel.WorkbrachCode = ArrRet.Data.WorkbrachCode; vw_DurmsUpFeedingModel.ExecuteOrder = ArrRet.Data.ExecuteOrder; vw_DurmsUpFeedingModel.ExecuteStatus = ArrRet.Data.ExecuteStatus;//暂定用于判断保存时数据是否被后台或同一时间进行了修正 vw_DurmsUpFeedingModel.CraftsName = ArrRet.Data.CraftsName; vw_DurmsUpFeedingModel.CraftsCode = ArrRet.Data.CraftsCode; vw_DurmsUpFeedingModel.ArrangedVouchCode = ArrRet.Data.ArrangedVouchCode; if (vw_DurmsUpFeedingModel.CraftsName != "上料" && vw_DurmsUpFeedingModel.CraftsName != "空鼓") { ClsMsg.ShowErrMsg("本转鼓不处于空鼓或上料开始阶段,无法使用保存功能"); vw_DurmsUpFeedingModel.WorkbrachCode = ""; RFIDCodeTextEdit.Properties.ReadOnly = true; } else if (vw_DurmsUpFeedingModel.CraftsName == "空鼓") { vw_DurmsUpFeedingModel.ArrangedVouchCode = ""; OperatDescEdit.Text = "上料开始"; NewCraftsName.Text = "上料"; RFIDCodeTextEdit.Properties.ReadOnly = true; } else if (vw_DurmsUpFeedingModel.CraftsName == "上料" && ArrRet.Data.ExecuteStatus != 2) { vw_DurmsUpFeedingModel.ArrangedVouchCode = ArrRet.Data.ArrangedVouchCode; OperatDescEdit.Text = "原料扫卡绑定"; NewCraftsName.Text = "上料"; RFIDCodeTextEdit.Properties.ReadOnly = false; } else { ClsMsg.ShowErrMsg("本转鼓不处于空鼓或上料开始阶段,无法使用保存功能"); vw_DurmsUpFeedingModel.WorkbrachCode = ""; RFIDCodeTextEdit.Properties.ReadOnly = true; } } using (var MESclient = new SRCfPExecute.CfPExecuteServiceClient()) { var ret = MESclient.GetArrangedVouchLogByCode(context.SessionID, ArrangedVouchCodeTextEdit.Text); if (ret.Data != null) { e.Result = ret.Data; } else { BgWait.ReportProgress(PubConstant.WaitMessageStatus.WARNING, ret.Message); } } break; case "SearchDevStatus": using (var MESclient = new SRCfPExecute.CfPExecuteServiceClient()) { var ret = MESclient.GetDurmsUpFeedingByDevCode(context.SessionID, WorkbrachNameTextEdit.Text); if (ret.Data != null) { DeveUseStatusSpinEdit.EditValue = ret.Data[0].DeveUseStatus.ToString(); vw_DurmsUpFeedingModel.DevName = ret.Data[0].DevName; vw_DurmsUpFeedingModel.WorkbrachName = ret.Data[0].DevName; vw_DurmsUpFeedingModel.WorkbrachCode = ret.Data[0].DevCode; } else { ClsMsg.ShowErrMsg("无该设备状态数据,请跟管理员沟通"); } //vw_DurmsUpFeedingModel.WorkbrachName = ret.Data[0].DevCode; var Proret = MESclient.GeCraftsProcessdByWorkbrachName(context.SessionID, WorkbrachNameTextEdit.Text); // vw_DurmsUpFeedingModel.WorkbrachName = Proret.Data.WorkbrachName; vw_DurmsUpFeedingModel.ExecuteOrder = Proret.Data.ExecuteOrder; vw_DurmsUpFeedingModel.ExecuteStatus = Proret.Data.ExecuteStatus; //暂定用于判断保存时数据是否被后台或同一时间进行了修正 vw_DurmsUpFeedingModel.CraftsName = Proret.Data.CraftsName; vw_DurmsUpFeedingModel.RFIDCode = ""; vw_DurmsUpFeedingModel.FormulaName = ""; vw_DurmsUpFeedingModel.InputWeight = null; if (vw_DurmsUpFeedingModel.CraftsName != "上料" && vw_DurmsUpFeedingModel.CraftsName != "空鼓") { ClsMsg.ShowErrMsg("本转鼓不处于空鼓或上料开始阶段,无法使用保存功能"); vw_DurmsUpFeedingModel.WorkbrachCode = ""; RFIDCodeTextEdit.Properties.ReadOnly = true; } else if (vw_DurmsUpFeedingModel.CraftsName == "空鼓") { vw_DurmsUpFeedingModel.ArrangedVouchCode = ""; OperatDescEdit.Text = "上料开始"; NewCraftsName.Text = "上料"; RFIDCodeTextEdit.Properties.ReadOnly = true; } else if (vw_DurmsUpFeedingModel.CraftsName == "上料" && Proret.Data.ExecuteStatus != 2) { vw_DurmsUpFeedingModel.ArrangedVouchCode = Proret.Data.ArrangedVouchCode; // OperatDescEdit.Text = "原料扫卡绑定"; NewCraftsName.Text = "上料"; RFIDCodeTextEdit.Properties.ReadOnly = false; } else { ClsMsg.ShowErrMsg("本转鼓不处于空鼓或上料开始阶段,无法使用保存功能"); vw_DurmsUpFeedingModel.WorkbrachCode = ""; RFIDCodeTextEdit.Properties.ReadOnly = true; } using (var MESclientLog = new SRCfPExecute.CfPExecuteServiceClient()) { var retLog = MESclientLog.GetArrangedVouchLogByCode(context.SessionID, ArrangedVouchCodeTextEdit.Text); if (retLog.Data != null) { e.Result = retLog.Data; } else { BgWait.ReportProgress(PubConstant.WaitMessageStatus.WARNING, retLog.Message); } } } vw_DurmsUpFeedingModel.CreateTime = DateTime.Now; break; case "SearchArrangedVouchLogCode": using (var MESclient = new SRCfPExecute.CfPExecuteServiceClient()) { var ret = MESclient.GetArrangedVouchLogByCode(context.SessionID, ArrangedVouchCodeTextEdit.Text); if (ret.Data != null) { e.Result = ret.Data; } else { BgWait.ReportProgress(PubConstant.WaitMessageStatus.WARNING, ret.Message); } } break; case "InsterArrangedVouchCode": using (var MESclient = new SRCfPExecute.CfPExecuteServiceClient()) { var ret = MESclient.InsterArrVouchByVw(context.SessionID, vw_DurmsUpFeedingModel); //保存排配单数据 if (ret.IsSuccess) { var logModel = new SRCfPExecute.ArrangedVouchLog() { ArrangedVouchCode = ret.Data.ArrangedVouchCode, OperatingTime = vw_DurmsUpFeedingModel.CreateTime, OperatDesc = OperatDescEdit.Text, Operator = OperatorEdit.Text, Frequency = FrequencyEdit.Text, CraftsName = CraftsNameTextEdit.Text, }; vw_DurmsUpFeedingModel.ArrangedVouchCode = ret.Data.ArrangedVouchCode; MESclient.InsterArrVouchLog(context.SessionID, logModel); //保存操作日志数据 BgWait.ReportProgress(99, "保存成功!"); vw_DurmsUpFeedingModel.WorkbrachCode = ""; OperatDescEdit.Text = ""; RFIDCodeTextEdit.Properties.ReadOnly = false; vw_DurmsUpFeedingModel.CreateTime = DateTime.Now; vw_DurmsUpFeedingModel.Creator = context.UserName; using (var MESclientLog = new SRCfPExecute.CfPExecuteServiceClient()) { var retLog = MESclientLog.GetArrangedVouchLogByCode(context.SessionID, ArrangedVouchCodeTextEdit.Text); if (retLog.Data != null) { e.Result = retLog.Data; } else { BgWait.ReportProgress(PubConstant.WaitMessageStatus.WARNING, retLog.Message); } } } } break; case "InsterCraProDataById": using (var MESclient = new SRCfPExecute.CfPExecuteServiceClient()) { var ret = MESclient.UpdateCraftsProcessData(context.SessionID, "CSGH17011", vw_DurmsUpFeedingModel); //保存排配单数据 if (ret.IsSuccess) { BgWait.ReportProgress(99, "保存成功!"); } else { BgWait.ReportProgress(PubConstant.WaitMessageStatus.WARNING, ret.Message); } } break; case "UpdateArrangedVouchCode": using (var MESclient = new SRCfPExecute.CfPExecuteServiceClient()) { var ret = MESclient.UpdateArrangedVouchCode(context.SessionID, vw_DurmsUpFeedingModel); //保存排配单数据 var retTail = MESclient.UpdateCraftsProcessData(context.SessionID, vw_DurmsUpFeedingModel.ProPlanNum, vw_DurmsUpFeedingModel); //修改执行子表跟主表数据 var TestRet = MESclient.UpdateCraftsProcessExecute(context.SessionID, vw_DurmsUpFeedingModel.ArrangedVouchCode, 1, 2); if (ret.IsSuccess) { var logModel = new SRCfPExecute.ArrangedVouchLog() { ArrangedVouchCode = ret.Data.ArrangedVouchCode, OperatingTime = vw_DurmsUpFeedingModel.CreateTime, OperatDesc = OperatDescEdit.Text, Operator = OperatorEdit.Text, Frequency = FrequencyEdit.Text, CraftsName = CraftsNameTextEdit.Text, }; MESclient.InsterArrVouchLog(context.SessionID, logModel); //保存操作日志数据 BgWait.ReportProgress(99, "保存成功!"); vw_DurmsUpFeedingModel.WorkbrachCode = ""; OperatDescEdit.Text = ""; RFIDCodeTextEdit.Properties.ReadOnly = true; vw_DurmsUpFeedingModel.CreateTime = DateTime.Now; vw_DurmsUpFeedingModel.Creator = context.UserName; using (var MESclientLog = new SRCfPExecute.CfPExecuteServiceClient()) { var retLog = MESclientLog.GetArrangedVouchLogByCode(context.SessionID, ArrangedVouchCodeTextEdit.Text); if (retLog.Data != null) { e.Result = retLog.Data; } else { BgWait.ReportProgress(PubConstant.WaitMessageStatus.WARNING, retLog.Message); } } } } break; default: break; } } catch (Exception ex) { BgWait.ReportProgress(PubConstant.WaitMessageStatus.ERROR, ex.Message); } BgWait.ReportProgress(PubConstant.WaitMessageStatus.END); }
private void BgWait_DoWork(object sender, DoWorkEventArgs e) { BgWait.ReportProgress(0); try { switch (e.Argument.ToString()) { case "SearchData": //清空列表 //model2 = new SRQZDDrumesSet.QC_FindLeakDrumsSet(); //qCFindLeakDrumsSetBindingSource.DataSource = model2; using (var client = new SRQZDDrumesSet.QCDrumsSetServiceClient()) { strLeakDrums = DeveCodeTextEdit.Text; var ret = client.GetQCDrumsSetQRCode(context.SessionID, strLeakDrums); if (ret.IsSuccess) { e.Result = ret.Data; } else { BgWait.ReportProgress(101, ret.Message); } } break; case "SearchData2": SearchData2(e); break; case "SaveData": using (var client = new SRFindLeak.QCDFindLeakServiceClient()) //引用服务 { var ret = client.AddQCDrumsFindLeakReport(context.SessionID, model); //应用,增加的方法 if (ret.IsSuccess) { BgWait.ReportProgress(PubConstant.WaitMessageStatus.PROMPT, "提交成功!"); this.Invoke((MethodInvoker) delegate() { AddFun(); }); SearchData2(e); } else { BgWait.ReportProgress(PubConstant.WaitMessageStatus.WARNING, ret.Message); } } break; default: break; } } catch (Exception ex) { Utils.Logger.Error(ex.ToString()); BgWait.ReportProgress(PubConstant.WaitMessageStatus.ERROR, ex.Message); } BgWait.ReportProgress(PubConstant.WaitMessageStatus.END); }