mjohnson7

Custom Work Flow Manager Application

Discussion created by mjohnson7 on Oct 10, 2012
Background:
A custom work flow application was created in Work Flow Manager using a C# DLL and extended property tables for the custom work flow information.   The custom work flow tabs were added to the jtxuiconfig.xml file.   Presently there is a need to display the AOI information for the jobs on a map.  The user can enter bounding box or point information using one of the custom work flow tabs. 

Assumptions:

1. Users can create and update the AOI information using the custom application and user interface.
2. The AOI information needs to be written to the JTX_JOBS_AOI table using FeatureClass.
3. AOI information will be written to the application???s extended properties table.

Questions/Comments:

1. How can the AOI information be displayed on the Map in the Map View tab and on the AOI tab?
2. Has anyone else done something similar and could provide some guidance or sample code?
3. Are there any other tables that need to be updated with the AOI information in order for the Map view tab and AOI tab to display the job AOIs?


Below is the code I am using to convert/save the user entered AOI information to the JTX_JOBS_AOI and to the application???s extended properties table.  The code to save to the application???s extended properties table works, I am not sure if I am on the right track for the JTX_JOBS_AOI. 

Any guidance/sample code would be greatly appreciated!  

private void CommitBboxChangesToJob()
{
    if (!(StaticUtils.UpdatingJobName))
    {
      ICursor updateCursor = null;
      try
      {
   //update the custom extended properties table
        IPropertySet properties = this.jtxDatabase.JTXWorkspace.ConnectionProperties;
        IWorkspaceFactory factory = new SdeWorkspaceFactoryClass();
        IWorkspace workspace = factory.Open(properties, 0);
        IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
        ITable prodPropsTable = featureWorkspace.OpenTable(StaticUtils.TableNameProductProps);
        IQueryFilter filter = new QueryFilterClass();

                    filter.WhereClause = "JOBID = " + this.job.ID.ToString();
                    updateCursor = prodPropsTable.Update(filter, true);
                    IRow row = updateCursor.NextRow();

                    if (row != null)
                    {
                        row.set_Value(row.Fields.FindField("EXTENT_TOP"), txtBboxTopDD.Text);
                        row.set_Value(row.Fields.FindField("EXTENT_BOTTOM"), txtBboxBottomDD.Text);
                        row.set_Value(row.Fields.FindField("EXTENT_RIGHT"), txtBboxRightDD.Text);
                        row.set_Value(row.Fields.FindField("EXTENT_LEFT"), txtBboxLeftDD.Text);
                        row.set_Value(row.Fields.FindField("COORDINATE_TYPE"), "BBOX");

                        updateCursor.UpdateRow(row);

                        // Log to job history
                       
                       IJTXActivityType ipCommentActivity =
                       jtxDatabase.ConfigurationManager.GetActivityType(Constants.ACTTYPE_UPDATE_EXT_PROPS); 
                       this.job.LogJobAction(ipCommentActivity, null, "Updated Bounding Box to TOP: " +
                            txtBboxTopDD.Text + ", BOTTOM: " + txtBboxBottomDD.Text + ", LEFT: " +
                            txtBboxLeftDD.Text + ", RIGHT: " + txtBboxRightDD.Text);

         // update JTX_JOBS_AOI
                        IFeatureClass aoiFeatClass = featureWorkspace.OpenFeatureClass("WMX.JTX_JOBS_AOI");
                        IQueryFilter aoiFilter = new QueryFilterClass();
                        aoiFilter.WhereClause = "JOB_ID = " + this.job.ID.ToString();
                       
                        int featureCount = aoiFeatClass.FeatureCount(aoiFilter);
                
                        ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
                        IGeographicCoordinateSystem geographicCoordinateSystem =
                        spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
                      
        IPoint lowerLeft = new PointClass();
                        IPoint lowerRight = new PointClass();
                        IPoint upperLeft = new PointClass();
                        IPoint upperRight = new PointClass();
        //get user entered coordinates from custom tab
                        lowerLeft.PutCoords(double.Parse(txtBboxLeftDD.Text), double.Parse(txtBboxBottomDD.Text));
                        lowerRight.PutCoords(double.Parse(txtBboxRightDD.Text), double.Parse(txtBboxBottomDD.Text));
                        upperRight.PutCoords(double.Parse(txtBboxRightDD.Text), double.Parse(txtBboxTopDD.Text));
                        upperLeft.PutCoords(double.Parse(txtBboxLeftDD.Text), double.Parse(txtBboxTopDD.Text));

                        // create polygon with the user entered coocridinates from custom tab
             IPolygon thePoly = new PolygonClass();
                        thePoly.SpatialReference = geographicCoordinateSystem;
                        thePoly.Envelope.LowerLeft = lowerLeft;
                        thePoly.Envelope.LowerRight = lowerRight;
                        thePoly.Envelope.UpperLeft = upperLeft;
                        thePoly.Envelope.UpperRight = upperRight;

        // create new Feature if one does not exist for specified job
                        if (aoiFeatClass.FeatureCount(aoiFilter) == 0)
                        {
                            //// Add a new feature
                            IFeatureBuffer aoiBuffer = aoiFeatClass.CreateFeatureBuffer();
                            IFeatureCursor aoiInsertCursor = aoiFeatClass.Insert(true);
                            aoiBuffer.Shape = thePoly;
                            aoiInsertCursor.InsertFeature(aoiBuffer);
                            aoiInsertCursor.Flush();
                        }
                        else  // feature exists update
                        {
                            // TBD: 
                        }

                        // Update AOI in the JTX_JOBS_AOI feature class
                        //job is  IJTXJob2
                        this.job.AOIExtent = thePoly;
                        this.job.Store();
                    }
                }
                catch (Exception)
                {
                }
                finally
                {
      // TBD: release Cursor
                }
            } //(!(StaticUtils.UpdatingJobName))
        }

Outcomes