public void SendReport <T>(REPORT_TYPE _type, T _obj, Model.Header _header, string _eqpID) { try { switch (_type) { case REPORT_TYPE.EqpStatuChangeReport: // Step 1: Check Validation of the object // if (!(_obj is Report.StatuChangeReport)) { throw new ObjectValidationException(); } // Step 2: Convert into JSON // string msg = SemiJSONHelper.GetString(_obj, _header, Model.MESSAGE_TYPE.REQUEST, _eqpID); // step 3: Send to Server // if (!string.IsNullOrEmpty(msg)) { SendAsyn(msg, true); } break; case REPORT_TYPE.EqpAlarmReport: if (!(_obj is Report.AlarmReport)) { throw new ObjectValidationException(); } // TO-DO break; case REPORT_TYPE.EqpEdcReport: if (!(_obj is Report.EdcReport)) { throw new ObjectValidationException(); } // TO-DO break; default: throw new ObjectValidationException("Object type invalid"); } } catch (Exception ex) { throw new Exception(ex.ToString()); } }
private async Task messageBody(string _msg, string _body, Model.Header _header, Action <Object, Model.Header> callback) { try { if (_msg == Report.REPORT_TYPE.EqpStatuChangeReport.ToString()) { var obj = JsonConvert.DeserializeObject <Report.StatuChangeReport>(_body); callback(obj, _header); } } catch (Exception ex) { throw new Exception(E_CODE.JSON_MSG_BODY_VALIDATION_FAILED.ToString() + ":" + ex.Message); } }
private void requestObject(object _obj, Model.Header _header) { try { if (_obj is Report.StatuChangeReport) { string msg = SemiJSONHelper.GetString(_obj, _header, Model.MESSAGE_TYPE.RESPONSE, "A"); if (SemiManager.Instance != null) { SemiManager.Instance.SendAsyn(msg, false); } } } catch (Exception ex) { throw new Exception(E_CODE.JSON_REQ_OBJECT_FAILED.ToString() + ":" + ex.Message); } }
private static string sendReport(object _report, Model.Header _header) { try { string msg = string.Empty; RequestMessage message = new RequestMessage(); message.Request = new Model.Request(); message.Request.Header = _header; message.Request.Body = _report; msg = JsonConvert.SerializeObject(message, Formatting.Indented); return(msg); } catch (Exception ex) { throw new Exception(ex.ToString()); } }
public static string GetString <T>(T _obj, Model.Header _head, MESSAGE_TYPE _type, string _eqpID) { try { switch (_type) { case MESSAGE_TYPE.REQUEST: return(requestObject(_obj, _head)); case MESSAGE_TYPE.RESPONSE: return(reponseMessage(_head, _eqpID)); } return(string.Empty); } catch (Exception ex) { throw new Exception(ex.ToString()); } }