private void syncCompleteCallback(GeodatabaseStatusInfo info, Exception exp) { this.SyncProgressBar.Visibility = System.Windows.Visibility.Hidden; if (exp != null) { this.SyncStatusTextBlock.Text = "Error synchronizing geodatabase: " + exp.Message; } else { this.SyncStatusTextBlock.Text = "Synchronization complete."; } }
// Download a generated geodatabase file private async Task <StorageFile> DownloadGeodatabaseAsync(GeodatabaseStatusInfo statusResult) { var file = await GetGeodatabaseFileAsync(); var client = new ArcGISHttpClient(); var download = await client.GetOrPostAsync(statusResult.ResultUri, null); using (var fileStream = await file.OpenStreamForWriteAsync()) { await download.EnsureSuccessStatusCode().Content.CopyToAsync(fileStream); } return(file); }
// Download a generated geodatabase file private async Task <StorageFile> DownloadGeodatabase(GeodatabaseStatusInfo statusResult) { var file = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(GDB_NAME, CreationCollisionOption.ReplaceExisting); var client = new ArcGISHttpClient(); var download = await client.GetOrPostAsync(statusResult.ResultUri, null); using (var fileStream = await file.OpenStreamForWriteAsync()) { await download.EnsureSuccessStatusCode().Content.CopyToAsync(fileStream); } return(file); }
// Download a generated geodatabase file private async Task DownloadGeodatabaseAsync(GeodatabaseStatusInfo statusResult) { var client = new ArcGISHttpClient(); var gdbStream = client.GetOrPostAsync(statusResult.ResultUri, null); SetGeodatabaseFileName(); await Task.Run(async() => { using (var stream = System.IO.File.Create(_gdbPath)) { await gdbStream.Result.Content.CopyToAsync(stream); } }); }
private void syncCompleteCallback(GeodatabaseStatusInfo statusInfo, Exception ex) { // reset the cancellation token source _syncCancellationTokenSource = null; // if unsuccessful, report the exception and return if (ex != null) { //this.ReportStatus("An exception occured: " + ex.Message); Console.WriteLine("An exception occured: " + ex.Message); return; } // if successful, notify the user //this.ReportStatus("Synchronization of '" + statusInfo.GeodatabaseName + "' is complete."); Console.WriteLine("Synchronization of '" + statusInfo.GeodatabaseName + "' is complete."); // optionally, do something with the result var resultUri = statusInfo.ResultUri; // ... }
// Download a generated geodatabase file private async Task <string> DownloadGeodatabase(GeodatabaseStatusInfo statusResult) { var client = new ArcGISHttpClient(); var gdbStream = client.GetOrPostAsync(statusResult.ResultUri, null); var gdbFolder = System.IO.Path.GetTempPath(); var gdbPath = System.IO.Path.Combine(gdbFolder, statusResult.GeodatabaseName); if (!System.IO.Directory.Exists(gdbFolder)) { System.IO.Directory.CreateDirectory(gdbFolder); } await Task.Run(async() => { using (var stream = System.IO.File.Create(gdbPath)) { await gdbStream.Result.Content.CopyToAsync(stream); } }); return(gdbPath); }
// Download a generated geodatabase file private async Task<string> DownloadGeodatabase(GeodatabaseStatusInfo statusResult) { var client = new ArcGISHttpClient(); var gdbStream = client.GetOrPostAsync(statusResult.ResultUri, null); var gdbFolder = System.IO.Path.GetTempPath(); var gdbPath = System.IO.Path.Combine(gdbFolder, statusResult.GeodatabaseName); if (!System.IO.Directory.Exists(gdbFolder)) System.IO.Directory.CreateDirectory(gdbFolder); await Task.Run(async () => { using (var stream = System.IO.File.Create(gdbPath)) { await gdbStream.Result.Content.CopyToAsync(stream); } }); return gdbPath; }
// Download a generated geodatabase file private async Task DownloadGeodatabaseAsync(GeodatabaseStatusInfo statusResult) { var client = new ArcGISHttpClient(); var gdbStream = client.GetOrPostAsync(statusResult.ResultUri, null); SetGeodatabaseFileName(); await Task.Run(async () => { using (var stream = System.IO.File.Create(_gdbPath)) { await gdbStream.Result.Content.CopyToAsync(stream); } }); }
// Download a generated geodatabase file private async Task<StorageFile> DownloadGeodatabaseAsync(GeodatabaseStatusInfo statusResult) { var file = await GetGeodatabaseFileAsync(); var client = new ArcGISHttpClient(); var download = await client.GetOrPostAsync(statusResult.ResultUri, null); using (var fileStream = await file.OpenStreamForWriteAsync()) { await download.EnsureSuccessStatusCode().Content.CopyToAsync(fileStream); } return file; }
// Download a generated geodatabase file private async Task<StorageFile> DownloadGeodatabase(GeodatabaseStatusInfo statusResult) { var file = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(statusResult.GeodatabaseName, CreationCollisionOption.ReplaceExisting); var client = new ArcGISHttpClient(); var download = await client.GetOrPostAsync(statusResult.ResultUri, null); using (var fileStream = await file.OpenStreamForWriteAsync()) { await download.EnsureSuccessStatusCode().Content.CopyToAsync(fileStream); } return file; }
private async void GenerateFeatuersCompleteCallback(GeodatabaseStatusInfo statusInfo, Exception ex) { if(ex != null) { this.Dispatcher.Invoke(() => StatusMessagesList.Items.Add("An exception has occured: " + ex.Message)); return; } // if successful, download the generated geodatabase from the server var client = new ArcGISHttpClient(); var geodatabaseStream = client.GetOrPostAsync(statusInfo.ResultUri, null); // create a path for the local geodatabse var outFolder = System.AppDomain.CurrentDomain.BaseDirectory; var geodatabasePath = System.IO.Path.Combine(outFolder, "Wildlife.geodatabase"); await Task.Factory.StartNew(async delegate { using (var stream = System.IO.File.Create(geodatabasePath)) { await geodatabaseStream.Result.Content.CopyToAsync(stream); } this.localGeodatabasePath = geodatabasePath; this.Dispatcher.Invoke(() => LocalDataPathTextBlock.Text = geodatabasePath); this.Dispatcher.Invoke(() => LocalDataPathTextBlock.ToolTip = geodatabasePath); this.Dispatcher.Invoke(() => StatusMessagesList.Items.Add("Features downloaded to " + geodatabasePath)); this.Dispatcher.Invoke(() => StatusProgressBar.IsIndeterminate = false); }); }
// Download a generated geodatabase file private async Task<string> DownloadGeodatabase(GeodatabaseStatusInfo statusResult, string gdbName) { var client = new ArcGISHttpClient(); var gdbStream = client.GetOrPostAsync(statusResult.ResultUri, null); var gdbPath = Path.GetFullPath(string.Format("{0}/{1}{2}", _exportMapPath, gdbName, OfflineMapItem.GeodatabaseFilenameExtension)); await Task.Factory.StartNew(async () => { using (var stream = File.Create(gdbPath)) { await gdbStream.Result.Content.CopyToAsync(stream); } }); return gdbPath; }
// Download a generated geodatabase file private async Task<string> DownloadGeodatabase(GeodatabaseStatusInfo statusResult, string gdbPath) { var client = new ArcGISHttpClient(); var gdbStream = client.GetOrPostAsync(statusResult.ResultUri, null); var gdbFolder = Path.GetDirectoryName(gdbPath); if (!Directory.Exists(gdbFolder)) Directory.CreateDirectory(gdbFolder); await Task.Factory.StartNew(async () => { using (var stream = File.Create(gdbPath)) { await gdbStream.Result.Content.CopyToAsync(stream); } }); return gdbPath; }