Beispiel #1
0
        public void gpToolExecuted(object sender, ToolExecutedEventArgs e)
        {
            IGeoProcessorResult2 result = e.GPResult as IGeoProcessorResult2;

            if (result.Status.Equals(esriJobStatus.esriJobSucceeded))
            {
                //Check that there are no information or warning messages.
                if (result.MaxSeverity == 0)
                {
                    //Get the return value.
                    object returnValue = result.ReturnValue;
                    //Application specific code,
                    //for example, find the layer to which this return value corresponds.
                }
                else
                {
                    //Application specific code.
                }
            }
            else
            {
                //Get all messages.
                IGPMessages msgs = result.GetResultMessages();
                for (int i = 0; i < result.MessageCount; i++)
                {
                    IGPMessage2 msg = msgs.GetMessage(i) as IGPMessage2;
                    //Application specific code.
                }
            }
        }
Beispiel #2
0
 private void GP_ToolExecuted(object sender, ToolExecutedEventArgs e)
 {
     TM.Stop();
     SW.Stop();
     pStepPro.Message = string.Format("Finished...({0}), may not respond for a while.", SW.Elapsed.ToString("hh\\:mm\\:ss"));
     TM.Dispose();
     Thread.Sleep(1000);
     pProDlg.HideDialog();
 }
        /// <summary>
        /// Handles the ToolExecuted event. All tools end by firing this event. If the tool executed successfully
        /// the next tool in the queue is removed and submitted for execution.  If unsuccessful, geoprocessing is terminated,
        /// an error message is written to the ListViewControl and the is queue cleared. After the final tool has executed
        /// the result layer is added to the Map.
        /// </summary>
        void _gp_ToolExecuted(object sender, ToolExecutedEventArgs e)
        {
            IGeoProcessorResult2 gpResult = (IGeoProcessorResult2)e.GPResult;

            try
            {
                //The first GP tool has completed, if it was successful process the others
                if (gpResult.Status == esriJobStatus.esriJobSucceeded)
                {
                    listView1.Items.Add(new ListViewItem(new string[2] {
                        "ToolExecuted", gpResult.Process.Tool.Name
                    }, "success"));

                    //Execute next tool in the queue
                    if (_myGPToolsToExecute.Count > 0)
                    {
                        _gp.ExecuteAsync(_myGPToolsToExecute.Dequeue());
                    }
                    //If last tool has executed add the output layer to the map
                    else
                    {
                        IFeatureClass resultFClass = _gp.Open(gpResult.ReturnValue) as IFeatureClass;
                        IFeatureLayer resultLayer  = new FeatureLayerClass();
                        resultLayer.FeatureClass = resultFClass;
                        resultLayer.Name         = resultFClass.AliasName;

                        //Add the result to the map
                        axMapControl1.AddLayer((ILayer)resultLayer, 2);
                        axTOCControl1.Update();

                        //add the result layer to the List of result layers
                        _resultsList.Add(resultLayer);
                    }
                }
                //If the GP process failed, do not try to process any more tools in the queue
                else if (gpResult.Status == esriJobStatus.esriJobFailed)
                {
                    //The actual GP error message will be output by the MessagesCreated event handler
                    listView1.Items.Add(new ListViewItem(new string[2] {
                        "ToolExecuted", gpResult.Process.Tool.Name + " failed, any remaining processes will not be executed."
                    }, "error"));
                    //Empty the queue
                    _myGPToolsToExecute.Clear();
                }
            }
            catch (Exception ex)
            {
                listView1.Items.Add(new ListViewItem(new string[2] {
                    "ToolExecuted", ex.Message
                }, "error"));
            }
        }
