示例#1
0
        private async void Timer_Tick(object sender, object e)
        {
            if (livetemperature() >= 23)
            {
                TestPostMessage(livetemperature().ToString());
                //Take photo and save into Intrusos
                if (webcam == null || !webcam.IsInitialized())
                {
                    // Initialize Webcam Helper
                    webcam = new WebcamHelper();
                    await webcam.InitializeCameraAsync();
                }
                currentIdPhotoFile = await webcam.CapturePhoto();

                // Create or open the folder in which the Whitelist is stored
                StorageFolder whitelistFolder = await KnownFolders.PicturesLibrary.CreateFolderAsync(GeneralConstants.WhiteListFolderName, CreationCollisionOption.OpenIfExists);

                // Create a folder to store this specific user's photos
                StorageFolder currentFolder = await whitelistFolder.CreateFolderAsync("Intrusos", CreationCollisionOption.OpenIfExists);

                // Move the already captured photo the user's folder
                await currentIdPhotoFile.MoveAsync(currentFolder);
            }
            await Task.Run(async() => { await AzureIoTHub.SendTemperatureAsync(livetemperature()); });
        }