Пример #1
0
        public async Task BatchInserts(List <Profile> profiles)
        {
            BatchWrite <Profile> batchWrite = _context.CreateBatchWrite <Profile>();

            batchWrite.AddPutItems(profiles);
            await batchWrite.ExecuteAsync();

            Console.WriteLine("Items inserted successfully");
        }
        private async Task <bool> AddManyItems(List <T> items)
        {
            _ = UpdateTableTracker();
            BatchWrite <T> batch = _context.CreateBatchWrite <T>();

            batch.AddPutItems(items);
            await batch.ExecuteAsync();

            return(true);
        }
Пример #3
0
        public async Task AddBulk(IEnumerable <CarDTO> cars)
        {
            // Adding the uid manually.. this sucks
            cars.Select(c => { c.Id = Guid.NewGuid().ToString(); return(c); }).ToList();

            // Start the batch
            BatchWrite <Car> bulkBatch = dbContext.CreateBatchWrite <Car>();

            bulkBatch.AddPutItems(mapper.Map <IEnumerable <Car> >(cars));
            await bulkBatch.ExecuteAsync();
        }
        public async Task AddItems <T>(IEnumerable <T> items)
        {
            IDynamoDBContext context = new DynamoDBContext(client, new DynamoDBContextConfig()
            {
                ConsistentRead = true
            });
            BatchWrite <T> batch = context.CreateBatchWrite <T>();

            batch.AddPutItems(items);

            await batch.ExecuteAsync();
        }
Пример #5
0
        public async Task InsertNewItems(List <Profile> profiles)
        {
            if (profiles != null && profiles.Count > 0)
            {
                try
                {
                    BatchWrite <Profile> batchWrite = _context.CreateBatchWrite <Profile>();
                    batchWrite.AddPutItems(profiles);
                    Console.WriteLine("Inserting list of profiles...");
                    await batchWrite.ExecuteAsync();

                    Console.WriteLine("Done");
                }
                catch (Exception ex)
                {
                    Console.WriteLine("[!] Insert data failed");
                    Console.WriteLine(ex);
                }
            }
        }
Пример #6
0
        private async Task LoadData(IEnumerable <DashboardEventRaw> data, string source)
        {
            if (data == null)
            {
                this._context.LogError("Null was provided to LoadData, no data to load.");
                return;
            }

            BatchWrite <DashboardEventParsed> batch = ddbContext.CreateBatchWrite <DashboardEventParsed>();

            int misses = 0;

            foreach (DashboardEventRaw item in data)
            {
                DashboardEventParsed parsed;

                try
                {
                    parsed = DashboardEventParsed.FromRawEvent(item);
                    batch.AddPutItem(parsed);

                    if (parsed.Timeline.StartTimeWasFoundInDescription == false)
                    {
                        this._context.LogError($"Did not find start/end in description: {item.Description}");
                        misses += 1;
                    }
                }
                catch (Exception e)
                {
                    this._context.LogError(e);
                }
            }

            try
            {
                await batch.ExecuteAsync();
            }
            catch (Exception e)
            {
                this._context.LogError(e);
            }

            await cwClient.PutMetricDataAsync(new PutMetricDataRequest()
            {
                MetricData = new List <MetricDatum>()
                {
                    new MetricDatum()
                    {
                        Value        = misses,
                        MetricName   = Environment.GetEnvironmentVariable("ExtractionFailureMetricName"),
                        TimestampUtc = DateTime.UtcNow,
                        Unit         = StandardUnit.Count,
                        Dimensions   = new List <Dimension>()
                        {
                            new Dimension()
                            {
                                Name  = "source",
                                Value = source
                            }
                        }
                    }
                },
                Namespace = "SHD"
            });
        }