示例#1
0
        private void HistoryReceivedCallback(Selection historyRequest, List <Bar> bars)
        {
            var request = default(HistoryDataRequest);

            lock (_historyWorker.HistoryRequest)
            {
                request = _historyWorker.HistoryRequest.FirstOrDefault(p => p.Selection.Id.Equals(historyRequest.Id));
                if (request == null)
                {
                    return;
                }

                _historyWorker.HistoryRequest.Remove(request);
            }

            try
            {
                var aResponse = new HistoryDataResponse
                {
                    Bars = bars.OrderByDescending(o => o.Date).ToList(),
                    ID   = historyRequest.Id,
                    User = request.User
                };

                PushResponse(aResponse);
            }
            catch (Exception e)
            {
                Logger.Error("HistoryReceivedCallback", e);
                try
                {
                    request.User.SendError(new ApplicationException($"Historical request (ID='{historyRequest.Id}')"));
                }
                catch
                {
                }
            }
        }
 internal void OnHistoricalData(HistoryDataResponse message) =>
     HistoricalData?.Invoke(this, new EventArgs<HistoryDataResponse>(message));
 /// <summary>
 /// Преобразовать ответ в клиентскую версию
 /// </summary>
 public static IHistoryData ToClient(HistoryDataResponse historyDataResponse) =>
 new HistoryDataClient(historyDataResponse.PackageId, historyDataResponse.CreationDateTime,
                       historyDataResponse.ClientName, historyDataResponse.StatusProcessingProject,
                       historyDataResponse.FilesCount);