private async void MainPage_Loaded(object sender, RoutedEventArgs e) { _dispatcher = CoreWindow.GetForCurrentThread().Dispatcher; var cams = await CamAgent.GetAllCameras(); foreach (var camera in cams) { this.Cameras.Add(new CamAgent(camera.Id, PhotoPreview)); this.Timers.Add(GetTimer(camera.Id)); } await RegisterOnSignalR(); //var client = new ErmIoTServiceClient(); //await client.UploadFileAsync(string.Empty); RegisterCamera(@"\\?\USB#VID_046D&PID_082B&MI_00#6&ff670fd&0&0000#{e5323777-f976-4f5b-9b55-b94699c46e44}\GLOBAL", 10); }
private async void Timer_Tick(object sender, object e) { JobMediaQueue.Enqueue(async() => { var id = (sender as CamTimer).Id; this.messageText.Text = "Capturing image..."; var camera = this.Cameras.FirstOrDefault(x => x.Id == id); await camera.StartPreviewAsync(); var file = await camera.CaptureImage(); await camera.StopPreviewAsync(); this.messageText.Text = "Uploading image..."; await Task.Delay(1000); var base64img = await CamAgent.ImageToBase64(file); var client = new ErmIoTServiceClient(); ((BasicHttpBinding)client.Endpoint.Binding).MaxReceivedMessageSize = int.MaxValue; ((BasicHttpBinding)client.Endpoint.Binding).MaxBufferSize = int.MaxValue; ((BasicHttpBinding)client.Endpoint.Binding).MaxBufferPoolSize = long.MaxValue; await client.UploadFileAsync(base64img); this.messageText.Text = "Upload successful."; await Task.Delay(1000); }); }