Download/Save GP Result

1853
1
05-30-2013 10:29 AM
brettangel
Occasional Contributor II
I�??ve created a GP service with files as input and zip file as output (%scratchfolder%), and a Usercontrol\ iCommand add-in for a Silverlight viewer utilizing the script.  The GP works, but I cannot save the output from the Silverlight viewer.  I used the sample Extract Data to download and save the zip file, but I get an �??object not set to instance�?? after saving the output.zip.  I�??ve checked and the zip exists in the jobs folder, the GP works from catalog and map, but I can�??t access the output using the output url or with the save dialog code.  I have a feeling it�??s something as simple as security, but I thought permissions for the active directory was set during the install.



        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;
                    };
                    webClient.OpenReadAsync(new Uri((ev1.Parameter as GPDataFile).Url), UriKind.Absolute);

                    mywindow = mywindow ?? new ExtractAsbuilts();
                    MapApplication.Current.ShowWindow("Selected Asbuilts", mywindow);
                }
            }
        }
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog dialog = new SaveFileDialog();
            dialog.DefaultFileName = "output.zip";
            dialog.Filter = "Zip file (*.zip)|*.zip";

            bool? dialogResult = dialog.ShowDialog();

            if (dialogResult != true) return;
            try
            {
                using (Stream fs = (Stream)dialog.OpenFile())
                {
                    streamedDataFile.CopyTo(fs);
                    fs.Flush();
                    fs.Close();
                    streamedDataFile = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error saving file :" + ex.Message);
            }
        }


What I�??m really looking for is a shove in the right direction.  All I need to do is save my output from a Silverlight web app.
0 Kudos
1 Reply
brettangel
Occasional Contributor II
Follow up - no solution found.  Using hyperlink instead.  Same difference, but not want we wanted.
0 Kudos