public async Task CreateOrUpdateAsync(string simulationId, SimulationStatisticsModel statistics) { var nodeId = this.clusterNodes.GetCurrentNodeId(); var statisticsRecordId = this.GetStatisticsRecordId(simulationId, nodeId); var statisticsRecord = new SimulationStatisticsRecord { NodeId = nodeId, SimulationId = simulationId, Statistics = statistics }; var statisticsStorageRecord = new StorageRecord { Id = statisticsRecordId, Data = JsonConvert.SerializeObject(statisticsRecord) }; try { this.log.Debug("Creating statistics record", () => new { statisticsStorageRecord }); await this.simulationStatisticsStorage.CreateAsync(statisticsStorageRecord); } catch (Exception e) { this.log.Error("Error on saving statistics records", e); } }
private IDataRecord BuildStorageRecord(string simulationId, SimulationStatisticsModel statistics) { var nodeId = this.clusterNodes.GetCurrentNodeId(); var statisticsRecordId = this.BuildRecordId(simulationId, nodeId); var statisticsRecord = new SimulationStatisticsRecord { NodeId = nodeId, SimulationId = simulationId, Statistics = statistics }; return(this.simulationStatisticsStorage.BuildRecord( statisticsRecordId, JsonConvert.SerializeObject(statisticsRecord))); }
private StorageRecord GetStorageRecord(string simulationId, SimulationStatisticsModel statistics) { var nodeId = this.clusterNodes.GetCurrentNodeId(); var statisticsRecordId = this.GetStatisticsRecordId(simulationId, nodeId); var statisticsRecord = new SimulationStatisticsRecord { NodeId = nodeId, SimulationId = simulationId, Statistics = statistics }; return(new StorageRecord { Id = statisticsRecordId, Data = JsonConvert.SerializeObject(statisticsRecord) }); }