/// <summary> /// Проверить подписку по вендорскому коду /// </summary> public async Task <Tuple <bool, string> > TrySubscribeAsync(string code, SecurityType type) { using (LogManager.Scope()) { await securityTypeIndexCompleted.Task; int typeId; if (!securityTypeIndex.TryGetValue(type, out typeId)) { var message = LogMessage.Format($"Failed to find an identifier for {type}").ToString(); Logger.Warn().Print(message); return(Tuple.Create(false, message)); } var operation = new SubscriptionTest(code, type); var requestId = LookupSocketWrapper.RequestIdPrefix + Guid.NewGuid().ToString("N"); using (subscriptionTestsLock.Lock()) { subscriptionTests[requestId] = operation; } lookupSocket.RequestSymbolLookup(code, typeId, requestId); var result = await operation.Task; return(Tuple.Create(result, operation.Message)); } }
/// <summary> /// Проверить подписку /// </summary> async Task <SubscriptionTestResult> ISubscriptionTester <IQFeedInstrumentData> .TestSubscriptionAsync(IQFeedInstrumentData data) { using (LogManager.Scope()) { await securityTypeIndexCompleted.Task; if (!securityTypeIndex.TryGetValue(data.SecurityType, out var typeId)) { var message = LogMessage.Format($"Failed to find an identifier for {data.SecurityType}").ToString(); Logger.Warn().Print(message); return(SubscriptionTestResult.Failed(message)); } var operation = new SubscriptionTest(data.Symbol, data.SecurityType); var requestId = LookupSocketWrapper.RequestIdPrefix + Guid.NewGuid().ToString("N"); using (subscriptionTestsLock.Lock()) { subscriptionTests[requestId] = operation; } lookupSocket.RequestSymbolLookup(data.Symbol, typeId, requestId); var result = await operation.Task; if (result) { return(SubscriptionTestResult.Passed()); } return(SubscriptionTestResult.Failed()); } }