public void BindOrderToOecOrderVersion(BusinessEntities.Order order, OEC.API.Version ver)
            {
                if (ver.ID > 0)
                {
                    order.Id = ver.ID;
                }

                if (_versionOrderSet.ContainsKey(ver))
                {
                    if (_versionOrderSet[ver] != order)
                    {
                        _connector.AddWarningLog("Старая версия заявки не была удалена из коллекции.");
                        _versionOrderSet.Remove(ver);
                        _versionOrderSet[ver] = order;
                    }
                }
                else
                {
                    _versionOrderSet[ver] = order;
                }
            }
        /// <inheritdoc />
        protected override void OnInnerAdapterNewOutMessage(Message message)
        {
            long TryReplaceOriginId(long id)
            {
                if (id == 0)
                {
                    return(0);
                }

                lock (_sync)
                    return(_replaceId.TryGetValue(id, out var prevId) ? prevId : id);
            }

            var prevOriginId = 0L;
            var newOriginId  = 0L;

            if (message is IOriginalTransactionIdMessage originIdMsg1)
            {
                newOriginId  = originIdMsg1.OriginalTransactionId;
                prevOriginId = originIdMsg1.OriginalTransactionId = TryReplaceOriginId(newOriginId);
            }

            switch (message.Type)
            {
            case MessageTypes.SubscriptionResponse:
            {
                lock (_sync)
                {
                    if (((SubscriptionResponseMessage)message).IsOk())
                    {
                        if (_subscriptionsById.TryGetValue(prevOriginId, out var info))
                        {
                            // no need send response after re-subscribe cause response was handled prev time
                            if (_replaceId.ContainsKey(newOriginId))
                            {
                                if (info.State != SubscriptionStates.Stopped)
                                {
                                    return;
                                }
                            }
                            else
                            {
                                ChangeState(info, SubscriptionStates.Active);
                            }
                        }
                    }
                    else
                    {
                        if (!_historicalRequests.Remove(prevOriginId))
                        {
                            if (_subscriptionsById.TryGetAndRemove(prevOriginId, out var info))
                            {
                                ChangeState(info, SubscriptionStates.Error);

                                _replaceId.Remove(newOriginId);
                            }
                        }
                    }
                }

                break;
            }

            case MessageTypes.SubscriptionOnline:
            {
                lock (_sync)
                {
                    if (!_subscriptionsById.TryGetValue(prevOriginId, out var info))
                    {
                        break;
                    }

                    if (_replaceId.ContainsKey(newOriginId))
                    {
                        // no need send response after re-subscribe cause response was handled prev time

                        if (info.State == SubscriptionStates.Online)
                        {
                            return;
                        }
                    }
                    else
                    {
                        ChangeState(info, SubscriptionStates.Online);
                    }
                }

                break;
            }

            case MessageTypes.SubscriptionFinished:
            {
                lock (_sync)
                {
                    if (_replaceId.ContainsKey(newOriginId))
                    {
                        return;
                    }

                    _historicalRequests.Remove(prevOriginId);

                    if (_subscriptionsById.TryGetValue(newOriginId, out var info))
                    {
                        ChangeState(info, SubscriptionStates.Finished);
                    }
                }

                break;
            }

            default:
            {
                if (message is ISubscriptionIdMessage subscrMsg)
                {
                    lock (_sync)
                    {
                        var ids = subscrMsg.GetSubscriptionIds();

                        if (ids.Length == 0)
                        {
                            if (subscrMsg.OriginalTransactionId != 0 && _historicalRequests.ContainsKey(subscrMsg.OriginalTransactionId))
                            {
                                subscrMsg.SetSubscriptionIds(subscriptionId: subscrMsg.OriginalTransactionId);
                            }
                        }
                        else
                        {
                            lock (_sync)
                            {
                                if (_replaceId.Count > 0)
                                {
                                    subscrMsg.SetSubscriptionIds(ids.Select(id => _replaceId.TryGetValue2(id) ?? id).ToArray());
                                }
                            }
                        }
                    }
                }

                break;
            }
            }

            base.OnInnerAdapterNewOutMessage(message);

            switch (message.Type)
            {
            case ExtendedMessageTypes.ReconnectingFinished:
            {
                ProcessSuspendedMessage supended = null;

                lock (_sync)
                {
                    _replaceId.Clear();
                    _reMapSubscriptions.Clear();

                    _reMapSubscriptions.AddRange(_subscriptionsById.Values.Distinct().Where(i => i.State.IsActive()).Select(i =>
                        {
                            var subscription           = i.Subscription.TypedClone();
                            subscription.TransactionId = TransactionIdGenerator.GetNextId();

                            _replaceId.Add(subscription.TransactionId, i.Subscription.TransactionId);

                            this.AddInfoLog("Re-map subscription: {0}->{1} for '{2}'.", i.Subscription.TransactionId, subscription.TransactionId, i.Subscription);

                            return((Message)subscription);
                        }));

                    if (_reMapSubscriptions.Count > 0)
                    {
                        supended = new ProcessSuspendedMessage(this);
                    }
                }

                if (supended != null)
                {
                    base.OnInnerAdapterNewOutMessage(supended);
                }

                break;
            }
            }
        }