Пример #1
0
        public static IArray OrganizeMapWorkspaceAndLayer(IMap pMap)
        {
            IArray        arrayClass       = new ESRI.ArcGIS.esriSystem.ArrayClass();
            IPropertySet  propertySetClass = new PropertySetClass();
            IFeatureLayer featureLayer     = null;


            UID uid = new UIDClass();

            uid.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}";
            IEnumLayer layers = pMap.Layers[uid, true];

            layers.Reset();
            ILayer pLayer = layers.Next();

            while (pLayer != null)
            {
                if (pLayer is IFeatureLayer)
                {
                    featureLayer = pLayer as IFeatureLayer;
                    IDataset featureClass = featureLayer.FeatureClass as IDataset;
                    if (featureClass != null && !(featureClass is ICoverageFeatureClass))
                    {
                        IWorkspace workspace = featureClass.Workspace;
                        if (workspace is IFeatureWorkspace)
                        {
                            IPropertySet connectionProperties = workspace.ConnectionProperties;
                            bool         hasFindWorkspace     = false;
                            for (int i = 0; i < arrayClass.Count; i++)
                            {
                                PipeWorkspaceInfo workspaceInfo = arrayClass.Element[i] as PipeWorkspaceInfo;
                                if (workspaceInfo.Workspace.ConnectionProperties.Equals(connectionProperties))
                                {
                                    workspaceInfo.AddClass(featureLayer.FeatureClass);
                                    hasFindWorkspace = true;
                                    break;
                                }
                            }
                            if (hasFindWorkspace == false)
                            {
                                PipeWorkspaceInfo workspaceInfo = new PipeWorkspaceInfo(workspace);
                                workspaceInfo.AddClass(featureLayer.FeatureClass);
                                arrayClass.Add(workspaceInfo);
                            }
                        }
                    }
                }
                pLayer = layers.Next();
            }
            return(arrayClass);
        }
        public static void ResetFilterSubsetParameters(INetworkAttribute2 netAttribute, List <string> netSourceNames)
        {
            IArray netParams = new ESRI.ArcGIS.esriSystem.ArrayClass();
            INetworkAttributeParameter netParam = null;
            object paramValue = null;

            netParam   = new NetworkAttributeParameterClass();
            paramValue = true;

            string paramName = "";

            paramName  = BaseParameterName;
            paramName += "_Restrict";

            netParam.Name         = paramName;
            netParam.VarType      = (int)VarType.Bool;
            netParam.Value        = paramValue;
            netParam.DefaultValue = paramValue;
            netParams.Add(netParam);

            netParam   = new NetworkAttributeParameterClass();
            paramValue = 1;

            foreach (string netSourceName in netSourceNames)
            {
                netParam   = new NetworkAttributeParameterClass();
                paramValue = null;

                paramName             = BaseParameterName;
                paramName            += "_EIDs_";
                paramName            += netSourceName;
                netParam.Name         = paramName;
                netParam.VarType      = (int)(VarType.Array | VarType.Integer);
                netParam.Value        = paramValue;
                netParam.DefaultValue = paramValue;
                netParams.Add(netParam);
            }

            //does not preserve existing parameters if any
            netAttribute.Parameters = netParams;
        }
