private void btnTables_Click(object sender, System.EventArgs e) { QATest theSelectedTest = this.SelectedTest; ArrayList theAvailableTables = this.MapTables; Hashtable theTableLookup = new Hashtable(theAvailableTables.Count); string[] theAvailableTableNames = new string[theAvailableTables.Count]; for (int i = 0; i < theAvailableTables.Count; i++) { IDataset theDataset = (IDataset)theAvailableTables[i]; theAvailableTableNames[i] = theDataset.Name; if (theTableLookup.ContainsKey(theDataset.Name) == false) theTableLookup.Add(theDataset.Name, theDataset); } // test Apr 17, 2008 string[] theEditedLayerNames = new string[editLayers.Count]; for (int i = 0; i < editLayers.Count; i++) { theEditedLayerNames[i] = editLayers[i].ToString(); } string[] theSelectedTableNames = new string[this.listTables.Items.Count]; for (int i = 0; i < theSelectedTableNames.Length; i++) { theSelectedTableNames[i] = this.listTables.Items[i].ToString(); } ChooseLayersForm theForm = new ChooseLayersForm(theAvailableTableNames, theSelectedTableNames, theEditedLayerNames); theForm.Text = "Choose Tables"; if (theForm.ShowDialog() == DialogResult.OK) { for (int i = theSelectedTest.Test.TableCount -1; i >= 0; i--) theSelectedTest.Test.RemoveTable(i); for (int i = 0; i < theForm.Chosen.Length; i++) { theSelectedTest.Test.AddTable((ITable)theTableLookup[theForm.Chosen[i]]); } this.PopulateDetails(); } this.EnableControls(); }
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(); } }
private void btnLayers_Click(object sender, System.EventArgs e) { QATest theSelectedTest = this.SelectedTest; ArrayList theAvailableLayers = this.MapLayers; Hashtable theLayerLookup = new Hashtable(theAvailableLayers.Count); // test Apr 17, 2008 Add the edited layers to the list string[] theEditedLayerNames = new string[editLayers.Count]; for (int i = 0; i < editLayers.Count; i++) { theEditedLayerNames[i] = editLayers[i].ToString(); } string[] theAvailableLayerNames = new string[theAvailableLayers.Count]; for (int i = 0; i < theAvailableLayers.Count; i++) { ILayer theLayer = (ILayer)theAvailableLayers[i]; theAvailableLayerNames[i] = theLayer.Name; if (theLayerLookup.ContainsKey(theLayer.Name) == false) theLayerLookup.Add(theLayer.Name, theLayer); } string[] theSelectedLayerNames = new string[this.listLayers.Items.Count]; for (int i = 0; i < theSelectedLayerNames.Length; i++) { theSelectedLayerNames[i] = this.listLayers.Items[i].ToString(); } ChooseLayersForm theForm = new ChooseLayersForm(theAvailableLayerNames, theSelectedLayerNames, theEditedLayerNames); if (theForm.ShowDialog() == DialogResult.OK) { for (int i = theSelectedTest.Test.LayerCount -1; i >= 0; i--) theSelectedTest.Test.RemoveLayer(i); for (int i = 0; i < theForm.Chosen.Length; i++) { theSelectedTest.Test.AddLayer((IFeatureLayer)theLayerLookup[theForm.Chosen[i]]); } this.PopulateDetails(); } this.EnableControls(); }