/// <summary> /// Method that process the MSG table. /// Reads the unprocessed messages, and sends them to the becsfecs queue. /// </summary> protected virtual void ProcessMessages() { if (_logger != null) { _logger.AddLog("MSG_D::Processing pending messages.", LoggerSeverities.Debug); } if (_queue == null) { return; } try { CmpMessagesDB cmp = new CmpMessagesDB(); // At the first iteration _ds is NULL, so we get ALL messages (SENDING and PENDING). // At the rest of iterations only PENDING messages will be retrieved each time... _ds = cmp.GetPendingMessages(_ds == null); // Process one-on-one the messages of the table... foreach (DataRow dr in _ds.Tables[0].Rows) { MessageFromBD msg = ProcessMessage(dr); msg.UpdateData(); } // At that point data on DataSet _ds has been updated in dataset, so we update the DataBase. cmp.UpdateMessages(_ds); } catch (Exception e) { if (_logger != null) { _logger.AddLog(e); } } }
/// <summary> /// Processes ONE pending messsage. /// The message is marked as MSG_STATUS sending (1) and is put in the becsfecs queue. /// </summary> /// <param name="dr">DataRow with info about the message to be sended</param> /// <returns>MessageFromBD object containing info about the message to be send</returns> protected virtual MessageFromBD ProcessMessage(DataRow dr) { MessageFromBD msg = null; try { // Get info of the message, and sends it to the fecsbecs queue. msg = new MessageFromBD(dr); msg.Send(_queue); return(msg); } catch (Exception) { // Some exception processing the message // TODO: Log the exception return(msg); } }