Пример #3
0
        /// <summary>
        /// 获取覆盖区域
        /// </summary>
        /// <param name="geometry"></param>
        /// <param name="featureClass"></param>
        public static void seek_IntersectFeature(IGeometry geometry, IFeatureClass featureClass, ref IArray array)
        {
            try
            {
                IFeature feature = null;
                if (array != null)
                {
                    //让我们显示控制COM对象的生存==你调用这个方法,就是通过.NET环境,告诉COM对象,不用你了,马上消失。)
                    Marshal.ReleaseComObject(array);
                }
                array = new ESRI.ArcGIS.esriSystem.ArrayClass();
                //SpatialFilter空间查询
                ISpatialFilter spatialFilter = new SpatialFilterClass();
                IQueryFilter   pQueryFilter  = spatialFilter as IQueryFilter;

                // 设置空间过滤器的范围(多边形)
                spatialFilter.Geometry = geometry;
                // 设置空间过滤器空间关系类型
                spatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                spatialFilter.WhereClause = null;
                //获取FeatureCursor游标
                IFeatureCursor featureCursor = featureClass.Search(pQueryFilter, false);
                //遍历FeatureCursor
                feature = featureCursor.NextFeature();
                while (feature != null)
                {
                    //获取要素对象
                    array.Add(feature);
                    feature = featureCursor.NextFeature();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        protected override void OnClick()
        {
            m_pApp = (IApplication)ArcMap.Application;
            if (m_pApp == null)
            {
                //if the app is null then could be running from ArcCatalog
                m_pApp = (IApplication)ArcCatalog.Application;
            }

            if (m_pApp == null)
            {
                MessageBox.Show("Could not access the application.", "No Application found");
                return;
            }

            IGxApplication pGXApp = (IGxApplication)m_pApp;

            stdole.IUnknown pUnk = null;
            try
            {
                pUnk = (stdole.IUnknown)pGXApp.SelectedObject.InternalObjectName.Open();
            }
            catch (COMException ex)
            {
                if (ex.ErrorCode == (int)fdoError.FDO_E_DATASET_TYPE_NOT_SUPPORTED_IN_RELEASE ||
                    ex.ErrorCode == -2147220944)
                {
                    MessageBox.Show("The dataset is not supported in this release.", "Could not open the dataset");
                }
                else
                {
                    MessageBox.Show(ex.ErrorCode.ToString(), "Could not open the dataset");
                }
                return;
            }

            if (pUnk is ICadastralFabric)
            {
                m_pCadaFab = (ICadastralFabric)pUnk;
            }
            else
            {
                MessageBox.Show("Please select a parcel fabric and try again.", "Not a parcel fabric");
                return;
            }

            IMouseCursor pMouseCursor = new MouseCursorClass();

            pMouseCursor.SetCursor(2);

            clsFabricUtils   FabricUTILS       = new clsFabricUtils();
            IProgressDialog2 pProgressorDialog = null;

            ITable     pTable          = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTParcels);
            IDataset   pDS             = (IDataset)pTable;
            IWorkspace pWS             = pDS.Workspace;
            bool       bIsFileBasedGDB = true;
            bool       bIsUnVersioned  = true;

            FabricUTILS.GetFabricPlatform(pWS, m_pCadaFab, out bIsFileBasedGDB,
                                          out bIsUnVersioned);

            if (!bIsFileBasedGDB && !bIsUnVersioned)
            {
                MessageBox.Show("Truncate operates on non-versioned fabrics."
                                + Environment.NewLine +
                                "Please unversion the fabric and try again.", "Tables are versioned");
                return;
            }


            //Do a Start and Stop editing to make sure truncate it not running within an edit session
            if (!FabricUTILS.StartEditing(pWS, bIsUnVersioned))
            {//if start editing fails then bail
                Cleanup(pProgressorDialog, pMouseCursor);
                return;
            }
            FabricUTILS.StopEditing(pWS);

            dlgTruncate pTruncateDialog = new dlgTruncate();
            IArray      TableArray      = new ESRI.ArcGIS.esriSystem.ArrayClass();

            pTruncateDialog.TheFabric     = m_pCadaFab;
            pTruncateDialog.TheTableArray = TableArray;

            //Display the dialog
            DialogResult pDialogResult = pTruncateDialog.ShowDialog();

            if (pDialogResult != DialogResult.OK)
            {
                pTruncateDialog = null;
                if (TableArray != null)
                {
                    TableArray.RemoveAll();
                }
                return;
            }

            m_pProgressorDialogFact     = new ProgressDialogFactoryClass();
            m_pTrackCancel              = new CancelTrackerClass();
            m_pStepProgressor           = m_pProgressorDialogFact.Create(m_pTrackCancel, m_pApp.hWnd);
            pProgressorDialog           = (IProgressDialog2)m_pStepProgressor;
            m_pStepProgressor.MinRange  = 0;
            m_pStepProgressor.MaxRange  = pTruncateDialog.DropRowCount;
            m_pStepProgressor.StepValue = 1;
            pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;
            bool bSuccess         = false;
            int  iControlRowCount = 0;
            //look in registry to get flag on whether to run truncate on standard tables, or to delete by row.
            string sDesktopVers = FabricUTILS.GetDesktopVersionFromRegistry();

            if (sDesktopVers.Trim() == "")
            {
                sDesktopVers = "Desktop10.0";
            }
            else
            {
                sDesktopVers = "Desktop" + sDesktopVers;
            }

            bool bDeleteTablesByRowInsteadOfTruncate = false;

            string sValues = FabricUTILS.ReadFromRegistry(RegistryHive.CurrentUser, "Software\\ESRI\\" + sDesktopVers + "\\ArcMap\\Cadastral",
                                                          "AddIn.DeleteFabricRecords_Truncate");

            if (sValues.Trim().ToLower() == "deletebytruncateonstandardtables" || bIsFileBasedGDB)
            {
                bDeleteTablesByRowInsteadOfTruncate = false;
            }

            if (sValues.Trim().ToLower() == "deletebyrowonstandardtables")
            {
                bDeleteTablesByRowInsteadOfTruncate = true;
            }

            if (pTruncateDialog.TruncateControl && !pTruncateDialog.TruncateParcelsLinesPoints)
            { // get the control point count
                ITable pControlTable = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTControl);
                iControlRowCount = pControlTable.RowCount(null);
            }

            try
            {
                //Work on the table array
                pTable = null;

                m_pFIDSet = new FIDSetClass();
                for (int i = 0; i <= TableArray.Count - 1; i++)
                {
                    //if (TableArray.get_Element(i) is ITable) ...redundant
                    {
                        pTable = (ITable)TableArray.get_Element(i);
                        IDataset pDataSet = (IDataset)pTable;
                        //Following code uses the truncate method
                        //***
                        if (pTable is IFeatureClass || !bDeleteTablesByRowInsteadOfTruncate)
                        {
                            ITableWrite2 pTableWr = (ITableWrite2)pTable;
                            m_pStepProgressor.Message = "Deleting all rows in " + pDataSet.Name;
                            int RowCnt = pTable.RowCount(null);
                            pTableWr.Truncate();
                            m_pStepProgressor.MaxRange -= RowCnt;
                            //now re-insert the default plan
                            string sName = pDataSet.Name.ToUpper().Trim();
                            if (sName.EndsWith("_PLANS"))
                            {
                                int idxPlanName               = pTable.FindField("Name");
                                int idxPlanDescription        = pTable.FindField("Description");
                                int idxPlanAngleUnits         = pTable.FindField("AngleUnits");
                                int idxPlanAreaUnits          = pTable.FindField("AreaUnits");
                                int idxPlanDistanceUnits      = pTable.FindField("DistanceUnits");
                                int idxPlanDirectionFormat    = pTable.FindField("DirectionFormat");
                                int idxPlanLineParameters     = pTable.FindField("LineParameters");
                                int idxPlanCombinedGridFactor = pTable.FindField("CombinedGridFactor");
                                int idxPlanTrueMidBrg         = pTable.FindField("TrueMidBrg");
                                int idxPlanAccuracy           = pTable.FindField("Accuracy");
                                int idxPlanInternalAngles     = pTable.FindField("InternalAngles");

                                ICursor pCur = pTableWr.InsertRows(false);

                                IRowBuffer pRowBuff = pTable.CreateRowBuffer();

                                double dOneMeterEquals = FabricUTILS.ConvertMetersToFabricUnits(1, m_pCadaFab);
                                bool   bIsMetric       = (dOneMeterEquals == 1);

                                //write category 1
                                pRowBuff.set_Value(idxPlanName, "<map>");
                                pRowBuff.set_Value(idxPlanDescription, "System default plan");
                                pRowBuff.set_Value(idxPlanAngleUnits, 3);

                                //
                                if (bIsMetric)
                                {
                                    pRowBuff.set_Value(idxPlanAreaUnits, 5);
                                    pRowBuff.set_Value(idxPlanDistanceUnits, 9001);
                                    pRowBuff.set_Value(idxPlanDirectionFormat, 1);
                                }
                                else
                                {
                                    pRowBuff.set_Value(idxPlanAreaUnits, 4);
                                    pRowBuff.set_Value(idxPlanDistanceUnits, 9003);
                                    pRowBuff.set_Value(idxPlanDirectionFormat, 4);
                                }

                                pRowBuff.set_Value(idxPlanLineParameters, 4);
                                pRowBuff.set_Value(idxPlanCombinedGridFactor, 1);
                                //pRowBuff.set_Value(idxPlanTrueMidBrg, 1);
                                pRowBuff.set_Value(idxPlanAccuracy, 4);
                                pRowBuff.set_Value(idxPlanInternalAngles, 0);

                                pCur.InsertRow(pRowBuff);

                                pCur.Flush();
                                if (pRowBuff != null)
                                {
                                    Marshal.ReleaseComObject(pRowBuff);
                                }
                                if (pCur != null)
                                {
                                    Marshal.ReleaseComObject(pCur);
                                }
                            }
                        }
                    }
                }
            }
            catch (COMException ex)
            {
                MessageBox.Show(ex.Message + ": " + Convert.ToString(ex.ErrorCode));
                Cleanup(pProgressorDialog, pMouseCursor);
                return;
            }

            //do the loop again, this time within the edit transaction and using the delete function for the chosen tables
            try
            {
                //Start an Edit Transaction
                if (!FabricUTILS.StartEditing(pWS, bIsUnVersioned))
                {//if start editing fails then bail
                    Cleanup(pProgressorDialog, pMouseCursor);
                    return;
                }
                for (int i = 0; i <= TableArray.Count - 1; i++)
                {
                    //if (TableArray.get_Element(i) is ITable)
                    {
                        pTable = (ITable)TableArray.get_Element(i);
                        IDataset pDataSet = (IDataset)pTable;

                        if (pTable is IFeatureClass || !bDeleteTablesByRowInsteadOfTruncate)
                        {
                        }
                        else
                        {
                            //The following code is in place to workaround a limitation of truncate for fabric classes
                            //without a shapefield. It uses an alternative method for removing all the rows
                            //with the Delete function.
                            //General note: This method could be used exclusively, without needing the truncate method.
                            //One advantage is that it allows the option to cancel the whole
                            //operation using the cancel tracker. Truncate is faster, but is problematic if
                            //the truncate fails, and leaves a partially deleted fabric. For example, if the
                            //lines table is deleted but the points table truncate fails, the fabric would be in a
                            //corrupt state.
                            //****

                            m_pFIDSet.SetEmpty();
                            string sName = pDataSet.Name.ToUpper().Trim();
                            m_pStepProgressor.Message = "Loading rows from " + pDataSet.Name;

                            if (sName.EndsWith("_PLANS"))
                            {//for Plans table make sure the default plan is not deleted
                                IQueryFilter pQF = new QueryFilterClass();
                                string       sPref; string sSuff;
                                ISQLSyntax   pSQLSyntax = (ISQLSyntax)pWS;
                                sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
                                sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);
                                string sFieldName = "NAME";
                                //pQF.WhereClause = sPref + sFieldName + sSuff + " <> '<map>'";
                                pQF.WhereClause = sFieldName + " <> '<map>'";
                                if (!BuildFIDSetFromTable(pTable, pQF, ref m_pFIDSet))
                                {
                                    FabricUTILS.AbortEditing(pWS);
                                    Cleanup(pProgressorDialog, pMouseCursor);
                                    return;
                                }
                            }
                            else
                            {
                                if (!BuildFIDSetFromTable(pTable, null, ref m_pFIDSet))
                                {
                                    FabricUTILS.AbortEditing(pWS);
                                    Cleanup(pProgressorDialog, pMouseCursor);
                                    return;
                                }
                            }

                            if (m_pFIDSet.Count() == 0)
                            {
                                continue;
                            }

                            m_pStepProgressor.Message = "Deleting all rows in " + pDataSet.Name;
                            bSuccess = FabricUTILS.DeleteRowsUnversioned(pWS, pTable, m_pFIDSet,
                                                                         m_pStepProgressor, m_pTrackCancel);
                            if (!bSuccess)
                            {
                                FabricUTILS.AbortEditing(pWS);
                                Cleanup(pProgressorDialog, pMouseCursor);
                                return;
                            }
                        }
                    }
                }



                //now need to Fix control-to-point associations if one table was truncated
                //and the other was not
                if (pTruncateDialog.TruncateControl && !pTruncateDialog.TruncateParcelsLinesPoints)
                {
                    IQueryFilter pQF = new QueryFilterClass();
                    string       sPref; string sSuff;
                    ISQLSyntax   pSQLSyntax = (ISQLSyntax)pWS;
                    sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
                    sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);
                    ITable PointTable = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTPoints);
                    m_pStepProgressor.Message = "Resetting control associations on points...please wait.";
                    int    idxFld     = PointTable.FindField("NAME");
                    string sFieldName = PointTable.Fields.get_Field(idxFld).Name;

                    //NAME IS NOT NULL AND (NAME <>'' OR NAME <>' ')
                    //pQF.WhereClause = sPref + sFieldName + sSuff + " IS NOT NULL AND (" +
                    //  sPref + sFieldName + sSuff + "<>'' OR " + sPref + sFieldName + sSuff + " <>' ')";
                    //pQF.WhereClause = sFieldName + " IS NOT NULL AND (" + sFieldName + "<>'' OR " + sFieldName + " <>' ')";
                    pQF.WhereClause = sFieldName + " IS NOT NULL AND " + sFieldName + " > ''"; //changed 1/14/2016

                    ICadastralFabricSchemaEdit2 pSchemaEd = (ICadastralFabricSchemaEdit2)m_pCadaFab;
                    pSchemaEd.ReleaseReadOnlyFields(PointTable, esriCadastralFabricTable.esriCFTPoints);

                    m_pStepProgressor.MinRange = 0;
                    m_pStepProgressor.MaxRange = iControlRowCount;

                    if (!ResetPointAssociations(PointTable, pQF, true, m_pStepProgressor, m_pTrackCancel))
                    {
                        pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTPoints);
                        FabricUTILS.AbortEditing(pWS);
                        Cleanup(pProgressorDialog, pMouseCursor);
                        return;
                    }

                    pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTPoints);
                }

                else if (pTruncateDialog.TruncateParcelsLinesPoints && !pTruncateDialog.TruncateControl)
                {
                    IQueryFilter pQF = new QueryFilterClass();
                    string       sPref; string sSuff;
                    ISQLSyntax   pSQLSyntax = (ISQLSyntax)pWS;
                    sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
                    sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);
                    //POINTID >=0 AND POINTID IS NOT NULL
                    m_pStepProgressor.Message = "Resetting associations on control points...please wait.";
                    ITable ControlTable = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTControl);
                    int    idxFld       = ControlTable.FindField("POINTID");
                    string sFieldName   = ControlTable.Fields.get_Field(idxFld).Name;

                    //pQF.WhereClause = sPref + sFieldName + sSuff + " IS NOT NULL AND " +
                    //  sPref + sFieldName + sSuff + " >=0";
                    pQF.WhereClause = sFieldName + " IS NOT NULL AND " + sFieldName + " >=0";

                    ICadastralFabricSchemaEdit2 pSchemaEd = (ICadastralFabricSchemaEdit2)m_pCadaFab;
                    pSchemaEd.ReleaseReadOnlyFields(ControlTable, esriCadastralFabricTable.esriCFTControl);
                    if (!FabricUTILS.ResetControlAssociations(ControlTable, null, true))
                    {
                        pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTControl);
                        FabricUTILS.AbortEditing(pWS);
                        Cleanup(pProgressorDialog, pMouseCursor);
                        return;
                    }
                    pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTControl);
                }

                //now need to re-assign default accuracy table values, if the option was checked
                if (pTruncateDialog.ResetAccuracyTableDefaults)
                {
                    double dCat1 = FabricUTILS.ConvertMetersToFabricUnits(0.001, m_pCadaFab);
                    double dCat2 = FabricUTILS.ConvertMetersToFabricUnits(0.01, m_pCadaFab);
                    double dCat3 = FabricUTILS.ConvertMetersToFabricUnits(0.02, m_pCadaFab);
                    double dCat4 = FabricUTILS.ConvertMetersToFabricUnits(0.05, m_pCadaFab);
                    double dCat5 = FabricUTILS.ConvertMetersToFabricUnits(0.2, m_pCadaFab);
                    double dCat6 = FabricUTILS.ConvertMetersToFabricUnits(1, m_pCadaFab);
                    double dCat7 = FabricUTILS.ConvertMetersToFabricUnits(10, m_pCadaFab);

                    ITable       pAccTable      = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTAccuracy);
                    int          idxBrgSD       = pAccTable.FindField("BrgSD");
                    int          idxDistSD      = pAccTable.FindField("DistSD");
                    int          idxPPM         = pAccTable.FindField("PPM");
                    int          idxCategory    = pAccTable.FindField("Category");
                    int          idxDescription = pAccTable.FindField("Description");
                    ITableWrite2 pTableWr       = (ITableWrite2)pAccTable;
                    ICursor      pCur           = pTableWr.InsertRows(false);

                    IRowBuffer pRowBuff = pAccTable.CreateRowBuffer();

                    //write category 1
                    pRowBuff.set_Value(idxCategory, 1);
                    pRowBuff.set_Value(idxBrgSD, 5);
                    pRowBuff.set_Value(idxDistSD, dCat1);
                    pRowBuff.set_Value(idxPPM, 5);
                    pRowBuff.set_Value(idxDescription, "1 - Highest");
                    pCur.InsertRow(pRowBuff);

                    //write category 2
                    pRowBuff.set_Value(idxCategory, 2);
                    pRowBuff.set_Value(idxBrgSD, 30);
                    pRowBuff.set_Value(idxDistSD, dCat2);
                    pRowBuff.set_Value(idxPPM, 25);
                    pRowBuff.set_Value(idxDescription, "2 - After 1980");
                    pCur.InsertRow(pRowBuff);

                    //write category 3
                    pRowBuff.set_Value(idxCategory, 3);
                    pRowBuff.set_Value(idxBrgSD, 60);
                    pRowBuff.set_Value(idxDistSD, dCat3);
                    pRowBuff.set_Value(idxPPM, 50);
                    pRowBuff.set_Value(idxDescription, "3 - 1908 to 1980");
                    pCur.InsertRow(pRowBuff);

                    //write category 4
                    pRowBuff.set_Value(idxCategory, 4);
                    pRowBuff.set_Value(idxBrgSD, 120);
                    pRowBuff.set_Value(idxDistSD, dCat4);
                    pRowBuff.set_Value(idxPPM, 125);
                    pRowBuff.set_Value(idxDescription, "4 - 1881 to 1907");
                    pCur.InsertRow(pRowBuff);

                    //write category 5
                    pRowBuff.set_Value(idxCategory, 5);
                    pRowBuff.set_Value(idxBrgSD, 300);
                    pRowBuff.set_Value(idxDistSD, dCat5);
                    pRowBuff.set_Value(idxPPM, 125);
                    pRowBuff.set_Value(idxDescription, "5 - Before 1881");
                    pCur.InsertRow(pRowBuff);

                    //write category 6
                    pRowBuff.set_Value(idxCategory, 6);
                    pRowBuff.set_Value(idxBrgSD, 3600);
                    pRowBuff.set_Value(idxDistSD, dCat6);
                    pRowBuff.set_Value(idxPPM, 1000);
                    pRowBuff.set_Value(idxDescription, "6 - 1800");
                    pCur.InsertRow(pRowBuff);

                    //write category 7
                    pRowBuff.set_Value(idxCategory, 7);
                    pRowBuff.set_Value(idxBrgSD, 6000);
                    pRowBuff.set_Value(idxDistSD, dCat7);
                    pRowBuff.set_Value(idxPPM, 5000);
                    pRowBuff.set_Value(idxDescription, "7 - Lowest");
                    pCur.InsertRow(pRowBuff);

                    pCur.Flush();
                    if (pRowBuff != null)
                    {
                        Marshal.ReleaseComObject(pRowBuff);
                    }
                    if (pCur != null)
                    {
                        Marshal.ReleaseComObject(pCur);
                    }
                }

                //now need to cleanup the IDSequence table if ALL the tables were truncated
                if (pTruncateDialog.TruncateControl &&
                    pTruncateDialog.TruncateParcelsLinesPoints &&
                    pTruncateDialog.TruncateJobs &&
                    pTruncateDialog.TruncateAdjustments)
                {
                    IWorkspace2       pWS2        = (IWorkspace2)pWS;
                    IDataset          TheFabricDS = (IDataset)m_pCadaFab;
                    string            sFabricName = TheFabricDS.Name;
                    string            sName       = sFabricName + "_IDSequencer";
                    bool              bExists     = pWS2.get_NameExists(esriDatasetType.esriDTTable, sName);
                    IFeatureWorkspace pFWS        = (IFeatureWorkspace)pWS;
                    ITable            pSequencerTable;
                    if (bExists)
                    {
                        pSequencerTable = pFWS.OpenTable(sName);
                        IFIDSet pFIDSet = new FIDSetClass();
                        if (BuildFIDSetFromTable(pSequencerTable, null, ref pFIDSet))
                        {
                            FabricUTILS.DeleteRowsUnversioned(pWS, pSequencerTable, pFIDSet, null, null);
                        }
                    }
                }

                Cleanup(pProgressorDialog, pMouseCursor);

                if (TableArray != null)
                {
                    TableArray.RemoveAll();
                }
                FabricUTILS.StopEditing(pWS);
            }
            catch (Exception ex)
            {
                FabricUTILS.AbortEditing(pWS);
                Cleanup(pProgressorDialog, pMouseCursor);
                MessageBox.Show(Convert.ToString(ex.Message));
            }
        }
        protected override void OnClick()
        {
            m_pApp = (IApplication)ArcMap.Application;
              if (m_pApp == null)
            //if the app is null then could be running from ArcCatalog
            m_pApp = (IApplication)ArcCatalog.Application;

              if (m_pApp == null)
              {
            MessageBox.Show("Could not access the application.", "No Application found");
            return;
              }

              IGxApplication pGXApp = (IGxApplication)m_pApp;
              stdole.IUnknown pUnk = null;
              try
              {
            pUnk = (stdole.IUnknown)pGXApp.SelectedObject.InternalObjectName.Open();
              }
              catch (COMException ex)
              {
            if (ex.ErrorCode == (int)fdoError.FDO_E_DATASET_TYPE_NOT_SUPPORTED_IN_RELEASE ||
            ex.ErrorCode == -2147220944)
              MessageBox.Show("The dataset is not supported in this release.", "Could not open the dataset");
            else
              MessageBox.Show(ex.ErrorCode.ToString(), "Could not open the dataset");
            return;
              }

              if (pUnk is ICadastralFabric)
            m_pCadaFab = (ICadastralFabric)pUnk;
              else
              {
            MessageBox.Show("Please select a parcel fabric and try again.", "Not a parcel fabric");
            return;
              }

              IMouseCursor pMouseCursor = new MouseCursorClass();
              pMouseCursor.SetCursor(2);

              clsFabricUtils FabricUTILS = new clsFabricUtils();
              IProgressDialog2 pProgressorDialog = null;

              ITable pTable = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTParcels);
              IDataset pDS = (IDataset)pTable;
              IWorkspace pWS = pDS.Workspace;
              bool bIsFileBasedGDB = true;
              bool bIsUnVersioned = true;

              FabricUTILS.GetFabricPlatform(pWS, m_pCadaFab, out bIsFileBasedGDB,
            out bIsUnVersioned);

              if (!bIsFileBasedGDB && !bIsUnVersioned)
              {
            MessageBox.Show("Truncate operates on non-versioned fabrics."
              + Environment.NewLine +
              "Please unversion the fabric and try again.", "Tables are versioned");
            return;
              }

              //Do a Start and Stop editing to make sure truncate it not running within an edit session
              if (!FabricUTILS.StartEditing(pWS, bIsUnVersioned))
              {//if start editing fails then bail
            Cleanup(pProgressorDialog, pMouseCursor);
            return;
              }
              FabricUTILS.StopEditing(pWS);

              dlgTruncate pTruncateDialog = new dlgTruncate();
              IArray TableArray = new ESRI.ArcGIS.esriSystem.ArrayClass();
              pTruncateDialog.TheFabric = m_pCadaFab;
              pTruncateDialog.TheTableArray = TableArray;

              //Display the dialog
              DialogResult pDialogResult = pTruncateDialog.ShowDialog();

              if (pDialogResult != DialogResult.OK)
              {
            pTruncateDialog = null;
            if (TableArray != null)
            {
              TableArray.RemoveAll();
            }
            return;
              }

              m_pProgressorDialogFact = new ProgressDialogFactoryClass();
              m_pTrackCancel = new CancelTrackerClass();
              m_pStepProgressor = m_pProgressorDialogFact.Create(m_pTrackCancel, m_pApp.hWnd);
              pProgressorDialog = (IProgressDialog2)m_pStepProgressor;
              m_pStepProgressor.MinRange = 0;
              m_pStepProgressor.MaxRange = pTruncateDialog.DropRowCount;
              m_pStepProgressor.StepValue = 1;
              pProgressorDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressSpiral;
              bool bSuccess = false;
              int iControlRowCount=0;
              //look in registry to get flag on whether to run truncate on standard tables, or to delete by row.
              string sDesktopVers = FabricUTILS.GetDesktopVersionFromRegistry();
              if (sDesktopVers.Trim() == "")
            sDesktopVers = "Desktop10.0";
              else
            sDesktopVers = "Desktop" + sDesktopVers;

              bool bDeleteTablesByRowInsteadOfTruncate = false;

              string sValues = FabricUTILS.ReadFromRegistry(RegistryHive.CurrentUser, "Software\\ESRI\\" + sDesktopVers + "\\ArcMap\\Cadastral",
            "AddIn.DeleteFabricRecords_Truncate");

              if (sValues.Trim().ToLower() == "deletebytruncateonstandardtables" || bIsFileBasedGDB)
            bDeleteTablesByRowInsteadOfTruncate = false;

              if (sValues.Trim().ToLower() == "deletebyrowonstandardtables")
            bDeleteTablesByRowInsteadOfTruncate = true;

              if (pTruncateDialog.TruncateControl && !pTruncateDialog.TruncateParcelsLinesPoints)
              { // get the control point count
            ITable pControlTable = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTControl);
            iControlRowCount = pControlTable.RowCount(null);
              }

              try
              {
            //Work on the table array
            pTable = null;

            m_pFIDSet = new FIDSetClass();
            for (int i = 0; i <= TableArray.Count - 1; i++)
            {
              //if (TableArray.get_Element(i) is ITable) ...redundant
              {
            pTable = (ITable)TableArray.get_Element(i);
            IDataset pDataSet = (IDataset)pTable;
            //Following code uses the truncate method
            //***
            if (pTable is IFeatureClass || !bDeleteTablesByRowInsteadOfTruncate)
            {
              ITableWrite2 pTableWr = (ITableWrite2)pTable;
              m_pStepProgressor.Message = "Deleting all rows in " + pDataSet.Name;
              int RowCnt=pTable.RowCount(null);
              pTableWr.Truncate();
              m_pStepProgressor.MaxRange -= RowCnt;
              //now re-insert the default plan
              string sName = pDataSet.Name.ToUpper().Trim();
              if (sName.EndsWith("_PLANS"))
              {

                int idxPlanName = pTable.FindField("Name");
                int idxPlanDescription = pTable.FindField("Description");
                int idxPlanAngleUnits = pTable.FindField("AngleUnits");
                int idxPlanAreaUnits = pTable.FindField("AreaUnits");
                int idxPlanDistanceUnits = pTable.FindField("DistanceUnits");
                int idxPlanDirectionFormat = pTable.FindField("DirectionFormat");
                int idxPlanLineParameters = pTable.FindField("LineParameters");
                int idxPlanCombinedGridFactor = pTable.FindField("CombinedGridFactor");
                int idxPlanTrueMidBrg = pTable.FindField("TrueMidBrg");
                int idxPlanAccuracy = pTable.FindField("Accuracy");
                int idxPlanInternalAngles = pTable.FindField("InternalAngles");

                ICursor pCur = pTableWr.InsertRows(false);

                IRowBuffer pRowBuff = pTable.CreateRowBuffer();

                double dOneMeterEquals = FabricUTILS.ConvertMetersToFabricUnits(1, m_pCadaFab);
                bool bIsMetric = (dOneMeterEquals==1);

                //write category 1
                pRowBuff.set_Value(idxPlanName, "<map>");
                pRowBuff.set_Value(idxPlanDescription, "System default plan");
                pRowBuff.set_Value(idxPlanAngleUnits, 3);

                //
                if (bIsMetric)
                {
                  pRowBuff.set_Value(idxPlanAreaUnits, 5);
                  pRowBuff.set_Value(idxPlanDistanceUnits, 9001);
                  pRowBuff.set_Value(idxPlanDirectionFormat, 1);
                }
                else
                {
                  pRowBuff.set_Value(idxPlanAreaUnits, 4);
                  pRowBuff.set_Value(idxPlanDistanceUnits, 9003);
                  pRowBuff.set_Value(idxPlanDirectionFormat, 4);
                }

                pRowBuff.set_Value(idxPlanLineParameters, 4);
                pRowBuff.set_Value(idxPlanCombinedGridFactor, 1);
                //pRowBuff.set_Value(idxPlanTrueMidBrg, 1);
                pRowBuff.set_Value(idxPlanAccuracy, 4);
                pRowBuff.set_Value(idxPlanInternalAngles, 0);

                pCur.InsertRow(pRowBuff);

                pCur.Flush();
                if (pRowBuff != null)
                  Marshal.ReleaseComObject(pRowBuff);
                if (pCur != null)
                  Marshal.ReleaseComObject(pCur);

              }

            }
              }
             }
            }
            catch(COMException ex)
            {
              MessageBox.Show(ex.Message + ": " + Convert.ToString(ex.ErrorCode));
              Cleanup(pProgressorDialog, pMouseCursor);
              return;
            }

              //do the loop again, this time within the edit transaction and using the delete function for the chosen tables
              try
              {
            //Start an Edit Transaction
            if (!FabricUTILS.StartEditing(pWS, bIsUnVersioned))
            {//if start editing fails then bail
              Cleanup(pProgressorDialog, pMouseCursor);
              return;
            }
            for (int i = 0; i <= TableArray.Count - 1; i++)
            {
              //if (TableArray.get_Element(i) is ITable)
              {
            pTable = (ITable)TableArray.get_Element(i);
            IDataset pDataSet = (IDataset)pTable;

            if (pTable is IFeatureClass || !bDeleteTablesByRowInsteadOfTruncate)
            {
            }
            else
            {
              //The following code is in place to workaround a limitation of truncate for fabric classes
              //without a shapefield. It uses an alternative method for removing all the rows
              //with the Delete function.
              //General note: This method could be used exclusively, without needing the truncate method.
              //One advantage is that it allows the option to cancel the whole
              //operation using the cancel tracker. Truncate is faster, but is problematic if
              //the truncate fails, and leaves a partially deleted fabric. For example, if the
              //lines table is deleted but the points table truncate fails, the fabric would be in a
              //corrupt state.
              //****

              m_pFIDSet.SetEmpty();
              string sName = pDataSet.Name.ToUpper().Trim();
              m_pStepProgressor.Message = "Loading rows from " + pDataSet.Name;

              if (sName.EndsWith("_PLANS"))
              {//for Plans table make sure the default plan is not deleted
                IQueryFilter pQF = new QueryFilterClass();
                string sPref; string sSuff;
                ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS;
                sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
                sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);
                string sFieldName = "NAME";
                //pQF.WhereClause = sPref + sFieldName + sSuff + " <> '<map>'";
                pQF.WhereClause = sFieldName + " <> '<map>'";
                if (!BuildFIDSetFromTable(pTable, pQF, ref m_pFIDSet))
                {
                  FabricUTILS.AbortEditing(pWS);
                  Cleanup(pProgressorDialog, pMouseCursor);
                  return;
                }

              }
              else
              {
                if (!BuildFIDSetFromTable(pTable, null, ref m_pFIDSet))
                {
                  FabricUTILS.AbortEditing(pWS);
                  Cleanup(pProgressorDialog, pMouseCursor);
                  return;
                }
              }

              if (m_pFIDSet.Count() == 0)
                continue;

              m_pStepProgressor.Message = "Deleting all rows in " + pDataSet.Name;
              bSuccess = FabricUTILS.DeleteRowsUnversioned(pWS, pTable, m_pFIDSet,
                m_pStepProgressor, m_pTrackCancel);
              if (!bSuccess)
              {
                FabricUTILS.AbortEditing(pWS);
                Cleanup(pProgressorDialog, pMouseCursor);
                return;
              }
            }
              }
            }

            //now need to Fix control-to-point associations if one table was truncated
            //and the other was not
            if (pTruncateDialog.TruncateControl && !pTruncateDialog.TruncateParcelsLinesPoints)
            {
              IQueryFilter pQF = new QueryFilterClass();
              string sPref; string sSuff;
              ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS;
              sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
              sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);
              ITable PointTable = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTPoints);
              m_pStepProgressor.Message = "Resetting control associations on points...please wait.";
              int idxFld = PointTable.FindField("NAME");
              string sFieldName = PointTable.Fields.get_Field(idxFld).Name;

              //NAME IS NOT NULL AND (NAME <>'' OR NAME <>' ')
              //pQF.WhereClause = sPref + sFieldName + sSuff + " IS NOT NULL AND (" +
              //  sPref + sFieldName + sSuff + "<>'' OR " + sPref + sFieldName + sSuff + " <>' ')";
              //pQF.WhereClause = sFieldName + " IS NOT NULL AND (" + sFieldName + "<>'' OR " + sFieldName + " <>' ')";
              pQF.WhereClause = sFieldName + " IS NOT NULL AND " + sFieldName + " > ''"; //changed 1/14/2016

              ICadastralFabricSchemaEdit2 pSchemaEd = (ICadastralFabricSchemaEdit2)m_pCadaFab;
              pSchemaEd.ReleaseReadOnlyFields(PointTable, esriCadastralFabricTable.esriCFTPoints);

              m_pStepProgressor.MinRange = 0;
              m_pStepProgressor.MaxRange = iControlRowCount;

              if (!ResetPointAssociations(PointTable, pQF, true, m_pStepProgressor, m_pTrackCancel))
              {
            pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTPoints);
            FabricUTILS.AbortEditing(pWS);
            Cleanup(pProgressorDialog, pMouseCursor);
            return;
              }

              pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTPoints);

            }

            else if (pTruncateDialog.TruncateParcelsLinesPoints && !pTruncateDialog.TruncateControl)
            {
              IQueryFilter pQF = new QueryFilterClass();
              string sPref; string sSuff;
              ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS;
              sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
              sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);
              //POINTID >=0 AND POINTID IS NOT NULL
              m_pStepProgressor.Message = "Resetting associations on control points...please wait.";
              ITable ControlTable = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTControl);
              int idxFld = ControlTable.FindField("POINTID");
              string sFieldName = ControlTable.Fields.get_Field(idxFld).Name;

              //pQF.WhereClause = sPref + sFieldName + sSuff + " IS NOT NULL AND " +
              //  sPref + sFieldName + sSuff + " >=0";
              pQF.WhereClause = sFieldName + " IS NOT NULL AND " + sFieldName + " >=0";

              ICadastralFabricSchemaEdit2 pSchemaEd = (ICadastralFabricSchemaEdit2)m_pCadaFab;
              pSchemaEd.ReleaseReadOnlyFields(ControlTable, esriCadastralFabricTable.esriCFTControl);
              if (!FabricUTILS.ResetControlAssociations(ControlTable, null, true))
              {
            pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTControl);
            FabricUTILS.AbortEditing(pWS);
            Cleanup(pProgressorDialog, pMouseCursor);
            return;
              }
              pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTControl);
            }

            //now need to re-assign default accuracy table values, if the option was checked
            if (pTruncateDialog.ResetAccuracyTableDefaults)
            {
              double dCat1 = FabricUTILS.ConvertMetersToFabricUnits(0.001, m_pCadaFab);
              double dCat2 = FabricUTILS.ConvertMetersToFabricUnits(0.01, m_pCadaFab);
              double dCat3 = FabricUTILS.ConvertMetersToFabricUnits(0.02, m_pCadaFab);
              double dCat4 = FabricUTILS.ConvertMetersToFabricUnits(0.05, m_pCadaFab);
              double dCat5 = FabricUTILS.ConvertMetersToFabricUnits(0.2, m_pCadaFab);
              double dCat6 = FabricUTILS.ConvertMetersToFabricUnits(1, m_pCadaFab);
              double dCat7 = FabricUTILS.ConvertMetersToFabricUnits(10, m_pCadaFab);

              ITable pAccTable = m_pCadaFab.get_CadastralTable(esriCadastralFabricTable.esriCFTAccuracy);
              int idxBrgSD = pAccTable.FindField("BrgSD");
              int idxDistSD = pAccTable.FindField("DistSD");
              int idxPPM = pAccTable.FindField("PPM");
              int idxCategory = pAccTable.FindField("Category");
              int idxDescription = pAccTable.FindField("Description");
              ITableWrite2 pTableWr = (ITableWrite2)pAccTable;
              ICursor pCur = pTableWr.InsertRows(false);

              IRowBuffer pRowBuff = pAccTable.CreateRowBuffer();

              //write category 1
              pRowBuff.set_Value(idxCategory, 1);
              pRowBuff.set_Value(idxBrgSD, 5);
              pRowBuff.set_Value(idxDistSD, dCat1);
              pRowBuff.set_Value(idxPPM, 5);
              pRowBuff.set_Value(idxDescription, "1 - Highest");
              pCur.InsertRow(pRowBuff);

              //write category 2
              pRowBuff.set_Value(idxCategory, 2);
              pRowBuff.set_Value(idxBrgSD, 30);
              pRowBuff.set_Value(idxDistSD, dCat2);
              pRowBuff.set_Value(idxPPM, 25);
              pRowBuff.set_Value(idxDescription, "2 - After 1980");
              pCur.InsertRow(pRowBuff);

              //write category 3
              pRowBuff.set_Value(idxCategory, 3);
              pRowBuff.set_Value(idxBrgSD, 60);
              pRowBuff.set_Value(idxDistSD, dCat3);
              pRowBuff.set_Value(idxPPM, 50);
              pRowBuff.set_Value(idxDescription, "3 - 1908 to 1980");
              pCur.InsertRow(pRowBuff);

              //write category 4
              pRowBuff.set_Value(idxCategory, 4);
              pRowBuff.set_Value(idxBrgSD, 120);
              pRowBuff.set_Value(idxDistSD, dCat4);
              pRowBuff.set_Value(idxPPM, 125);
              pRowBuff.set_Value(idxDescription, "4 - 1881 to 1907");
              pCur.InsertRow(pRowBuff);

              //write category 5
              pRowBuff.set_Value(idxCategory, 5);
              pRowBuff.set_Value(idxBrgSD, 300);
              pRowBuff.set_Value(idxDistSD, dCat5);
              pRowBuff.set_Value(idxPPM, 125);
              pRowBuff.set_Value(idxDescription, "5 - Before 1881");
              pCur.InsertRow(pRowBuff);

              //write category 6
              pRowBuff.set_Value(idxCategory, 6);
              pRowBuff.set_Value(idxBrgSD, 3600);
              pRowBuff.set_Value(idxDistSD, dCat6);
              pRowBuff.set_Value(idxPPM, 1000);
              pRowBuff.set_Value(idxDescription, "6 - 1800");
              pCur.InsertRow(pRowBuff);

              //write category 7
              pRowBuff.set_Value(idxCategory, 7);
              pRowBuff.set_Value(idxBrgSD, 6000);
              pRowBuff.set_Value(idxDistSD, dCat7);
              pRowBuff.set_Value(idxPPM, 5000);
              pRowBuff.set_Value(idxDescription, "7 - Lowest");
              pCur.InsertRow(pRowBuff);

              pCur.Flush();
              if (pRowBuff != null)
            Marshal.ReleaseComObject(pRowBuff);
              if (pCur != null)
            Marshal.ReleaseComObject(pCur);
            }

            //now need to cleanup the IDSequence table if ALL the tables were truncated
            if(pTruncateDialog.TruncateControl&&
               pTruncateDialog.TruncateParcelsLinesPoints &&
               pTruncateDialog.TruncateJobs &&
               pTruncateDialog.TruncateAdjustments)
            {
              IWorkspace2 pWS2=(IWorkspace2)pWS;
              IDataset TheFabricDS=(IDataset)m_pCadaFab;
              string sFabricName=TheFabricDS.Name;
              string sName = sFabricName + "_IDSequencer";
              bool bExists=pWS2.get_NameExists(esriDatasetType.esriDTTable, sName);
              IFeatureWorkspace pFWS=(IFeatureWorkspace)pWS;
              ITable pSequencerTable;
              if (bExists)
              {
            pSequencerTable = pFWS.OpenTable(sName);
            IFIDSet pFIDSet= new FIDSetClass();
            if (BuildFIDSetFromTable(pSequencerTable, null, ref pFIDSet))
              FabricUTILS.DeleteRowsUnversioned(pWS, pSequencerTable, pFIDSet, null, null);
              }
            }

            Cleanup(pProgressorDialog, pMouseCursor);

            if (TableArray != null)
            {
              TableArray.RemoveAll();
            }
            FabricUTILS.StopEditing(pWS);
              }
              catch (Exception ex)
              {
            FabricUTILS.AbortEditing(pWS);
            Cleanup(pProgressorDialog, pMouseCursor);
            MessageBox.Show(Convert.ToString(ex.Message));
              }
        }
		public static void ResetScaleSubsetParameters(INetworkAttribute2 netAttribute, List<string> netSourceNames)
		{
			IArray netParams = new ESRI.ArcGIS.esriSystem.ArrayClass();
			INetworkAttributeParameter netParam = null;
			object paramValue = null;
			string paramName = "";

			netParam = new NetworkAttributeParameterClass();
			paramValue = 1;

			paramName = BaseParameterName;
			paramName += "_Factor";

			netParam.Name = paramName;
			netParam.VarType = (int)VarType.Double;
			netParam.Value = paramValue;
			netParam.DefaultValue = paramValue;
			netParams.Add(netParam);

			foreach (string netSourceName in netSourceNames)
			{
				netParam = new NetworkAttributeParameterClass();
				paramValue = null;

				paramName = BaseParameterName;
				paramName += "_eids_";
				paramName += netSourceName;
				netParam.Name = paramName;
				netParam.VarType = (int)(VarType.Array | VarType.Integer);
				netParam.Value = paramValue;
				netParam.DefaultValue = paramValue;
				netParams.Add(netParam);
			}

			//does not preserve existing parameters if any
			netAttribute.Parameters = netParams;
		}