Ejemplo n.º 1
0
        private void PopulateDetails()
        {
            /*
             * Populate the main area with controls for viewing/editing the test setup
             * Most is read-only, the admin has set it up
             * But we need to set up the layers to process. If the user has a transaction,
             * the layers may be proscribed.
             */

            // Clear information
            this.lblTestName.Text = "";
            this.lblTestDesc.Text = "";
            this.listLayers.Items.Clear();
            this.listTables.Items.Clear();
            this.chkDefer.Checked = false;
            this.chkExcept.Checked = false;
            this.listParams.Items.Clear();
            this._reqLayerMessages = "";

            // Get the selected test
            QATest theSelectedTest = this.SelectedTest;
            if (theSelectedTest == null)
                return;

            // Basics
            this.lblTestName.Text = theSelectedTest.Name;
            this.lblTestDesc.Text = theSelectedTest.Test.Description;

            // Get the contents of the map
            ArrayList theMapLayers = this.MapLayers;
            Hashtable theMapLayersByFClass = new Hashtable();
            for (int j = 0; j < theMapLayers.Count; j++)
            {
                IFeatureLayer theFLayer = (IFeatureLayer)theMapLayers[j];
                IDataset theDataset = (IDataset)theFLayer.FeatureClass;
                if (theMapLayersByFClass.ContainsKey(theDataset.Name) == false)
                    theMapLayersByFClass.Add(theDataset.Name, theFLayer);
            }
            ArrayList theMapTables = this.MapTables;
            Hashtable theMapTablesByName = new Hashtable();
            for (int j = 0; j < theMapTables.Count; j++)
            {
                ITable theTable = (ITable)theMapTables[j];
                IDataset theDataset = (IDataset)theTable;
                if (theMapTablesByName.ContainsKey(theDataset.Name) == false)
                    theMapTablesByName.Add(theDataset.Name, theTable);
            }

            // Index the layers and tables already passed to the test
            Hashtable theTestLayersByFClass = new Hashtable();
            for (int j = 0; j < theSelectedTest.Test.LayerCount; j++)
            {
                IFeatureLayer theFLayer = theSelectedTest.Test.get_Layer(j);
                IDataset theDataset = (IDataset)theFLayer.FeatureClass;
                if (theTestLayersByFClass.ContainsKey(theDataset.Name) == false)
                    theTestLayersByFClass.Add(theDataset.Name, theFLayer);
            }
            Hashtable theTestTablesByName = new Hashtable();
            for (int j = 0; j < theSelectedTest.Test.TableCount; j++)
            {
                ITable theTable = theSelectedTest.Test.get_Table(j);
                IDataset theDataset = (IDataset)theTable;
                if (theTestTablesByName.ContainsKey(theDataset.Name) == false)
                    theTestTablesByName.Add(theDataset.Name, theTable);
            }

            // Parameters
            QAParameterCollection thePColl = theSelectedTest.Parameters;
            for (int i = 0; i < thePColl.Count; i++)
            {
                QAParameter theParam = thePColl.get_Parameter(i);
                if (theParam.Name.Equals(ParameterInfo.PARAM_CANDEFER))
                {
                    BooleanParameterInfo theBPInfo = new BooleanParameterInfo(theParam.Name, "", theParam.Value);
                    this.chkDefer.Checked = (bool)theBPInfo.ParamValue;
                }
                else if (theParam.Name.Equals(ParameterInfo.PARAM_CANEXCEPT))
                {
                    BooleanParameterInfo theBPInfo = new BooleanParameterInfo(theParam.Name, "", theParam.Value);
                    this.chkExcept.Checked = (bool)theBPInfo.ParamValue;
                }
                else if (theParam.Name.Equals(ParameterInfo.PARAM_REQUIREDLAYERS))
                {
                    if (this._tm.Current() != null)
                    {
                        // Find all required featureclasses and add them
                        ChooseLayersParameterInfo theCLInfo = new ChooseLayersParameterInfo(theParam.Name, "", theParam.Value);
                        for (int j = 0; j < theCLInfo.ParamValueArray.Length; j++)
                        {
                            string theReqName = theCLInfo.ParamValueArray[j];
                            if (theTestLayersByFClass.ContainsKey(theReqName) == false)
                            {
                                if (theMapLayersByFClass.ContainsKey(theReqName))
                                    theSelectedTest.Test.AddLayer((IFeatureLayer)theMapLayersByFClass[theReqName]);
                                else
                                    this._reqLayerMessages += theSelectedTest.Name + " missing required layer '" + theReqName + "'" + Environment.NewLine;
                            }
                        }
                    }
                }
                else
                {
                    if (theParam.Name.Equals("see-id"))
                    {
                        if (this._tm.Current() != null)
                        {
                            // Set to the current transaction id
                            theSelectedTest.Test.set_ParameterValue(i, this._tm.Current().TxId.ToString());
                            theParam.Value = theSelectedTest.Test.get_ParameterValue(i);
                        }
                    }

                    // Add to the listview
                    string[] theTextByCol = new string[] {
                                                             theSelectedTest.Test.get_ParameterText(i),
                                                             theParam.Value
                                                         };
                    ListViewItem theItem = new ListViewItem(theTextByCol);
                    theItem.Tag = i; // Index into the Parameters collection
                    this.listParams.Items.Add(theItem);

                    // Add tables and layers if available in the map
                    if (theSelectedTest.Test.get_ParameterType(i).Equals(ChooseLayerParameterInfo.TYPE_WKT))
                    {
                        string theLayerName = theParam.Value;
                        if (theTestLayersByFClass.ContainsKey(theLayerName) == false)
                        {
                            if (theMapLayersByFClass.ContainsKey(theLayerName))
                                theSelectedTest.Test.AddLayer((IFeatureLayer)theMapLayersByFClass[theLayerName]);
                            /*
                             * Dealing with the public synonym issue:
                             * truncate "OSDB:" prefix and try to find them in ISDUT, TANT or FADM
                             * sbiickert 2007-06-01
                             */
                            else if (theLayerName.StartsWith("OSDB:"))
                            {
                                //string isdutUsername = this.GetUserName(this._tm.ConnectionManager.Isdut);
                                string fadmUsername = this.GetUserName(this._tm.ConnectionManager.Fadm);
                                string tantUsername = this.GetUserName(this._tm.ConnectionManager.Tant);
                                string isdutSchema = this._defaults.get_Default("db.isdut.schema");
                                string fadmSchema = this._defaults.get_Default("db.fadm.schema");
                                string tantSchema = this._defaults.get_Default("db.tant.schema");

                                string unq = theLayerName.Substring(5);

                                bool skip = false;
                                if (unq.Equals("Spatial Edit Extent"))
                                {
                                    foreach (DictionaryEntry pair in theTestLayersByFClass)
                                    {
                                        String layerName = (String)pair.Key;
                                        if (layerName.Contains("Spatial Edit Extent")){
                                            skip = true;
                                            break;
                                        }
                                    }
                                }

                                if (!skip)
                                {
                                    if (theMapLayersByFClass.ContainsKey(isdutSchema + "." + unq))
                                        theSelectedTest.Test.AddLayer((IFeatureLayer)theMapLayersByFClass[isdutSchema + "." + unq]);
                                    else if (theMapLayersByFClass.ContainsKey(fadmSchema + "." + unq))
                                        theSelectedTest.Test.AddLayer((IFeatureLayer)theMapLayersByFClass[fadmSchema + "." + unq]);
                                    else if (theMapLayersByFClass.ContainsKey(tantSchema + "." + unq))
                                        theSelectedTest.Test.AddLayer((IFeatureLayer)theMapLayersByFClass[tantSchema + "." + unq]);
                                   // else if (theMapLayersByFClass.ContainsKey(isdutUsername + "." + unq))
                                   //     theSelectedTest.Test.AddLayer((IFeatureLayer)theMapLayersByFClass[isdutUsername + "." + unq]);
                                    else if (theMapLayersByFClass.ContainsKey(fadmUsername + "." + unq))
                                        theSelectedTest.Test.AddLayer((IFeatureLayer)theMapLayersByFClass[fadmUsername + "." + unq]);
                                    else if (theMapLayersByFClass.ContainsKey(tantUsername + "." + unq))
                                        theSelectedTest.Test.AddLayer((IFeatureLayer)theMapLayersByFClass[tantUsername + "." + unq]);
                                }
                            }
                        }
                    }
                    else if (theSelectedTest.Test.get_ParameterType(i).Equals(ChooseTableParameterInfo.TYPE_WKT))
                    {
                        string theTableName = theParam.Value;
                        if (theTestTablesByName.ContainsKey(theTableName) == false)
                        {
                            if (theMapTablesByName.ContainsKey(theTableName))
                                theSelectedTest.Test.AddTable((ITable)theMapTablesByName[theTableName]);
                            /*
                             * Dealing with the public synonym issue:
                             * truncate "OSDB:" prefix and try to find them in ISDUT, TANT or FADM
                             * sbiickert 2007-06-01
                             */
                            else if (theTableName.StartsWith("OSDB:"))
                            {
                                //string isdutUsername = this.GetUserName(this._tm.ConnectionManager.Isdut);
                                string fadmUsername = this.GetUserName(this._tm.ConnectionManager.Fadm);
                                string tantUsername = this.GetUserName(this._tm.ConnectionManager.Tant);
                                string isdutSchema = this._defaults.get_Default("db.isdut.schema");
                                string fadmSchema = this._defaults.get_Default("db.fadm.schema");
                                string tantSchema = this._defaults.get_Default("db.tant.schema");

                                string unq = theTableName.Substring(5);

                                bool skip = false;
                                if (unq.Equals("Spatial Edit Extent"))
                                {
                                    foreach (DictionaryEntry pair in theTestLayersByFClass)
                                    {
                                        String layerName = (String)pair.Key;
                                        if (layerName.Contains("Spatial Edit Extent")){
                                            skip = true;
                                            break;
                                        }
                                    }
                                }

                                if (!skip)
                                {
                                    if (theMapTablesByName.ContainsKey(isdutSchema + "." + unq))
                                        theSelectedTest.Test.AddTable((ITable)theMapTablesByName[isdutSchema + "." + unq]);
                                    else if (theMapTablesByName.ContainsKey(fadmSchema + "." + unq))
                                        theSelectedTest.Test.AddTable((ITable)theMapTablesByName[fadmSchema + "." + unq]);
                                    else if (theMapTablesByName.ContainsKey(tantSchema + "." + unq))
                                        theSelectedTest.Test.AddTable((ITable)theMapTablesByName[tantSchema + "." + unq]);
                                    //else if (theMapTablesByName.ContainsKey(isdutUsername + "." + unq))
                                    //    theSelectedTest.Test.AddTable((ITable)theMapTablesByName[isdutUsername + "." + unq]);
                                    else if (theMapTablesByName.ContainsKey(fadmUsername + "." + unq))
                                        theSelectedTest.Test.AddTable((ITable)theMapTablesByName[fadmUsername + "." + unq]);
                                    else if (theMapTablesByName.ContainsKey(tantUsername + "." + unq))
                                        theSelectedTest.Test.AddTable((ITable)theMapTablesByName[tantUsername + "." + unq]);
                                }
                            }
                        }
                    }
                }
            }

            // Layers
            for (int i = 0; i < theSelectedTest.Test.LayerCount; i++)
            {
                IFeatureLayer theFLayer = theSelectedTest.Test.get_Layer(i);
                //if (theMapLayers.Contains(theFLayer))
                    this.listLayers.Items.Add(theFLayer.Name);
            }

            // Tables
            for (int i = 0; i < theSelectedTest.Test.TableCount; i++)
            {
                IDataset theDataset = (IDataset)theSelectedTest.Test.get_Table(i);
                //if (theMapTables.Contains(theDataset))
                    this.listTables.Items.Add(theDataset.Name);
            }

            // Add in all edited layers to the validation test
            //string[] theEditedLayerNames = new string[editLayers.Count];
            //for (int i = 0; i < editLayers.Count; i++)
            //{
            //    if (!this.listLayers.Items.Contains(editLayers[i].ToString()))
            //    {
            //        this.listLayers.Items.Add(editLayers[i].ToString());
            //    }
            //}
        }
