protected virtual void S2F17ReceiveDateAndTimeRequest(object sender, SECSEventArgs e) { try { S2F17 s2f17 = ((S2F17)e.secsHandler.Parse <S2F17>(e)); SCUtility.secsActionRecordMsg(scApp, true, s2f17); if (!isProcess(s2f17)) { return; } S2F18 s2f18 = null; s2f18 = new S2F18(); s2f18.SystemByte = s2f17.SystemByte; s2f18.SECSAgentName = scApp.EAPSecsAgentName; s2f18.TIME = DateTime.Now.ToString("yyyyMMddHHmmss"); TrxSECS.ReturnCode rtnCode = ISECSControl.replySECS(bcfApp, s2f18); SCUtility.secsActionRecordMsg(scApp, false, s2f18); if (rtnCode != TrxSECS.ReturnCode.Normal) { logger.Warn("Reply EQPT S2F18 Error:{0}", rtnCode); } } catch (Exception ex) { logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}", line.LINE_ID, "S2F17_Receive_Date_Time_Req", ex.ToString()); } }
public virtual bool S2F17SendDateAndTimeRequest() { try { S2F17 s2f17 = new S2F17(); s2f17.SECSAgentName = scApp.EAPSecsAgentName; S2F18 s2f18 = null; string rtnMsg = string.Empty; SXFY abortSecs = null; SCUtility.secsActionRecordMsg(scApp, false, s2f17); TrxSECS.ReturnCode rtnCode = ISECSControl.sendRecv <S2F18>(bcfApp, s2f17, out s2f18, out abortSecs, out rtnMsg, null); SCUtility.actionRecordMsg(scApp, s2f17.StreamFunction, line.Real_ID, "Date Time Request.", rtnCode.ToString()); if (rtnCode == TrxSECS.ReturnCode.Normal) { SCUtility.secsActionRecordMsg(scApp, true, s2f18); string timeStr = s2f18.TIME; DateTime mesDateTime = DateTime.Now; try { mesDateTime = DateTime.ParseExact(timeStr.Trim(), SCAppConstants.TimestampFormat_16, CultureInfo.CurrentCulture); } catch (Exception dtEx) { logger.Error(dtEx, String.Format("Receive Date Time Set Request From MES. Format Error![Date Time:{0}]", timeStr)); } if (!DebugParameter.DisableSyncTime) { SCUtility.updateSystemTime(mesDateTime); } //todo 跟其他設備同步 return(true); } else { logger.Warn("Send Date Time Request[S2F17] Error!"); } } catch (Exception ex) { logger.Error("MESDefaultMapAction has Error[Line Name:{0}],[Error method:{1}],[Error Message:{2}", line.LINE_ID, "sendS2F17_DateTimeReq", ex.ToString()); } return(false); }