void _geoprocessorTask_GetResultDataCompleted(object sender, GPParameterEventArgs ev1)
        {
            if (ev1.Parameter is GPDataFile)
            {
                GPDataFile ClipResultFile = ev1.Parameter as GPDataFile;

                if (String.IsNullOrEmpty(ClipResultFile.Url))
                {
                    return;
                }

                MessageBoxResult res = MessageBox.Show("Data file created. Would you like to download the file?", "Geoprocessing Task Success", MessageBoxButton.OKCancel);
                if (res == MessageBoxResult.OK)
                {
                    WebClient webClient = new WebClient();
                    webClient.OpenReadCompleted += (s, ev) =>
                    {
                        _streamedDataFile         = ev.Result;
                        SaveFileButton.Visibility = Visibility.Visible;
                        ProcessingTextBlock.Text  = "Download completed.  Click on 'Save data file' button to save to disk.";
                    };
                    webClient.OpenReadAsync(new Uri((ev1.Parameter as GPDataFile).Url), UriKind.Absolute);
                }
                else
                {
                    ProcessingTextBlock.Text       = "";
                    ProcessingTextBlock.Visibility = Visibility.Collapsed;
                    SaveFileButton.Visibility      = Visibility.Collapsed;
                }
            }
            _processingTimer.Stop();
        }
        // Saves results to a local file - with user prompt for file name
        private async Task SaveResultsToFile(GPDataFile gpDataFile)
        {
            MessageBoxResult res = MessageBox.Show("Data file created. Would you like to download the file?", "Success", MessageBoxButton.OKCancel);

            if (res == MessageBoxResult.OK)
            {
                WebClient webClient = new WebClient();
                var       stream    = await webClient.OpenReadTaskAsync(gpDataFile.Uri);

                SaveFileDialog dialog = new SaveFileDialog();
                dialog.FileName = "Output.zip";
                dialog.Filter   = "Zip file (*.zip)|*.zip";

                if (dialog.ShowDialog() == true)
                {
                    try
                    {
                        using (Stream fs = (Stream)dialog.OpenFile())
                        {
                            stream.CopyTo(fs);
                            fs.Flush();
                            fs.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error saving file :" + ex.Message);
                    }
                }
            }
        }
Exemple #3
0
        // Saves results to a local file - with user prompt for file name
        private async Task SaveResultsToFile(GPDataFile gpDataFile)
        {
            var dlg = new MessageDialog("Data file created. Would you like to download the file?", "Success");

            dlg.Commands.Add(new UICommand("Yes", async cmd => { await DownloadDataAndDisplayAsync(gpDataFile.Uri); }));
            dlg.Commands.Add(new UICommand("No"));
            await dlg.ShowAsync();
        }
 // Saves results to a local file - with user prompt for file name
 private async Task SaveResultsToFile(GPDataFile gpDataFile)
 {
     var dlg = new MessageDialog("Data file created. Would you like to download the file?", "Success");
     dlg.Commands.Add(new UICommand("Yes", async cmd => { await DownloadDataAndDisplayAsync(gpDataFile.Uri); }));
     dlg.Commands.Add(new UICommand("No"));
     await dlg.ShowAsync();
 }
		// Saves results to a local file - with user prompt for file name
		private async Task SaveResultsToFile(GPDataFile gpDataFile)
		{
			MessageBoxResult res = MessageBox.Show("Data file created. Would you like to download the file?", "Success", MessageBoxButton.OKCancel);
			if (res == MessageBoxResult.OK)
			{
				WebClient webClient = new WebClient();
				var stream = await webClient.OpenReadTaskAsync(gpDataFile.Uri);

				SaveFileDialog dialog = new SaveFileDialog();
				dialog.FileName = "Output.zip";
				dialog.Filter = "Zip file (*.zip)|*.zip";

				if (dialog.ShowDialog() == true)
				{
					try
					{
						using (Stream fs = (Stream)dialog.OpenFile())
						{
							stream.CopyTo(fs);
							fs.Flush();
							fs.Close();
						}
					}
					catch (Exception ex)
					{
						MessageBox.Show("Error saving file :" + ex.Message);
					}
				}
			}
		}
Exemple #6
0
        public static string ParameterToString(GPParameterType type, GPParameter param, CultureInfo culture)
        {
            if (param == null)
            {
                return(string.Empty);
            }
            switch (type)
            {
            case GPParameterType.Boolean:
                GPBoolean boo = param as GPBoolean;
                if (boo != null)
                {
                    return(boo.Value.ToString());
                }
                else
                {
                    return(string.Empty);
                }

            case GPParameterType.Date:
                GPDate date = param as GPDate;
                if (date != null && date.Value != null)
                {
                    return(date.Value.Ticks.ToString());
                }
                else
                {
                    return(string.Empty);
                }

            case GPParameterType.Double:
                GPDouble dub = param as GPDouble;
                if (dub != null && !double.IsNaN(dub.Value))
                {
                    return(dub.Value.ToString(culture));
                }
                else
                {
                    return(string.Empty);
                }

            case GPParameterType.Long:
                GPLong lon = param as GPLong;
                if (lon != null)
                {
                    return(lon.Value.ToString());
                }
                else
                {
                    return(string.Empty);
                }

            case GPParameterType.String:
                GPString stir = param as GPString;
                if (stir != null && stir.Value != null)
                {
                    return(stir.Value);
                }
                else
                {
                    return(string.Empty);
                }

            case GPParameterType.FeatureLayer:
                GPFeatureRecordSetLayer feat = param as GPFeatureRecordSetLayer;
                if (feat != null && feat.Url != null)
                {
                    return(feat.Url);
                }
                else
                {
                    return(string.Empty);
                }

            case GPParameterType.RecordSet:
                GPRecordSet rsl = param as GPRecordSet;
                if (rsl != null && rsl.Url != null)
                {
                    return(rsl.Url);
                }
                else
                {
                    return(string.Empty);
                }

            case GPParameterType.DataFile:
                GPDataFile dat = param as GPDataFile;
                if (dat != null && dat.Url != null)
                {
                    return(dat.Url);
                }
                else
                {
                    return(string.Empty);
                }
            }
            return(string.Empty);
        }