/// <summary> /// Send all of the items in the collector to Microsoft Graph API /// </summary> /// <param name="cancellationToken">Used to propagate notifications</param> /// <returns>Task representing the flushing of the collector</returns> public async Task FlushAsync(CancellationToken cancellationToken = default(CancellationToken)) { if (_rows.Count == 0) { return; } // Distinguish between appending and updating if (this._attribute.UpdateType != null && this._attribute.UpdateType == "Update") { if (_rows.FirstOrDefault(row => row["column"] != null && row["value"] != null) != null) { foreach (var row in this._rows) { row[O365Constants.RowsKey] = 1; row[O365Constants.ColsKey] = row.Children().Count(); if (row["column"] != null && row["value"] != null) { await _manager.UpdateColumn(this._attribute, row); } else { // Update whole worksheet await _manager.UpdateWorksheet(this._attribute, row); } } } else if (_rows.Count > 0) { // Update whole worksheet at once JObject consolidatedRows = GetConsolidatedRows(_rows); await _manager.UpdateWorksheet(_attribute, consolidatedRows); } } else { // DEFAULT: Append (rows to specific table) foreach (var row in this._rows) { await _manager.AddRow(this._attribute, row); } } this._rows.Clear(); }