GetNextSenderMsgSeqNum() public method

public GetNextSenderMsgSeqNum ( ) : int
return int
Exemplo n.º 1
0
        public void PopulateCache()
        {
            string queryString = string.Empty;

            queryString = "SELECT creation_time, incoming_seqnum, outgoing_seqnum FROM " + sessions_table + " WHERE " +
                          "beginstring=" + "'" + _sessionID.BeginString + "' and " +
                          "sendercompid=" + "'" + _sessionID.SenderCompID + "' and " +
                          "targetcompid=" + "'" + _sessionID.TargetCompID + "' and " +
                          "session_qualifier=" + "'" + _sessionID.SessionQualifier + "'";

            using (OdbcConnection odbc = GetODBCConnection())
            {
                OdbcCommand    cmd    = new OdbcCommand(queryString, odbc);
                OdbcDataReader reader = cmd.ExecuteReader();
                int            rows   = 0;
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        rows++;
                        if (rows > 1)
                        {
                            throw new ConfigError("Multiple entries found for session in database");
                        }

                        cache_.CreationTime = DateTime.SpecifyKind((DateTime)reader[0], DateTimeKind.Utc);
                        //DateTime.SpecifyKind(cache_.CreationTime.Value, DateTimeKind.Utc);
                        cache_.SetNextTargetMsgSeqNum((int)reader[1]);
                        cache_.SetNextSenderMsgSeqNum((int)reader[2]);
                    }
                }
                else
                {
                    DateTime createTime  = cache_.CreationTime.HasValue ? cache_.CreationTime.Value : DateTime.UtcNow;
                    string   insertQuery = "INSERT INTO " + sessions_table + " (beginstring, sendercompid, targetcompid, session_qualifier," +
                                           "creation_time, incoming_seqnum, outgoing_seqnum) VALUES(" +
                                           "'" + _sessionID.BeginString + "'," +
                                           "'" + _sessionID.SenderCompID + "'," +
                                           "'" + _sessionID.TargetCompID + "'," +
                                           "'" + _sessionID.SessionQualifier + "'," +
                                           "{ts '" + ODBCHelper.DateTimeToODBCConverter(createTime) + "'}," +
                                           cache_.GetNextTargetMsgSeqNum() + "," +
                                           cache_.GetNextSenderMsgSeqNum() + ")";

                    OdbcCommand cmdInsert = new OdbcCommand(insertQuery, odbc);
                    if (0 == cmdInsert.ExecuteNonQuery())
                    {
                        throw new ConfigError("Unable to create session in database");
                    }
                }
            }
        }
Exemplo n.º 2
0
 public int GetNextSenderMsgSeqNum()
 {
     return(cache_.GetNextSenderMsgSeqNum());
 }