private List <MSG_SEND> FindMessagesToSend(string CHANNEL_TYPE_I) { IDataReader r; List <MSG_SEND> Messages_List = new List <MSG_SEND>(); dbWebServiceSendRMS.GetMessagesCur(CHANNEL_TYPE_I, out r); try { while (r.Read()) { MSG_SEND t = new MSG_SEND(); // Build MSG_SEND object if (r["MSG_OUT_ID"] == DBNull.Value) { t.MSG_OUT_ID = ""; } else { t.MSG_OUT_ID = r["MSG_OUT_ID"] as String; } if (r["MSG_SEND_ID"] == DBNull.Value) { t.MSG_SEND_ID = ""; } else { t.MSG_SEND_ID = r["MSG_SEND_ID"] as String; } if (r["MSG_ID"] == DBNull.Value) { t.MSG_ID = ""; } else { t.MSG_ID = r["MSG_ID"] as String; } if (r["URL"] == DBNull.Value) { t.URL = ""; } else { t.URL = r["URL"] as String; } if (r["APILOGIN"] == DBNull.Value) { t.APILOGIN = ""; } else { t.APILOGIN = r["APILOGIN"] as String; } if (r["FIRSTSNDDTM"] == DBNull.Value) { t.FIRSTSNDDTM = System.DateTime.Now; } else { t.FIRSTSNDDTM = (DateTime)r["FIRSTSNDDTM"]; } if (r["COMM_PARTNER_ID"] == DBNull.Value) { t.COMM_PARTNER_ID = ""; } else { t.COMM_PARTNER_ID = r["COMM_PARTNER_ID"] as String; } if (r["CHANNEL_ID"] == DBNull.Value) { t.CHANNEL_ID = ""; } else { t.CHANNEL_ID = r["CHANNEL_ID"] as String; } Messages_List.Add(t); Tracing.TraceEvent(TraceEventType.Verbose, 0, String.Format("{0} - {1}", t.MSG_SEND_ID, t.MSG_ID)); } } finally { if (r != null) { r.Close(); } } return(Messages_List); }
private string HandleMessageType(MSG_SEND message_send) { string error = ""; string Url = message_send.URL; try { Tracing.TraceEvent(TraceEventType.Verbose, 0, String.Format(" use Url = {0}", Url)); if (String.IsNullOrEmpty(Url)) { return("unknown url for communication partner/channel " + message_send.COMM_PARTNER_ID + " / " + message_send.CHANNEL_ID + " - " + message_send.MSG_ID); } sender.Url = Url; switch (message_send.MSG_ID) { case "DEP": // -- Departure Message { DepartureSelect handler = new DepartureSelect(this.db); DepartureDoc message = handler.Process(message_send.MSG_OUT_ID); if (message == null) { error = string.Format("{0} obj missing.", message_send.MSG_ID); } else { sender.Departure(message_send.COMM_PARTNER_ID, message_send.MSG_SEND_ID, message); } break; } case "DEP_NODE": // -- Departure Node Message { DepartureNodeSelect handler = new DepartureNodeSelect(this.db); DepartureNodeDoc message = handler.Process(message_send.MSG_OUT_ID); if (message == null) { error = string.Format("{0} obj missing.", message_send.MSG_ID); } else { sender.DepartureNode(message_send.COMM_PARTNER_ID, message_send.MSG_SEND_ID, message); } break; } case "DEP_TRP": // -- Departure Transport Type { DepartureTransportTypeSelect handler = new DepartureTransportTypeSelect(this.db); DepartureTransportTypeDoc message = handler.Process(message_send.MSG_OUT_ID); if (message == null) { error = string.Format("{0} obj missing.", message_send.MSG_ID); } else { sender.DepartureTransportType(message_send.COMM_PARTNER_ID, message_send.MSG_SEND_ID, message); } break; } case "DEP_LOAD": // -- Departure Load { DepartureLoadSelect handler = new DepartureLoadSelect(this.db); DepartureLoadDoc message = handler.Process(message_send.MSG_OUT_ID); if (message == null) { error = string.Format("{0} obj missing.", message_send.MSG_ID); } else { sender.DepartureLoad(message_send.COMM_PARTNER_ID, message_send.MSG_SEND_ID, message); } break; } case "MOD_DEP_LOAD": // -- Modify Departure Load { ModifyDepartureLoadSelect handler = new ModifyDepartureLoadSelect(this.db); ModifyDepartureLoadDoc message = handler.Process(message_send.MSG_OUT_ID); if (message == null) { error = string.Format("{0} obj missing.", message_send.MSG_ID); } else { sender.ModifyDepartureLoad(message_send.COMM_PARTNER_ID, message_send.MSG_SEND_ID, message); } break; } case "REM_DEP": // -- Remove Departure { RemoveDepartureSelect handler = new RemoveDepartureSelect(this.db); RemoveDepartureDoc message = handler.Process(message_send.MSG_OUT_ID); if (message == null) { error = string.Format("{0} obj missing.", message_send.MSG_ID); } else { sender.RemoveDeparture(message_send.COMM_PARTNER_ID, message_send.MSG_SEND_ID, message); } break; } case "REM_DEP_NODE": // -- Remove Departure Node { RemoveDepartureNodeSelect handler = new RemoveDepartureNodeSelect(this.db); RemoveDepartureNodeDoc message = handler.Process(message_send.MSG_OUT_ID); if (message == null) { error = string.Format("{0} obj missing.", message_send.MSG_ID); } else { sender.RemoveDepartureNode(message_send.COMM_PARTNER_ID, message_send.MSG_SEND_ID, message); } break; } case "REM_DEP_TRP": // -- Remove Departure Transport Type { RemoveDepartureTransportTypeSelect handler = new RemoveDepartureTransportTypeSelect(this.db); RemoveDepartureTransportTypeDoc message = handler.Process(message_send.MSG_OUT_ID); if (message == null) { error = string.Format("{0} obj missing.", message_send.MSG_ID); } else { sender.RemoveDepartureTransportType(message_send.COMM_PARTNER_ID, message_send.MSG_SEND_ID, message); } break; } case "CONFIRM": // -- Confirmation Message { ConfirmSelect handler = new ConfirmSelect(this.db); ConfirmDoc message = handler.Process(message_send.MSG_OUT_ID); if (message == null) { error = string.Format("{0} obj missing.", message_send.MSG_ID); } else { sender.Confirm(message_send.COMM_PARTNER_ID, message_send.MSG_SEND_ID, message); } break; } default: error = string.Format("message type {0} not found", message_send.MSG_ID); break; } // switch (message_send.MSG_ID) } catch (UriFormatException e) { error = "The format of the URI is invalid. URL: " + Url + ", MSG_SEND_ID: " + message_send.MSG_SEND_ID + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace; } catch (InvalidOperationException e) { error = "Failed to reach " + sender.Url + " for " + message_send.MSG_ID + ". MSG_SEND_ID: " + message_send.MSG_SEND_ID + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace; } catch (System.Web.Services.Protocols.SoapException e) { error = "Interface mismatch. URL: " + sender.Url + ", MSG_ID: " + message_send.MSG_ID + ", MSG_SEND_ID: " + message_send.MSG_SEND_ID + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace; } catch (Exception e) { error = "Unexpected error. URL: " + sender.Url + ", MSG_ID: " + message_send.MSG_ID + ", MSG_SEND_ID: " + message_send.MSG_SEND_ID + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace; } return(error); }