Beispiel #1
0
 public static void AddSubscriber(Guid clientKey, string[] fixMsgsTypes, string callbackQueue)
 {
     lock (m_sessions)
     {
         if (!m_sessions.ContainsKey(clientKey))
         {
             string msgTypesString = string.Empty;
             foreach (string msgType in fixMsgsTypes)
             {
                 msgTypesString += string.Format("{0},", msgType);
                 if (!m_fixMsgType_SubscribersKeys.ContainsKey(msgType))
                 {
                     m_fixMsgType_SubscribersKeys.Add(msgType, new List <Guid>());
                 }
                 if (!m_fixMsgType_SubscribersKeys[msgType].Contains(clientKey))
                 {
                     m_fixMsgType_SubscribersKeys[msgType].Add(clientKey);
                 }
             }
             msgTypesString = msgTypesString.Remove(msgTypesString.Length - 1, 1);
             using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope())
             {
                 DateTime        dtNow = DateTime.Now;
                 DatabaseMethods db    = new DatabaseMethods();
                 db.AddReplicationSessionSubscriber(clientKey, msgTypesString, callbackQueue, dtNow);
                 m_sessions.Add(clientKey, new ReplicatedSessionSubscriberDetails()
                 {
                     SessionRemoteQueue = new MessageQueue(callbackQueue), SubscribedFixMsgsTypes = fixMsgsTypes, LastHeartBeatRequest = dtNow, LastHeartBeatResponse = dtNow, QueuePath = callbackQueue, SubscriberKey = clientKey, SubscriptionDateTime = dtNow
                 });
                 ts.Complete();
             }
         }
     }
 }