Ejemplo n.º 2
0
        private void btnEditParam_Click(object sender, System.EventArgs e)
        {
            QATest theSelectedTest = this._tests.get_Test((int)this.testView.SelectedItems[0].Tag);
            int index = (int)this.paramView.SelectedItems[0].Tag;
            QAParameter theSelectedParam = theSelectedTest.Parameters.get_Parameter(index);

            if (theSelectedParam.Name.Equals(ParameterInfo.PARAM_REQUIREDLAYERS))
            {
                // See if we need to encode the fkeys
                QAParameter theReqLayersFKeyParam = null;
                for (int i = 0; i < theSelectedTest.Parameters.Count; i++)
                {
                    if (theSelectedTest.Parameters.get_Parameter(i).Name == ParameterInfo.PARAM_REQUIREDLAYERSFKEYS)
                    {
                        theReqLayersFKeyParam = theSelectedTest.Parameters.get_Parameter(i);
                        break;
                    }
                }

                // Get the list of featureclasses associated with the operationalDataset
                tm.TransactionConfig theConfig = this._ext.TransactionManager.transactionConfig();
                ArrayList theLayerConfig = theConfig.TantalisLayers;

                string[] theBusinessLayers = new string[theLayerConfig.Count];
                string[] theBusinessLayerFkeys = new string[theLayerConfig.Count];
                for (int i = 0; i < theBusinessLayers.Length; i++)
                {
                    tm.TransactionConfig.LayerConfig lc = (tm.TransactionConfig.LayerConfig)theLayerConfig[i];
                    theBusinessLayers[i] = lc.WorkingLayerName;
                    theBusinessLayerFkeys[i] = lc.Keys[0]; // Only supports simple primary key
                }

                // Get the list of featureclasses currently selected
                ChooseLayersParameterInfo theInfo = new ChooseLayersParameterInfo(theSelectedParam.Name, "", theSelectedParam.Value);
                ChooseFieldsParameterInfo theFieldInfo = null;
                if (theReqLayersFKeyParam != null)
                    theFieldInfo = new ChooseFieldsParameterInfo(theReqLayersFKeyParam.Name, "", theReqLayersFKeyParam.Value);

                string[] dummyString = null;
                 ChooseLayersForm theForm = new ChooseLayersForm(theBusinessLayers, theInfo.ParamValueArray, dummyString);
                //ChooseLayersForm theForm = new ChooseLayersForm(theBusinessLayers, theInfo.ParamValueArray);

                if (theForm.ShowDialog(this) == DialogResult.OK)
                {
                    string[] theChosen = theForm.Chosen;
                    theInfo.ParamValue = theChosen;
                    theSelectedParam.Value = (string)theInfo.ParamValue;
                    theSelectedParam.Store(QAParameterCollection.Table);

                    if (theFieldInfo != null)
                    {
                        List<FeatureClassField> theFkeys = new List<FeatureClassField>();
                        foreach (string selLayer in theChosen)
                        {
                            for (int i = 0; i < theBusinessLayers.Length; i++)
                            {
                                if (selLayer == theBusinessLayers[i])
                                {
                                    theFkeys.Add(new FeatureClassField(selLayer, theBusinessLayerFkeys[i]));
                                    break;
                                }
                            }
                        }
                        theFieldInfo.ParamValue = theFkeys.ToArray();
                        theReqLayersFKeyParam.Value = (string)theFieldInfo.ParamValue;
                        theReqLayersFKeyParam.Store(QAParameterCollection.Table);
                    }

                    this.PopulateParamGrid();
                }
            }
            else if (theSelectedTest.Test.get_ParameterType(index).Equals(ChooseFieldsParameterInfo.TYPE_WKT))
            {
                if (theSelectedParam.Name == ParameterInfo.PARAM_REQUIREDLAYERSFKEYS)
                {
                    MessageBox.Show("This parameter is set via the " + ParameterInfo.PARAM_REQUIREDLAYERS + " parameter.");
                    return;
                }
                // Need to pass required layers selected by the user
                QAParameter theReqLayersParam = null;
                for (int i = 0; i < theSelectedTest.Parameters.Count; i++)
                {
                    if (theSelectedTest.Parameters.get_Parameter(i).Name == ParameterInfo.PARAM_REQUIREDLAYERS)
                    {
                        theReqLayersParam = theSelectedTest.Parameters.get_Parameter(i);
                        break;
                    }
                }

                if (theReqLayersParam == null || theReqLayersParam.Value.Length == 0)
                {
                    MessageBox.Show("Please set the required layers for this test first.");
                    return;
                }

                ChooseLayersParameterInfo theReqLayersInfo = new ChooseLayersParameterInfo(theReqLayersParam.Name, "", theReqLayersParam.Value);
                ChooseFieldsParameterInfo theInfo = new ChooseFieldsParameterInfo(theSelectedParam.Name, "", theSelectedParam.Value);
                string[] theReqLayerNames = theReqLayersInfo.ParamValueArray;

                ChooseLayerFieldsForm theForm = new ChooseLayerFieldsForm();
                IFeatureWorkspace theOsdbWorkspace = null;

                theOsdbWorkspace = (IFeatureWorkspace)RestTransactionManager.Instance.BaseTransactionManager.Current().PGDBConnection;

                for (int i = 0; i < theReqLayerNames.Length; i++)
                {
                    string theFcName = theReqLayerNames[i];
                    IFeatureClass theFC = theOsdbWorkspace.OpenFeatureClass(theFcName);
                    string[] theFieldNames = new string[theFC.Fields.FieldCount];
                    for (int j = 0; j < theFieldNames.Length; j++)
                    {
                        theFieldNames[j] = theFC.Fields.get_Field(j).Name;
                    }
                    string[] theSelectedFieldNames = new string[theInfo.ParamValueArray.Length];
                    for (int j = 0; j < theSelectedFieldNames.Length; j++)
                    {
                        theSelectedFieldNames[j] = theInfo.ParamValueArray[j].FieldName;
                    }
                    theForm.AddLayer(theReqLayerNames[i], theFieldNames, theSelectedFieldNames);
                }

                if (theForm.ShowDialog(this) == DialogResult.OK)
                {
                    theInfo.ParamValue = theForm.CheckedFields;
                    theSelectedParam.Value = (string)theInfo.ParamValue;
                    theSelectedParam.Store(QAParameterCollection.Table);
                    this.PopulateParamGrid();
                }
            }
            else
            {
                ParameterEditForm theForm = new ParameterEditForm(theSelectedParam, theSelectedTest.Test.get_ParameterType(index));

                // Need to pass the names of the featureclasses in the map
                if (theSelectedTest.Test.get_ParameterType(index).Equals(ChooseLayerParameterInfo.TYPE_WKT))
                {
                    ArrayList theNames = new ArrayList();
                    IEnumLayer theLayers = this._ext.AllMapLayers;
                    if (theLayers != null)
                    {
                        ILayer theLayer = theLayers.Next();
                        while (theLayer != null)
                        {
                            if (theLayer is IFeatureLayer && theLayer.Valid)
                            {
                                IDataset theDataset = (IDataset)((IFeatureLayer)theLayer).FeatureClass;
                                /*
                                 * updated to deal with public synonyms:
                                 * trunc the schema name and prefix with custom string
                                 * sbiickert 2007-06-01
                                 */
                                int theDotIndex = theDataset.Name.IndexOf(".");
                                if (theDotIndex > 0)
                                {
                                    string unq = theDataset.Name.Substring(theDotIndex + 1);
                                    tm.TransactionManager theTM = this._ext.TransactionManager;
                                    if (theDataset.Workspace.Equals(theTM.ConnectionManager.Fadm))
                                        theNames.Insert(0, "OSDB:" + unq);
                                    else if (theDataset.Workspace.Equals(theTM.ConnectionManager.Tant))
                                        theNames.Insert(0, "OSDB:" + unq);
                                    //else if (theDataset.Workspace.Equals(theTM.ConnectionManager.Isdut))
                                    //	theNames.Insert(0, "OSDB:" + unq);
                                    else
                                        theNames.Add(theDataset.Name); // fully qualified
                                }
                                else
                                    theNames.Add(theDataset.Name);
                            }
                            theLayer = theLayers.Next();
                        }
                    }

                    if (theNames.Count == 0)
                    {
                        MessageBox.Show("No layers found in the map.");
                        return;
                    }
                    string[] theLayerNames = new string[theNames.Count];
                    for (int i = 0; i < theNames.Count; i++)
                    {
                        theLayerNames[i] = theNames[i] as string;
                    }
                    theForm.LayerNames = theLayerNames;
                }

                if (theSelectedTest.Test.get_ParameterType(index).Equals(ChooseTableParameterInfo.TYPE_WKT))
                {
                    ArrayList theNames = new ArrayList();
                    IStandaloneTableCollection theSTC = (IStandaloneTableCollection)this._ext.FocusMap;

                    if (theSTC.StandaloneTableCount == 0)
                    {
                        MessageBox.Show("No tables found in the map.");
                        return;
                    }

                    string[] theLayerNames = new string[theSTC.StandaloneTableCount];
                    for (int i = 0; i < theSTC.StandaloneTableCount; i++)
                    {
                        /*
                         * updated to deal with public synonyms:
                         * trunc the schema name and prefix with custom string
                         * sbiickert 2007-06-01
                         */
                        IDataset theDataset = (IDataset)theSTC.get_StandaloneTable(i);
                        int theDotIndex = theDataset.Name.IndexOf(".");
                        if (theDotIndex > 0)
                        {
                            string unq = theDataset.Name.Substring(theDotIndex + 1);
                            tm.TransactionManager theTM = this._ext.TransactionManager;
                            if (theDataset.Workspace.Equals(theTM.ConnectionManager.Fadm))
                                theLayerNames[i] = "OSDB:" + unq;
                            else if (theDataset.Workspace.Equals(theTM.ConnectionManager.Tant))
                                theLayerNames[i] = "OSDB:" + unq;
                            //else if (theDataset.Workspace.Equals(theTM.ConnectionManager.Isdut))
                            //	theLayerNames[i] = "OSDB:" + unq;
                            else
                                theLayerNames[i] = theDataset.Name; // fully qualified
                        }
                        else
                            theLayerNames[i] = theDataset.Name;
                    }
                    theForm.LayerNames = theLayerNames;
                }

                if (theForm.ShowDialog(this) == DialogResult.OK)
                    this.PopulateParamGrid();
            }
        }
