Ejemplo n.º 1
0
        void WriteAggregateResponseToExcel(AggregateResponse response, string path)
        {
            var workbook = new XSSFWorkbook();
            var sheet    = workbook.CreateSheet(StocksTicker);

            var header = sheet.CreateRow(0);

            header.CreateCell(0).SetCellValue("UTC");
            header.CreateCell(1).SetCellValue("Open");
            header.CreateCell(2).SetCellValue("High");
            header.CreateCell(3).SetCellValue("Low");
            header.CreateCell(4).SetCellValue("Close");
            header.CreateCell(5).SetCellValue("Volume");
            header.CreateCell(6).SetCellValue("Samples");

            var rowCount = 1;

            foreach (var rowResult in response.Results)
            {
                var row = sheet.CreateRow(rowCount);
                row.CreateCell(0).SetCellValue(rowResult.Timestamp.UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss"));
                row.CreateCell(1).SetCellValue((double)rowResult.Open);
                row.CreateCell(2).SetCellValue((double)rowResult.High);
                row.CreateCell(3).SetCellValue((double)rowResult.Low);
                row.CreateCell(4).SetCellValue((double)rowResult.Close);
                row.CreateCell(5).SetCellValue((double)rowResult.Volume);
                row.CreateCell(6).SetCellValue((double)rowResult.Samples);
                rowCount++;
            }

            var sw = File.Create(path);

            workbook.Write(sw);
            sw.Close();
        }
        public async Task <List <Event <T> > > GetEventsAsync <T>(string streamName, Guid streamId)
        {
            streamName = streamName.ToLower();
            AggregateResponse <T> events = await _aggregatesClient.GetAsync <T>(streamName, streamId);

            return(events.Events.Select(x => new Event <T>
            {
                Data = x.Data
            }).ToList());
        }
Ejemplo n.º 3
0
        public override void WriteJson(JsonWriter writer, AggregateResponse <T> value, JsonSerializer serializer)
        {
            writer.WriteStartArray();
            foreach (var item in value.Items)
            {
                foreach (var v in item)
                {
                    serializer.Serialize(writer, v);
                }
            }

            writer.WriteEndArray();
        }
Ejemplo n.º 4
0
        public override void WriteJson(JsonWriter writer, AggregateResponse <CompletionList> value, JsonSerializer serializer)
        {
            var values = value.Items.ToArray();

            if (!values.Any(z => z.IsIncomplete))
            {
                writer.WriteStartArray();
                foreach (var item in value.Items)
                {
                    foreach (var v in item)
                    {
                        serializer.Serialize(writer, v);
                    }
                }

                writer.WriteEndArray();
                return;
            }

            writer.WriteStartObject();
            writer.WritePropertyName("isIncomplete");
            writer.WriteValue(true);

            writer.WritePropertyName("items");
            writer.WriteStartArray();
            foreach (var item in value.Items)
            {
                foreach (var v in item)
                {
                    serializer.Serialize(writer, v);
                }
            }

            writer.WriteEndArray();
            writer.WriteEndObject();
        }
Ejemplo n.º 5
0
 public override AggregateResponse <CompletionList> ReadJson(
     JsonReader reader, Type objectType, AggregateResponse <CompletionList> existingValue, bool hasExistingValue, JsonSerializer serializer
     ) => throw new NotImplementedException();