SetNextTargetMsgSeqNum() public method

public SetNextTargetMsgSeqNum ( int value ) : void
value int
return void
Esempio n. 1
0
        private void ConstructFromFileCache()
        {
            offsets_.Clear();
            if (System.IO.File.Exists(headerFileName_))
            {
                using (System.IO.StreamReader reader = new System.IO.StreamReader(headerFileName_))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        string[] headerParts = line.Split(',');
                        if (headerParts.Length == 3)
                        {
                            offsets_[Convert.ToInt32(headerParts[0])] = new MsgDef(
                                Convert.ToInt64(headerParts[1]), Convert.ToInt32(headerParts[2]));
                        }
                    }
                }
            }

            if (System.IO.File.Exists(seqNumsFileName_))
            {
                using (System.IO.StreamReader seqNumReader = new System.IO.StreamReader(seqNumsFileName_))
                {
                    string[] parts = seqNumReader.ReadToEnd().Split(':');
                    if (parts.Length == 2)
                    {
                        cache_.SetNextSenderMsgSeqNum(Convert.ToInt32(parts[0]));
                        cache_.SetNextTargetMsgSeqNum(Convert.ToInt32(parts[1]));
                    }
                }
            }
        }
Esempio n. 2
0
        private void open()
        {
            lastWrite_ = DateTime.MinValue;

            var(senderMsgSeqNum, targetMsgSeqNum, sessionStart) = load();

            if (senderMsgSeqNum.HasValue)
            {
                cache_.SetNextSenderMsgSeqNum(senderMsgSeqNum.Value);
            }

            if (targetMsgSeqNum.HasValue)
            {
                cache_.SetNextTargetMsgSeqNum(targetMsgSeqNum.Value);
            }

            if (sessionStart.HasValue)
            {
                cache_.CreationTime = new DateTime(sessionStart.Value.Ticks, DateTimeKind.Utc);
            }
            else
            {
                save(null, null, cache_.CreationTime.Value);
            }
        }
Esempio n. 3
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");
                    }
                }
            }
        }