示例#1
0
        async void WriteToDB(string tag, float data)
        {
            try
            {
                sensorapp sensorItem = new sensorapp {
                    sensor_role = tag, sensor_data = data
                };
                IMobileServiceTable <sensorapp> table = MobileService.GetTable <sensorapp>();
                await table.InsertAsync(sensorItem);

                await table.UpdateAsync(sensorItem);
            }
            catch (Exception e)
            {
                logger.Log("[Database operation has failed] " + e.GetType().ToString() + " -> " + e.InnerException.ToString());
                logger.Log("[Logging data offline]" + tag + "," + data);
            }

            //To Do: In the offline disconnected scenario, there's a way to write to a local sql db first and then sync to the online db
            //destails on how to implement an offline sync here:
            //http://azure.microsoft.com/en-us/documentation/articles/mobile-services-windows-store-dotnet-get-started-offline-data/
        }
示例#2
0
        async void WriteToDB(string tag, float data)
        {

            try
            {
                sensorapp sensorItem = new sensorapp { sensor_role = tag, sensor_data = data };
                IMobileServiceTable<sensorapp> table = MobileService.GetTable<sensorapp>();
                await table.InsertAsync(sensorItem);
                await table.UpdateAsync(sensorItem);

            }
            catch (Exception e)
            {
                logger.Log("[Database operation has failed] " + e.GetType().ToString() + " -> " + e.InnerException.ToString());
                logger.Log("[Logging data offline]"+ tag + "," + data );
            }

            //To Do: In the offline disconnected scenario, there's a way to write to a local sql db first and then sync to the online db 
            //destails on how to implement an offline sync here: 
            //http://azure.microsoft.com/en-us/documentation/articles/mobile-services-windows-store-dotnet-get-started-offline-data/

        }