private void ProcessSubscriberSignal(MT4TradeSignal signal, int providerOrderId, long providerId) { var providerServer = AccountsDictionary[providerId].Item1; var providerOrder = new OrderModel { OrderId = providerOrderId, Server = providerServer }; var subscriberOrder = new OrderModel { OrderId = signal.OrderID, Server = signal.Server }; var subscriber = signalServiceRepository.GetSubscriberByLogin(signal.Login, serversDictionary.First(x => x.Value == signal.Server).Key); if (subscriber == null) { SignalService.Logger.Error("Subscriber not found"); return; } if (!mt4AccountsDictionary[signal.Server].ContainsKey(signal.Login)) { mt4AccountsDictionary[signal.Server].Add(signal.Login, subscriber.id); } lock (OpenedOrdersDictionary) { var contains = OpenedOrdersDictionary.ContainsKey(providerOrder); if (!contains) { SignalService.Logger.Error("OpenedOrdersDictionary don't contains providerOrder (OrderId: {0}, Server: {1}", providerOrder.OrderId, providerOrder.Server); return; } if (signal.ActionType == ActionType.Open) { OpenedOrdersDictionary[providerOrder].Add(subscriberOrder); } else { OpenedOrdersDictionary[providerOrder].Remove(subscriberOrder); if (OpenedOrdersDictionary[providerOrder].Count == 0) { OpenedOrdersDictionary.Remove(providerOrder); } } } }