private void Button_Click_1(object sender, RoutedEventArgs e) { TestObject newObject = new TestObject(); newObject.FirstName = "Cloud"; newObject.LastName = "Base"; newObject.Title = ".io"; App.helper.InsertDocument("test_windows8", newObject, delegate(CBResponseInfo resp) { this.OutputText.Text = "OUTPUT: " + resp.OutputString; return true; }); }
private async void InsertFileButton_Click(object sender, RoutedEventArgs e) { var openPicker = new Windows.Storage.Pickers.FileOpenPicker(); openPicker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary; openPicker.FileTypeFilter.Add(".png"); openPicker.FileTypeFilter.Add(".Jpeg"); openPicker.FileTypeFilter.Add(".Jpg"); StorageFile file = await openPicker.PickSingleFileAsync(); var stream = await file.OpenReadAsync(); using (var dataReader = new DataReader(stream)) { var bytes = new byte[stream.Size]; await dataReader.LoadAsync((uint)stream.Size); dataReader.ReadBytes(bytes); //var stream2 = new MemoryStream(bytes); CBHelperAttachment attachment = new CBHelperAttachment(); attachment.FileName = file.Name; attachment.FileData = bytes; TestObject newObject = new TestObject(); newObject.FirstName = "Cloud"; newObject.LastName = "Base"; newObject.Title = ".io"; List<CBHelperAttachment> attList = new List<CBHelperAttachment>(); attList.Add(attachment); App.helper.InsertDocument("test_windows8", newObject, attList, delegate(CBResponseInfo resp) { this.OutputText.Text = "OUTPUT: " + resp.OutputString; return true; }); } }