protected override void AfterExecute(TEntityCustomLog log) { if (log.ErrCode == 0) { string[] splitString = log.ErrText.Split(','); string recvBatchNo = splitString[49].Replace("\"", ""); string strSQL = "UPDATE IRAPRIMCS..utb_MaterialStore " + "SET RecvBatchNo=@RecvBatchNo " + "WHERE SKUID=@SKUID"; IList <IDataParameter> paramList = new List <IDataParameter>(); paramList.Add(new IRAPProcParameter("@RecvBatchNo", DbType.String, recvBatchNo)); paramList.Add(new IRAPProcParameter("@SKUID", DbType.String, skuID)); try { using (IRAPSQLConnection conn = new IRAPSQLConnection(SysParams.Instance.DBConnectionString)) { conn.Update(strSQL, paramList); } } catch (Exception error) { MSGHelp.Instance.ShowErrorMessage( string.Format( "将SKUID[{0}]的RecvBatchNo更新为[{1}]的操作未成功,原因:[{2}]", skuID, recvBatchNo, error.Message)); } } else { MSGHelp.Instance.ShowErrorMessage( string.Format( "执行未成功,不能进行后续处理,结果:[{0}]", log.ErrText)); } }
public void Delete() { string strSQL = "UPDATE IRAP..stb_Log_WebServiceShuttling " + "SET Retried=1 WHERE LogID=@LogID"; IList <IDataParameter> paramList = new List <IDataParameter>(); paramList.Add(new IRAPProcParameter("@LogID", DbType.Int32, LogID)); try { using (IRAPSQLConnection conn = new IRAPSQLConnection(SysParams.Instance.DBConnectionString)) { conn.Update(strSQL, paramList); } } catch (Exception error) { MSGHelp.Instance.ShowErrorMessage(error); } }
/// <summary> /// 人工检查记录保存 /// </summary> /// <param name="userCode">系统登录用户号</param> /// <param name="agencyLeaf">登录用户的机构叶标识</param> /// <param name="productLeaf">产品叶标识</param> /// <param name="workUnitLeaf">工位叶标识</param> /// <param name="t107EntityID">工位实体标识</param> /// <param name="t132LeafID">产品族叶标识</param> /// <param name="containerNo">容器号</param> /// <param name="functionName">功能名称</param> /// <param name="wipInspecting">人工检查实体对象</param> /// <param name="confirmTime">检查确认时间</param> /// <returns></returns> public IRAPJsonResult msp_SaveFact_ManualInspecting( int communityID, string userCode, int agencyLeaf, int productLeaf, int workUnitLeaf, int t107EntityID, int t132LeafID, string containerNo, string functionName, Inspecting wipInspecting, DateTime confirmTime, long sysLogID, out int errCode, out string errText) { string strProcedureName = string.Format("{0}.{1}", className, MethodBase.GetCurrentMethod().Name); WriteLog.Instance.WriteBeginSplitter(strProcedureName); try { WriteLog.Instance.Write(string.Format("CommunityID={0}|UserCode={1}|AgencyLeaf={2}|" + "ProductLeaf={3}|WorkUnitLeaf={4}|T107EntityID={5}|T132LeafID={6}|" + "ContainerNo={7}|FunctionName={8}|ConfirmTime={9}|SysLogID={10}", communityID, userCode, agencyLeaf, productLeaf, workUnitLeaf, t107EntityID, t132LeafID, containerNo, functionName, confirmTime, sysLogID), strProcedureName); using (IRAPSQLConnection conn = new IRAPSQLConnection()) { long transactNo = 0; #region 申请交易号 WriteLog.Instance.Write("开始申请交易号", strProcedureName); try { ssp_GetSequenceNo( communityID, "NextTransactNo", 1, sysLogID, "-6", "", ref transactNo, out errCode, out errText); WriteLog.Instance.Write( string.Format("({0}){1}", errCode, errText), strProcedureName); if (errCode == 0) { WriteLog.Instance.Write(string.Format("申请到的交易号:{0}", transactNo), strProcedureName); } else { errCode = 99001; errText = string.Format("申请交易号出错:{0}", errText); WriteLog.Instance.Write(errText, strProcedureName); return(Json(errCode)); } } catch (Exception error) { errCode = 99001; errText = string.Format("申请交易号出错:{0}", error.Message); WriteLog.Instance.Write(errText, strProcedureName); WriteLog.Instance.Write(error.StackTrace, strProcedureName); return(Json(errCode)); } #endregion int passByTimes = ufn_GetWIPPassByTimes( communityID, productLeaf, workUnitLeaf, wipInspecting.MainWIPIDCode.WIPCode); long stdcycleTimeOfOperation = ufn_GetStdCycleTimeOfOperation( communityID, productLeaf, workUnitLeaf); long unscheduledPDTofAWorkUnit = ufn_GetUnscheduledPDTofAWorkUnit( communityID, workUnitLeaf, wipInspecting.MainWIPIDCode.MoveInTime, confirmTime, sysLogID); // 开始事务处理 conn.BeginTran(); foreach (SubWIPIDCodeInfo_Inspecting wip in wipInspecting.SubWIPIDCodes) { long factID = 0; long partitionPolicy = 0; long factPartitioningKey = 0; #region 申请事实编号 try { factID = IRAPDAL.UTS.Instance.msp_GetSequenceNo("NextFactNo", 1); } catch (Exception error) { errCode = 99001; errText = string.Format("申请事实编号出错:{0}", error.Message); WriteLog.Instance.Write(errText, strProcedureName); WriteLog.Instance.Write(error.StackTrace, strProcedureName); conn.RollBack(); return(Json(errCode)); } if (factID <= 0) { errCode = 99001; errText = "未申请到事实编号!"; WriteLog.Instance.Write(errText, strProcedureName); conn.RollBack(); return(Json(errCode)); } else { WriteLog.Instance.Write(string.Format("申请到的事实编号:{0}", factID), strProcedureName); } #endregion #region 在行集事实表(RSFact_Inspecting)中添加纪录 WriteLog.Instance.Write("保存行集事实", strProcedureName); partitionPolicy = Int64.Parse(DateTime.Now.Year.ToString() + (100000000L + communityID).ToString().Substring(1, 8) + "0006"); wip.GetListFromDataTable(); for (int i = 0; i < wip.FailureItems.Count; i++) { RSFact_Inspecting rsFactInspecting = new RSFact_Inspecting() { FactID = factID, PartitionPolicy = partitionPolicy, WFInstanceID = wipInspecting.MainWIPIDCode.PWONo, Ordinal = i + 1, T101LeafID = wip.FailureItems[i].T101LeafID, T110LeafID = wip.FailureItems[i].T110LeafID, T118LeafID = wip.FailureItems[i].T118LeafID, T216LeafID = wip.FailureItems[i].T216LeafID, T183LeafID = wip.FailureItems[i].T183LeafID, T184LeafID = wip.FailureItems[i].T184LeafID, CntDefect = wip.FailureItems[i].CntDefect, }; try { conn.Insert(rsFactInspecting); } catch (Exception error) { errCode = 99002; errText = string.Format("保存行集事实失败:{0}", error.Message); WriteLog.Instance.Write(errText, strProcedureName); WriteLog.Instance.Write(error.StackTrace, strProcedureName); conn.RollBack(); return(Json(errCode)); } } WriteLog.Instance.Write("行集事实保存完成", strProcedureName); #endregion #region 在辅助事实表(AuxFact_PDC)中添加纪录 WriteLog.Instance.Write("保存辅助事实", strProcedureName); partitionPolicy = Int64.Parse(communityID.ToString() + (100000000L + t132LeafID).ToString().Substring(1, 8) + DateTime.Now.Year.ToString()); factPartitioningKey = Int64.Parse(DateTime.Now.Year.ToString() + (100000000L + communityID).ToString().Substring(1, 8) + "0006"); AuxFact_PDC auxFactPDC = new AuxFact_PDC() { FactID = factID, PartitioningKey = partitionPolicy, FactPartitioningKey = factPartitioningKey, WFInstanceID = wipInspecting.MainWIPIDCode.PWONo, WIPCode = wip.SubWIPIDCode, AltWIPCode = wipInspecting.MainWIPIDCode.AltWIPCode, SerialNumber = wipInspecting.MainWIPIDCode.SerialNumber, LotNumber = wipInspecting.MainWIPIDCode.LotNumber, ContainerNo = containerNo, FakePreventingCode = "", CustomerAssignedID = "", ElectronicProductCode = "", }; #region 计算 QCStatus 值 if (wip.InspectingStatus == 3) { wip.QCStatus = CalculateQCStatus(communityID, productLeaf, workUnitLeaf, wipInspecting.MainWIPIDCode.PWONo, wip.QCStatus); } auxFactPDC.QCStatus = wip.QCStatus; #endregion try { conn.Insert(auxFactPDC); } catch (Exception error) { errCode = 99002; errText = string.Format("保存辅助事实表失败:{0}", error.Message); WriteLog.Instance.Write(errText, strProcedureName); WriteLog.Instance.Write(error.StackTrace, strProcedureName); conn.RollBack(); return(Json(errCode)); } WriteLog.Instance.Write("辅助事实保存完成", strProcedureName); #endregion #region 在主事实表(FixedFact_MES)中添加记录 WriteLog.Instance.Write("保存主事实", strProcedureName); partitionPolicy = Int64.Parse(DateTime.Now.Year.ToString() + (100000000L + communityID).ToString().Substring(1, 8) + "0006"); #region 准备需要保存的数据 FixedFact_MES fixedFactMES = new FixedFact_MES() { FactID = factID, PartitioningKey = partitionPolicy, TransactNo = transactNo, IsFixed = 1, OpID = 6, OpType = wip.InspectingStatus, BusinessDate = confirmTime, Code01 = wipInspecting.MainWIPIDCode.T102Code, Code02 = wipInspecting.MainWIPIDCode.T120Code, Code03 = wipInspecting.MainWIPIDCode.T107Code, Code04 = wipInspecting.MainWIPIDCode.T126Code, Code05 = wipInspecting.MainWIPIDCode.T1Code, Code06 = wipInspecting.MainWIPIDCode.T134Code, Code07 = wipInspecting.MainWIPIDCode.T181Code, Code08 = wipInspecting.MainWIPIDCode.T1002Code, Leaf01 = wipInspecting.MainWIPIDCode.T102Leaf, Leaf02 = wipInspecting.MainWIPIDCode.T120Leaf, Leaf03 = wipInspecting.MainWIPIDCode.T107Leaf, Leaf04 = wipInspecting.MainWIPIDCode.T126Leaf, Leaf05 = wipInspecting.MainWIPIDCode.T1Leaf, Leaf06 = wipInspecting.MainWIPIDCode.T134Leaf, Leaf07 = wipInspecting.MainWIPIDCode.T181Leaf, Leaf08 = wipInspecting.MainWIPIDCode.T1002Leaf, }; fixedFactMES.AChecksum = 0; fixedFactMES.CorrelationID = 0; fixedFactMES.Metric01 = 1; // 此处应该由前台传入 fixedFactMES.Metric02 = passByTimes; fixedFactMES.Metric03 = 1; fixedFactMES.Metric04 = Int64.Parse((confirmTime - wipInspecting.MainWIPIDCode.MoveInTime).TotalMilliseconds.ToString()) / wipInspecting.MainWIPIDCode.NumOfSubWIPs; fixedFactMES.Metric05 = fixedFactMES.Metric04 + fixedFactMES.Metric02; fixedFactMES.Metric06 = fixedFactMES.Metric04 + fixedFactMES.Metric03; fixedFactMES.Metric07 = stdcycleTimeOfOperation; fixedFactMES.Metric08 = TimeParser.LocalTimeToUnix(confirmTime); fixedFactMES.Metric09 = (long)(wipInspecting.ScanTime - wipInspecting.MainWIPIDCode.MoveInTime).TotalMilliseconds; fixedFactMES.Metric10 = unscheduledPDTofAWorkUnit; fixedFactMES.BChecksum = 0; fixedFactMES.MeasurementID = 0; fixedFactMES.WFInstanceID = wipInspecting.MainWIPIDCode.PWONo; fixedFactMES.Remark = functionName; fixedFactMES.LinkedFactID = 0; #endregion #region 添加记录 try { conn.Insert(fixedFactMES); } catch (Exception error) { errCode = 99002; errText = string.Format("保存主事实表失败:{0}", error.Message); WriteLog.Instance.Write(errText, strProcedureName); WriteLog.Instance.Write(error.StackTrace, strProcedureName); conn.RollBack(); return(Json(errCode)); } #endregion WriteLog.Instance.Write("主事实保存完成", strProcedureName); #endregion } if (NeedRepair(wipInspecting)) { #region 调整路由送修(IRAPMES..usp_MarkNGWIP) { WriteLog.Instance.Write("调整路由送修", strProcedureName); WIP wip = new WIP(); try { IRAPJsonResult rlt = wip.usp_MarkNGWIP( communityID, productLeaf, wipInspecting.MainWIPIDCode.WIPCode, wipInspecting.MainWIPIDCode.LotNumber, containerNo, wipInspecting.MainWIPIDCode.PWONo, wipInspecting.MainWIPIDCode.QCStatus, workUnitLeaf, 0, sysLogID, out errCode, out errText); WriteLog.Instance.Write(string.Format("({0}){1}", errCode, errText), strProcedureName); if (errCode != 0) { conn.RollBack(); return(Json(errCode)); } } catch (Exception error) { errCode = 99003; errText = string.Format("调用 usp_MarkNGWIP 失败:{0}", error.Message); WriteLog.Instance.Write(errText, strProcedureName); WriteLog.Instance.Write(error.StackTrace, strProcedureName); conn.RollBack(); return(Json(errCode)); } WriteLog.Instance.Write("路由送修调整完毕", strProcedureName); } #endregion } else { #region 调整路由(IRAPMES..usp_WIPForward) { WriteLog.Instance.Write("调整路由", strProcedureName); WIP wip = new WIP(); try { IRAPJsonResult rlt = wip.usp_WIPForward( communityID, productLeaf, wipInspecting.MainWIPIDCode.WIPPattern, wipInspecting.MainWIPIDCode.LotNumber, containerNo, wipInspecting.MainWIPIDCode.PWONo, wipInspecting.MainWIPIDCode.QCStatus, workUnitLeaf, 0, sysLogID, out errCode, out errText); WriteLog.Instance.Write(string.Format("({0}){1}", errCode, errText), strProcedureName); if (errCode != 0) { conn.RollBack(); return(Json(errCode)); } } catch (Exception error) { errCode = 99003; errText = string.Format("调用 usp_WIPForward 失败:{0}", error.Message); WriteLog.Instance.Write(errText, strProcedureName); WriteLog.Instance.Write(error.StackTrace, strProcedureName); conn.RollBack(); return(Json(errCode)); } WriteLog.Instance.Write("路由调整完成", strProcedureName); } #endregion } #region 更新工位的第二个瞬态属性(IRAPMDM..stb060) { WriteLog.Instance.Write("更新工位第二个瞬态属性", strProcedureName); int partitioningKey = Int32.Parse(communityID.ToString() + "0107"); List <IDataParameter> paramList = new List <IDataParameter>(); paramList.Add(new IRAPProcParameter("@Statistic02", DbType.Int64, TimeParser.LocalTimeToUnix(confirmTime))); paramList.Add(new IRAPProcParameter("@PartitioningKey", DbType.Int64, partitioningKey)); paramList.Add(new IRAPProcParameter("@T107EntityID", DbType.Int32, t107EntityID)); try { conn.Update("UPDATE IRAPMDM..stb060 SET Statistic02 = @Statistic02 " + "WHERE PartitioningKey = @PartitioningKey AND EntityID = @T107EntityID", paramList); } catch (Exception error) { errCode = 99004; errText = string.Format("更新工位(IRAPMDM..stb060)的第二个瞬态属性失败:{0}", error.Message); WriteLog.Instance.Write(errText, strProcedureName); WriteLog.Instance.Write(error.StackTrace, strProcedureName); conn.RollBack(); return(Json(errCode)); } WriteLog.Instance.Write("工位第二个瞬态属性更新完成", strProcedureName); } #endregion #region 交易复核(IRAPMES..stb010) { WriteLog.Instance.Write("交易复核", strProcedureName); long partitionPolicy = Int64.Parse(confirmTime.Year.ToString() + (100000000L + communityID).ToString().Substring(1, 8)); List <IDataParameter> paramList = new List <IDataParameter>(); paramList.Add(new IRAPProcParameter("@OkayTime", DbType.DateTime2, confirmTime)); paramList.Add(new IRAPProcParameter("@AgencyLeaf2", DbType.Int32, agencyLeaf)); paramList.Add(new IRAPProcParameter("@Checked", DbType.String, userCode)); paramList.Add(new IRAPProcParameter("@TransactNo", DbType.Int64, transactNo)); paramList.Add(new IRAPProcParameter("@PartitioningKey", DbType.Int64, partitionPolicy)); try { conn.Update("UPDATE IRAPMES..stb010 SET OkayTime = @OkayTime, " + "AgencyLeaf2 = @AgencyLeaf2, Checked = @Checked, " + "Status = 5 WHERE TransactNo = @TransactNo AND " + "PartitioningKey = @PartitioningKey", paramList); } catch (Exception error) { errCode = 99004; errText = string.Format("交易复核(IRAPMES..stb010)失败:{0}", error.Message); WriteLog.Instance.Write(errText, strProcedureName); WriteLog.Instance.Write(error.StackTrace, strProcedureName); conn.RollBack(); return(Json(errCode)); } WriteLog.Instance.Write("交易复核完成", strProcedureName); } #endregion conn.Commit(); errCode = 0; errText = "保存成功"; return(Json(errCode)); } } finally { WriteLog.Instance.WriteEndSplitter(strProcedureName); } }
/// <summary> /// 处理当前的日志 /// </summary> public void Do() { if (ShowEditorDialogs()) { string newXMLString = (ExChange[0] as IXMLNodeObject).GetXMLString(); TEntityCustomLog logWait4Exec = null; if (ErrCode != 0 && !Retried) { // 当前日志的最新待重试记录 try { TWaitting.Instance.ShowWaitForm("获取最新待重试记录"); logWait4Exec = DAL.TDBHelper.GetLastUnsuccessedLogWithLinkedLogID(LinkedLogID); } catch (Exception error) { TWaitting.Instance.CloseWaitForm(); MSGHelp.Instance.ShowErrorMessage(error); return; } } else { logWait4Exec = this; } if (logWait4Exec == null) { Exception error = new Exception(); error.Data["ErrCode"] = 999999; error.Data["ErrText"] = "当前待处理的日志已经被批量作业处理成功"; TWaitting.Instance.CloseWaitForm(); MSGHelp.Instance.ShowErrorMessage(error); } else { using (IRAPSQLConnection conn = new IRAPSQLConnection(SysParams.Instance.DBConnectionString)) { try { TWaitting.Instance.ShowWaitForm("更新日志记录"); logWait4Exec.ExChangeXML = (ExChange[0] as IXMLNodeObject).GetXMLString(); IList <IDataParameter> paramList = new List <IDataParameter>(); paramList.Add(new IRAPProcParameter("@ExChangeXML", DbType.Xml, newXMLString)); paramList.Add(new IRAPProcParameter("@LogID", DbType.Int64, LogID)); conn.Update( "UPDATE IRAP..stb_Log_WebServiceShuttling " + "SET ExChangeXML=@ExChangeXML " + "WHERE LogID=@LogID", paramList); } catch (Exception error) { error.Data["ErrCode"] = 999999; error.Data["ErrText"] = string.Format( "更新日志记录时发生异常:[{0}]", error.Message); TWaitting.Instance.CloseWaitForm(); MSGHelp.Instance.ShowErrorMessage(error); return; } int errCode = 0; string errText = ""; try { TWaitting.Instance.ShowWaitForm("调用 WebService"); IList <IDataParameter> paramList = new List <IDataParameter>(); paramList.Add(new IRAPProcParameter("@CommunityID", DbType.Int32, 60010)); paramList.Add(new IRAPProcParameter("@SysLogID", DbType.Int64, 1)); paramList.Add(new IRAPProcParameter("@WSSLogID", DbType.Int64, logWait4Exec.LogID)); paramList.Add(new IRAPProcParameter("@ErrCode", DbType.Int32, ParameterDirection.Output, 4)); paramList.Add(new IRAPProcParameter("@ErrText", DbType.String, ParameterDirection.Output, 400)); IRAPError error = conn.CallProc("IRAP..ssp_BackgroundJob_WSRetry", ref paramList); errCode = error.ErrCode; errText = error.ErrText; if (errCode != 0) { MSGHelp.Instance.ShowErrorMessage(errText); return; } } catch (Exception error) { error.Data["ErrCode"] = 999999; error.Data["ErrText"] = string.Format( "执行 IRAP..ssp_BackgroundJob_WSRetry 时发生异常:[{0}]", error.Message); TWaitting.Instance.CloseWaitForm(); MSGHelp.Instance.ShowErrorMessage(error); return; } try { TWaitting.Instance.ShowWaitForm("获取执行结果"); IList <TEntityCustomLog> datas = conn.CallTableFunc <TEntityCustomLog>( string.Format( "SELECT TOP 1 * FROM IRAP..stb_Log_WebServiceShuttling " + "WHERE LinkedLogID={0} ORDER BY LogID DESC", logWait4Exec.LinkedLogID), new List <IDataParameter>()); if (datas.Count > 0) { logWait4Exec = datas[0]; } else { logWait4Exec = null; } if (logWait4Exec != null) { if (logWait4Exec.ErrCode == 0) { //MSGHelp.Instance.ShowNormalMessage("手工处理成功,稍后进行后续处理"); AfterExecute(logWait4Exec); } else { MSGHelp.Instance.ShowErrorMessage( logWait4Exec.ErrCode, logWait4Exec.ErrText); } } else { MSGHelp.Instance.ShowErrorMessage("未获取到执行的结果"); } } catch (Exception error) { MSGHelp.Instance.ShowErrorMessage(error); } } } } }