Пример #1
0
        private static async System.Threading.Tasks.Task SaveDataToAzureTable(IConfigurationRoot config, SensorData oSensorData)
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(config[_APPSET_CONNSTRING_STORAGEACC]);
            CloudTableClient    tableClient    = storageAccount.CreateCloudTableClient();
            CloudTable          table          = tableClient.GetTableReference(config[_APPSET_TABLE]);
            await table.CreateIfNotExistsAsync();

            SensorDataAzTbl sensorData = BuildAzureTableDocument(oSensorData);

            TableOperation insertOperation = TableOperation.Insert(sensorData);
            await table.ExecuteAsync(insertOperation);
        }
Пример #2
0
        private static SensorDataAzTbl BuildAzureTableDocument(SensorData oSensorData)
        {
            DateTime creationDt = DateTime.Now;

            SensorDataAzTbl sensorData = new SensorDataAzTbl()
            {
                PartitionKey = oSensorData.SensorId,
                RowKey       = creationDt.Ticks.ToString(),

                SensorId    = oSensorData.SensorId,
                ReadAt      = oSensorData.ReadAt,
                CreatedAt   = creationDt,
                SensorName  = oSensorData.SensorName,
                SensorType  = oSensorData.SensorType,
                SensorValue = oSensorData.SensorValue
            };

            return(sensorData);
        }