コード例 #1
0
ファイル: TestManagerForm.cs プロジェクト: EAWCS1/SUITT
        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();
            }
        }
コード例 #2
0
ファイル: RunTestsForm.cs プロジェクト: EAWCS1/SUITT
        private void listParams_DoubleClick(object sender, System.EventArgs e)
        {
            QATest theSelectedTest = this.SelectedTest;

            if (theSelectedTest == null || this._tm.Current() != null)
            {
                MessageBox.Show("Test parameters within a transaction are set by the administrator.",
                    "Cannot Update",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information);
                return;
            }

            int index = (int)this.listParams.SelectedItems[0].Tag;
            QAParameter theSelectedParam = theSelectedTest.Parameters.get_Parameter(index);

            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;
                }
                ChooseLayerFieldsForm theLFForm = new ChooseLayerFieldsForm();
                ChooseFieldsParameterInfo theInfo = new ChooseFieldsParameterInfo(theSelectedParam.Name, "", theSelectedParam.Value);

                // Need to pass the layers selected by the user
                for (int i = 0; i < theSelectedTest.Test.LayerCount; i++)
                {
                    IFeatureLayer theLayer = theSelectedTest.Test.get_Layer(i);
                    IFeatureClass theFC = theLayer.FeatureClass;
                    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;
                    }
                    theLFForm.AddLayer(((IDataset)theFC).Name, theFieldNames, theSelectedFieldNames);
                }

                if (theLFForm.ShowDialog(this) == DialogResult.OK)
                {
                    theInfo.ParamValue = theLFForm.CheckedFields;
                    theSelectedTest.Test.set_ParameterValue(index, theSelectedParam.Value);
                    this.PopulateDetails();
                }
            }
            else
            {
                ParameterEditForm thePEForm = new ParameterEditForm(
                    theSelectedParam,
                    theSelectedTest.Test.get_ParameterType(index),
                    false);

                // Need to pass the names of the featureclasses in the map
                if (theSelectedTest.Test.get_ParameterType(index).Equals(ChooseLayerParameterInfo.TYPE_WKT))
                {
                    ArrayList theLayers = this.MapLayers;
                    string[] theLayerNames = new string[theLayers.Count];
                    for (int i = 0; i < theLayers.Count; i++)
                    {
                        IDataset theDataset = (IDataset)((IFeatureLayer)theLayers[i]).FeatureClass;
                        theLayerNames[i] = theDataset.Name;
                    }
                    thePEForm.LayerNames = theLayerNames;
                }

                if (thePEForm.ShowDialog(this) == DialogResult.OK)
                {
                    theSelectedTest.Test.set_ParameterValue(index, theSelectedParam.Value);
                    this.PopulateDetails();
                }
            }

            this.EnableControls();
        }