Beispiel #4
0
        private void Tool_ToolExecuted(object sender, ToolExecutedEventArgs e)
        {
            switch (e.EventType)
            {
            case ToolResult.Executed:
                if ((SelectedTool == (Tool)sender) && executeOnce)
                {
                    SelectDefaultTool();
                }
                break;

            case ToolResult.Canceled:
                if (!selecting)
                {
                    SelectDefaultTool(true);
                }
                break;

            default:
                throw new NShapeUnsupportedValueException(e.EventType);
            }
        }
    /// <summary>
    /// Handles the ToolExecuted event. All tools end by firing this event. If the tool executed successfully  
    /// the next tool in the queue is removed and submitted for execution.  If unsuccessful, geoprocessing is terminated,
    /// an error message is written to the ListViewControl and the is queue cleared. After the final tool has executed
    /// the result layer is added to the Map.
    /// </summary>
    void _gp_ToolExecuted(object sender, ToolExecutedEventArgs e)
    {   
      IGeoProcessorResult2 gpResult = (IGeoProcessorResult2)e.GPResult;

      try
      {
        //The first GP tool has completed, if it was successful process the others
        if (gpResult.Status == esriJobStatus.esriJobSucceeded)
        {
          listView1.Items.Add(new ListViewItem(new string[2] { "ToolExecuted", gpResult.Process.Tool.Name }, "success"));

          //Execute next tool in the queue
          if (_myGPToolsToExecute.Count > 0)
          {
            _gp.ExecuteAsync(_myGPToolsToExecute.Dequeue());
          }
          //If last tool has executed add the output layer to the map
          else
          {
            IFeatureClass resultFClass = _gp.Open(gpResult.ReturnValue) as IFeatureClass;
            IFeatureLayer resultLayer = new FeatureLayerClass();
            resultLayer.FeatureClass = resultFClass;
            resultLayer.Name = resultFClass.AliasName;

            //Add the result to the map
            axMapControl1.AddLayer((ILayer)resultLayer, 2);
            axTOCControl1.Update();

            //add the result layer to the List of result layers
            _resultsList.Add(resultLayer);
          }
        }
        //If the GP process failed, do not try to process any more tools in the queue
        else if (gpResult.Status == esriJobStatus.esriJobFailed)
        {
          //The actual GP error message will be output by the MessagesCreated event handler
          listView1.Items.Add(new ListViewItem(new string[2] { "ToolExecuted", gpResult.Process.Tool.Name + " failed, any remaining processes will not be executed." }, "error"));
          //Empty the queue
          _myGPToolsToExecute.Clear();
        }
      }
      catch (Exception ex)
      {
        listView1.Items.Add(new ListViewItem(new string[2] { "ToolExecuted", ex.Message }, "error")); 
      } 
    }
        static void gp_ToolExecuted(object sender, ToolExecutedEventArgs e)
        {
            IGeoProcessorResult igpr = null;

            try
            {
                igpr = e.GPResult;

                if (igpr.Status == esriJobStatus.esriJobSucceeded && dslc.IsGPBusy)
                {
                    if (igpr.Status == esriJobStatus.esriJobFailed || igpr.Status == esriJobStatus.esriJobSucceeded ||
                        igpr.Status == esriJobStatus.esriJobTimedOut)
                    {
                        dslc.IsGPBusy = false;
                    }

                    ProcessResult();
                }

                ArcMap.Document.ActiveView.ContentsChanged();
                ArcMap.Document.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);

                //ArcMap.Document.CurrentContentsView.Deactivate();
                //ArcMap.Document.ContentsView[0].Activate(ArcMap.Application.hWnd, ArcMap.Document);
            }
            catch (Exception err)
            {
            }

            finally
            {
            }
        }
        void gp_ToolExecuted(object sender, ToolExecutedEventArgs e)
        {
            IGeoProcessorResult igpr = e.GPResult;

            switch (igpr.Status)
            {
                case esriJobStatus.esriJobExecuting:
                    break;

                case esriJobStatus.esriJobSucceeded:
                    {
                        try
                        {
                            IFeatureLayer ifl_Results = (IFeatureLayer)igpu.FindMapLayer(gd.Name.Split('.')[0]);

                            /*var dlg_result = System.Windows.Forms.MessageBox.Show("Re-calculate areas? (required before query returns correct results)", "", System.Windows.Forms.MessageBoxButtons.YesNo);
                            if (dlg_result == System.Windows.Forms.DialogResult.No) return;*/

                            CalcAllValues.DoCalculation(ifl_Results);
                        }
                        catch (Exception eeeee)
                        {
                        }
                    }
                    goto default;

                default:
                    gp.ToolExecuted -= gp_ToolExecuted;
                    gp.ProgressChanged -= gp_ProgressChanged;
                    break;
            }
        }
 private void gpToolExecuted(object sender, ToolExecutedEventArgs e)
 {
     try
     {
         IGeoProcessorResult2 result = e.GPResult as IGeoProcessorResult2;
         if (result.Status.Equals(esriJobStatus.esriJobSucceeded))
         {
             //Check that there are no information or warning messages.
             if (result.MaxSeverity == 0)
             {
                 MessageBox.Show("Synchronization Completed");
             }
             else
             {
                 MessageBox.Show("Synchronization Failed");
             }
         }
         else
         {
             //Get all messages.
             IGPMessages msgs = result.GetResultMessages();
             for (int i = 0; i < result.MessageCount; i++)
             {
                 IGPMessage2 msg = msgs.GetMessage(i) as IGPMessage2;
                 //Application specific code.
             }
         }
     }
     catch { }
     finally
     {
         GP.ToolExecuted -= new EventHandler<ESRI.ArcGIS.Geoprocessor.ToolExecutedEventArgs>(gpToolExecuted);
     }
 }