Ejemplo n.º 1
0
 /// <summary>
 /// Saves a MDSMessageRecord object.
 /// </summary>
 /// <param name="messageRecord"></param>
 public int StoreMessage(MDSMessageRecord messageRecord)
 {
     lock (_messages)
     {
         messageRecord.Id = (++_lastRecordId);
         _messages.Add(messageRecord.Id, messageRecord);
         return messageRecord.Id;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Saves a MDSMessageRecord.
 /// </summary>
 /// <param name="messageRecord">MDSMessageRecord object to save</param>
 /// <returns>Auto Increment Id of saved message</returns>
 public int StoreMessage(MDSMessageRecord messageRecord)
 {
     var bytesOfMessage = MDSSerializationHelper.SerializeToByteArray(messageRecord.Message);
     var id = InsertAndGetLastId(
         "INSERT INTO messages(MessageId, DestServer, NextServer, DestApplication, MessageData, MessageDataLength, RecordDate) VALUES(?,?,?,?,?,?,now());",
         new OdbcParameter("?MessageId", messageRecord.MessageId),
         new OdbcParameter("?DestServer", messageRecord.DestServer),
         new OdbcParameter("?NextServer", messageRecord.NextServer),
         new OdbcParameter("?DestApplication", messageRecord.DestApplication),
         new OdbcParameter("?MessageData", bytesOfMessage),
         new OdbcParameter("?MessageDataLength", bytesOfMessage.Length)
         );
     messageRecord.Id = id;
     return id;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Saves a MDSMessageRecord.
 /// </summary>
 /// <param name="messageRecord">MDSMessageRecord object to save</param>
 /// <returns>Auto Increment Id of saved message</returns>
 public int StoreMessage(MDSMessageRecord messageRecord)
 {
     lock (_syncObj)
     {
         var bytesOfMessage = MDSSerializationHelper.SerializeToByteArray(messageRecord.Message);
         var id = InsertAndGetLastId(
             "INSERT INTO messages(MessageId, DestServer, NextServer, DestApplication, MessageData, MessageDataLength, RecordDate) VALUES(@MessageId,@DestServer,@NextServer,@DestApplication,@MessageData,@MessageDataLength,@RecordDate);",
             new SQLiteParameter("@MessageId", messageRecord.MessageId),
             new SQLiteParameter("@DestServer", messageRecord.DestServer),
             new SQLiteParameter("@NextServer", messageRecord.NextServer),
             new SQLiteParameter("@DestApplication", messageRecord.DestApplication),
             new SQLiteParameter("@MessageData", bytesOfMessage),
             new SQLiteParameter("@MessageDataLength", bytesOfMessage.Length),
             new SQLiteParameter("@RecordDate", DateTime.Now)
             );
         messageRecord.Id = id;
         return id;
     }
 }