//Handling event capture from MCS component #region IReceiveMsg Members public void OnMsg(int MsgID, string MsgType, string MsgValue, string MsgGroup, string Sender, string SenderGroup, string Receiver, DateTime Timestamp) { LogInfoController.AddLogInfo(LogInfoLevelEnum.Debug, "Into OnMsg, MsgValue = " + MsgValue, SessionInfo.LoginName, this.GetType().ToString() + "->" + "OnMsg()", SessionInfo.ExperimentID); if (onReceiveError != null) { onReceiveError(); } string m_OriginMsgGUID = ""; // create instance of XmlMsgBase and parse MsgValue content EVOApiErrorMsg.XmlMsgBase msgBase = new EVOApiErrorMsg.XmlMsgBase("", MsgValue); // save MsgGUID for response message (required since EVOApiErrorMessage V2.2.0.2) //m_OriginMsgGUID = msgBase.MsgGUID; System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.LoadXml(MsgValue); System.Xml.XmlNode node = xmlDoc.SelectSingleNode("/*/Header/MsgID"); if (null != node) { m_OriginMsgGUID = node.InnerText; } //Get Message type in order to create correct message object to access to the error member XmlMsgType msgType; msgType = (XmlMsgType)Enum.Parse(typeof(XmlMsgType), MsgType); switch (msgType) { case (XmlMsgType.MST_DetectError): XmlMsgDetectError msgDetect = new XmlMsgDetectError(MsgValue); msgDetect.ParsingXmlContent(); EVOErrorBox.MsgDetectError detectError = new EVOErrorBox.MsgDetectError(msgDetect); detectError.ShowDialog(); SendRespons(m_OriginMsgGUID, detectError.ErrorResponse); break; //the clot error message has no content case (XmlMsgType.MST_ClotError): XmlMsgClotError msgClotError = new XmlMsgClotError(MsgValue); msgClotError.ParsingXmlContent(); EVOErrorBox.ClotError clotError = new EVOErrorBox.ClotError(msgClotError); clotError.ShowDialog(); SendRespons(m_OriginMsgGUID, clotError.ErrorResponse); break; case (XmlMsgType.MST_DiluterCheckError): XmlMsgDiluterCheckError msg = new XmlMsgDiluterCheckError(MsgValue); msg.ParsingXmlContent(); EVOErrorBox.DiluterCheckError dulterCheckError = new EVOErrorBox.DiluterCheckError(msg); dulterCheckError.ShowDialog(); SendRespons(m_OriginMsgGUID, dulterCheckError.ErrorResponse); break; case (XmlMsgType.MST_DiTiFetchError): XmlMsgDiTiFetchError msgDiTiFetch = new XmlMsgDiTiFetchError(MsgValue); msgDiTiFetch.ParsingXmlContent(); EVOErrorBox.DiTiFetchError diTiFetchError = new EVOErrorBox.DiTiFetchError(msgDiTiFetch); diTiFetchError.ShowDialog(); SendRespons(m_OriginMsgGUID, diTiFetchError.ErrorResponse); break; case (XmlMsgType.MST_DiTiNotMountedError): XmlMsgDiTiNotMountedError msgditiNotMount = new XmlMsgDiTiNotMountedError(MsgValue); msgditiNotMount.ParsingXmlContent(); EVOErrorBox.DiTiNotMountedError ditiNotMount = new EVOErrorBox.DiTiNotMountedError(msgditiNotMount); ditiNotMount.ShowDialog(); SendRespons(m_OriginMsgGUID, ditiNotMount.ErrorResponse); break; case (XmlMsgType.MST_DiTiLostError): XmlMsgDiTiLostError msgditiLost = new XmlMsgDiTiLostError(MsgValue); msgditiLost.ParsingXmlContent(); EVOErrorBox.DiTiLostError ditiLost = new EVOErrorBox.DiTiLostError(msgditiLost); ditiLost.ShowDialog(); SendRespons(m_OriginMsgGUID, ditiLost.ErrorResponse); break; case (XmlMsgType.MST_DiTiMountedError): XmlMsgDiTiMountedError msgDitiMount = new XmlMsgDiTiMountedError(MsgValue); msgDitiMount.ParsingXmlContent(); EVOErrorBox.DiTiMountedError DitiMount = new EVOErrorBox.DiTiMountedError(msgDitiMount); DitiMount.ShowDialog(); SendRespons(m_OriginMsgGUID, DitiMount.ErrorResponse); break; case (XmlMsgType.MST_MessageBox): XmlMsgMessageBox msgMB = new XmlMsgMessageBox(MsgValue); msgMB.ParsingXmlContent(); if (msgMB.errorPrompt.Contains("Evoware switches to offline mode and aborts script")) { EVOOffline = true; if (onOfflineStatus != null) { onOfflineStatus(); } } EVOErrorBox.MsgMessageBox messageBox = new EVOErrorBox.MsgMessageBox(msgMB); messageBox.ShowDialog(); if (msgMB.errorPrompt.Contains("No connection to the instrument")) { if (messageBox.ErrorResponse == ErrorResponseOption.DLG_NO) { EVOOffline = true; if (onOfflineStatus != null) { onOfflineStatus(); } } else { isNoConnection = true; } } SendRespons(m_OriginMsgGUID, messageBox.ErrorResponse); break; case (XmlMsgType.MST_DoorLockError): XmlMsgDoorLockError msgDoorLockError = new XmlMsgDoorLockError(MsgValue); msgDoorLockError.ParsingXmlContent(); EVOErrorBox.DoorLockError doorLockError = new EVOErrorBox.DoorLockError(msgDoorLockError); doorLockError.ShowDialog(); SendRespons(m_OriginMsgGUID, doorLockError.ErrorResponse); break; case (XmlMsgType.MST_GripError): XmlMsgGripError msgGripError = new XmlMsgGripError(MsgValue); msgGripError.ParsingXmlContent(); EVOErrorBox.GripError gripError = new EVOErrorBox.GripError(msgGripError); gripError.ShowDialog(); SendRespons(m_OriginMsgGUID, gripError.ErrorResponse); break; default: SendRespons(m_OriginMsgGUID, ErrorResponseOption.NONE); break; //All other message type here } }
public MsgMessageBox(XmlMsgMessageBox MsgMessageBox) { InitializeComponent(); _MsgMessageBox = MsgMessageBox; if (_MsgMessageBox.errorPrompt.Contains("Evoware switches to offline mode and aborts script")) { this.errorPrompt.Text = WanTai.Common.Resources.WanTaiResource.OffLineModeMessage; } else if (_MsgMessageBox.errorPrompt.Contains("No connection to the instrument")) { this.errorPrompt.Text = WanTai.Common.Resources.WanTaiResource.OffLineMessage; } else { this.errorPrompt.Text = _MsgMessageBox.errorPrompt; } this.Text = _MsgMessageBox.hdrCaption; if (string.IsNullOrEmpty(_MsgMessageBox.btnOneCaption)) { this.btnOne.Visible = false; } else { string text = WanTai.Common.Resources.WanTaiResource.ResourceManager.GetString(_MsgMessageBox.btnOneCaption, WanTai.Common.Resources.WanTaiResource.Culture); if (!string.IsNullOrEmpty(text)) { this.btnOne.Text = text; } else { this.btnOne.Text = _MsgMessageBox.btnOneCaption; } } if (string.IsNullOrEmpty(_MsgMessageBox.btnTwoCaption)) { this.btnTwo.Visible = false; } else { string text = WanTai.Common.Resources.WanTaiResource.ResourceManager.GetString(_MsgMessageBox.btnTwoCaption, WanTai.Common.Resources.WanTaiResource.Culture); if (!string.IsNullOrEmpty(text)) { this.btnTwo.Text = text; } else { this.btnTwo.Text = _MsgMessageBox.btnTwoCaption; } } if (string.IsNullOrEmpty(_MsgMessageBox.btnThreeCaption)) { this.btnThree.Visible = false; } else { string text = WanTai.Common.Resources.WanTaiResource.ResourceManager.GetString(_MsgMessageBox.btnThreeCaption, WanTai.Common.Resources.WanTaiResource.Culture); if (!string.IsNullOrEmpty(text)) { this.btnThree.Text = text; } else { this.btnThree.Text = _MsgMessageBox.btnThreeCaption; } } }