Ejemplo n.º 3
0
        private void btnTMLayers_Click(object sender, System.EventArgs e)
        {
            try
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                // Get the selected test
                QATest theSelectedTest = this.SelectedTest;

                // Remove its layers
                for (int i = theSelectedTest.Test.LayerCount - 1; i >= 0; i--)
                {
                    theSelectedTest.Test.RemoveLayer(i);
                }

                // Remove its tables
                if (this.cboSpecial.SelectedIndex == LC_PAIR_OSDB_TABLES)
                {
                    for (int i = theSelectedTest.Test.TableCount - 1; i >= 0; i--)
                    {
                        theSelectedTest.Test.RemoveTable(i);
                    }
                }

                // Get the list of required layers
                List<string> theRequiredLayers = new List<string>();
                for (int i = 0; i < theSelectedTest.Parameters.Count; i++)
                {
                    if (theSelectedTest.Parameters.get_Parameter(i).Name == ParameterInfo.PARAM_REQUIREDLAYERS)
                    {
                        QAParameter theReqLayersParam = theSelectedTest.Parameters.get_Parameter(i);
                        ChooseLayersParameterInfo theCLInfo = new ChooseLayersParameterInfo(theReqLayersParam.Name, "", theReqLayersParam.Value);
                        foreach (string s in theCLInfo.ParamValueArray)
                            theRequiredLayers.Add(s);
                        break;
                    }
                }

                // Get the list of working/osdb pairs associated with the transaction
                TransactionConfig theConfig = this._tm.transactionConfig();

                ArrayList theLayerConfig;
                IFeatureWorkspace theOsdbWorkspace;
                string thePrefix = "";
                if (this._tm.Current().OperationalDatasetName.Equals("TANT"))
                {
                    theLayerConfig = theConfig.TantalisLayers;
                    theOsdbWorkspace = (IFeatureWorkspace)this._tm.ConnectionManager.Tant;
                    thePrefix = _defaults.get_Default(tm.dao.DAOUtils.TANT_SCHEMA_KEY);
                }
                else
                {
                    theLayerConfig = theConfig.AdminBoundaryLayers;
                    theOsdbWorkspace = (IFeatureWorkspace)this._tm.ConnectionManager.Fadm;
                    thePrefix = _defaults.get_Default(tm.dao.DAOUtils.FADM_SCHEMA_KEY);
                }
                if (thePrefix.Length > 0)
                    thePrefix += ".";

                // Get the working workspace
                IFeatureWorkspace theWorkingWorkspace = (IFeatureWorkspace)this._tm.Current().PGDBConnection;

                string[] theWorkingLayers;
                string[] theOSDBLayers;
                string[] theOSDBTables;
                if (theRequiredLayers.Count == 0)
                {
                    // include all
                    theWorkingLayers = new string[theLayerConfig.Count];
                    theOSDBLayers = new string[theLayerConfig.Count];
                    theOSDBTables = new string[theLayerConfig.Count];
                    for (int i = 0; i < theLayerConfig.Count; i++)
                    {
                        TransactionConfig.LayerConfig lc = (TransactionConfig.LayerConfig)theLayerConfig[i];
                        theWorkingLayers[i] = lc.WorkingLayerName;
                        theOSDBLayers[i] = thePrefix + lc.OsdbLayerName;
                        theOSDBTables[i] = thePrefix + lc.JoinTable;
                    }
                }
                else
                {
                    // only required layers
                    theWorkingLayers = new string[theRequiredLayers.Count];
                    theOSDBLayers = new string[theRequiredLayers.Count];
                    theOSDBTables = new string[theRequiredLayers.Count];
                    for (int i = 0, j = 0; i < theLayerConfig.Count; i++)
                    {
                        TransactionConfig.LayerConfig lc = (TransactionConfig.LayerConfig)theLayerConfig[i];
                        if (theRequiredLayers.Contains(lc.WorkingLayerName))
                        {
                            theWorkingLayers[j] = lc.WorkingLayerName;
                            theOSDBLayers[j] = thePrefix + lc.OsdbLayerName;
                            theOSDBTables[j] = thePrefix + lc.JoinTable;
                            theRequiredLayers.Remove(lc.WorkingLayerName);
                            j++;
                        }
                        if (theRequiredLayers.Count == 0)
                            break;
                    }
                }

                // Where the layer exists in the map, use that layer
                // Otherwise, make a new layer with the featureclass
                ArrayList theMapLayers = this.MapLayers;
                Hashtable theMapContents = new Hashtable();
                for (int i = 0; i < theMapLayers.Count; i++)
                {
                    IFeatureLayer theFLayer = (IFeatureLayer)theMapLayers[i];
                    IDataset theDataset = (IDataset)theFLayer.FeatureClass;
                    if (theMapContents.ContainsKey(theDataset.Name) == false)
                        theMapContents.Add(theDataset.Name, theFLayer);
                }

                for (int i = 0; i < theWorkingLayers.Length; i++)
                {
                    try
                    {
                        // Working layer
                        IFeatureClass theWorkingFC = null;

                        IFeatureLayer theWorkingFL = null;
                        IFeatureLayer theOsdbFL = null;
                        ITable theOsdbTable = null;

                        if (theMapContents.ContainsKey(theWorkingLayers[i]))
                        {
                            theWorkingFL = (IFeatureLayer)theMapContents[theWorkingLayers[i]];
                            theWorkingFC = theWorkingFL.FeatureClass;
                        }
                        else
                        {
                            theWorkingFL = new FeatureLayerClass();
                            theWorkingFL.Name = theWorkingLayers[i];
                            // This may not work if a working layer does not exist in the personal gdb
                            // Ran into this during development. Current solution is to just log the
                            // error and move on. -- SJB
                            try
                            {
                                theWorkingFC = theWorkingWorkspace.OpenFeatureClass(theWorkingLayers[i]);
                                theWorkingFL.FeatureClass = theWorkingFC;
                            }
                            catch (Exception)
                            {
                                util.Logger.Write("Could not open featureclass '" + theWorkingLayers[i] + "' in the working PGDB");
                                theWorkingFL = null;
                            }
                        }

                        if (theWorkingFL == null || theWorkingFL.Valid == false)
                            continue;

                        // OSDB layer
                        if (this.cboSpecial.SelectedIndex == LC_INTERLEAVE_OSDB_LAYERS)
                        {
                            if (theMapContents.ContainsKey(theOSDBLayers[i]))
                            {
                                theOsdbFL = (IFeatureLayer)theMapContents[theOSDBLayers[i]];
                            }
                            else
                            {
                                theOsdbFL = new FeatureLayerClass();
                                theOsdbFL.Name = theOSDBLayers[i];
                                IFeatureClass theOSDBFC = theOsdbWorkspace.OpenFeatureClass(theOSDBLayers[i]);
                                theOsdbFL.FeatureClass = theOSDBFC;
                            }

                            theSelectedTest.Test.AddLayer(theWorkingFL);
                            theSelectedTest.Test.AddLayer(theOsdbFL);
                        }

                        // OSDB table
                        if (this.cboSpecial.SelectedIndex == LC_PAIR_OSDB_TABLES)
                        {
                            string sid;
                            theOsdbTable = this._qa.get_OsdbBizTable(theWorkingFC, out sid);

                            if (theOsdbTable != null)
                            {
                                theSelectedTest.Test.AddLayer(theWorkingFL);
                                theSelectedTest.Test.AddTable(theOsdbTable);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        util.Logger.Write("Exception caught adding interleaved working/OSDB layers: " + Environment.NewLine
                            + ex.Message + Environment.NewLine + ex.StackTrace);
                    }

                }
            }
            catch (Exception ex)
            {
                util.Logger.Write("Exception caught reading Layer config: " + Environment.NewLine
                    + ex.Message + Environment.NewLine + ex.StackTrace);
            }
            finally
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            }

            PopulateDetails();
            EnableControls();
        }