public EErrorCodes GetTimeSeriesInfo(string country, string ticker) { EErrorCodes result = EErrorCodes.GeneralError; try { if (Client != null && SessionToken != null) { GetTimeSeriesInfo reqGetTSInfo = new GetTimeSeriesInfo(); reqGetTSInfo.SessionToken = SessionToken; reqGetTSInfo.Ticker = ticker; reqGetTSInfo.CountryCode = country; GetTimeSeriesInfoResponse resGetTSInfo = Post <GetTimeSeriesInfo, GetTimeSeriesInfoResponse>("/api/timeseries/GetTimeSeriesInfo", reqGetTSInfo); if (resGetTSInfo.Success) { IndicatorData indData = null; if (!Indicators.TryGetValue(ticker, out indData)) { indData = new IndicatorData(); indData.Name = resGetTSInfo.Payload.Name; indData.Code = resGetTSInfo.Payload.Ticker; Indicators.Add(ticker, indData); } indData.SetColumns(resGetTSInfo.Payload.Columns); result = EErrorCodes.Success; } else { result = resGetTSInfo.Errors[0].Code; } } else { return(EErrorCodes.SessionClosed); } } catch (Exception ex) { _lastError = ex; result = EErrorCodes.GeneralError; } return(result); }
public GetTimeSeriesInfoResponse Any(GetTimeSeriesInfo request) { _logger.Log(EErrorType.Info, " ****** Call start: GetTimeSeriesInfo"); GetTimeSeriesInfoResponse response = new GetTimeSeriesInfoResponse(); TransferHeader(request, response); try { if (IsValidSessionToken(request)) { IQuotesDalGetTimeSeriesInfoParams getTInfoParams = _dal.CreateGetTimeSeriesInfoParams(); getTInfoParams.CountryCode = request.CountryCode; getTInfoParams.Ticker = request.Ticker; IQuotesDalGetTimeSeriesInfoResult getTInfoResult = _dal.GetTimeSeriesInfo(getTInfoParams); if (getTInfoResult.Success) { response.Payload.Ticker = request.Ticker; response.Payload.Type = getTInfoResult.Type; response.Payload.Unit = getTInfoResult.Unit; response.Payload.Name = getTInfoResult.Name; response.Payload.CountryCode = request.CountryCode; foreach (var t in getTInfoResult.Series) { response.Payload.Series.Add( new TimeSeriesInfoItem() { TimeFrame = (DTO.ETimeFrame)t.Timeframe, PeriodEnd = t.PeriodEnd, PeriodStart = t.PeriodStart } ); } foreach (var c in getTInfoResult.Columns) { response.Payload.Columns.Add(c); } if (getTInfoResult.Metadata != null && getTInfoResult.Metadata.Count > 0) { response.Payload.Metadata = new List <TimeseriesMetadataRecord>(); foreach (var k in getTInfoResult.Metadata.Keys) { TimeseriesMetadataRecord metaRec = new TimeseriesMetadataRecord(); metaRec.Key = k; metaRec.Value = getTInfoResult.Metadata[k]; response.Payload.Metadata.Add(metaRec); } } response.Success = true; } else { response.Errors.AddRange(getTInfoResult.Errors); } } else { response.Success = false; response.Errors.Add(new Error() { Code = EErrorCodes.InvalidSession, Type = EErrorType.Error, Message = "Invalid session token" }); } } catch (Exception ex) { _logger.Log(ex); response.Success = false; response.Errors.Add(new Error() { Code = EErrorCodes.GeneralError, Type = EErrorType.Error, Message = string.Format("Unpexcted error: {0}", ex.Message) }); } _logger.Log(EErrorType.Info, " ****** Call end: GetTimeSeriesList"); return(response); }