private void DrawSymbolsInOrder(IFeatureCursor Cursor, esriDrawPhase drawPhase, IDisplay Display, ITrackCancel trackCancel)
		{
			// this sub draws either markers or line symbols from large small so that the smallest symbols will be drawn on top

			// in graduated symbol case, a cursor is built and parsed n times for n size classes
			// in proportional symbol case, symbols are sorted and drawn from largest to smallest

			int iSizeIndex = 0;
			int iCurrentDrawableSymbolIndex = 0;
			IFeatureCursor pMyCursor = null;
			IFeature pFeat = null;
			IFeatureDraw pFeatDraw = null;
			bool bContinue = true;
			ISymbol pSizeSym = null;
			ISymbol pDrawSym = null;
			IFeatureCursor pSortedCursor = null;

			if (m_pSizeRend is IProportionalSymbolRenderer)
			{
				// sort 
				pSortedCursor = SortData(Cursor, trackCancel);

				// draw
				pFeat = pSortedCursor.NextFeature();
				while (pFeat != null)
				{
					pDrawSym = GetFeatureSymbol(pFeat);
					// draw the feature
					pFeatDraw = pFeat as IFeatureDraw;
					Display.SetSymbol(pDrawSym);

          //implementation of IExportSupport
          BeginFeature(pFeat, Display);
          					
					pFeatDraw.Draw(drawPhase, Display, pDrawSym, true, null, esriDrawStyle.esriDSNormal);

          //implementation of IExportSupport
          GenerateExportInfo(pFeat, Display);
          EndFeature(Display);
					
					// get next feature
					pFeat = pSortedCursor.NextFeature();
					if (trackCancel != null)
							bContinue = trackCancel.Continue();
				}

			}
			else
			{
				IClassBreaksRenderer pSizeCBRend = null;
                pSizeCBRend = m_pSizeRend as IClassBreaksRenderer;
				pMyCursor = Cursor;
				for (iCurrentDrawableSymbolIndex = (pSizeCBRend.BreakCount - 1); iCurrentDrawableSymbolIndex >= 0; iCurrentDrawableSymbolIndex--)
				{
					// do not build a cursor the 1st time because we already have one
					if (iCurrentDrawableSymbolIndex < (pSizeCBRend.BreakCount - 1))
					{
						// build pMyCursor
						pMyCursor = m_pFeatureClass.Search(m_pQueryFilter, true);
					}
					pFeat = pMyCursor.NextFeature();
					while (pFeat != null)
					{
						// check to see if we will draw in this pass
						pSizeSym = m_pSizeRend.get_SymbolByFeature(pFeat);
						iSizeIndex = GetSymbolIndex(pSizeSym, pSizeCBRend);
						if (iSizeIndex == iCurrentDrawableSymbolIndex)
						{
							// go ahead and draw the symbol
							// get symbol to draw
							pDrawSym = GetFeatureSymbol(pFeat);

							// draw the feature
							pFeatDraw = pFeat as IFeatureDraw;
							Display.SetSymbol(pDrawSym);

              //implementation of IExportSupport
              BeginFeature(pFeat, Display);
							
							pFeatDraw.Draw(drawPhase, Display, pDrawSym, true, null, esriDrawStyle.esriDSNormal);

              //implementation of IExportSupport
              GenerateExportInfo(pFeat, Display);
              EndFeature(Display);
              
							if (trackCancel != null)
									bContinue = trackCancel.Continue();
						}

						pFeat = pMyCursor.NextFeature();
					}

				} // increment DOWN to next symbol size

			}

		}
 private void 添加字段ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FormAddField formaddfield = new FormAddField(pFLayer, gdvAttribute);
     formaddfield.Show();
     pFCuror = pFClass.Search(null, false);
     RefreshDataGridViewDataSource(gdvAttribute, GetAttributeTable(pFClass, pFCuror));
 }
        public static int GetFeaturesForInput(IGPValue inputValue, out IFeatureClass inputFClass, out IFeatureCursor inputFeatures)
        {
            //
            // GET FEATURECURSOR RESPECTING SELECTION
            IGPUtilities gpUtils = new GPUtilitiesClass();
            int numFeatures = 0;
            IGeoFeatureLayer inputFLayer = null;

            if (inputValue is IDEFeatureClass)
            {
                // IF THE INPUT IS A FEATURECLASS THEN JUST OPEN THE DATASET AND
                // CREATE A FEATURE CURSOR OF ALL THE FEATURES AND RETURN THE TOTAL
                // NUMBER OF FEATURES IN THE FEATURECLASS
                inputFClass = (IFeatureClass)gpUtils.OpenDataset(inputValue);
                inputFeatures = inputFClass.Search(null, false);
                numFeatures = inputFClass.FeatureCount(null);
            }
            else
            {
                // IF THE INPUT IS A FEATURELAYER THEN OPEN THE FEATURELAYER
                // AND USE THE DISPLAYFEATURECLASS THAT RESPECTS JOINED FIELDS.
                inputFLayer = (IGeoFeatureLayer)gpUtils.OpenDataset(inputValue);
                inputFClass = inputFLayer.DisplayFeatureClass;
                IFeatureSelection inputSelection = (IFeatureSelection)inputFLayer;
                if (inputSelection.SelectionSet.Count > 0)
                {
                    // IF THE FEATURELAYER HAS A SELECTION THEN CREATE A FEATURECURSOR
                    // OF ALL THE SELECTED FEATURES AND RETURN THE NUMBER OF FEATURES
                    // IN THE SELECTION
                    ICursor selectionCursor = null;
                    inputSelection.SelectionSet.Search(null, false, out selectionCursor);
                    inputFeatures = (IFeatureCursor)selectionCursor;
                    numFeatures = inputSelection.SelectionSet.Count;
                }
                else
                {
                    // IF THE FEATURELAYER HAS NO SELECTION THEN CREATE A FEATURECURSOR
                    // USING THE DEFINITIONEXPRESSION OF THE LAYER AND RETURN THE NUMBER
                    // OF FEATURES BASED ON THE DEFINITIONEXPRESSION.
                    IFeatureLayerDefinition layerDef = (IFeatureLayerDefinition)inputFLayer;
                    IQueryFilter queryFilter = new QueryFilterClass();
                    queryFilter.WhereClause = layerDef.DefinitionExpression;
                    inputFeatures = inputFLayer.SearchDisplayFeatures(queryFilter, false);
                    numFeatures = inputFLayer.FeatureClass.FeatureCount(queryFilter);
                }
            }

            return numFeatures;
        }
示例#4
0
文件: GisUtils.cs 项目: ezequias/Esri
        private static IFeature LinhaMaisProxima(IPoint ponto, ref IFeatureCursor fcursor, ref IFeature ftrLinha, ref IFeature ftrMaisProx)
        {
            IProximityOperator proxOper = ponto as IProximityOperator;
            Double distancia = double.MaxValue;

            while (ftrLinha != null)
            {
                //verifica se está mais próximo
                if (proxOper.ReturnDistance(ftrLinha.Shape) < distancia)
                {
                    ftrMaisProx = ftrLinha;
                    distancia = proxOper.ReturnDistance(ftrLinha.Shape);
                }

                ftrLinha = fcursor.NextFeature();
            }

            return ftrMaisProx;
        }
示例#5
0
 void IFeatureRenderer.Draw(IFeatureCursor cursor, esriDrawPhase DrawPhase, IDisplay Display, ITrackCancel trackCancel)
 {
     Display.SetSymbol(sym);
     IFeature f = cursor.NextFeature();
     while (f != null)
     {
         IFeatureDraw fd = f as IFeatureDraw;
         fd.Draw(DrawPhase, Display, sym, true, f.Shape, esriDrawStyle.esriDSNormal);
         f = cursor.NextFeature();
     }
 }
示例#6
0
        private List <FeatureItem> Check(IBasicLayerInfo basicLayerInfo, string pipelineName, string keyName)
        {
            List <FeatureItem> list = new List <FeatureItem>();

            int keyIndex = basicLayerInfo.FeatureClass.FindField(keyName);

            if (keyIndex < 0)
            {
                list.Add(new FeatureItem()
                {
                    PipelineName  = pipelineName,
                    PipeLayerName = basicLayerInfo.FeatureClass.AliasName,
                    CheckItem     = "字段重复值检查",
                    ErrDesc       = $"字段唯一值字段配置错误,字段 {keyName} 不存在",
                });
                return(list);
            }
            IDictionary <string, IFeature> uniqueDictionary = new Dictionary <string, IFeature>();
            IDictionary <string, int>      repeatDictionary = new Dictionary <string, int>();
            IFeatureCursor featureCursor = basicLayerInfo.FeatureClass.Search(null, false);
            IFeature       feature;

            while ((feature = featureCursor.NextFeature()) != null)
            {
                if (_worker != null && _worker.CancellationPending)
                {
                    return(list);
                }
                object curValue = feature.Value[keyIndex];

                if (curValue == null || curValue is DBNull || string.IsNullOrWhiteSpace(curValue.ToString()))
                {
                    list.Add(new FeatureItem(feature)
                    {
                        PipelineName  = pipelineName,
                        PipeLayerName = basicLayerInfo.FeatureClass.AliasName,
                        CheckItem     = "字段重复值检查",
                        ErrDesc       = "字段 " + keyName + " 为空值",
                    });
                }
                else
                {
                    if (uniqueDictionary.ContainsKey(curValue.ToString()))
                    {
                        if (repeatDictionary.ContainsKey(curValue.ToString()))
                        {
                            repeatDictionary[curValue.ToString()]++;
                        }
                        else
                        {
                            repeatDictionary.Add(curValue.ToString(), 2);
                        }
                    }
                    else
                    {
                        uniqueDictionary.Add(curValue.ToString(), feature);
                    }
                }
            }
            foreach (KeyValuePair <string, int> keyValuePair in repeatDictionary)
            {
                list.Add(new FeatureItem(uniqueDictionary[keyValuePair.Key])
                {
                    PipelineName  = pipelineName,
                    PipeLayerName = basicLayerInfo.FeatureClass.AliasName,
                    CheckItem     = "字段重复值检查",
                    ErrDesc       = "字段 " + keyName + " 的值:" + keyValuePair.Key + " 有 " + keyValuePair.Value + " 处重复",
                });
            }
            return(list);
        }
        /// <summary>
        /// 刷新虚拟干扰源图层
        /// </summary>
        public bool ConstuctSelectPoints(string fromname)
        {
            Hashtable ht = new Hashtable();

            ht["fromName"] = fromname;
            DataTable virTable = IbatisHelper.ExecuteQueryForDataTable("GetSelectedPoint", ht);

            if (virTable.Rows.Count < 2)
            {
                return(false);
            }
            IDataset   dataset   = (IDataset)pFeatureClass;
            IWorkspace workspace = dataset.Workspace;
            //Cast for an IWorkspaceEdit
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)workspace;

            //start an edit session and operation
            workspaceEdit.StartEditing(true);
            workspaceEdit.StartEditOperation();

            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);
            IFeatureBuffer pFeatureBuffer;


            //循环添加
            double circRadius = 60;//扇区生成的半径大小
            double every      = 1;


            foreach (DataRow vir in virTable.Rows)
            {
                int    ci        = Convert.ToInt32(vir["CI"]);
                string fromName  = Convert.ToString(vir["fromName"]);
                double ReceivePW = Convert.ToDouble(vir["ReceivePW"]);
                double azimuth   = Convert.ToDouble(vir["Azimuth"]);



                pFeatureBuffer = pFeatureClass.CreateFeatureBuffer();//创建图元缓冲


                double x = Convert.ToDouble(vir["x"]);
                double y = Convert.ToDouble(vir["y"]);

                IPoint startPoint = GeometryUtilities.ConstructPoint3D(x, y, 0);

                LTE.Geometric.Point p = new Geometric.Point(x, y, 0);
                PointConvertByProj.Instance.GetGeoPoint(p);

                double Direction = (450 - azimuth) % 360;

                IPoint leftPoint  = GeometryUtilities.ConstructPoint3D(circRadius * Math.Cos((Direction - 18 * every) * Math.PI / 180) + x, y + circRadius * Math.Sin((Direction - 18 * every) * Math.PI / 180), 0);
                IPoint rightPoint = GeometryUtilities.ConstructPoint3D(circRadius * Math.Cos((Direction + 18 * every) * Math.PI / 180) + x, y + circRadius * Math.Sin((Direction + 9 * every) * Math.PI / 180), 0);

                IGeometryCollection pGeometryColl = GeometryUtilities.ConstructPolygon(new IPoint[] { startPoint, leftPoint, rightPoint });
                GeometryUtilities.MakeZAware(pGeometryColl as IGeometry);

                ///暂时没添加经纬度

                pFeatureBuffer.Shape = pGeometryColl as IGeometry;
                pFeatureBuffer.set_Value(CIIndex, ci);
                pFeatureBuffer.set_Value(FromIndex, fromName);
                pFeatureBuffer.set_Value(AziIndex, azimuth);
                pFeatureBuffer.set_Value(LonIndex, p.X);
                pFeatureBuffer.set_Value(LatIndex, p.Y);
                pFeatureBuffer.set_Value(RecPwIndex, 10 * (Math.Log10(ReceivePW) + 3));
                pFeatureCursor.InsertFeature(pFeatureBuffer);
            }

            //一次性提交
            pFeatureCursor.Flush();

            //stop editing
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            GISMapApplication.Instance.RefreshLayer(pFeatureLayer);
            return(true);
            //GISMapApplication.Instance.FullExtent(pFeatureLayer.AreaOfInterest);
        }
示例#8
0
 /// <summary>
 /// Clip features in the recordset to the tile envelope
 /// </summary>
 /// <param name="featureCursor"></param>
 /// <param name="recordset"></param>
 /// <param name="tileEnvelope"></param>
 private void ClipFeaturesToTile(ref IFeatureCursor featureCursor, ref IRecordSet recordset, IEnvelope tileEnvelope)
 {
     //IFeatureCursor cursor = recordset.get_Cursor(true) as IFeatureCursor;
     featureCursor = recordset.get_Cursor(false) as IFeatureCursor;
     IFeature feature = featureCursor.NextFeature();
     ITopologicalOperator topologicalOperator = null;
     while (feature != null)
     {
         topologicalOperator = feature.Shape as ITopologicalOperator; // modifying shape so don't use ShapeCopy
         // TODO: verify clip geometry is retained in recordset ********************************
         topologicalOperator.Clip(tileEnvelope);
         feature = featureCursor.NextFeature();
     }
 }
 private void FormAttributeTable_Load(object sender, EventArgs e)
 {
     pFCuror = pFClass.Search(null, false);
     RefreshDataGridViewDataSource(gdvAttribute, GetAttributeTable(pFClass, pFCuror));
 }
示例#10
0
        public DataTable DoQuery(string property, string propName, DF2DFeatureClass dffc)
        {
            DataTable    dt          = new DataTable();
            IQueryFilter queryFilter = new QueryFilterClass();
            List <int>   intlist     = new List <int>();
            //List<string> pfname = new List<string>();

            IFeatureClass    fc    = dffc.GetFeatureClass();
            FacilityClass    fac   = dffc.GetFacilityClass();
            List <FieldInfo> ficol = fac.FieldInfoCollection;

            //queryFilter.SubFields = prop;
            queryFilter.WhereClause = propName + "=" + "'" + property + "'";
            IFeatureCursor featureCursor = fc.Search(queryFilter, false);
            IFeature       pfeature      = featureCursor.NextFeature();

            if (fc == null || pfeature == null)
            {
                return(null);
            }

            for (int i = 0; i < fc.Fields.FieldCount; i++)
            {
                IField pField = fc.Fields.get_Field(i);
                foreach (FieldInfo f in ficol)
                {
                    if (pField.Name == f.Name && f.CanQuery)
                    {
                        DataColumn dc = new DataColumn(pField.AliasName, Type.GetType("System.String"));

                        intlist.Add(i);
                        //pfname.Add(pField.Name);
                        dt.Columns.Add(dc);
                    }
                }



                //DataRow dr = dt.NewRow();
                //dr[dc] = pfeature.get_Value(i).ToString();

                //DataRow dr = dt.NewRow();
                //dr[dc1] = pField.AliasName;
                //dr[dc2] = pfeature.get_Value(i);
                //dt.Rows.Add(dr);
            }

            while (pfeature != null)
            {
                if (dt.Columns.Count > 0 && intlist.Count == dt.Columns.Count)
                {
                    DataRow dr = dt.NewRow();
                    string  str;

                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        //int index = pfeature.Fields.FindField(pfname[i]);
                        if (pfeature.get_Value(intlist[i]) == null)
                        {
                            continue;
                        }
                        else
                        {
                            str = pfeature.get_Value(intlist[i]).ToString();
                        }
                        dr[dt.Columns[i].ColumnName] = str;
                    }
                    dt.Rows.Add(dr);
                }



                pfeature = featureCursor.NextFeature();
            }
            return(dt);
        }
        public bool SetDynamicValues(IObject inObject, string mode, out List<IObject> ChangeFeatureList, out List<IObject> NewFeatureList)
        {
            ChangeFeatureList = null;
            NewFeatureList = null;

            IFeature inFeature = null;
            // IRow inRow = null;

            IMSegmentation mseg = null;
            INetworkFeature netFeat = null;

            IJunctionFeature iJuncFeat = null;
            IEdgeFeature iEdgeFeat = null;
            //ProgressBar
            ESRI.ArcGIS.Framework.IProgressDialogFactory progressDialogFactory = null;
            ESRI.ArcGIS.esriSystem.IStepProgressor stepProgressor = null;
            ESRI.ArcGIS.Framework.IProgressDialog2 progressDialog = null;
            // Create a CancelTracker
            ESRI.ArcGIS.esriSystem.ITrackCancel trackCancel = new ESRI.ArcGIS.Display.CancelTrackerClass();

            try
            {
                if (AAState._PerformUpdates && AAState._dv == null)
                {

                    AAState.WriteLine("Dynamic Value Table is missing - Name in Config:" + AAState._defaultsTableName);

                    //    MessageBox.Show("The Attribute Assistant is turned on, but the Dynamic Value table is missing, please add the table and toggle the extension on");
                    AAState._PerformUpdates = false;
                    return false;
                }
                if (AAState._PerformUpdates && AAState._dv != null)
                {
                    if (inObject == null)
                        return false;
                    if (inObject.Table == AAState._tab)
                    {
                        AAState.WriteLine("Dynamic Value Table is the table that is edited, skipping");
                        return false;
                    }
                    //Convert row to feature (test for feature is null before using - this could be a table update)
                    inFeature = inObject as IFeature;
                    // inRow = inObject as IRow;
                    string modeVal;

                    if (AAState._dv.Table.Columns[mode].DataType == System.Type.GetType("System.String"))
                    {
                        modeVal = "(" + mode + " = '1' or " + mode + " = 'Yes' or " + mode + " = 'YES' or " + mode + " = 'True' or " + mode + " = 'TRUE')";

                    }
                    else
                    {
                        modeVal = mode + " = 1";
                    }
                    System.Int32 int32_hWnd = ArcMap.Application.hWnd;

                    progressDialogFactory = new ESRI.ArcGIS.Framework.ProgressDialogFactoryClass();
                    stepProgressor = progressDialogFactory.Create(trackCancel, int32_hWnd);

                    stepProgressor.MinRange = 0;
                    stepProgressor.MaxRange = inObject.Fields.FieldCount;
                    stepProgressor.StepValue = 1;
                    stepProgressor.Message = "Attribute Assistant Progress";
                    // Create the ProgressDialog. This automatically displays the dialog
                    progressDialog = (ESRI.ArcGIS.Framework.IProgressDialog2)stepProgressor; // Explict Cast

                    // Set the properties of the ProgressDialog
                    progressDialog.CancelEnabled = true;
                    progressDialog.Description = "Checking rules for " + inObject.Class.AliasName;
                    progressDialog.Title = "Attribute Assistant Progress";
                    progressDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressGlobe;
                    progressDialog.ShowDialog();
                    //for each field in this row/feature
                    // Skip orphan junctions (saves time)

                    if (Globals.isOrpanJunction(inFeature))
                        return false;
                    //Get table name for this feature
                    _currentDataset = inObject.Class as IDataset;
                    _currentDatasetNameItems = _currentDataset.Name.Split('.');
                    tableName = _currentDatasetNameItems[_currentDatasetNameItems.GetLength(0) - 1];

                    stepProgressor.Message = "Checking rules for edited feature: " + inObject.Class.AliasName;
                    progressDialog.Description = "Checking rules for edited feature: " + inObject.Class.AliasName;
                    AAState.WriteLine("***********************************************************");
                    AAState.WriteLine("############ " + DateTime.Now + " ################");

                    AAState.WriteLine("");
                    AAState.WriteLine("  Setting sort order: Field - RUNORDER");

                    if (AAState._dv.Table.Columns.Contains("RUN_WEIGHT"))
                        AAState._dv.Sort = "RUN_WEIGHT DESC";

                    AAState.WriteLine("  Querying table for Last Value for layer: " + inObject.Class.AliasName);
                    AAState.WriteLine("  Query Used: (TABLENAME = '*' OR TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') AND VALUEMETHOD = 'Last_Value'");
                    AAState._dv.RowFilter = "(TABLENAME = '*' OR TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') AND VALUEMETHOD = 'Last_Value'";
                    AAState.WriteLine("  Number of results: " + AAState._dv.Count.ToString());

                    if (AAState._dv.Count > 0)
                    {
                        IRowChanges pRowChLast = inObject as IRowChanges;
                        for (int retRows = 0; retRows < AAState._dv.Count; retRows++)
                        {
                            DataRowView drv = AAState._dv[retRows];
                            AAState.WriteLine("       Looking for " + drv["FIELDNAME"].ToString());

                            int fldLoc = inObject.Fields.FindField(drv["FIELDNAME"].ToString());

                            if (fldLoc > 0)
                            {
                                AAState.WriteLine("       " + drv["FIELDNAME"].ToString() + " field found at position: " + fldLoc);

                                if (pRowChLast.get_ValueChanged(fldLoc))
                                {
                                    AAState.WriteLine("       " + drv["FIELDNAME"].ToString() + " Has Changed");

                                    try
                                    {
                                        if (inObject.get_Value(fldLoc) != null)
                                        {
                                            if (inObject.get_Value(fldLoc) != DBNull.Value)
                                            {
                                                if (AAState.lastValueProperties.GetProperty(drv["FIELDNAME"].ToString()) != null)
                                                {
                                                    AAState.WriteLine("                      Setting Last Value");
                                                    AAState.WriteLine("                           " + drv["FIELDNAME"].ToString() + ": " + inObject.get_Value(fldLoc).ToString());
                                                    AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), inObject.get_Value(fldLoc));
                                                }

                                                else
                                                {
                                                    AAState.WriteLine("                      Setting Last Value");
                                                    AAState.WriteLine("                           " + drv["FIELDNAME"].ToString() + ": " + inObject.get_Value(fldLoc));

                                                    AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), inObject.get_Value(fldLoc));
                                                }
                                            }
                                            else
                                            {
                                                if (mode == "ON_CREATE")
                                                {
                                                    AAState.WriteLine("                      Skipping null on create");

                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                      Setting Last Value");
                                                    AAState.WriteLine("                           " + drv["FIELDNAME"].ToString() + ": NULL");
                                                    AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), null);
                                                }

                                            }
                                        }
                                        else
                                        {
                                            if (mode == "ON_CREATE")
                                            {
                                                AAState.WriteLine("                      Skipping null on create");

                                            }
                                            else
                                            {
                                                AAState.WriteLine("                      Setting Last Value");
                                                AAState.WriteLine("                           " + drv["FIELDNAME"].ToString() + ": NULL");
                                                AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), null);
                                            }
                                        }

                                    }

                                    catch
                                    {
                                        //AAState.WriteLine("        Error Setting Last Value " + inObject.Fields.get_Field(intFldIdxs[0]).Name);

                                    }

                                }
                                else
                                {
                                    AAState.WriteLine("       " + drv["FIELDNAME"].ToString() + " Has not changed");

                                }
                            }
                        }

                        pRowChLast = null;
                        // pRowChLast.
                    }

                    //if (inObject != null)
                    //{

                    //    inChanges = inObject as IRowChanges;
                    //    if (intFldIdxs.Count > 0)
                    //    {
                    //        if (intFldIdxs[0] > -1)
                    //        {
                    //            changed = inChanges.get_ValueChanged(intFldIdxs[0]);
                    //            if (changed)
                    //                //  if (fieldName.ToUpper() != "SHAPE")
                    //                try
                    //                {
                    //                    //  if (AAState.lastValueProperties.
                    //                    // AAState.WriteLine("                      Setting Last Value");
                    //                    if (AAState.lastValueProperties.GetProperty(strFldNames[0]) != null)
                    //                    {
                    //                        AAState.WriteLine("                      Setting Last Value");
                    //                        AAState.WriteLine("                           " + strFldNames[0] + ": " + inObject.get_Value(intFldIdxs[0]).ToString());
                    //                        AAState.lastValueProperties.SetProperty(strFldNames[0], inObject.get_Value(intFldIdxs[0]));
                    //                    }

                    //                    else
                    //                    {
                    //                        AAState.WriteLine("                      Setting Last Value");
                    //                        AAState.WriteLine("                           " + strFldNames[0] + ": " + inObject.get_Value(intFldIdxs[0]).ToString());

                    //                        AAState.lastValueProperties.SetProperty(strFldNames[0], inObject.get_Value(intFldIdxs[0]));
                    //                    }

                    //                }
                    //                catch
                    //                {
                    //                    //AAState.WriteLine("        Error Setting Last Value " + inObject.Fields.get_Field(intFldIdxs[0]).Name);

                    //                }

                    //        }
                    //    }
                    //}

                    AAState.WriteLine("  Querying table for rules for layer: " + inObject.Class.AliasName);
                    AAState.WriteLine("  Query Used: (TABLENAME = '*' OR TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') AND " + modeVal);
                    AAState._dv.RowFilter = "(TABLENAME = '*' OR TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') AND " + modeVal;
                    AAState.WriteLine("  Number of results: " + AAState._dv.Count.ToString());
                    //AAState._processCount;
                    if (AAState._processCount > 2)
                    {
                        System.Threading.Thread.Sleep(400);
                    }
                    if (AAState._processCount > 15)
                    {
                        MessageBox.Show("You have more than 15 processes running, more than likely your rules are causing an infinite loop.  Any rule that creates a new feature with * as the table name can cause this issue.");

                        return false;

                    }
                    if (AAState._dv.Count > 0)
                    {
                        bool proc = false;
                        AAState.WriteLine("  Looping through the rows");

                        for (int retRows = 0; retRows < AAState._dv.Count; retRows++)
                        {
                            DataRowView drv = AAState._dv[retRows];

                            AAState.WriteLine("    ------------------------------------------------");
                            AAState.WriteLine("      Row Info");
                            AAState.WriteLine("        Row Number " + (retRows + 1).ToString());
                            AAState.WriteLine("        TableName: " + drv["TABLENAME"].ToString());
                            AAState.WriteLine("        FieldName: " + drv["FIELDNAME"].ToString());
                            AAState.WriteLine("        ValueInfo: " + drv["VALUEINFO"].ToString());
                            AAState.WriteLine("        ValueMethod: " + drv["VALUEMETHOD"].ToString());
                            AAState.WriteLine("        On Create: " + drv["ON_CREATE"].ToString());
                            AAState.WriteLine("        On Change: " + drv["ON_CHANGE"].ToString());
                            if (AAState._dv.Table.Columns.Contains("RUNORDER"))
                                AAState.WriteLine("        Order: " + drv["RUNORDER"].ToString());

                            AAState.WriteLine("");

                            AAState.WriteLine("      Checking for Subtype Restriction");
                            valFC = drv["TABLENAME"].ToString().Trim();
                            if (valFC.Contains("|"))
                            {
                                AAState.WriteLine("        Subtype restriction Found");
                                string[] spliVal = valFC.Split('|');
                                List<string> validSubtypes = new List<string>(spliVal[1].Split(','));
                                List<string> inValidSubtypes;
                                if (spliVal.GetLength(0) == 3)
                                {
                                    inValidSubtypes = new List<string>(spliVal[2].Split(','));
                                }
                                else
                                {
                                    inValidSubtypes = new List<string>();
                                }

                                int obSubVal;
                                ISubtypes pSub = inObject.Class as ISubtypes;
                                if (pSub != null)
                                {
                                    if (pSub.HasSubtype)
                                    {
                                        if (inObject.get_Value(pSub.SubtypeFieldIndex).ToString() != "")
                                        {
                                            obSubVal = Convert.ToInt32(inObject.get_Value(pSub.SubtypeFieldIndex).ToString());
                                            if (validSubtypes.Contains("*"))
                                            {
                                                if (inValidSubtypes.Contains(obSubVal.ToString()))
                                                {
                                                    AAState.WriteLine("        Skipping, not the subtype defined");
                                                    proc = false;
                                                    continue;
                                                }
                                                else
                                                {
                                                    AAState.WriteLine("        Subtype is valid");
                                                }
                                            }

                                            else if (validSubtypes.Contains(obSubVal.ToString()))
                                            {
                                                AAState.WriteLine("        Subtype is valid");
                                            }
                                            else
                                            {
                                                AAState.WriteLine("        Skipping, not the subtype defined");
                                                proc = false;
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            AAState.WriteLine("        Skipping, subtype is not set");
                                            proc = false;
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        AAState.WriteLine("        ERROR: Layer does not have subtypes");
                                    }
                                }
                                else
                                {
                                    AAState.WriteLine("        ERROR: Layer does not have subtypes");
                                }

                            }
                            valMethod = drv["VALUEMETHOD"].ToString().ToUpper().Trim();
                            valData = drv["VALUEINFO"].ToString().Trim();
                            if (valData.Contains(Environment.NewLine))
                            {
                                valData = valData.Substring(0, valData.IndexOf(Environment.NewLine));

                            }
                            List<string> strFldNames = new List<string>();
                            List<int> intFldIdxs = new List<int>();
                            fieldObj = null;
                            if (drv["FIELDNAME"] != null && drv["FIELDNAME"].ToString().Trim() != "" && drv["FIELDNAME"].ToString().Trim() != "*" && drv["FIELDNAME"].ToString().Trim() != "#")
                            {
                                strFldNames = new List<string>(drv["FIELDNAME"].ToString().Trim().Split(','));
                                foreach (string strFldName in strFldNames)
                                {
                                    if (inObject.Fields.FindField(strFldName) >= 0)
                                    {
                                        int tem = inObject.Fields.FindField(strFldName);
                                        intFldIdxs.Add(tem);
                                        fieldObj = inObject.Fields.get_Field(tem);
                                        AAState.WriteLine("      Field Name: " + strFldName + " was found at index: " + tem);

                                        proc = true;
                                    }
                                    else if (inObject.Fields.FindFieldByAliasName(strFldName) >= 0)
                                    {
                                        int tem = inObject.Fields.FindFieldByAliasName(strFldName);
                                        intFldIdxs.Add(tem);

                                        fieldObj = inObject.Fields.get_Field(tem);

                                        AAState.WriteLine("      Field Name: " + strFldName + " was found at index: " + tem);

                                        proc = true;
                                    }
                                    else
                                    {
                                        intFldIdxs.Add(-1);

                                        AAState.WriteLine("      " + strFldName + " Field not found");
                                        //  strFldNames.Remove
                                        fieldObj = null;
                                        proc = false;
                                    }
                                }
                            }
                            else if (drv["FIELDNAME"].ToString() == "#")
                            {
                                AAState.WriteLine("      Field is set to edited field");
                                IRowChanges pRowCh = null;
                                IField pTmpFld = null;
                                pRowCh = inObject as IRowChanges;

                                for (int i = 0; i < inObject.Fields.FieldCount; i++)
                                {
                                    pTmpFld = inObject.Fields.get_Field(i);

                                    if (pTmpFld.Type != esriFieldType.esriFieldTypeGlobalID &&
                                                               pTmpFld.Type != esriFieldType.esriFieldTypeOID &&
                                                               pTmpFld.Type != esriFieldType.esriFieldTypeGeometry &&
                                                                pTmpFld.Name.ToUpper() != "SHAPE_LENGTH" &&
                                                               pTmpFld.Name.ToUpper() != "SHAPE.LEN" &&
                                                               pTmpFld.Name.ToUpper() != "SHAPE_AREA" &&
                                                               pTmpFld.Name.ToUpper() != "SHAPE.AREA")
                                    {
                                        if (pRowCh.get_ValueChanged(i) == true)
                                        {
                                            AAState.WriteLine("      Adding " + pTmpFld.Name + " to field array");
                                            strFldNames.Add(pTmpFld.Name);
                                            intFldIdxs.Add(i);
                                            proc = true;

                                        }
                                    }

                                }
                                pRowCh = null;
                                pTmpFld = null;
                            }
                            else
                            {
                                AAState.WriteLine("      Field is not specified, empty, or set for all.");
                                fieldObj = null;
                                proc = true;
                            }

                            if (proc)
                            {

                                try
                                {
                                    switch (valMethod)
                                    {

                                        case "FIELD_TRIGGER"://Value|FieldToChange|Value

                                            try
                                            {
                                                AAState.WriteLine("                  Trying: FIELD_TRIGGER");
                                                if (inFeature != null & valData != null)
                                                {

                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    string valToCheck = "";
                                                    string fldToChange = "";
                                                    string valToSet = "";
                                                    if (args.GetLength(0) == 3)
                                                    {
                                                        valToCheck = args[0];
                                                        fldToChange = args[1];
                                                        valToSet = args[2];

                                                    }

                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Incorrect Value info was not found");
                                                        continue;
                                                    }

                                                    IRowChanges pRowCh = null;

                                                    pRowCh = inObject as IRowChanges;
                                                    //Globals.GetFieldIndex(inObject.Fields,
                                                    if (intFldIdxs.Count == 0)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Field Not Set");
                                                        continue;
                                                    }
                                                    if (intFldIdxs[0] == -1)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Field Not Found");
                                                        continue;
                                                    }
                                                    if (pRowCh.get_ValueChanged(intFldIdxs[0]))
                                                    {
                                                        AAState.WriteLine("                  Listed field changed");
                                                        if (inObject.get_Value(intFldIdxs[0]).ToString() == valToCheck)
                                                        {
                                                            AAState.WriteLine("                  Values Match");
                                                            int chngFldIdx = Globals.GetFieldIndex(inObject.Fields, fldToChange);
                                                            if (chngFldIdx == -1)
                                                            {
                                                                AAState.WriteLine("                  ERROR: Field Not Found");
                                                                continue;
                                                            }
                                                            try
                                                            {
                                                                inObject.set_Value(chngFldIdx, valToSet);
                                                                AAState.WriteLine("                  Value Set");
                                                            }
                                                            catch
                                                            {
                                                                AAState.WriteLine("                  ERROR: Could not store Value: " + valToSet);
                                                            }

                                                        }
                                                    }
                                                    pRowCh = null;

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: FIELD_TRIGGER: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: FIELD_TRIGGER");
                                            }
                                            break;
                                        case "VALIDATE_ATTRIBUTE_LOOKUP":
                                            {
                                                AAState.WriteLine("                  Trying VALIDATE_ATTRIBUTE_LOOKUP");
                                                IRowChanges pRowCh = null;
                                                ISQLSyntax sqlSyntax = null;
                                                IQueryFilter pQFilt = null;
                                                try
                                                {
                                                    if ((valData != null) && (inFeature != null))
                                                    {

                                                        pRowCh = inObject as IRowChanges;
                                                        bool valueChanged = false;
                                                        for (int i = 0; i < intFldIdxs.Count; i++)
                                                        {
                                                            if (pRowCh.get_ValueChanged(intFldIdxs[i]) == true)
                                                            {
                                                                valueChanged = true;
                                                                break;

                                                            }
                                                        }
                                                        if (valueChanged == false)
                                                        {
                                                            AAState.WriteLine("                  VALIDATE_ATTRIBUTE_LOOKUP: Target value(s) did not change, skipping");
                                                            continue;
                                                        }
                                                        sourceLayerName = "";
                                                        string[] sourceFieldNames = null;
                                                        //string[] destFieldNames = null;

                                                        // Parse arguments
                                                        args = valData.Split('|');
                                                        if (args.Length == 2)
                                                        {
                                                            sourceLayerName = args[0].ToString().Trim();
                                                            sourceFieldNames = args[1].ToString().Split(',');

                                                        }

                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR:  the valuemethod is not defined properly for this rule");
                                                            continue;

                                                        }

                                                        if ((sourceFieldNames != null) &&
                                                            (sourceFieldNames.Length > 0))
                                                        {
                                                            AAState.WriteLine("                  Looking for layer: " + sourceLayerName);

                                                            boolLayerOrFC = true;
                                                            if (sourceLayerName.Contains("("))
                                                            {
                                                                string[] tempSplt = sourceLayerName.Split('(');
                                                                sourceLayerName = tempSplt[0];
                                                                sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                                if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                            }
                                                            else
                                                            {

                                                                sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                            }

                                                            IFields pFlds = null;
                                                            //IWorkspace pWork = null;
                                                            IDataset pDs = null;
                                                            string layNameFnd = "";
                                                            bool matchingLayFnd = false;
                                                            IStandaloneTable pTbl = null;
                                                            if (sourceLayer != null)
                                                            {
                                                                if (sourceLayer.FeatureClass != null)
                                                                {
                                                                    pFlds = sourceLayer.FeatureClass.Fields;
                                                                    pDs = sourceLayer.FeatureClass as IDataset;
                                                                    layNameFnd = sourceLayer.Name;
                                                                    matchingLayFnd = true;
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  ERROR: " + sourceLayerName + " data source is not set");
                                                                    continue;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                pTbl = Globals.FindStandAloneTable(AAState._editor.Map, sourceLayerName) as IStandaloneTable;

                                                                if (pTbl != null)
                                                                {
                                                                    if (pTbl.Table != null)
                                                                    {
                                                                        pFlds = pTbl.Table.Fields;
                                                                        pDs = pTbl.Table as IDataset;
                                                                        layNameFnd = pTbl.Name;

                                                                        matchingLayFnd = true;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  ERROR: " + sourceLayerName + " data source is not set");
                                                                    continue;
                                                                }

                                                            }
                                                            if (matchingLayFnd == false)
                                                            {
                                                                AAState.WriteLine("                  ERROR: " + sourceLayerName + " was not found");
                                                                continue;
                                                            }
                                                            sqlSyntax = (ISQLSyntax)(pDs.Workspace);
                                                            string specChar = sqlSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_WildcardManyMatch);

                                                            AAState.WriteLine("                  Lookup layer " + layNameFnd + " was Found: " + sourceLayerName);

                                                            AAState.WriteLine("                  Checking for field in Lookup table");

                                                            // string missingFieldMess = null;
                                                            if (sourceFieldNames.Length != intFldIdxs.Count)
                                                            {
                                                                AAState.WriteLine("                  Number of listed fields do not match");
                                                                continue;

                                                            }
                                                            int[] sourceFieldNums = new int[sourceFieldNames.Length];
                                                            // missingFieldMess = "";

                                                            pQFilt = new QueryFilterClass();
                                                            string sqlString = "";
                                                            string sqlStringUpper = "";
                                                            for (int i = 0; i < sourceFieldNames.Length; i++)
                                                            {
                                                                sourceFieldNums[i] = Globals.GetFieldIndex(pFlds, sourceFieldNames[i].Trim());
                                                                if (sourceFieldNums[i] < 0)
                                                                {
                                                                    AAState.WriteLine("                  Fields Missing: " + sourceFieldName[i]);
                                                                    break;

                                                                }
                                                                if (pFlds.get_Field(sourceFieldNums[i]).Type == esriFieldType.esriFieldTypeString)
                                                                {
                                                                    if (sqlString == "")
                                                                    {
                                                                        sqlString = pFlds.get_Field(sourceFieldNums[i]).Name + "" + " = '" + inObject.get_Value(intFldIdxs[i]).ToString() + "'";
                                                                        sqlStringUpper = "UPPER(" + pFlds.get_Field(sourceFieldNums[i]).Name + ")" + " LIKE '" + specChar + inObject.get_Value(intFldIdxs[i]).ToString().ToUpper().Replace(" ", specChar) + specChar + "'";
                                                                    }
                                                                    else
                                                                    {
                                                                        sqlString = sqlString + " AND " + pFlds.get_Field(sourceFieldNums[i]).Name + "" + " = '" + inObject.get_Value(intFldIdxs[i]).ToString() + "'";
                                                                        sqlStringUpper = sqlStringUpper + " AND " + "UPPER(" + pFlds.get_Field(sourceFieldNums[i]).Name + ")" + " LIKE '" + specChar + inObject.get_Value(intFldIdxs[i]).ToString().ToUpper().Replace(" ", specChar) + specChar + "'";
                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    if (sqlString == "")
                                                                    {
                                                                        sqlString = pFlds.get_Field(sourceFieldNums[i]).Name + " = " + inObject.get_Value(intFldIdxs[i]);
                                                                        sqlStringUpper = pFlds.get_Field(sourceFieldNums[i]).Name + " LIKE " + specChar + inObject.get_Value(intFldIdxs[i]) + specChar;
                                                                    }
                                                                    else
                                                                    {
                                                                        sqlString = sqlString + " AND " + pFlds.get_Field(sourceFieldNums[i]).Name + " = " + inObject.get_Value(intFldIdxs[i]);
                                                                        sqlStringUpper = sqlStringUpper + " AND " + pFlds.get_Field(sourceFieldNums[i]).Name + " LIKE " + specChar + inObject.get_Value(intFldIdxs[i]) + specChar;
                                                                    }
                                                                }

                                                            }
                                                            pQFilt.WhereClause = sqlString;

                                                            //if (inObject.get_Value(intFldIdxs[0]).ToString().Trim() == "")
                                                            //{
                                                            //    if (mode == "ON_CREATE")
                                                            //    {
                                                            //        AAState.WriteLine("                  Field Found");
                                                            //        continue;
                                                            //    }
                                                            //    pQFilt.WhereClause = "1=1";
                                                            //}
                                                            //else
                                                            //{
                                                            //}

                                                            AAState.WriteLine("                  " + pQFilt.WhereClause + " used to search for matching record");
                                                            int intRecFound = 0;
                                                            if (sourceLayer == null)
                                                            {
                                                                intRecFound = pTbl.Table.RowCount(pQFilt);
                                                            }
                                                            else
                                                            {
                                                                intRecFound = sourceLayer.FeatureClass.FeatureCount(pQFilt);
                                                            }

                                                            AAState.WriteLine("                  " + intRecFound + " rows found");

                                                            if (intRecFound != 1)
                                                            {
                                                                //if (inObject.get_Value(intFldIdxs[0]).ToString().Trim() == "")
                                                                //{
                                                                //    pQFilt.WhereClause = "1=1";
                                                                //}
                                                                //else
                                                                //{
                                                                pQFilt.WhereClause = sqlStringUpper;

                                                                // }
                                                                AAState.WriteLine("                  " + pQFilt.WhereClause + " used to search for matching record");
                                                                if (sourceLayer == null)
                                                                {
                                                                    intRecFound = pTbl.Table.RowCount(pQFilt);
                                                                }
                                                                else
                                                                {
                                                                    intRecFound = sourceLayer.FeatureClass.FeatureCount(pQFilt);
                                                                }
                                                                AAState.WriteLine("                  " + intRecFound + " rows found");

                                                                if (intRecFound == 0)
                                                                {
                                                                    AAState.WriteLine("                     Abort Edit");
                                                                    AAState._editor.AbortOperation();
                                                                    return false;

                                                                }

                                                                else
                                                                {
                                                                    AAState.WriteLine("                  Prompting for user input");
                                                                    ICursor pCurs = null;
                                                                    if (sourceLayer == null)
                                                                    {
                                                                        pCurs = pTbl.Table.Search(pQFilt, true);
                                                                    }
                                                                    else
                                                                    {
                                                                        pCurs = sourceLayer.FeatureClass.Search(pQFilt, true) as ICursor;
                                                                    }

                                                                    pQFilt = null;

                                                                    List<string> pLst = Globals.CursorToList(ref pCurs, sourceFieldNums);
                                                                    if (pCurs != null)
                                                                        Marshal.ReleaseComObject(pCurs);
                                                                    pCurs = null;

                                                                    string selectVal = Globals.showOptionsForm(pLst, "Select an value to store", ComboBoxStyle.DropDownList);
                                                                    if (selectVal == "||Cancelled||")
                                                                    {
                                                                        AAState.WriteLine("                     Abort Edit");
                                                                        AAState._editor.AbortOperation();
                                                                        return false;

                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  Value selected: " + selectVal);
                                                                        string[] strVals = selectVal.Split('|');

                                                                        for (int i = 0; i < sourceFieldNums.Length; i++)
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[i], strVals[i]);
                                                                        }

                                                                    }

                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  One Exact match was found");
                                                            }
                                                            pQFilt = null;

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR: Invalid Value Info: " + valData);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Not a feature or missing Value Info");
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: VALIDATE_ATTRIBUTE_LOOKUP" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    pQFilt = null;
                                                    sqlSyntax = null;
                                                    pRowCh = null;
                                                    AAState.WriteLine("                  Finished: VALIDATE_ATTRIBUTE_LOOKUP");
                                                }
                                                break;
                                            }

                                        case "ANGLE":

                                            try
                                            {
                                                AAState.WriteLine("                  Trying: ANGLE");
                                                if (inFeature != null)
                                                {
                                                    if (intFldIdxs.Count == 0)
                                                    {
                                                        AAState.WriteLine("                  Field not found");
                                                        continue;

                                                    }
                                                    if ((inFeature.Class as IFeatureClass).ShapeType != esriGeometryType.esriGeometryPolyline)
                                                    {
                                                        AAState.WriteLine("                 Input feature is not a line");
                                                        continue;
                                                    }

                                                    bool boolGeo = true;
                                                    if (valData.Trim() != "")
                                                    {
                                                        if (valData.ToUpper() == "A")
                                                        {
                                                            boolGeo = false;
                                                        }
                                                    }
                                                    AAState.WriteLine("                 Getting Angle for feature");
                                                    IPolyline pLyLine = inFeature.Shape as IPolyline;

                                                    ILine pLine = new LineClass();
                                                    pLine.ToPoint = pLyLine.FromPoint;
                                                    pLine.FromPoint = pLyLine.ToPoint;

                                                    double angArth = pLine.Angle * 180 / Math.PI;
                                                    if (angArth < 0)
                                                    {
                                                        angArth = 360 + angArth;
                                                    }

                                                    double angGeo = 270 - angArth;
                                                    if (angGeo < 0)
                                                    {
                                                        angGeo = 360 + angGeo;
                                                    }
                                                    double ang;
                                                    if (boolGeo)
                                                    {
                                                        ang = angGeo;
                                                    }
                                                    else
                                                    {
                                                        ang = angArth;
                                                    }
                                                    AAState.WriteLine("                  Angle Calculated: " + ang);
                                                    try
                                                    {
                                                        inObject.set_Value(intFldIdxs[0], ang);
                                                        AAState.WriteLine("                  Angle Stored");

                                                    }
                                                    catch
                                                    {
                                                        AAState.WriteLine("                  Could not store angle");
                                                    }

                                                    pLine = null;
                                                    pLyLine = null;

                                                    AAState.WriteLine("                  Done");

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: ANGLE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: ANGLE");
                                            }
                                            break;

                                        case "CREATE_PERP_LINE"://Layer to Search For|Offset Distante or Field|Search distance to look for a line|UseSnapPoint|TargetLayer|TargetLayerTemplate

                                            try
                                            {
                                                AAState.WriteLine("                  Trying: CREATE_PERP_LINE");
                                                if (inFeature != null & valData != null)
                                                {
                                                    sourceLayerName = "";
                                                    double offsetVal = 5;
                                                    bool useSnapPnt = false;
                                                    string targetLayerName = "";
                                                    IFeatureLayer targetLayer = null;
                                                    string targetLayerTemp = "";

                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    int fldOff = -1;
                                                    if (args.GetLength(0) == 6)
                                                    {
                                                        //    sourceLayerName = args[0].ToString();
                                                        sourceLayerNames = args[0].ToString().Split(',');
                                                        //offsetVal = Convert.ToDouble(args[1]);
                                                        if (Globals.IsNumeric(args[1]))
                                                            Double.TryParse(args[1], out offsetVal);
                                                        else
                                                        {
                                                            fldOff = Globals.GetFieldIndex(inObject.Fields, args[1]);

                                                        }

                                                        Double.TryParse(args[2], out searchDistance);
                                                        Boolean.TryParse(args[3], out useSnapPnt);
                                                        targetLayerName = args[4];
                                                        targetLayerTemp = args[5];

                                                    }
                                                    else if (args.GetLength(0) == 5)
                                                    {
                                                        //    sourceLayerName = args[0].ToString();
                                                        sourceLayerNames = args[0].ToString().Split(',');
                                                        //offsetVal = Convert.ToDouble(args[1]);
                                                        if (Globals.IsNumeric(args[1]))
                                                            Double.TryParse(args[1], out offsetVal);
                                                        else
                                                        {
                                                            fldOff = Globals.GetFieldIndex(inObject.Fields, args[1]);

                                                        }

                                                        Double.TryParse(args[2], out searchDistance);
                                                        Boolean.TryParse(args[3], out useSnapPnt);
                                                        targetLayerName = args[4];
                                                        targetLayerTemp = "";
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Incorrect Value info was not found");
                                                        continue;
                                                    }
                                                    if (intFldIdxs.Count > 0)
                                                    {
                                                        AAState.WriteLine("                  WARNING: Input fields are not used for this tool");
                                                        continue;
                                                    }

                                                    targetLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, targetLayerName, ref boolLayerOrFC);
                                                    if (targetLayer == null)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Target layer not found. " + targetLayerName);
                                                        continue;
                                                    }
                                                    if (targetLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Target layer is not a line layer. " + targetLayerName);
                                                        continue;
                                                    }

                                                    for (int i = 0; i < sourceLayerNames.Length; i++)
                                                    {
                                                        sourceLayerName = sourceLayerNames[i].ToString();
                                                        if (sourceLayerName != "")

                                                            sourceLayerName = args[i].ToString();
                                                        if (i == 0)
                                                            i++;
                                                        boolLayerOrFC = true;

                                                        if (sourceLayerName.Contains("("))
                                                        {
                                                            string[] tempSplt = sourceLayerName.Split('(');
                                                            sourceLayerName = tempSplt[0];
                                                            sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                            if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                            {
                                                                boolLayerOrFC = true;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                            {
                                                                boolLayerOrFC = true;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                            {
                                                                boolLayerOrFC = false;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                            {
                                                                boolLayerOrFC = false;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                            {
                                                                boolLayerOrFC = false;
                                                            }
                                                            else
                                                            {
                                                                boolLayerOrFC = true;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                        }
                                                        if (sourceLayer == null)
                                                        {
                                                            AAState.WriteLine("                  ERROR/WARNING: " + sourceLayer + " was not found");
                                                            continue;
                                                        }

                                                        IFeatureClass iFC = inFeature.Class as IFeatureClass;
                                                        if (sourceLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                                                        {
                                                            AAState.WriteLine("                  ERROR: " + sourceLayer + " is a polygon layer");

                                                            break;
                                                        }
                                                        if (sourceLayer != null)
                                                        {

                                                            sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false);

                                                            pFS = (IFeatureSelection)sourceLayer;
                                                            if (boolLayerOrFC)
                                                            {
                                                                if (pFS.SelectionSet.Count > 0)
                                                                {
                                                                    pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                    fCursor = cCurs as IFeatureCursor;

                                                                }
                                                                else
                                                                {
                                                                    fCursor = sourceLayer.Search(sFilter, true);
                                                                }
                                                            }
                                                            else
                                                            {
                                                                fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                            }

                                                            IPoint snapPnt = null;

                                                            while ((sourceFeature = fCursor.NextFeature()) != null)
                                                            {
                                                                double dAlong = 0;
                                                                if (sourceFeature.Class != inFeature.Class)
                                                                {
                                                                    IPoint pIntPnt;
                                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                                    {
                                                                        pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint;

                                                                    }
                                                                    else
                                                                        pIntPnt = inFeature.ShapeCopy as IPoint;

                                                                    dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt);

                                                                    pIntPnt = null;

                                                                    //AAState.WriteLine("                  Value set to: " + strDis);
                                                                    //inObject.set_Value(intFldIdxs[0], strDis);
                                                                    //break;

                                                                }

                                                                else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                {
                                                                    IPoint pIntPnt;
                                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                                    {
                                                                        pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint;

                                                                    }
                                                                    else
                                                                        pIntPnt = inFeature.ShapeCopy as IPoint;

                                                                    dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt);
                                                                    pIntPnt = null;
                                                                    //AAState.WriteLine("                  Value set to: " + strDis);
                                                                    // inObject.set_Value(intFldIdxs[0], strDis);
                                                                    // break;

                                                                }
                                                                AAState.WriteLine("                  Distance found: " + dAlong);
                                                                IPoint pNewPt = new PointClass();
                                                                IConstructPoint2 pConsPoint = pNewPt as IConstructPoint2;

                                                                if (fldOff != -1)
                                                                {
                                                                    string temp = inObject.get_Value(fldOff).ToString();
                                                                    if (Globals.IsNumeric(temp))
                                                                    {
                                                                        Double.TryParse(temp, out offsetVal);
                                                                    }

                                                                }
                                                                AAState.WriteLine("                  Offset Value: " + offsetVal);
                                                                pConsPoint.ConstructOffset
                                                                    (sourceFeature.Shape as ICurve, esriSegmentExtension.esriNoExtension, dAlong, false, offsetVal);
                                                                AAState.WriteLine("                  Offset Constrcuted");
                                                                AAState.WriteLine("                  Creating Line");
                                                                IPolyline pTempLine = new PolylineClass();
                                                                if (useSnapPnt && snapPnt != null)
                                                                {
                                                                    if (snapPnt.IsEmpty)
                                                                    {
                                                                        AAState.WriteLine("                  Using feature Point");
                                                                        pTempLine.ToPoint = inFeature.ShapeCopy as IPoint;
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  Using Snap Point");
                                                                        pTempLine.ToPoint = snapPnt;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  Using feature Point");
                                                                    pTempLine.ToPoint = inFeature.ShapeCopy as IPoint;
                                                                }
                                                                pTempLine.FromPoint = pNewPt;
                                                                AAState.WriteLine("                  Line Created");
                                                                IEditTemplate pTemp = null;
                                                                IFeature pFeat = null;
                                                                AAState.WriteLine("                  Looking for Edit Template");
                                                                if (targetLayerTemp != "")
                                                                    pTemp = Globals.GetEditTemplate(targetLayerTemp, targetLayer);
                                                                if (pTemp != null)
                                                                {
                                                                    AAState.WriteLine("                  Template found");
                                                                    pFeat = Globals.CreateFeature(pTempLine, pTemp, AAState._editor, ArcMap.Application, false, false, false);

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  Template not found and creating a feature without it");
                                                                    pFeat = Globals.CreateFeature(pTempLine, targetLayer, AAState._editor, ArcMap.Application, false, false, false);
                                                                }
                                                                AAState.WriteLine("                  Feature Created");
                                                                if (NewFeatureList == null)
                                                                {
                                                                    NewFeatureList = new List<IObject>();
                                                                }
                                                                AAState.WriteLine("                  Added to the new feature list");
                                                                NewFeatureList.Add(pFeat);

                                                                pTemp = null;
                                                                pNewPt = null;
                                                                pConsPoint = null;
                                                                snapPnt = null;
                                                                AAState.WriteLine("                  Finished");
                                                                break;
                                                            }
                                                            //else if (inObject.Fields.get_Field(intFldIdxs[0]).IsNullable)
                                                            //    inObject.set_Value(intFldIdxs[0], null);
                                                        }

                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: CREATE_PERP_LINE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: CREATE_PERP_LINE");
                                            }
                                            break;
                                        case "AUTONUMBER"://Layer to Search For|Offset Distante or Field|Search distance to look for a line

                                            try
                                            {
                                                AAState.WriteLine("                  Trying: AUTONUMBER");
                                                if (inObject != null)
                                                {
                                                    if (intFldIdxs.Count == 0)
                                                    {
                                                        AAState.WriteLine("                  Field not found");
                                                        continue;

                                                    }
                                                    AAState.WriteLine("                  Getting Max value for Field: " + strFldNames[0]);
                                                    string res = Globals.GetFieldStats(inObject.Class as IFeatureClass, strFldNames[0], Globals.statsType.Max);
                                                    AAState.WriteLine("                  Value returned: " + res);
                                                    if (res == "External component has thrown an exception.")
                                                    {
                                                        AAState.WriteLine("                  The field specified was not a numeric field");
                                                    }
                                                    else
                                                    {

                                                        if (Globals.IsNumeric(res))
                                                        {
                                                            AAState.WriteLine("                  Value is numeric");

                                                            AAState.WriteLine("                  Trying to Incriment " + res);
                                                            long val = (Convert.ToInt64(res) + 1);
                                                            AAState.WriteLine("                  Incrimented to " + res);
                                                            try
                                                            {
                                                                AAState.WriteLine("                  Trying to set value " + res);
                                                                inObject.set_Value(intFldIdxs[0], val);
                                                                AAState.WriteLine("                  Value set" + res);

                                                            }
                                                            catch (Exception ex)
                                                            {
                                                                AAState.WriteLine("                  ERROR: Could not set value: " + ex.Message.ToString());
                                                            }

                                                        }

                                                        else
                                                        {
                                                            AAState.WriteLine("                  Value is not numeric: " + res);
                                                        }
                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: AUTONUMBER: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: AUTONUMBER");
                                            }
                                            break;

                                        case "COPY_LINKED_RECORD"://Feature Layer|Field To Copy|Primary Key Field|Foreign Key Field
                                            {
                                                try
                                                {
                                                    AAState.WriteLine("                  Trying: COPY_LINKED_RECORD");
                                                    if (!String.IsNullOrEmpty(valData))
                                                    {
                                                        args = valData.Split('|');
                                                        if (args.Length != 4)
                                                        {
                                                            AAState.WriteLine("                  ERROR: Format of valdata incorrect");
                                                            break;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Format of valdata incorrect");
                                                        break;
                                                    }
                                                    if (inFeature == null)
                                                    {
                                                        AAState.WriteLine("                  ERROR: The input features is null");
                                                        break;
                                                    }
                                                    string[] targetLayerNames;
                                                    string targetFieldName = "";

                                                    found = false;
                                                    AAState.WriteLine("                  Getting Value Info");
                                                    targetLayerNames = args[0].ToString().Split(',');
                                                    targetFieldName = args[1].ToString();
                                                    string targetLayerName = "";
                                                    string sourceIDFieldName = args[2].ToString();
                                                    string targetIDFieldName = args[3].ToString();
                                                    AAState.WriteLine("                  Checking values");
                                                    if (targetFieldName != null)
                                                    {
                                                        AAState.WriteLine("                  Checking Field in Edited Layer");

                                                        int fldIDSourecIdx = inObject.Fields.FindField(sourceIDFieldName);
                                                        if (fldIDSourecIdx > -1 && intFldIdxs.Count > 0)
                                                        {
                                                            if (inObject.get_Value(fldIDSourecIdx) != null && inObject.get_Value(fldIDSourecIdx) != DBNull.Value)
                                                            {
                                                                if (inObject.get_Value(fldIDSourecIdx).ToString() != "")
                                                                {

                                                                    for (int i = 0; i < targetLayerNames.Length; i++)
                                                                    {
                                                                        targetLayerName = targetLayerNames[i].ToString();

                                                                        if (targetLayerName != "")
                                                                        {

                                                                            // Get layer
                                                                            AAState.WriteLine("                  Checking for join record");
                                                                            bool FCorLayerSource = true;
                                                                            sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, targetLayerName, ref FCorLayerSource);

                                                                            if (sourceLayer != null)
                                                                            {

                                                                                int fldValToCopyIdx = sourceLayer.FeatureClass.Fields.FindField(targetFieldName);
                                                                                int fldIDTargetIdx = sourceLayer.FeatureClass.Fields.FindField(targetIDFieldName);
                                                                                if (fldIDTargetIdx > -1 && fldValToCopyIdx > -1)
                                                                                {
                                                                                    IQueryFilter pQFilt = Globals.createQueryFilter();
                                                                                    if (sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeString)
                                                                                    {
                                                                                        pQFilt.WhereClause = "" + sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString() + "'";

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        pQFilt.WhereClause = sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx);

                                                                                    }
                                                                                    IFeatureCursor pCurs;

                                                                                    pCurs = sourceLayer.FeatureClass.Search(pQFilt, true);
                                                                                    IFeature pRow;
                                                                                    while ((pRow = pCurs.NextFeature()) != null)
                                                                                    {
                                                                                        AAState.WriteLine("                  Trying to Copy Value from Record");
                                                                                        try
                                                                                        {
                                                                                            inObject.set_Value(intFldIdxs[0], pRow.get_Value(fldValToCopyIdx));
                                                                                            break;

                                                                                        }
                                                                                        catch
                                                                                        {
                                                                                            AAState.WriteLine("                  ERROR: Could not Copy: " + inObject.get_Value(fldValToCopyIdx) + " to field: " + strFldNames[0]);
                                                                                        }

                                                                                        pRow = null;
                                                                                    }
                                                                                    pRow = null;

                                                                                    AAState.WriteLine("                  Value successfully copied");

                                                                                    if (pCurs != null)
                                                                                        Marshal.ReleaseComObject(pCurs);
                                                                                    pCurs = null;

                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  ERROR: ID or Field to populate was not found");
                                                                                }

                                                                            }
                                                                            else
                                                                            {

                                                                                ITable pTable = Globals.FindTable(AAState._editor.Map, targetLayerName);
                                                                                if (pTable != null)
                                                                                {
                                                                                    int fldValToCopyIdx = pTable.Fields.FindField(targetFieldName);
                                                                                    int fldIDTargetIdx = pTable.Fields.FindField(targetIDFieldName);
                                                                                    if (fldIDTargetIdx > -1 && fldValToCopyIdx > -1)
                                                                                    {
                                                                                        IQueryFilter pQFilt = Globals.createQueryFilter();
                                                                                        if (pTable.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeString)
                                                                                        {
                                                                                            pQFilt.WhereClause = "" + pTable.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString() + "'";

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            pQFilt.WhereClause = pTable.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx);

                                                                                        }
                                                                                        ICursor pCurs;

                                                                                        pCurs = pTable.Search(pQFilt, true);
                                                                                        IRow pRow;
                                                                                        while ((pRow = pCurs.NextRow()) != null)
                                                                                        {
                                                                                            AAState.WriteLine("                  Trying to Copy Value from Record");
                                                                                            try
                                                                                            {
                                                                                                inObject.set_Value(intFldIdxs[0], pRow.get_Value(fldValToCopyIdx));
                                                                                                break;

                                                                                            }
                                                                                            catch
                                                                                            {
                                                                                                AAState.WriteLine("                  ERROR: Could not Copy: " + inObject.get_Value(fldValToCopyIdx) + " to field: " + strFldNames[0]);
                                                                                            }

                                                                                            pRow = null;
                                                                                        }
                                                                                        pRow = null;

                                                                                        AAState.WriteLine("                  Value successfully copied");

                                                                                        if (pCurs != null)
                                                                                            Marshal.ReleaseComObject(pCurs);
                                                                                        pCurs = null;

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine("                  ERROR: ID or Field to populate was not found");
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  ERROR: Table to populate not found: " + sourceLayerName);
                                                                                }
                                                                                pTable = null;

                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR: ID or Field to Copy was not found");
                                                        }

                                                        //if ((!found) && (inObject.Fields.get_Field(intFldIdxs[0]).IsNullable))
                                                        //{
                                                        //    inObject.set_Value(intFldIdxs[0], null);
                                                        //}
                                                    }

                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: COPY_LINKED_RECORD" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine("                  Finished: COPY_LINKED_RECORD");
                                                    // intFldIdxs[0] = -1;

                                                }
                                                break;

                                            }

                                        case "OFFSET"://Layer to Search For|Offset Distante or Field|Search distance to look for a line

                                            try
                                            {
                                                AAState.WriteLine("                  Trying: OFFSET");
                                                if (inFeature != null & valData != null)
                                                {
                                                    sourceLayerName = "";
                                                    double offsetVal = 5;

                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    int fldOff = -1;
                                                    if (args.GetLength(0) >= 3)
                                                    {
                                                        //    sourceLayerName = args[0].ToString();
                                                        sourceLayerNames = args[0].ToString().Split(',');
                                                        //offsetVal = Convert.ToDouble(args[1]);
                                                        if (Globals.IsNumeric(args[1]))
                                                            Double.TryParse(args[1], out offsetVal);
                                                        else
                                                        {
                                                            fldOff = Globals.GetFieldIndex(inObject.Fields, args[1]);

                                                        }

                                                        Double.TryParse(args[2], out searchDistance);
                                                    }
                                                    else if (args.GetLength(0) >= 2)
                                                    {
                                                        //    sourceLayerName = args[0].ToString();
                                                        sourceLayerNames = args[0].ToString().Split(',');
                                                        //offsetVal = Convert.ToDouble(args[1]);
                                                        if (Globals.IsNumeric(args[1]))
                                                            Double.TryParse(args[1], out offsetVal);
                                                        else
                                                        {
                                                            fldOff = Globals.GetFieldIndex(inObject.Fields, args[1]);

                                                        }

                                                        Double.TryParse("1", out searchDistance);
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Incorrect Value info was not found");
                                                        continue;
                                                    }
                                                    if (intFldIdxs.Count != 2)
                                                    {
                                                        AAState.WriteLine("                  ERROR: 2 fields in fieldname are required for this tool");
                                                        continue;
                                                    }

                                                    // Get layer

                                                    for (int i = 0; i < sourceLayerNames.Length; i++)
                                                    {
                                                        sourceLayerName = sourceLayerNames[i].ToString();
                                                        if (sourceLayerName != "")

                                                            sourceLayerName = args[i].ToString();
                                                        if (i == 0)
                                                            i++;
                                                        boolLayerOrFC = true;

                                                        if (sourceLayerName.Contains("("))
                                                        {
                                                            string[] tempSplt = sourceLayerName.Split('(');
                                                            sourceLayerName = tempSplt[0];
                                                            sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                            if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                            {
                                                                boolLayerOrFC = true;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                            {
                                                                boolLayerOrFC = true;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                            {
                                                                boolLayerOrFC = false;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                            {
                                                                boolLayerOrFC = false;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                            {
                                                                boolLayerOrFC = false;
                                                            }
                                                            else
                                                            {
                                                                boolLayerOrFC = true;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                        }
                                                        if (sourceLayer == null)
                                                        {
                                                            AAState.WriteLine("                  ERROR/WARNING: " + sourceLayer + " was not found");
                                                            continue;
                                                        }

                                                        IFeatureClass iFC = inFeature.Class as IFeatureClass;
                                                        if (sourceLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                                                        {
                                                            AAState.WriteLine("                  ERROR: " + sourceLayer + " is a polygon layer");

                                                            break;
                                                        }
                                                        if (sourceLayer != null)
                                                        {

                                                            sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false);

                                                            pFS = (IFeatureSelection)sourceLayer;
                                                            if (boolLayerOrFC)
                                                            {
                                                                if (pFS.SelectionSet.Count > 0)
                                                                {
                                                                    pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                    fCursor = cCurs as IFeatureCursor;

                                                                }
                                                                else
                                                                {
                                                                    fCursor = sourceLayer.Search(sFilter, true);
                                                                }
                                                            }
                                                            else
                                                            {
                                                                fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                            }

                                                            while ((sourceFeature = fCursor.NextFeature()) != null)
                                                            {
                                                                double dAlong = 0;
                                                                if (sourceFeature.Class != inFeature.Class)
                                                                {
                                                                    IPoint pIntPnt;
                                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                                    {
                                                                        pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint;

                                                                    }
                                                                    else
                                                                        pIntPnt = inFeature.ShapeCopy as IPoint;
                                                                    IPoint snapPnt = null;

                                                                    dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt);

                                                                    snapPnt = null;
                                                                    pIntPnt = null;

                                                                    //AAState.WriteLine("                  Value set to: " + strDis);
                                                                    //inObject.set_Value(intFldIdxs[0], strDis);
                                                                    //break;

                                                                }

                                                                else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                {
                                                                    IPoint pIntPnt;
                                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                                    {
                                                                        pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint;

                                                                    }
                                                                    else
                                                                        pIntPnt = inFeature.ShapeCopy as IPoint;
                                                                    IPoint snapPnt = null;

                                                                    dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt);
                                                                    snapPnt = null;

                                                                    pIntPnt = null;
                                                                    //AAState.WriteLine("                  Value set to: " + strDis);
                                                                    // inObject.set_Value(intFldIdxs[0], strDis);
                                                                    // break;

                                                                }
                                                                AAState.WriteLine("                  Distance found: " + dAlong);
                                                                IPoint pNewPt = new PointClass();
                                                                IConstructPoint2 pConsPoint = pNewPt as IConstructPoint2;

                                                                if (fldOff != -1)
                                                                {
                                                                    string temp = inObject.get_Value(fldOff).ToString();
                                                                    if (Globals.IsNumeric(temp))
                                                                    {
                                                                        Double.TryParse(temp, out offsetVal);
                                                                    }

                                                                }
                                                                pConsPoint.ConstructOffset
                                                                    (sourceFeature.Shape as ICurve, esriSegmentExtension.esriNoExtension, dAlong, false, offsetVal);

                                                                inObject.set_Value(intFldIdxs[0], pNewPt.X);
                                                                inObject.set_Value(intFldIdxs[1], pNewPt.Y);

                                                                pNewPt = null;
                                                                pConsPoint = null;
                                                            }
                                                            //else if (inObject.Fields.get_Field(intFldIdxs[0]).IsNullable)
                                                            //    inObject.set_Value(intFldIdxs[0], null);
                                                        }

                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: OFFSET: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: OFFSET");
                                            }
                                            break;

                                        case "SIDE":
                                            {
                                                AAState.WriteLine("                  Trying: SIDE");

                                                try
                                                {
                                                    //Layer|IDField|IDField source

                                                    if ((valData != null) && (inFeature != null))
                                                    {
                                                        AAState.WriteLine("                     Feature and valueinfo is valid");

                                                        AAState.WriteLine("                     Splitting up value info: " + valData);
                                                        sourceLayerName = "";
                                                        sourceFieldName = "";
                                                        sourceField = -1;
                                                        string inputFieldName = "";
                                                        args = valData.Split('|');
                                                        if (args.Length < 2)
                                                        {
                                                            AAState.WriteLine("                  ERROR: SIDE: Value info does not have enough parameters");
                                                            continue;
                                                        }

                                                        switch (args.Length)
                                                        {
                                                            case 3:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                sourceFieldName = args[1].ToString();
                                                                inputFieldName = args[2].ToString();
                                                                break;
                                                            default:
                                                                AAState.WriteLine("                  ERROR: SIDE: Value info does not have enough parameters");
                                                                continue;

                                                        }
                                                        int fldValToCopyIdx = inObject.Fields.FindField(inputFieldName);

                                                        if (fldValToCopyIdx > -1)
                                                        {

                                                            for (int i = 0; i < sourceLayerNames.Length; i++)
                                                            {
                                                                sourceLayerName = sourceLayerNames[i].ToString();

                                                                if (sourceLayerName != "")
                                                                {

                                                                    boolLayerOrFC = true;
                                                                    if (sourceLayerName.Contains("("))
                                                                    {
                                                                        string[] tempSplt = sourceLayerName.Split('(');
                                                                        sourceLayerName = tempSplt[0];
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                    }
                                                                    if (sourceLayer != null)
                                                                    {

                                                                        // Get layer
                                                                        AAState.WriteLine("                  " + sourceLayerName + " Layer found");
                                                                        int fldValTargetJoinIdx = Globals.GetFieldIndex(sourceLayer, sourceFieldName);
                                                                        if (fldValTargetJoinIdx > -1)
                                                                        {
                                                                            IQueryFilter pQFilt = Globals.createQueryFilter();

                                                                            if (sourceLayer.FeatureClass.Fields.get_Field(fldValTargetJoinIdx).Type == esriFieldType.esriFieldTypeString)
                                                                            {
                                                                                pQFilt.WhereClause = "" + sourceLayer.FeatureClass.Fields.get_Field(fldValTargetJoinIdx).Name + "" + " = '" + inObject.get_Value(fldValToCopyIdx).ToString() + "'";

                                                                            }
                                                                            else
                                                                            {
                                                                                pQFilt.WhereClause = sourceLayer.FeatureClass.Fields.get_Field(fldValTargetJoinIdx).Name + " = " + inObject.get_Value(fldValToCopyIdx);

                                                                            }
                                                                            AAState.WriteLine("                     Where Clause: " + pQFilt.WhereClause);
                                                                            int cnt = sourceLayer.FeatureClass.FeatureCount(pQFilt);
                                                                            AAState.WriteLine("                     Feature Found: " + cnt);
                                                                            if (cnt > 0)
                                                                            {

                                                                                fCursor = sourceLayer.FeatureClass.Search(pQFilt, true);
                                                                                while ((sourceFeature = fCursor.NextFeature()) != null)
                                                                                {
                                                                                    bool side = false;
                                                                                    if (Globals.GetPointOnLine(inFeature.Shape, sourceFeature.Shape, 450, out side) != null)
                                                                                    {

                                                                                        if (side)
                                                                                        {
                                                                                            AAState.WriteLine("                     Right Side");

                                                                                            inFeature.set_Value(intFldIdxs[0], "Right");
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            AAState.WriteLine("                     Left Side");
                                                                                            inFeature.set_Value(intFldIdxs[0], "Left");
                                                                                        }
                                                                                        if (fCursor != null)
                                                                                            Marshal.ReleaseComObject(fCursor);
                                                                                        fCursor = null;
                                                                                        continue;
                                                                                    }

                                                                                }
                                                                                if (fCursor != null)
                                                                                    Marshal.ReleaseComObject(fCursor);
                                                                                fCursor = null;
                                                                            }
                                                                            pQFilt = null;

                                                                        }

                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: SIDE" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    if (fCursor != null)
                                                        Marshal.ReleaseComObject(fCursor);
                                                    fCursor = null;
                                                    //                                                    pRowCh = null
                                                    AAState.WriteLine("                  Finished: SIDE");

                                                }
                                                break;

                                            }

                                        case "PROMPT":
                                            {
                                                //Loop through all fields list in the fieldname
                                                //If blank or null, prompt user for value
                                                //Store Value
                                                // IRowChanges pRowCh = null;
                                                IDomain pDom = default(IDomain);
                                                ISubtypes pSubType = null;
                                                List<Globals.DomSubList> lst = null;

                                                Globals.DomSubList dmRetVal = null;
                                                // ICodedValueDomain pCV = null;
                                                try
                                                {
                                                    if ((inObject != null)) // (valData != null) &&
                                                    {

                                                        //   pRowCh = inObject as IRowChanges;

                                                        //if (pRowCh.get_ValueChanged(intFldIdxs[0]) == false)
                                                        //{
                                                        //    AAState.WriteLine("                  PROMPT: Target value did not change, skipping");
                                                        //    continue;
                                                        //}
                                                        //else
                                                        //{
                                                        pSubType = (ISubtypes)inObject.Class;

                                                        if (pSubType.HasSubtype)
                                                        {
                                                            int intSub;
                                                            if (intFldIdxs.Contains(pSubType.SubtypeFieldIndex))
                                                            {
                                                                lst = Globals.SubtypeToList(pSubType);
                                                                if (inObject.get_Value(pSubType.SubtypeFieldIndex) == null || inObject.get_Value(pSubType.SubtypeFieldIndex) == "" || inObject.get_Value(pSubType.SubtypeFieldIndex) == DBNull.Value)
                                                                {
                                                                    dmRetVal = Globals.showValuesOptionsForm(lst, "Provide a value for " + inObject.Class.AliasName + ":" + pSubType.SubtypeFieldName, "Provide a value for " + inObject.Class.AliasName + ":" + pSubType.SubtypeFieldName, ComboBoxStyle.DropDownList);
                                                                    inObject.set_Value(pSubType.SubtypeFieldIndex, dmRetVal.Value);

                                                                    intSub = Convert.ToInt32(dmRetVal.Value);
                                                                }
                                                                else
                                                                {
                                                                    intSub = Convert.ToInt32(inObject.get_Value(pSubType.SubtypeFieldIndex));
                                                                }
                                                                // intSub = (int)inObject.get_Value(pSubType.SubtypeFieldIndex);
                                                                for (int l = 0; l < strFldNames.Count; l++)
                                                                {
                                                                    if (intFldIdxs[l] == pSubType.SubtypeFieldIndex)
                                                                        continue;

                                                                    if (intFldIdxs[l] != -1)
                                                                    {
                                                                        pDom = pSubType.get_Domain(intSub, inObject.Fields.get_Field(intFldIdxs[l]).Name);
                                                                        //pDom = inObject.Fields.get_Field(intFldIdxs[l]).Domain;
                                                                        if (pDom == null)
                                                                        {
                                                                            if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                            {
                                                                                IList<string> pVals = new List<string>();

                                                                                string strRetVal = Globals.showValuesOptionsForm(pVals, "Provide a value for " + inObject.Class.AliasName + ":" + strFldNames[l], "Provide a value for " + inObject.Class.AliasName + ":" + strFldNames[l], ComboBoxStyle.DropDown);

                                                                                try
                                                                                {
                                                                                    inObject.set_Value(intFldIdxs[l], strRetVal);
                                                                                }
                                                                                catch
                                                                                {

                                                                                }
                                                                                pVals = null;
                                                                            }

                                                                        }
                                                                        else
                                                                        {

                                                                            if (pDom is CodedValueDomain)
                                                                            {
                                                                                //pCV = default(ICodedValueDomain);
                                                                                lst = Globals.DomainToList(pDom);
                                                                                if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                                {

                                                                                    dmRetVal = Globals.showValuesOptionsForm(lst, "Provide a value for " + strFldNames[l], "Provide a value for " + strFldNames[l], ComboBoxStyle.DropDownList);
                                                                                    try
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[l], dmRetVal.Value);
                                                                                    }
                                                                                    catch
                                                                                    {

                                                                                    }

                                                                                    lst = null;
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                                {

                                                                                    IList<string> pVals = new List<string>();
                                                                                    string strRetVal = Globals.showValuesOptionsForm(pVals, "Provide a value for " + strFldNames[l], "Provide a value for " + strFldNames[l], ComboBoxStyle.DropDown);

                                                                                    try
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[l], strRetVal);
                                                                                    }
                                                                                    catch
                                                                                    {

                                                                                    }

                                                                                    pVals = null;
                                                                                }
                                                                            }

                                                                        }

                                                                        //    IList<string> pVals = new List<string>();

                                                                        //    string strRetVal = Globals.showValuesOptionsForm(pVals, "Provide a value for " + strFldNames[l], "Provide a value for " + strFldNames[l], ComboBoxStyle.DropDown);
                                                                        //    inObject.set_Value(intFldIdxs[0], strRetVal);
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  PROMPT: " + strFldNames[l] + " was not found");
                                                                    }
                                                                }

                                                            }
                                                            else
                                                            {
                                                                if (inObject.get_Value(pSubType.SubtypeFieldIndex) == null)
                                                                    intSub = pSubType.DefaultSubtypeCode;
                                                                else

                                                                    intSub = Convert.ToInt32(inObject.get_Value(pSubType.SubtypeFieldIndex));
                                                                for (int l = 0; l < strFldNames.Count; l++)
                                                                {
                                                                    if (intFldIdxs[l] != -1)
                                                                    {
                                                                        pDom = pSubType.get_Domain(intSub, inObject.Fields.get_Field(intFldIdxs[l]).Name);
                                                                        //pDom = inObject.Fields.get_Field(intFldIdxs[l]).Domain;
                                                                        if (pDom == null)
                                                                        {
                                                                            if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                            {

                                                                                IList<string> pVals = new List<string>();
                                                                                string strRetVal = Globals.showValuesOptionsForm(pVals, "Provide a value for " + strFldNames[l], "Provide a value for " + strFldNames[l], ComboBoxStyle.DropDown);

                                                                                try
                                                                                {
                                                                                    inObject.set_Value(intFldIdxs[l], strRetVal);
                                                                                }
                                                                                catch
                                                                                {

                                                                                }

                                                                                pVals = null;
                                                                            }
                                                                        }
                                                                        else
                                                                        {

                                                                            if (pDom is CodedValueDomain)
                                                                            {
                                                                                if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                                {

                                                                                    //pCV = default(ICodedValueDomain);
                                                                                    lst = Globals.DomainToList(pDom);

                                                                                    dmRetVal = Globals.showValuesOptionsForm(lst, "Provide a value for " + strFldNames[l], "Provide a value for " + strFldNames[l], ComboBoxStyle.DropDownList);
                                                                                    try
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[l], dmRetVal.Value);
                                                                                    }
                                                                                    catch
                                                                                    {

                                                                                    }

                                                                                    lst = null;
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                                {

                                                                                    IList<string> pVals = new List<string>();
                                                                                    string strRetVal = Globals.showValuesOptionsForm(pVals, "Provide a value for " + strFldNames[l], "Provide a value for " + strFldNames[l], ComboBoxStyle.DropDown);

                                                                                    try
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[l], strRetVal);
                                                                                    }
                                                                                    catch
                                                                                    {

                                                                                    }

                                                                                    pVals = null;
                                                                                }
                                                                            }

                                                                        }

                                                                        //    IList<string> pVals = new List<string>();

                                                                        //    string strRetVal = Globals.showValuesOptionsForm(pVals, "Provide a value for " + strFldNames[l], "Provide a value for " + strFldNames[l], ComboBoxStyle.DropDown);
                                                                        //    inObject.set_Value(intFldIdxs[0], strRetVal);
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  PROMPT: " + strFldNames[l] + " was not found");
                                                                    }
                                                                }

                                                            }
                                                        }
                                                        else
                                                        {
                                                            for (int l = 0; l < strFldNames.Count; l++)
                                                            {

                                                                if (intFldIdxs[l] != -1)
                                                                {

                                                                    pDom = inObject.Fields.get_Field(intFldIdxs[l]).Domain;
                                                                    if (pDom == null)
                                                                    {
                                                                        if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                        {

                                                                            IList<string> pVals = new List<string>();
                                                                            string strRetVal = Globals.showValuesOptionsForm(pVals, "Provide a value for " + strFldNames[l], "Provide a value for " + strFldNames[l], ComboBoxStyle.DropDown);
                                                                            try
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[l], strRetVal);
                                                                            }
                                                                            catch
                                                                            {

                                                                            }

                                                                            pVals = null;
                                                                        }
                                                                    }
                                                                    else
                                                                    {

                                                                        if (pDom is CodedValueDomain)
                                                                        {
                                                                            if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                            {

                                                                                //pCV = default(ICodedValueDomain);
                                                                                lst = Globals.DomainToList(pDom);

                                                                                dmRetVal = Globals.showValuesOptionsForm(lst, "Provide a value for " + strFldNames[l], "Provide a value for " + strFldNames[l], ComboBoxStyle.DropDownList);
                                                                                try
                                                                                {
                                                                                    inObject.set_Value(intFldIdxs[l], dmRetVal.Value);
                                                                                }
                                                                                catch
                                                                                {

                                                                                }

                                                                                lst = null;
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                            {

                                                                                IList<string> pVals = new List<string>();
                                                                                string strRetVal = Globals.showValuesOptionsForm(pVals, "Provide a value for " + strFldNames[l], "Provide a value for " + strFldNames[l], ComboBoxStyle.DropDown);
                                                                                try
                                                                                {
                                                                                    inObject.set_Value(intFldIdxs[l], strRetVal);
                                                                                }
                                                                                catch
                                                                                {

                                                                                }
                                                                                pVals = null;
                                                                            }
                                                                        }

                                                                    }

                                                                    //    IList<string> pVals = new List<string>();

                                                                    //    string strRetVal = Globals.showValuesOptionsForm(pVals, "Provide a value for " + strFldNames[l], "Provide a value for " + strFldNames[l], ComboBoxStyle.DropDown);
                                                                    //    inObject.set_Value(intFldIdxs[0], strRetVal);
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  PROMPT: " + strFldNames[l] + " was not found");
                                                                }
                                                            }
                                                        }

                                                        //}
                                                    }
                                                }

                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: PROMPT" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    //                                                    pRowCh = null
                                                    AAState.WriteLine("                  Finished: PROMPT");
                                                    pDom = null;
                                                    pSubType = null;
                                                    lst = null;

                                                    dmRetVal = null;
                                                }
                                                break;
                                            }
                                        //Not Used
                                        case "VALIDATE_ATTRIBUTE_LOOKUP_old_NOT USED":
                                            {
                                                AAState.WriteLine("                  Trying VALIDATE_ATTRIBUTE_LOOKUP");
                                                IRowChanges pRowCh = null;
                                                ISQLSyntax sqlSyntax = null;
                                                IQueryFilter pQFilt = null;
                                                try
                                                {
                                                    if ((valData != null) && (inFeature != null))
                                                    {

                                                        pRowCh = inObject as IRowChanges;

                                                        if (pRowCh.get_ValueChanged(intFldIdxs[0]) == false)
                                                        {
                                                            AAState.WriteLine("                  VALIDATE_ATTRIBUTE_LOOKUP: Target value did not change, skipping");
                                                            continue;
                                                        }
                                                        sourceLayerName = "";
                                                        string[] sourceFieldNames = null;
                                                        //string[] destFieldNames = null;

                                                        // Parse arguments
                                                        args = valData.Split('|');
                                                        if (args.Length == 2)
                                                        {
                                                            sourceLayerName = args[0].ToString().Trim();
                                                            sourceFieldNames = args[1].ToString().Split(',');

                                                        }

                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR:  the valuemethod is not defined properly for this rule");
                                                            continue;

                                                        }

                                                        if ((sourceFieldNames != null) &&
                                                            (sourceFieldNames.Length > 0))
                                                        {
                                                            AAState.WriteLine("                  Looking for layer: " + sourceLayerName);

                                                            boolLayerOrFC = true;
                                                            if (sourceLayerName.Contains("("))
                                                            {
                                                                string[] tempSplt = sourceLayerName.Split('(');
                                                                sourceLayerName = tempSplt[0];
                                                                sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                                if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                            }
                                                            else
                                                            {

                                                                sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                            }
                                                            if (sourceLayer != null)
                                                            {
                                                                if (sourceLayer.FeatureClass != null)
                                                                {
                                                                    sqlSyntax = (ISQLSyntax)(((IDataset)sourceLayer.FeatureClass).Workspace);
                                                                    string specChar = sqlSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_WildcardManyMatch);

                                                                    AAState.WriteLine("                  Lookup layer " + sourceLayer.Name + " was Found: " + sourceLayerName);

                                                                    string missingFieldMess = null;
                                                                    int[] sourceFieldNums = new int[sourceFieldNames.Length];

                                                                    AAState.WriteLine("                  Checking for field in Lookup table");
                                                                    int fnum = sourceLayer.FeatureClass.FindField(sourceFieldNames[0].Trim());
                                                                    if (fnum < 0)
                                                                    {
                                                                        fnum = sourceLayer.FeatureClass.Fields.FindFieldByAliasName(sourceFieldNames[0].Trim());

                                                                    }

                                                                    if (fnum != -1)
                                                                    {
                                                                        AAState.WriteLine("                  Field Found");
                                                                        pQFilt = new QueryFilterClass();

                                                                        if (inObject.get_Value(intFldIdxs[0]).ToString().Trim() == "")
                                                                        {
                                                                            if (mode == "ON_CREATE")
                                                                            {
                                                                                AAState.WriteLine("                  Field Found");
                                                                                continue;
                                                                            }
                                                                            pQFilt.WhereClause = "1=1";
                                                                        }
                                                                        else
                                                                        {
                                                                            if (sourceLayer.FeatureClass.Fields.get_Field(fnum).Type == esriFieldType.esriFieldTypeString)
                                                                            {
                                                                                pQFilt.WhereClause = "" + sourceLayer.FeatureClass.Fields.get_Field(fnum).Name + "" + " LIKE '" + specChar + inObject.get_Value(intFldIdxs[0]).ToString() + specChar + "'";

                                                                            }
                                                                            else
                                                                            {
                                                                                pQFilt.WhereClause = sourceLayer.FeatureClass.Fields.get_Field(fnum).Name + " LIKE " + specChar + inObject.get_Value(intFldIdxs[0]) + specChar;

                                                                            }
                                                                        }

                                                                        AAState.WriteLine("                  " + pQFilt.WhereClause + " used to search for matching record");
                                                                        int intRecFound = sourceLayer.FeatureClass.FeatureCount(pQFilt);
                                                                        AAState.WriteLine("                  " + intRecFound + " rows found");

                                                                        if (intRecFound != 1)
                                                                        {
                                                                            if (inObject.get_Value(intFldIdxs[0]).ToString().Trim() == "")
                                                                            {
                                                                                pQFilt.WhereClause = "1=1";
                                                                            }
                                                                            else
                                                                            {
                                                                                if (sourceLayer.FeatureClass.Fields.get_Field(fnum).Type == esriFieldType.esriFieldTypeString)
                                                                                {
                                                                                    pQFilt.WhereClause = "UPPER(" + sourceLayer.FeatureClass.Fields.get_Field(fnum).Name + ")" + " LIKE '" + specChar + inObject.get_Value(intFldIdxs[0]).ToString().ToUpper() + specChar + "'";

                                                                                }
                                                                                else
                                                                                {
                                                                                    pQFilt.WhereClause = sourceLayer.FeatureClass.Fields.get_Field(fnum).Name + " LIKE " + specChar + inObject.get_Value(intFldIdxs[0]) + specChar;

                                                                                }
                                                                            }
                                                                            AAState.WriteLine("                  " + pQFilt.WhereClause + " used to search for matching record");
                                                                            intRecFound = sourceLayer.FeatureClass.FeatureCount(pQFilt);
                                                                            AAState.WriteLine("                  " + intRecFound + " rows found");

                                                                            if (intRecFound == 0)
                                                                            {
                                                                                AAState.WriteLine("                     Abort Edit");
                                                                                AAState._editor.AbortOperation();
                                                                                return false;

                                                                            }

                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  Prompting for user input");

                                                                                IFeatureCursor pFCurs = sourceLayer.FeatureClass.Search(pQFilt, true);
                                                                                pQFilt = null;

                                                                                ICursor pCurs = pFCurs as ICursor;
                                                                                List<string> pLst = Globals.CursorToList(ref pCurs, fnum);
                                                                                if (pCurs != null)
                                                                                    Marshal.ReleaseComObject(pCurs);
                                                                                pCurs = null;
                                                                                if (pFCurs != null)
                                                                                    Marshal.ReleaseComObject(pFCurs);
                                                                                pFCurs = null;
                                                                                string selectVal = Globals.showOptionsForm(pLst, "Select an value to store", ComboBoxStyle.DropDownList);
                                                                                if (selectVal == "||Cancelled||")
                                                                                {
                                                                                    AAState.WriteLine("                     Abort Edit");
                                                                                    AAState._editor.AbortOperation();
                                                                                    return false;

                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  Value selected: " + selectVal);
                                                                                    inObject.set_Value(intFldIdxs[0], selectVal as object);
                                                                                }

                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  One Exact match was found");
                                                                        }
                                                                        pQFilt = null;

                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  ERROR: Cant find field " + missingFieldMess);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  ERROR: " + sourceLayerName + " data source is not set");
                                                                }
                                                            }
                                                            else
                                                            {
                                                                IStandaloneTable pTbl = Globals.FindStandAloneTable(AAState._editor.Map, sourceLayerName) as IStandaloneTable;

                                                                if (pTbl != null)
                                                                {
                                                                    if (pTbl.Table != null)
                                                                    {
                                                                        sqlSyntax = (ISQLSyntax)(((IDataset)pTbl).Workspace);
                                                                        string specChar = sqlSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_WildcardManyMatch);

                                                                        AAState.WriteLine("                  Lookup layer " + pTbl.Name + " was Found: " + sourceLayerName);

                                                                        string missingFieldMess = null;
                                                                        int[] sourceFieldNums = new int[sourceFieldNames.Length];

                                                                        AAState.WriteLine("                  Checking for field in Lookup table");
                                                                        int fnum = pTbl.Table.FindField(sourceFieldNames[0].Trim());
                                                                        if (fnum < 0)
                                                                        {
                                                                            fnum = pTbl.Table.Fields.FindFieldByAliasName(sourceFieldNames[0].Trim());

                                                                        }

                                                                        if (fnum != -1)
                                                                        {
                                                                            AAState.WriteLine("                  Field Found");
                                                                            pQFilt = new QueryFilterClass();
                                                                            if (inObject.get_Value(intFldIdxs[0]).ToString().Trim() == "")
                                                                            {
                                                                                if (mode == "ON_CREATE")
                                                                                {
                                                                                    AAState.WriteLine("                  Empty Value on Create, skipping");
                                                                                    continue;
                                                                                }
                                                                                pQFilt.WhereClause = "1=1";
                                                                            }
                                                                            else
                                                                            {

                                                                                if (pTbl.Table.Fields.get_Field(fnum).Type == esriFieldType.esriFieldTypeString)
                                                                                {
                                                                                    pQFilt.WhereClause = "" + pTbl.Table.Fields.get_Field(fnum).Name + "" + " LIKE '" + specChar + inObject.get_Value(intFldIdxs[0]).ToString() + specChar + "'";

                                                                                }
                                                                                else
                                                                                {
                                                                                    pQFilt.WhereClause = pTbl.Table.Fields.get_Field(fnum).Name + " LIKE " + specChar + inObject.get_Value(intFldIdxs[0]) + specChar;

                                                                                }
                                                                            }

                                                                            AAState.WriteLine("                  " + pQFilt.WhereClause + " used to search for matching record");
                                                                            int intRecFound = pTbl.Table.RowCount(pQFilt);
                                                                            AAState.WriteLine("                  " + intRecFound + " rows found");

                                                                            if (intRecFound != 1)
                                                                            {
                                                                                if (inObject.get_Value(intFldIdxs[0]).ToString().Trim() == "")
                                                                                {
                                                                                    pQFilt.WhereClause = "1=1";
                                                                                }
                                                                                else
                                                                                {

                                                                                    if (pTbl.Table.Fields.get_Field(fnum).Type == esriFieldType.esriFieldTypeString)
                                                                                    {

                                                                                        pQFilt.WhereClause = "UPPER(" + pTbl.Table.Fields.get_Field(fnum).Name + ")" + " LIKE '" + specChar + inObject.get_Value(intFldIdxs[0]).ToString().ToUpper() + specChar + "'";

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        pQFilt.WhereClause = pTbl.Table.Fields.get_Field(fnum).Name + " LIKE " + specChar + inObject.get_Value(intFldIdxs[0]) + specChar;

                                                                                    }
                                                                                }
                                                                                AAState.WriteLine("                  " + pQFilt.WhereClause + " used to search for matching record");
                                                                                intRecFound = pTbl.Table.RowCount(pQFilt);
                                                                                AAState.WriteLine("                  " + intRecFound + " rows found");

                                                                                if (intRecFound == 0)
                                                                                {
                                                                                    AAState.WriteLine("                     Abort Edit");
                                                                                    AAState._editor.AbortOperation();
                                                                                    return false;

                                                                                }

                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  Prompting for user input");

                                                                                    ICursor pCurs = pTbl.Table.Search(pQFilt, true);
                                                                                    List<string> pLst = Globals.CursorToList(ref pCurs, fnum);
                                                                                    if (pCurs != null)
                                                                                        Marshal.ReleaseComObject(pCurs);
                                                                                    pCurs = null;
                                                                                    string selectVal = Globals.showOptionsForm(pLst, "Select an value to store", ComboBoxStyle.DropDownList);
                                                                                    if (selectVal == "||Cancelled||")
                                                                                    {
                                                                                        AAState.WriteLine("                     Abort Edit");
                                                                                        AAState._editor.AbortOperation();
                                                                                        return false;

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine("                  Value selected: " + selectVal);
                                                                                        inObject.set_Value(intFldIdxs[0], selectVal as object);
                                                                                    }

                                                                                    //AAState.WriteLine("                  Value selected: " + selectVal);
                                                                                    //inObject.set_Value(intFldIdxs[0], selectVal as object);
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  One Exact match was found");
                                                                            }
                                                                            pQFilt = null;

                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  ERROR: Cant find field " + missingFieldMess);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  ERROR: " + sourceLayerName + " data source is not set");
                                                                    }
                                                                    pTbl = null;
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  ERROR: " + sourceLayerName + " was not found");
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR: Invalid Value Info: " + valData);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Not a feature or missing Value Info");
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: VALIDATE_ATTRIBUTE_LOOKUP" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    pQFilt = null;
                                                    sqlSyntax = null;
                                                    pRowCh = null;
                                                    AAState.WriteLine("                  Finished: VALIDATE_ATTRIBUTE_LOOKUP");
                                                }
                                                break;
                                            }
                                        case "CASCADE_ATTRIBUTE":
                                            {
                                                AAState.WriteLine("                  Trying: CASCADE_ATTRIBUTE");

                                                string flds;
                                                string targetLayer;
                                                IRowChanges pRowCh = null;
                                                //IFeature pNewFeat = null;
                                                try
                                                {

                                                    if ((valData != null) && (inObject != null))
                                                    {
                                                        AAState.WriteLine("                     Feature and valueinfo is valid");

                                                        AAState.WriteLine("                     Splitting up value info: " + valData);
                                                        //field name is the field to Check
                                                        //value|Layer|tempalte|Cut or Copy|field-toField
                                                        args = valData.Split('|');
                                                        if (args.Length < 2)
                                                        {
                                                            AAState.WriteLine("                  ERROR: CASCADE_ATTRIBUTE: Value info does not have enough parameters");
                                                            continue;
                                                        }

                                                        targetLayer = args[0];
                                                        flds = args[1];
                                                        bool bPrompt;
                                                        if (args.Length == 3)
                                                        {
                                                            if (args[2].ToUpper() == "T" || args[2].ToUpper() == "TRUE" || args[2].ToUpper() == "YES")
                                                            {
                                                                bPrompt = true;
                                                            }
                                                            else
                                                            {
                                                                bPrompt = false;
                                                            }

                                                        }
                                                        else
                                                        {
                                                            bPrompt = true;
                                                        }
                                                        pRowCh = inObject as IRowChanges;
                                                        if (pRowCh.get_ValueChanged(intFldIdxs[0]) == false)
                                                        {
                                                            AAState.WriteLine("                  CASCADE_ATTRIBUTE: Target value did not change, skipping");
                                                            continue;
                                                        }

                                                        bool boolFoundAsLayer = true;

                                                        sourceLayer = Globals.FindLayer(ArcMap.Application, args[0].ToString(), ref boolFoundAsLayer) as IFeatureLayer;
                                                        if (sourceLayer == null)
                                                        {
                                                            AAState.WriteLine("                  ERROR: CASCADE_ATTRIBUTE: Target layer was not found");
                                                            continue;
                                                        }
                                                        int intTargFld = -1;
                                                        intTargFld = sourceLayer.FeatureClass.Fields.FindField(flds);
                                                        if (intTargFld == -1)
                                                        {
                                                            intTargFld = sourceLayer.FeatureClass.Fields.FindFieldByAliasName(flds);
                                                            if (intTargFld != -1)
                                                            {
                                                                flds = sourceLayer.FeatureClass.Fields.get_Field(intTargFld).Name;

                                                            }
                                                        }
                                                        if (intTargFld > -1)
                                                        {

                                                            if (pRowCh.get_OriginalValue(intFldIdxs[0]).ToString().Trim() == "")
                                                                continue;
                                                            IQueryFilter pQFilt = new QueryFilterClass();
                                                            if (sourceLayer.FeatureClass.Fields.get_Field(intTargFld).Type == esriFieldType.esriFieldTypeString)
                                                            {
                                                                pQFilt.WhereClause = flds + " = '" + pRowCh.get_OriginalValue(intFldIdxs[0]) + "'";

                                                            }
                                                            else
                                                            {
                                                                pQFilt.WhereClause = flds + " = " + pRowCh.get_OriginalValue(intFldIdxs[0]) + "";

                                                            }

                                                            int featCnt = sourceLayer.FeatureClass.FeatureCount(pQFilt);
                                                            if (featCnt == 0)
                                                            {
                                                                AAState.WriteLine("                  Skipping, no Matching records found");

                                                            }
                                                            else
                                                            {
                                                                string promptLayname;
                                                                //if (boolFoundAsLayer)
                                                                //{
                                                                //    promptLayname = sourceLayer.Name;

                                                                //}
                                                                //else
                                                                //{
                                                                promptLayname = Globals.getClassName(sourceLayer);
                                                                //}
                                                                if (bPrompt)
                                                                {
                                                                    if (MessageBox.Show("You are about to change " + featCnt + " rows in the " + promptLayname + " Feature Class, proceed?", "Cascade", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                                                    {
                                                                        AAState.WriteLine("                  User accepted prompt");

                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  User declined prompt");

                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  Prompt surpressed");
                                                                }
                                                            }

                                                            IFeatureCursor pCalcCursor = sourceLayer.FeatureClass.Update(pQFilt, false);
                                                            IFeature updateFeat;
                                                            if (ChangeFeatureList == null)
                                                            {
                                                                ChangeFeatureList = new List<IObject>();
                                                            }
                                                            while ((updateFeat = pCalcCursor.NextFeature()) != null)
                                                            {
                                                                updateFeat.set_Value(intTargFld, inObject.get_Value(intFldIdxs[0]));
                                                                ChangeFeatureList.Add(updateFeat);

                                                            }
                                                            updateFeat = null;
                                                            //ICalculator pCalc = new CalculatorClass();

                                                            // pCalc.Cursor = pCalcCursor as ICursor;

                                                            // //pCalc.PreExpression = "Dim OldValue As String" + Environment.NewLine +
                                                            // //    "OldValue = Trim ( [" + flds + "])" + Environment.NewLine +
                                                            // //    "Dim newValue As String" + Environment.NewLine +
                                                            // //    "newValue = " + pRowCh.get_ValueChanged(intFldIdxs[0]);

                                                            // if (sourceLayer.FeatureClass.Fields.get_Field(intTargFld).Type == esriFieldType.esriFieldTypeString)
                                                            // {
                                                            //     pCalc.PreExpression = "Dim newValue" + Environment.NewLine +
                                                            //     "newValue = \"" + inObject.get_Value(intFldIdxs[0]).ToString() + "\"";
                                                            // }
                                                            // else
                                                            // {
                                                            //     pCalc.PreExpression = "Dim newValue" + Environment.NewLine +
                                                            //       "newValue = " + inObject.get_Value(intFldIdxs[0]).ToString() ;
                                                            // }
                                                            //     pCalc.Expression = "newValue";
                                                            //// pCalc.Expression = inObject.get_Value(intFldIdxs[0]).ToString();
                                                            // pCalc.Field = flds;
                                                            // pCalc.ShowErrorPrompt = true;
                                                            // pCalc.Calculate();

                                                            // if (pCalcCursor != null)
                                                            // {
                                                            //     Marshal.ReleaseComObject(pCalcCursor);
                                                            // }
                                                            // pCalc = null;
                                                            if (pCalcCursor != null)
                                                            {
                                                                Marshal.ReleaseComObject(pCalcCursor);
                                                            }
                                                            pCalcCursor = null;

                                                            pQFilt = null;

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR: CASCADE_ATTRIBUTE: Field was not found");
                                                        }

                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: CASCADE_ATTRIBUTE" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    sourceLayer = null;

                                                    pRowCh = null;
                                                    // pNewFeat = null;
                                                    AAState.WriteLine("                  Finished: CASCADE_ATTRIBUTE");
                                                }
                                                break;
                                            }

                                        case "COPY_FEATURE":
                                            {
                                                AAState.WriteLine("                  Trying: COPY_FEATURE");
                                                IFeatureLayer pTargetFL;
                                                string[] FldPairs;
                                                string targetValue;
                                                IRowChanges pRowCh = null;
                                                IFeature pNewFeat = null;
                                                try
                                                {

                                                    if ((valData != null) && (inFeature != null))
                                                    {
                                                        AAState.WriteLine("                     Feature and valueinfo is valid");

                                                        AAState.WriteLine("                     Splitting up value info: " + valData);
                                                        //field name is the field to Check
                                                        //value|Layer|tempalte|Cut or Copy|field-toField
                                                        args = valData.Split('|');
                                                        if (args.Length < 2)
                                                        {
                                                            AAState.WriteLine("                  ERROR: COPY_FEATURE: Value info does not have enough parameters");
                                                            continue;
                                                        }

                                                        targetValue = args[0];

                                                        pRowCh = inObject as IRowChanges;
                                                        if (pRowCh.get_ValueChanged(intFldIdxs[0]) == false)
                                                        {
                                                            AAState.WriteLine("                  COPY_FEATURE: Field listed in the Field Name did not change, skipping");
                                                            continue;
                                                        }
                                                        if (inFeature.get_Value(intFldIdxs[0]).ToString() != targetValue.ToString())
                                                        {
                                                            AAState.WriteLine("                  COPY_FEATURE: Target value did not match listed value, skipping");
                                                            continue;
                                                        }
                                                        //changed = true;
                                                        bool FCorLayerTarget = true;

                                                        pTargetFL = Globals.FindLayer(ArcMap.Application, args[1].ToString(), ref FCorLayerTarget) as IFeatureLayer;
                                                        if (pTargetFL == null)
                                                        {
                                                            AAState.WriteLine("                  ERROR: COPY_FEATURE: Target layer was not found");
                                                            continue;
                                                        }
                                                        if (Globals.IsEditable(ref pTargetFL, ref AAState._editor) == false)
                                                        {
                                                            AAState.WriteLine("                  ERROR: COPY_FEATURE: Target layer is not editable");
                                                            continue;
                                                        }

                                                        if (pTargetFL.FeatureClass.ShapeType != (inFeature.Class as IFeatureClass).ShapeType)
                                                        {
                                                            AAState.WriteLine("                  ERROR: COPY_FEATURE: Target layer and Source layer are different geometry types");
                                                            continue;
                                                        }

                                                        FldPairs = null;
                                                        //value|Layer|tempalte|Cut or Copy|field-toField

                                                        IEditTemplate pEditTemp = null;
                                                        string sourceAction = "COPY";
                                                        string fldMatching = null;

                                                        switch (args.Length)
                                                        {
                                                            //case 2:

                                                            //    break;
                                                            case 3:
                                                                if (args[2].Trim() != "")
                                                                {
                                                                    //pEditTemp = Globals.PromptAndGetEditTemplate(ArcMap.Application, pTargetFL, args[2].Trim());
                                                                    pEditTemp = Globals.PromptAndGetEditTemplateGraphic(pTargetFL, args[2].Trim());

                                                                }
                                                                else
                                                                {
                                                                    pEditTemp = null;
                                                                }
                                                                break;
                                                            case 4:
                                                                if (args[2].Trim() != "")
                                                                {
                                                                    //pEditTemp = Globals.PromptAndGetEditTemplate(ArcMap.Application, pTargetFL, args[2].Trim());
                                                                    pEditTemp = Globals.PromptAndGetEditTemplateGraphic(pTargetFL, args[2].Trim());
                                                                }
                                                                else
                                                                {
                                                                    pEditTemp = null;
                                                                }
                                                                sourceAction = args[3].ToUpper().Trim();
                                                                //fldMatching = args[4].Trim();
                                                                break;
                                                            case 5:
                                                                if (args[2].Trim() != "")
                                                                {
                                                                    //pEditTemp = Globals.PromptAndGetEditTemplate(ArcMap.Application, pTargetFL, args[2].Trim());
                                                                    pEditTemp = Globals.PromptAndGetEditTemplateGraphic(pTargetFL, args[2].Trim());
                                                                }
                                                                else
                                                                {
                                                                    pEditTemp = null;
                                                                }
                                                                sourceAction = args[3].ToUpper().Trim();
                                                                fldMatching = args[4].Trim();
                                                                break;
                                                        }

                                                        if (pEditTemp != null)
                                                        {

                                                            pNewFeat = Globals.CreateFeature(inFeature.ShapeCopy, pEditTemp, AAState._editor, ArcMap.Application, false, false, false);

                                                        }
                                                        else
                                                        {
                                                            pNewFeat = Globals.CreateFeature(inFeature.ShapeCopy, pTargetFL, AAState._editor, ArcMap.Application, false, false, false);

                                                        }
                                                        pEditTemp = null;
                                                        if (fldMatching != null)
                                                        {
                                                            if (fldMatching == "")
                                                            {
                                                                FldPairs = new string[] { };
                                                            }
                                                            else
                                                            {
                                                                FldPairs = fldMatching.Split(',');
                                                            }
                                                        }
                                                        else
                                                        {
                                                            FldPairs = new string[] { };

                                                        }
                                                        //pNewFeat = pTargetFL.FeatureClass.CreateFeature();
                                                        //pNewFeat.Shape = inFeature.Shape;
                                                        List<string> targFilds = new List<string>();

                                                        foreach (string strFlpPair in FldPairs)
                                                        {
                                                            string[] fldMatch = strFlpPair.Split('-');
                                                            if (fldMatch.Length != 2)
                                                            {
                                                                AAState.WriteLine("                  ERROR: COPY_FEATURE: Field pairing is not properly defined");
                                                            }
                                                            else
                                                            {
                                                                string strSrcFldName = fldMatch[0];
                                                                string strTarFldName = fldMatch[1];
                                                                int intSrcFldIdx = Globals.GetFieldIndex((inFeature.Class as IFeatureClass).Fields, (strSrcFldName));
                                                                int intTarFldIdx = Globals.GetFieldIndex(pTargetFL.FeatureClass.Fields, strTarFldName);
                                                                if (intSrcFldIdx == -1 || intTarFldIdx == -1)
                                                                {
                                                                    AAState.WriteLine("                  ERROR: COPY_FEATURE: Either the source or target field was not found");
                                                                }
                                                                else
                                                                {
                                                                    targFilds.Add(strTarFldName.ToUpper());

                                                                    try
                                                                    {
                                                                        pNewFeat.set_Value(intTarFldIdx, inFeature.get_Value(intSrcFldIdx));
                                                                    }
                                                                    catch
                                                                    {
                                                                        AAState.WriteLine("                  ERROR: COPY_FEATURE: Setting value: " + strFlpPair);

                                                                    }
                                                                }

                                                            }
                                                        }
                                                        IFields pTarFields = pTargetFL.FeatureClass.Fields;
                                                        IField pTarField = null;
                                                        for (int i = 0; i < pTarFields.FieldCount; i++)
                                                        {
                                                            pTarField = pTarFields.get_Field(i);
                                                            if (pTarField.Type != esriFieldType.esriFieldTypeGlobalID &&
                                                                pTarField.Type != esriFieldType.esriFieldTypeOID &&
                                                                pTarField.Type != esriFieldType.esriFieldTypeGeometry &&
                                                                 pTarField.Name.ToUpper() != "SHAPE_LENGTH" &&
                                                                pTarField.Name.ToUpper() != "SHAPE.LEN" &&
                                                                pTarField.Name.ToUpper() != "SHAPE_AREA" &&
                                                                pTarField.Name.ToUpper() != "SHAPE.AREA")
                                                            {
                                                                if (targFilds.Contains(pTarField.Name.ToUpper()) == false)
                                                                {
                                                                    int fldIdx = inFeature.Fields.FindField(pTarField.Name);
                                                                    if (fldIdx > 0)
                                                                    {
                                                                        try
                                                                        {
                                                                            pNewFeat.set_Value(i, inFeature.get_Value(fldIdx));
                                                                        }
                                                                        catch
                                                                        {
                                                                            AAState.WriteLine("                  WARNING: COPY_FEATURE: Setting value: " + pTarField.Name);

                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }

                                                        pTarFields = null;
                                                        pTarField = null;
                                                        if (NewFeatureList == null)
                                                        {
                                                            NewFeatureList = new List<IObject>();
                                                        }
                                                        //AAState.WriteLine("                  INFO: New feature being store, AA rules will fire on it now");
                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                        //AAState.indent = AAState.indent + "                                  ";
                                                        //string rowFiltPre = AAState._dv.RowFilter;

                                                        //pNewFeat.Store();
                                                        //AAState._dv.RowFilter = rowFiltPre;
                                                        //AAState.indent = AAState.indent.Substring(0, AAState.indent.Length - "                                  ".Length);
                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                        //AAState.WriteLine("                  INFO: New Feature Complete");

                                                        NewFeatureList.Add(pNewFeat);

                                                        if (sourceAction == "CUT")
                                                        {
                                                            MessageBox.Show("CUT is not supported at the moment");

                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                     ERROR: Value info was not correct");

                                                    }
                                                }

                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: COPY_FEATURE" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    pTargetFL = null;

                                                    pRowCh = null;
                                                    pNewFeat = null;
                                                    AAState.WriteLine("                  Finished: COPY_FEATURE");
                                                }
                                                break;
                                            }

                                        case "VALIDATE_CONNECTIVITY":
                                            {
                                                AAState.WriteLine("                  Trying: VALIDATE_CONNECTIVITY");

                                                try
                                                {
                                                    //            if (netFeat != null)
                                                    //IRowChanges pRowCh = inObject as IRowChanges;
                                                    //changed = true;
                                                    //if (mode != "ON_CREATE")
                                                    //{

                                                    //}

                                                    if ((valData != null) && (inFeature != null))
                                                    {
                                                        AAState.WriteLine("                     Feature and valueinfo is valid");

                                                        AAState.WriteLine("                     Checking if feature is in a geometric network");
                                                        bool validFeat = false;
                                                        if (inFeature is INetworkFeature)
                                                        {
                                                            AAState.WriteLine("                     Feature is in a geometric network");

                                                            AAState.WriteLine("                     Splitting up value info: " + valData);

                                                            args = valData.Split('|');
                                                            int connectionCnt = Globals.getConnectionCount(inFeature);

                                                            foreach (string fldConPair in args)
                                                            {

                                                                string[] fldCon = fldConPair.Split(',');
                                                                if (fldCon.Length == 1)
                                                                {
                                                                    AAState.WriteLine("                     No values for the specified fields");
                                                                    if (Globals.IsNumeric(fldCon[0]))
                                                                    {
                                                                        if (connectionCnt == Convert.ToInt32(fldCon[0]))
                                                                        {
                                                                            AAState.WriteLine("                     Valid Connection Rule Found");
                                                                            validFeat = true;
                                                                            break;

                                                                        }

                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                     ERROR: Connection value is not numeric");
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (intFldIdxs.Count == 0)
                                                                    {
                                                                        AAState.WriteLine("                     No values for the specified fields");
                                                                        if (fldCon.Length == 2)
                                                                        {
                                                                            if (connectionCnt == Convert.ToInt32(fldCon[1]))
                                                                            {
                                                                                AAState.WriteLine("                     Valid Connection Rule Found");
                                                                                validFeat = true;
                                                                                break;

                                                                            }
                                                                        }
                                                                        if (fldCon.Length > 2)
                                                                        {
                                                                            if (connectionCnt >= Convert.ToInt32(fldCon[1]) && connectionCnt <= Convert.ToInt32(fldCon[2]))
                                                                            {
                                                                                AAState.WriteLine("                     Valid Connection Rule Found");
                                                                                validFeat = true;
                                                                                break;

                                                                            }
                                                                        }

                                                                    }

                                                                    else if (inFeature.get_Value(intFldIdxs[0]).ToString() == fldCon[0])
                                                                    {

                                                                        if (fldCon.Length == 2)
                                                                        {
                                                                            if (connectionCnt == Convert.ToInt32(fldCon[1]))
                                                                            {
                                                                                AAState.WriteLine("                     Valid Connection Rule Found");
                                                                                validFeat = true;
                                                                                break;

                                                                            }
                                                                        }
                                                                        if (fldCon.Length > 2)
                                                                        {
                                                                            if (connectionCnt >= Convert.ToInt32(fldCon[1]) && connectionCnt <= Convert.ToInt32(fldCon[2]))
                                                                            {
                                                                                AAState.WriteLine("                     Valid Connection Rule Found");
                                                                                validFeat = true;
                                                                                break;

                                                                            }
                                                                        }
                                                                        //iSJunc.EdgeFeatureCount <= 1

                                                                    }

                                                                }

                                                            }
                                                            if (validFeat == false)
                                                            {
                                                                AAState.WriteLine("                     Abort Edit");
                                                                AAState._editor.AbortOperation();
                                                                return false;

                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                     ERROR: Feature is not a geometric network feature");

                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                     ERROR: Value info was not correct");

                                                    }
                                                }

                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: VALIDATE_CONNECTIVITY" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine("                  Finished: VALIDATE_CONNECTIVITY");
                                                }
                                                break;
                                            }

                                        case "VALIDATE_ATTRIBUTES":
                                            {
                                                AAState.WriteLine("                  Trying: VALIDATE_ATTRIBUTES");

                                                try
                                                {
                                                    if ((valData != null) && (inFeature != null))
                                                    {

                                                        AAState.WriteLine("                     Feature and valueinfo is valid");
                                                        IRowChanges pRowCh = inObject as IRowChanges;
                                                        changed = true;
                                                        if (intFldIdxs != null && intFldIdxs.Count > 0 && mode != "ON_CREATE")
                                                        {
                                                            for (int fldIdx = 0; fldIdx < intFldIdxs.Count; fldIdx++)
                                                            {
                                                                AAState.WriteLine("                     Row to monitor specified");
                                                                changed = pRowCh.get_ValueChanged(intFldIdxs[fldIdx]);
                                                                AAState.WriteLine("                     " + strFldNames[fldIdx] + " changed value was " + changed);
                                                                if (changed)
                                                                    break;
                                                            }

                                                        }
                                                        if (changed)
                                                        {
                                                            args = valData.Split('|');
                                                            args = args[0].Split(',');
                                                            AAState.WriteLine("                     Checking fields to compare: " + args);
                                                            if (args.Length > 0)
                                                            {
                                                                // IList<string> pFldsToEval = new List<String>(args);
                                                                //pFldsToEval = args.ToList();

                                                                AAState.WriteLine("                     Getting templates for feature class");
                                                                IList<ILayer> pLayList = Globals.FindLayersByClassID(((IMxDocument)ArcMap.Application.Document).FocusMap, inObject.Class.ObjectClassID);
                                                                if (pLayList != null)
                                                                {
                                                                    if (pLayList.Count > 0)
                                                                    {

                                                                        AAState.WriteLine("                     " + pLayList.Count + " Layers found");
                                                                        bool ValidComb = false;

                                                                        foreach (ILayer pLay in pLayList)
                                                                        {
                                                                            AAState.WriteLine("                     Checking " + pLay.Name);
                                                                            if (pLay is IFeatureLayer)
                                                                            {
                                                                                AAState.WriteLine("                     Layer is a featurelayer");
                                                                                // IList<string> pEditTemplateNames = Globals.GetEditTemplateNames(ArcMap.Application, (IFeatureLayer)pLay);
                                                                                //IList<IEditTemplate> pEditTemplates = Globals.GetEditTemplates(ArcMap.Application, (IFeatureLayer)pLay);

                                                                                //foreach (string IEditTemplate in pEditTemplates)
                                                                                //{
                                                                                //Globals.GetEditTemplate(pEditTemplateName,
                                                                                //}
                                                                                AAState.WriteLine("                     Getting Edit Template Manager");
                                                                                IEditTemplateManager pEdTmpManager = Globals.GetEditTemplateManager((IFeatureLayer)pLay);
                                                                                AAState.WriteLine("                     Checking templates");
                                                                                ValidComb = Globals.FeatureIsValidTemplate(pEdTmpManager, inFeature, args);
                                                                                AAState.WriteLine("                     Template Found Status: " + ValidComb.ToString());
                                                                                if (ValidComb == true)
                                                                                    break;

                                                                            }

                                                                        }
                                                                        if (ValidComb == false)
                                                                        {
                                                                            AAState.WriteLine("                     Abort Edit");
                                                                            AAState._editor.AbortOperation();
                                                                            return false;

                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                     WARNING: No layers where found!");

                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                     WARNING: No layers where found!");

                                                                }

                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                     Monitored fields where not changed");

                                                        }
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: VALIDATE_ATTRIBUTES" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine("                  Finished: VALIDATE_ATTRIBUTES");
                                                }
                                                break;
                                            }

                                        //case "SPLIT_INTERSECTING_FEATURE":
                                        //    {
                                        //        AAState.WriteLine("                  Trying: SPLIT_INTERSECTING_FEATURE");

                                        //        try
                                        //        {
                                        //            if ((valData != null) && (inFeature != null))
                                        //            {
                                        //                intersectLayerName = "";
                                        //                intersectLayer = null;
                                        //                args = valData.Split('|');
                                        //                if (args.Length > 0)
                                        //                {
                                        //                    AAState.WriteLine("                  " + args.Length + " Layers listed ");

                                        //                    for (int i = 0; i < args.Length; i++)
                                        //                    {

                                        //                        intersectLayerName = args[i].Trim();
                                        //                        AAState.WriteLine("                  Searching for " + intersectLayerName);
                                        //                        boolLayerOrFC = true;
                                        //                        if (intersectLayerName.Contains("("))
                                        //                        {
                                        //                            string[] tempSplt = intersectLayerName.Split('(');
                                        //                            intersectLayerName = tempSplt[0];
                                        //                            intersectLayer = Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                        //                            if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                        //                            {
                                        //                                boolLayerOrFC = true;
                                        //                            }
                                        //                            else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                        //                            {
                                        //                                boolLayerOrFC = true;
                                        //                            }
                                        //                            else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                        //                            {
                                        //                                boolLayerOrFC = false;
                                        //                            }
                                        //                            else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                        //                            {
                                        //                                boolLayerOrFC = false;
                                        //                            }
                                        //                            else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                        //                            {
                                        //                                boolLayerOrFC = false;
                                        //                            }
                                        //                            else
                                        //                            {
                                        //                                boolLayerOrFC = true;
                                        //                            }
                                        //                        }
                                        //                        else
                                        //                        {
                                        //                            intersectLayer = Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                        //                        }
                                        //                        if (intersectLayer != null)
                                        //                        {
                                        //                            AAState.WriteLine("                  Layer Found " + intersectLayerName);
                                        //                            if (intersectLayer.FeatureClass != null)
                                        //                            {
                                        //                                AAState.WriteLine("                  Datasource is valid for " + intersectLayerName);

                                        //                                // sFilter = new SpatialFilterClass();
                                        //                                sFilter = Globals.createSpatialFilter(intersectLayer, inFeature, false);

                                        //                                AAState.WriteLine("                  Checking source Geometry Type");

                                        //                                AAState.WriteLine("                  Searching " + intersectLayerName + "for intersected feature");
                                        //                                //if (boolLayerOrFC)
                                        //                                //{
                                        //                                //    fCursor = intersectLayer.Search(sFilter, true);
                                        //                                //}
                                        //                                //else
                                        //                                //{
                                        //                                //    fCursor = intersectLayer.FeatureClass.Search(sFilter, true);
                                        //                                //}
                                        //                                pFS = (IFeatureSelection)intersectLayer;
                                        //                                if (boolLayerOrFC)
                                        //                                {
                                        //                                    if (pFS.SelectionSet.Count > 0)
                                        //                                    {
                                        //                                        pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                        //                                        fCursor = cCurs as IFeatureCursor;

                                        //                                    }
                                        //                                    else
                                        //                                    {
                                        //                                        fCursor = intersectLayer.Search(sFilter, true);
                                        //                                    }
                                        //                                }
                                        //                                else
                                        //                                {
                                        //                                    fCursor = intersectLayer.FeatureClass.Search(sFilter, true);
                                        //                                }

                                        //                                IFeature intsersectFeature;
                                        //                                int idx = 1;
                                        //                                while ((intsersectFeature = fCursor.NextFeature()) != null)
                                        //                                {
                                        //                                    if (intsersectFeature.Class != inFeature.Class)
                                        //                                    {
                                        //                                        AAState.WriteLine("                  Splitting Intersected Feature number: " + idx);
                                        //                                        idx++;

                                        //                                        IFeatureEdit2 featureEdit = intsersectFeature as IFeatureEdit2;
                                        //                                        ISet featset = featureEdit.SplitWithUpdate(inFeature.Shape);
                                        //                                        AAState.WriteLine("                  Adding split features to array to call the AA ext");

                                        //                                        if (featset.Count > 0)
                                        //                                        {
                                        //                                            if (NewFeatureList == null)
                                        //                                            {
                                        //                                                NewFeatureList = new List<IObject>();
                                        //                                            }
                                        //                                            object featobj;
                                        //                                            while ((featobj = featset.Next()) != null)
                                        //                                            {
                                        //                                                IFeature feature = featobj as IFeature;
                                        //                                                //feature.Store();
                                        //                                                if (feature != null)
                                        //                                                {
                                        //                                                    NewFeatureList.Add(feature as IObject);
                                        //                                                }
                                        //                                                feature = null;
                                        //                                            }

                                        //                                        }
                                        //                                        AAState.WriteLine("                  Split feature " + intersectLayerName + " into " + featset.Count);
                                        //                                        if (intsersectFeature != null)
                                        //                                        {
                                        //                                            Marshal.ReleaseComObject(intsersectFeature);
                                        //                                        }
                                        //                                        featureEdit = null;
                                        //                                        featset = null;
                                        //                                    }

                                        //                                    else if (intsersectFeature.Class == inFeature.Class && intsersectFeature.OID != inFeature.OID)
                                        //                                    {
                                        //                                        AAState.WriteLine("                  Splitting Intersected Feature number: " + idx);
                                        //                                        idx++;

                                        //                                        IFeatureEdit2 featureEdit = intsersectFeature as IFeatureEdit2;
                                        //                                        ISet featset = featureEdit.SplitWithUpdate(inFeature.Shape);
                                        //                                        AAState.WriteLine("                  Adding split features to array to call the AA ext");

                                        //                                        if (featset.Count > 0)
                                        //                                        {
                                        //                                            if (NewFeatureList == null)
                                        //                                            {
                                        //                                                NewFeatureList = new List<IObject>();
                                        //                                            }
                                        //                                            object featobj;
                                        //                                            while ((featobj = featset.Next()) != null)
                                        //                                            {
                                        //                                                IFeature feature = featobj as IFeature;
                                        //                                                if (feature != null)
                                        //                                                {
                                        //                                                    NewFeatureList.Add(feature as IObject);
                                        //                                                }
                                        //                                                feature = null;
                                        //                                                // feature.Store();
                                        //                                            }

                                        //                                        }
                                        //                                        AAState.WriteLine("                  Split feature " + intersectLayerName + " into " + featset.Count);
                                        //                                        if (intsersectFeature != null)
                                        //                                        {
                                        //                                            Marshal.ReleaseComObject(intsersectFeature);
                                        //                                        }
                                        //                                        featureEdit = null;
                                        //                                        featset = null;

                                        //                                    }

                                        //                                }
                                        //                                intsersectFeature = null;
                                        //                            }
                                        //                        }

                                        //                        else
                                        //                        {
                                        //                            AAState.WriteLine("                  Warning: Can't find intersecting layer: " + intersectLayerName);
                                        //                        }
                                        //                    }
                                        //                }
                                        //                else
                                        //                {
                                        //                    AAState.WriteLine("                  ERROR: Unsupported Value Info: " + valData);
                                        //                }
                                        //            }
                                        //            else
                                        //            {
                                        //                AAState.WriteLine("                  ERROR: not a feature or no Value Info");
                                        //            }
                                        //        }
                                        //        catch (Exception ex)
                                        //        {
                                        //            AAState.WriteLine("                  ERROR: SPLIT_INTERSECTING_FEATURE" + Environment.NewLine + ex.Message);
                                        //        }

                                        //        finally
                                        //        {
                                        //            AAState.WriteLine("                  Finished: SPLIT_INTERSECTING_FEATURE");
                                        //        }
                                        //        break;
                                        //    }

                                        case "SPLIT_INTERSECTING_FEATURE":
                                            {
                                                AAState.WriteLine("                  Trying: SPLIT_INTERSECTING_FEATURE");

                                                try
                                                {
                                                    if ((valData != null) && (inFeature != null))
                                                    {
                                                        intersectLayerName = "";
                                                        intersectLayer = null;
                                                        args = valData.Split('|');
                                                        if (args.Length > 0)
                                                        {
                                                            AAState.WriteLine("                  " + args.Length + " Layers listed ");

                                                            for (int i = 0; i < args.Length; i++)
                                                            {

                                                                intersectLayerName = args[i].Trim();
                                                                AAState.WriteLine("                  Searching for " + intersectLayerName);
                                                                boolLayerOrFC = true;
                                                                if (intersectLayerName.Contains("("))
                                                                {
                                                                    string[] tempSplt = intersectLayerName.Split('(');
                                                                    intersectLayerName = tempSplt[0];
                                                                    intersectLayer = Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                                    if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                    {
                                                                        boolLayerOrFC = true;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                    {
                                                                        boolLayerOrFC = true;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                    {
                                                                        boolLayerOrFC = false;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                    {
                                                                        boolLayerOrFC = false;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                    {
                                                                        boolLayerOrFC = false;
                                                                    }
                                                                    else
                                                                    {
                                                                        boolLayerOrFC = true;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    intersectLayer = Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                                }
                                                                if (intersectLayer != null)
                                                                {
                                                                    AAState.WriteLine("                  Layer Found " + intersectLayerName);
                                                                    if (intersectLayer.FeatureClass != null)
                                                                    {
                                                                        AAState.WriteLine("                  Datasource is valid for " + intersectLayerName);
                                                                        double snapTol = Globals.GetXYTolerance(intersectLayer);
                                                                        // sFilter = new SpatialFilterClass();
                                                                        sFilter = Globals.createSpatialFilter(intersectLayer, inFeature, false);

                                                                        AAState.WriteLine("                  Checking source Geometry Type");

                                                                        AAState.WriteLine("                  Searching " + intersectLayerName + "for intersected feature");
                                                                        //if (boolLayerOrFC)
                                                                        //{
                                                                        //    fCursor = intersectLayer.Search(sFilter, true);
                                                                        //}
                                                                        //else
                                                                        //{
                                                                        //    fCursor = intersectLayer.FeatureClass.Search(sFilter, true);
                                                                        //}
                                                                        pFS = (IFeatureSelection)intersectLayer;
                                                                        if (boolLayerOrFC)
                                                                        {
                                                                            if (pFS.SelectionSet.Count > 0)
                                                                            {
                                                                                pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                                fCursor = cCurs as IFeatureCursor;

                                                                            }
                                                                            else
                                                                            {
                                                                                fCursor = intersectLayer.Search(sFilter, true);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            fCursor = intersectLayer.FeatureClass.Search(sFilter, true);
                                                                        }

                                                                        IFeature intsersectFeature;
                                                                        int idx = 1;
                                                                        while ((intsersectFeature = fCursor.NextFeature()) != null)
                                                                        {
                                                                            if (intsersectFeature.Class != inFeature.Class)
                                                                            {
                                                                                AAState.WriteLine("                  Splitting Intersected Feature number: " + idx);
                                                                                idx++;

                                                                                // IFeatureEdit2 featureEdit = intsersectFeature as IFeatureEdit2;
                                                                                //ISet featset = featureEdit.SplitWithUpdate(inFeature.ShapeCopy);
                                                                                if (intsersectFeature is INetworkFeature)
                                                                                {
                                                                                    AAState.WriteLine("                  Line to split is a Geometric Network line, this operation is not valid for these types of features");
                                                                                }
                                                                                else
                                                                                {
                                                                                    ISet featset = Globals.splitLineWithPoint(intsersectFeature, inFeature.ShapeCopy as IPoint, snapTol, null, "{0:0.00}", ArcMap.Application);

                                                                                    if (featset != null)
                                                                                    {
                                                                                        AAState.WriteLine("                  Adding split features to array to call the AA ext");

                                                                                        if (featset.Count > 0)
                                                                                        {
                                                                                            if (NewFeatureList == null)
                                                                                            {
                                                                                                NewFeatureList = new List<IObject>();
                                                                                            }
                                                                                            object featobj;
                                                                                            while ((featobj = featset.Next()) != null)
                                                                                            {
                                                                                                IFeature feature = featobj as IFeature;
                                                                                                //feature.Store();
                                                                                                if (feature != null)
                                                                                                {
                                                                                                    NewFeatureList.Add(feature as IObject);
                                                                                                }
                                                                                                feature = null;
                                                                                            }

                                                                                        }
                                                                                        AAState.WriteLine("                  Split feature " + intersectLayerName + " into " + featset.Count);
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine("                  Split return no features");

                                                                                    }
                                                                                    featset = null;
                                                                                }
                                                                            }
                                                                            if (intsersectFeature != null)
                                                                            {
                                                                                Marshal.ReleaseComObject(intsersectFeature);
                                                                            }
                                                                            //featureEdit = null;

                                                                            else if (intsersectFeature.Class == inFeature.Class && intsersectFeature.OID != inFeature.OID)
                                                                            {
                                                                                AAState.WriteLine("                  Splitting Intersected Feature number: " + idx);
                                                                                idx++;
                                                                                if (intsersectFeature is INetworkFeature)
                                                                                {
                                                                                    AAState.WriteLine("                  Line to split is a Geometric Network line, this operation is not valid for these types of features");
                                                                                }
                                                                                else
                                                                                {
                                                                                    // IFeatureEdit2 featureEdit = intsersectFeature as IFeatureEdit2;
                                                                                    //ISet featset = featureEdit.SplitWithUpdate(inFeature.Shape);
                                                                                    ISet featset = Globals.splitLineWithPoint(intsersectFeature, inFeature.ShapeCopy as IPoint, snapTol, null, "{0:0.00}", ArcMap.Application);

                                                                                    if (featset == null)
                                                                                    {
                                                                                        AAState.WriteLine("                  Error splitting feature, the feature may be a geometric network feature");

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine("                  Adding split features to array to call the AA ext");

                                                                                        if (featset.Count > 0)
                                                                                        {
                                                                                            if (NewFeatureList == null)
                                                                                            {
                                                                                                NewFeatureList = new List<IObject>();
                                                                                            }
                                                                                            object featobj;
                                                                                            while ((featobj = featset.Next()) != null)
                                                                                            {
                                                                                                IFeature feature = featobj as IFeature;
                                                                                                if (feature != null)
                                                                                                {
                                                                                                    NewFeatureList.Add(feature as IObject);
                                                                                                }
                                                                                                feature = null;
                                                                                                // feature.Store();
                                                                                            }

                                                                                        }
                                                                                        AAState.WriteLine("                  Split feature " + intersectLayerName + " into " + featset.Count);
                                                                                    }
                                                                                    featset = null;

                                                                                }
                                                                                if (intsersectFeature != null)
                                                                                {
                                                                                    Marshal.ReleaseComObject(intsersectFeature);
                                                                                }

                                                                            }

                                                                        }
                                                                        intsersectFeature = null;
                                                                    }
                                                                }

                                                                else
                                                                {
                                                                    AAState.WriteLine("                  Warning: Can't find intersecting layer: " + intersectLayerName);
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR: Unsupported Value Info: " + valData);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: not a feature or no Value Info");
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: SPLIT_INTERSECTING_FEATURE" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine("                  Finished: SPLIT_INTERSECTING_FEATURE");
                                                }
                                                break;
                                            }

                                        case "NEAREST_FEATURE_ATTRIBUTES":
                                            {
                                                AAState.WriteLine("                  Trying NEAREST_FEATURE_ATTRIBUTES");
                                                try
                                                {
                                                    if ((valData != null) && (inFeature != null))
                                                    {
                                                        sourceLayerName = "";
                                                        string[] sourceFieldNames = null;
                                                        string[] destFieldNames = null;
                                                        searchDistance = 0;

                                                        // Parse arguments
                                                        args = valData.Split('|');
                                                        if (args.Length == 3)
                                                        {
                                                            sourceLayerName = args[0].ToString().Trim();
                                                            sourceFieldNames = args[1].ToString().Split(',');
                                                            destFieldNames = args[2].ToString().Split(',');
                                                            AAState.WriteLine("                  WARNING:  search distance as not specified, defaulting to 0");

                                                        }
                                                        else if (args.Length == 4)
                                                        {
                                                            sourceLayerName = args[0].ToString().Trim();
                                                            sourceFieldNames = args[1].ToString().Split(',');
                                                            destFieldNames = args[2].ToString().Split(',');
                                                            Double.TryParse(args[3], out searchDistance);
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR:  the valuemethod is not defined properly for this rule");
                                                            continue;

                                                        }

                                                        if ((sourceFieldNames != null) && (destFieldNames != null) &&
                                                            (sourceFieldNames.Length > 0) && (destFieldNames.Length > 0) &&
                                                            (sourceFieldNames.Length == destFieldNames.Length))
                                                        {
                                                            AAState.WriteLine("                  Looking for layer: " + sourceLayerName);

                                                            boolLayerOrFC = true;
                                                            if (sourceLayerName.Contains("("))
                                                            {
                                                                string[] tempSplt = sourceLayerName.Split('(');
                                                                sourceLayerName = tempSplt[0];
                                                                sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                                if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                            }

                                                            else
                                                            {
                                                                sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                            }
                                                            if (sourceLayer != null)
                                                            {
                                                                if (sourceLayer.FeatureClass != null)
                                                                {
                                                                    AAState.WriteLine("                  " + sourceLayer.Name + " layer Found: " + sourceLayerName);

                                                                    string missingFieldMess = null;
                                                                    int[] sourceFieldNums = new int[sourceFieldNames.Length];
                                                                    int[] destFieldNums = new int[destFieldNames.Length];
                                                                    AAState.WriteLine("                  Checking Field Mapping");

                                                                    for (int i = 0; i < sourceFieldNums.Length; i++)
                                                                    {
                                                                        int fnum = sourceLayer.FeatureClass.FindField(sourceFieldNames[i].Trim());
                                                                        if (fnum < 0)
                                                                        {
                                                                            missingFieldMess = sourceFieldNames[i].Trim() + " in table " + sourceLayerName;
                                                                            break;
                                                                        }
                                                                        sourceFieldNums[i] = fnum;
                                                                    }
                                                                    if (missingFieldMess == null)
                                                                    {
                                                                        for (int i = 0; i < destFieldNums.Length; i++)
                                                                        {
                                                                            int fnum = inFeature.Fields.FindField(destFieldNames[i].Trim());
                                                                            if (fnum < 0)
                                                                            {
                                                                                missingFieldMess = destFieldNames[i].Trim() + " in table " + tableName;
                                                                                break;
                                                                            }
                                                                            destFieldNums[i] = fnum;
                                                                        }
                                                                    }
                                                                    if (missingFieldMess == null)
                                                                    {
                                                                        AAState.WriteLine("                  Field Mapping verified");

                                                                        // found source and destination fields.
                                                                        //sFilter = new SpatialFilterClass();
                                                                        if (searchDistance > 0)
                                                                        {
                                                                            sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false);

                                                                            //searchEnvelope = inFeature.ShapeCopy.Envelope;
                                                                            //searchEnvelope.Expand(searchDistance, searchDistance, false);
                                                                            //sFilter.Geometry = searchEnvelope;
                                                                        }
                                                                        else
                                                                        {
                                                                            sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false);
                                                                            //sFilter.Geometry = inFeature.ShapeCopy;
                                                                        }

                                                                        //  sFilter.GeometryField = sourceLayer.FeatureClass.ShapeFieldName;
                                                                        // sFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                                                        AAState.WriteLine("                  Searching for Nearest Feature");
                                                                        //if (boolLayerOrFC)
                                                                        //{
                                                                        //    fCursor = sourceLayer.Search(sFilter, false);
                                                                        //}
                                                                        //else
                                                                        //{
                                                                        //    fCursor = sourceLayer.FeatureClass.Search(sFilter, false);
                                                                        //}
                                                                        pFS = (IFeatureSelection)sourceLayer;
                                                                        if (boolLayerOrFC)
                                                                        {
                                                                            if (pFS.SelectionSet.Count > 0)
                                                                            {
                                                                                pFS.SelectionSet.Search(sFilter, false, out cCurs);
                                                                                fCursor = cCurs as IFeatureCursor;

                                                                            }
                                                                            else
                                                                            {
                                                                                fCursor = sourceLayer.Search(sFilter, false);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            fCursor = sourceLayer.FeatureClass.Search(sFilter, false);
                                                                        }

                                                                        sourceFeature = fCursor.NextFeature();
                                                                        nearestFeature = null;

                                                                        proxOp = (IProximityOperator)inFeature.Shape;
                                                                        lastDistance = searchDistance;
                                                                        if (sourceFeature != null)
                                                                        {
                                                                            AAState.WriteLine("                  Features Found, looping for closest");

                                                                            while (sourceFeature != null)
                                                                            {
                                                                                if (sourceFeature.Class != inFeature.Class)
                                                                                {

                                                                                    //distance = proxOp.ReturnDistance(sourceFeature.Shape);
                                                                                    IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                    pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                    distance = proxOp.ReturnDistance(pTempGeo);
                                                                                    pTempGeo = null;
                                                                                    if (distance <= lastDistance)
                                                                                    {
                                                                                        nearestFeature = sourceFeature;
                                                                                        lastDistance = distance;
                                                                                    }
                                                                                }
                                                                                else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                                {
                                                                                    //distance = proxOp.ReturnDistance(sourceFeature.Shape);

                                                                                    IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                    pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                    distance = proxOp.ReturnDistance(pTempGeo);
                                                                                    pTempGeo = null;
                                                                                    if (distance <= lastDistance)
                                                                                    {
                                                                                        nearestFeature = sourceFeature;
                                                                                        lastDistance = distance;
                                                                                    }
                                                                                }
                                                                                sourceFeature = fCursor.NextFeature();
                                                                            }
                                                                        }
                                                                        if (nearestFeature != null)
                                                                        {
                                                                            AAState.WriteLine("                  Closest Feature is " + lastDistance + " Away with OID of " + nearestFeature.OID);

                                                                            for (int i = 0; i < sourceFieldNums.Length; i++)
                                                                            {
                                                                                try
                                                                                {
                                                                                    AAState.WriteLine("                  Trying to copy " + sourceFieldNames[i] + " to " + destFieldNames[i]);

                                                                                    inObject.set_Value(destFieldNums[i], nearestFeature.get_Value(sourceFieldNums[i]));
                                                                                }
                                                                                catch
                                                                                {
                                                                                    AAState.WriteLine("                  ERROR: copying " + sourceFieldNames[i] + " to " + destFieldNames[i]);

                                                                                }
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  No Feature was found, default fields");

                                                                            for (int i = 0; i < destFieldNums.Length; i++)
                                                                            {
                                                                                IField field = inObject.Fields.get_Field(destFieldNums[i]);
                                                                                object newval = field.DefaultValue;
                                                                                if (newval == null)
                                                                                {
                                                                                    if (field.IsNullable)
                                                                                    {
                                                                                        inObject.set_Value(destFieldNums[i], null);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    inObject.set_Value(destFieldNums[i], newval);
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  ERROR: Cant find field " + missingFieldMess);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  ERROR: " + sourceLayerName + " data source is not set");
                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  ERROR: " + sourceLayerName + " was not found");
                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR: Invalid Value Info: " + valData);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Not a feature or missing Value Info");
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: NEAREST_FEATURE_ATTRIBUTES" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine("                  Finished: NEAREST_FEATURE_ATTRIBUTES");
                                                }
                                                break;
                                            }
                                        case "MINIMUM_LENGTH":
                                            {
                                                try
                                                {
                                                    AAState.WriteLine("                  Trying MINIMUM_LENGTH");

                                                    double minlength;
                                                    AAState.WriteLine("                  Evaluating Minimum length value");

                                                    if (Double.TryParse(valData, out minlength))
                                                    {
                                                        if (inFeature != null)
                                                        {
                                                            ICurve curve = inFeature.Shape as ICurve;
                                                            if (curve != null)
                                                            {
                                                                if (curve.Length < minlength)
                                                                {
                                                                    String mess = "Line is shorter than " +
                                                                        String.Format("{0:0.00}", minlength) + " " + Globals.GetSpatRefUnitName(inFeature.Shape.SpatialReference, true) +
                                                                        ", aborting edit.";
                                                                    AAState.WriteLine("                  " + mess);

                                                                    MessageBox.Show(mess, "Line too short");
                                                                    AAState._editor.AbortOperation();
                                                                    return false;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  ERROR:  Feature is not a Line");

                                                            }
                                                        }
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  Error MINIMUM_LENGTH \n" + ex.Message);
                                                }
                                                finally
                                                {
                                                    AAState.WriteLine("                  Finished MINIMUM_LENGTH");

                                                }

                                                break;
                                            }
                                        case "LINK_TABLE_ASSET":

                                            try
                                            {
                                                intersectLayerName = "";
                                                intersectTable = null;
                                                intersectLayer = null;
                                                List<string> intersectLayerFieldNameList = new List<string>();
                                                List<int> intersectFieldPosList = new List<int>();
                                                AAState.WriteLine("                  Trying LINK_TABLE_ASSET");
                                                args = valData.Split('|');
                                                switch (args.GetLength(0))
                                                {
                                                    case 1:  // Feature Layer only
                                                        intersectLayerName = args[0].ToString();
                                                        break;
                                                    case 2:  // Feature Layer| Field to copy
                                                        intersectLayerName = args[0].ToString();

                                                        intersectLayerFieldNameList = new List<string>(args[1].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));

                                                        break;
                                                    case 3:  // Feature Layer| Field to copy | for future
                                                        intersectLayerName = args[0].ToString();
                                                        intersectLayerFieldNameList = new List<string>(args[1].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
                                                        //sequenceColumnName = args[2].ToString();
                                                        break;
                                                    default:
                                                        AAState.WriteLine("                  ERROR: Unsupported Value Method: " + valData);
                                                        continue;
                                                    // break;
                                                }
                                                bool FCorLayerIntersect = true;
                                                intersectLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref FCorLayerIntersect);
                                                intersectTable = Globals.FindStandAloneTable(AAState._editor.Map, intersectLayerName);

                                                if (intersectLayer != null)
                                                {
                                                    ////Find Area Field

                                                    foreach (string intersectLayerFieldName in intersectLayerFieldNameList)
                                                    {

                                                        intersectFieldPos  = intersectLayer.FeatureClass.Fields.FindField(intersectLayerFieldName);
                                                        if (intersectFieldPos < 0)
                                                        {
                                                            AAState.WriteLine("                  ERROR: Asset feature Layer Field(" + intersectLayerFieldName + ") not found");
                                                            break;
                                                        }

                                                        else
                                                        {
                                                            intersectFieldPosList.Add(intersectFieldPos);
                                                        }
                                                    }
                                                    intersectLayerSelection = (IFeatureSelection)intersectLayer;
                                                    if (intersectLayerSelection.SelectionSet.Count == 0)
                                                    {
                                                        AAState.WriteLine("                  ERROR: No assests selected in " + intersectLayerName);

                                                        break;
                                                    }
                                                    if (intersectLayerSelection.SelectionSet.Count > 1)
                                                    {
                                                        AAState.WriteLine("                  ERROR: To many assests are selected in " + intersectLayerName);

                                                        break;
                                                    }

                                                    intersectLayerSelection.SelectionSet.Search(null, true, out cCurs);
                                                }
                                                else if (intersectTable != null)
                                                {
                                                    if (intersectTable.Table == null)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Asset  Layer(" + intersectLayerName + ") not found");
                                                        break;
                                                    }
                                                    ////Find Area Field
                                                    //intersectFieldPos = intersectTable.Table.Fields.FindField(intersectLayerFieldName);
                                                    //if (intersectFieldPos < 0)
                                                    //{
                                                    //    AAState.WriteLine("                  ERROR: Asset Layer Field(" + intersectLayerFieldName + ") not found");
                                                    //    break;
                                                    //}
                                                    foreach (string intersectLayerFieldName in intersectLayerFieldNameList)
                                                    {

                                                        intersectFieldPos = intersectTable.Table.Fields.FindField(intersectLayerFieldName);
                                                        if (intersectFieldPos < 0)
                                                        {
                                                            AAState.WriteLine("                  ERROR: Asset  Layer Field(" + intersectLayerFieldName + ") not found");
                                                            break;
                                                        }
                                                        else
                                                        {
                                                            intersectFieldPosList.Add(intersectFieldPos);
                                                        }
                                                    }

                                                    intersectTableSelection = (ITableSelection)intersectTable;
                                                    if (intersectTableSelection.SelectionSet.Count == 0)
                                                    {
                                                        AAState.WriteLine("                  ERROR: No assests selected in " + intersectLayerName);

                                                        break;
                                                    }
                                                    if (intersectTableSelection.SelectionSet.Count > 1)
                                                    {
                                                        AAState.WriteLine("                  ERROR: To many assests are selected in " + intersectLayerName);

                                                        break;
                                                    }

                                                    intersectTableSelection.SelectionSet.Search(null, true, out cCurs);
                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  ERROR: Asset  Layer(" + intersectLayerName + ") not found");
                                                    break;
                                                }

                                                IRow row;

                                                while ((row = cCurs.NextRow()) != null)
                                                {
                                                    int idx = 0;
                                                    foreach (int fldIdxInt in intersectFieldPosList)
                                                    {
                                                        if (idx >= intFldIdxs.Count)
                                                            continue;

                                                        string val = row.get_Value(fldIdxInt).ToString();
                                                        if (inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeString)
                                                            inObject.set_Value(intFldIdxs[idx], val);
                                                        else if (inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeSmallInteger || inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeInteger)
                                                        {
                                                            if (Globals.IsNumeric(val))
                                                            {
                                                                inObject.set_Value(intFldIdxs[idx], Convert.ToInt32(val));

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  ERROR: Field is a number and Value is not" + val);

                                                            }
                                                        }
                                                        else if (inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeSingle || inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeDouble)
                                                        {
                                                            if (Globals.IsNumeric(val))
                                                            {
                                                                inObject.set_Value(intFldIdxs[idx], Convert.ToDouble(val));

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  ERROR: Field is a number and Value is not:" + val);

                                                            }
                                                        }
                                                        else
                                                        {
                                                            inObject.set_Value(intFldIdxs[idx], val);
                                                        }
                                                        idx++;

                                                    }

                                                }
                                                if (row != null)
                                                    Marshal.ReleaseComObject(cCurs);

                                                row = null;

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: LINK_TABLE_ASSET" + Environment.NewLine + ex.Message);
                                            }

                                            finally
                                            {
                                                if (cCurs != null)
                                                {
                                                    Marshal.ReleaseComObject(cCurs);
                                                    GC.Collect(300);
                                                    GC.WaitForFullGCComplete();
                                                    cCurs = null;

                                                }
                                                AAState.WriteLine("                  Finished: LINK_TABLE_ASSET");
                                            }
                                            break;

                                        case "GET_ADDRESS_FROM_CENTERLINE":

                                            AAState.WriteLine("                  Trying GET_ADDRESS_FROM_CENTERLINE");
                                            List<IPoint> pPnts = null;
                                            try
                                            {
                                                if ((valData != null) && (inFeature != null))
                                                {
                                                    sourceLayerName = "";
                                                    string[] sourceFieldNames = null;

                                                    searchDistance = 0;

                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    if (args.Length == 2)
                                                    {
                                                        sourceLayerName = args[0].ToString().Trim();
                                                        sourceFieldNames = args[1].ToString().Split(',');
                                                        searchDistance = 2;
                                                        AAState.WriteLine("                  WARNING:  search distance as not specified, defaulting to 0");

                                                    }
                                                    else if (args.Length == 3)
                                                    {
                                                        sourceLayerName = args[0].ToString().Trim();
                                                        sourceFieldNames = args[1].ToString().Split(',');
                                                        Double.TryParse(args[2], out searchDistance);

                                                    }

                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR:  the valuemethod is not defined properly for this rule");
                                                        continue;

                                                    }
                                                    //Globals.GetAddressInfo(
                                                    if (sourceFieldNames.Length != 5)
                                                    {
                                                        AAState.WriteLine("                  ERROR:  the valuemethod fields part does not have enough fields listed");
                                                        continue;

                                                    }

                                                    //AAState.WriteLine("                  Looking for layer: " + sourceLayerName);

                                                    boolLayerOrFC = false;
                                                    if (sourceLayerName.Contains("("))
                                                    {
                                                        string[] tempSplt = sourceLayerName.Split('(');
                                                        sourceLayerName = tempSplt[0];
                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                    }
                                                    // Globals.GetNearestFeature((inObject as IFeature).Shape,
                                                    pPnts = Globals.GetGeomCenter(inObject as IFeature);
                                                    if (pPnts.Count != 0)
                                                    {

                                                        AddressInfo pRetValu = Globals.GetAddressInfo(ArcMap.Application, pPnts[0] as IPoint, sourceLayerName,
                                                            sourceFieldNames[0].Trim(), sourceFieldNames[1].Trim(), sourceFieldNames[2].Trim(), sourceFieldNames[3].Trim(), sourceFieldNames[4].Trim(), false, searchDistance);
                                                        if (pRetValu != null)
                                                        {
                                                            if (pRetValu.Messages == "")
                                                            {

                                                                bool rightSide = true;
                                                                IPoint pPnt = Globals.GetPointOnLine((inObject as IFeature).Shape as IPoint, pRetValu.StreetGeometry as IPolyline, 400, out rightSide);

                                                                try
                                                                {
                                                                    if (strFldNames.Count == 2)
                                                                    {
                                                                        if (intFldIdxs[0] != -1)
                                                                        {
                                                                            if (rightSide)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], pRetValu.RightAddress);
                                                                            }
                                                                            else
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], pRetValu.LeftAddress);
                                                                            }
                                                                        }
                                                                        if (intFldIdxs[1] != -1)
                                                                            inObject.set_Value(intFldIdxs[1], pRetValu.StreetName);

                                                                    }
                                                                    else
                                                                    {
                                                                        if (intFldIdxs[0] != -1)
                                                                        {
                                                                            if (rightSide)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], pRetValu.RightAddress + " " + pRetValu.StreetName);
                                                                            }
                                                                            else
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], pRetValu.LeftAddress + " " + pRetValu.StreetName);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    AAState.WriteLine("                  ERROR: Error setting field values, GET_ADDRESS_FROM_CENTERLINE" + Environment.NewLine + ex.Message);
                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  ERROR: Error getting address info from the centerline: " + pRetValu.Messages);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR: Error getting address info from the centerline, GET_ADDRESS_FROM_CENTERLINE");
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Error getting Location, GET_ADDRESS_FROM_CENTERLINE");
                                                    }

                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: GET_ADDRESS_FROM_CENTERLINE" + Environment.NewLine + ex.Message);
                                            }

                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: GET_ADDRESS_FROM_CENTERLINE");
                                                pPnts = null;

                                            }

                                            break;

                                        case "GET_ADDRESS_USING_GEOCODER":
                                            {
                                                IReverseGeocoding reverseGeocoding = null;
                                                IAddressGeocoding addressGeocoding = null;
                                                IPoint revGCLoc = null;
                                                IFields matchFields = null;
                                                IField shapeField = null;

                                                IReverseGeocodingProperties reverseGeocodingProperties = null;
                                                IPropertySet addressProperties = null;

                                                IAddressInputs addressInputs = null;
                                                IFields addressFields = null;
                                                object key = null;
                                                object value = null;
                                                try
                                                {
                                                    AAState.WriteLine("                  Trying GET_ADDRESS_USING_GEOCODER");

                                                    if (!String.IsNullOrEmpty(valData))
                                                    {
                                                        args = valData.Split('|');
                                                        if (args.Length != 2)
                                                        {
                                                            AAState.WriteLine("                  ERROR: Format of valdata incorrect");
                                                            break;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Format of valdata incorrect");
                                                        break;
                                                    }
                                                    AAState.WriteLine("                  Trying to get address locator");
                                                    reverseGeocoding = Globals.OpenLocator(args[0], args[1]);

                                                    if (reverseGeocoding == null)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Reverse Address not locator found");
                                                        break;
                                                    }
                                                    AAState.WriteLine("                  Reverse Address locator found");
                                                    AAState.WriteLine("                  Retrieving Location to reverse geocode");
                                                    revGCLoc = Globals.GetGeomCenter(inFeature)[0];
                                                    AAState.WriteLine("                  Location retrieved");
                                                    // Create a Point at which to find the address.
                                                    addressGeocoding = (IAddressGeocoding)reverseGeocoding;

                                                    matchFields = addressGeocoding.MatchFields;
                                                    int shpFld = matchFields.FindField("Shape");

                                                    shapeField = matchFields.get_Field(shpFld);
                                                    AAState.WriteLine("                  Setting distance");
                                                    // Set the search tolerance for reverse geocoding.
                                                    reverseGeocodingProperties = (IReverseGeocodingProperties)reverseGeocoding;
                                                    reverseGeocodingProperties.SearchDistance = 100;
                                                    reverseGeocodingProperties.SearchDistanceUnits = esriUnits.esriFeet;
                                                    reverseGeocoding.InitDefaults();

                                                    // Find the address nearest the Point.
                                                    addressProperties = reverseGeocoding.ReverseGeocode(revGCLoc, false);

                                                    // Print the address properties.
                                                    addressInputs = (IAddressInputs)reverseGeocoding;
                                                    addressFields = addressInputs.AddressFields;

                                                    addressProperties.GetAllProperties(out key, out value);

                                                    string tempVal = "";
                                                    for (int i = 0; i < addressFields.FieldCount; i++)
                                                    {
                                                        IField addressField = addressFields.get_Field(i);
                                                        if (tempVal == "")
                                                        {
                                                            tempVal = addressProperties.GetProperty(addressField.Name).ToString();
                                                        }
                                                        else
                                                        {
                                                            tempVal = tempVal + ", " + addressProperties.GetProperty(addressField.Name).ToString();
                                                        }

                                                    }
                                                    inFeature.set_Value(intFldIdxs[0], tempVal);

                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: GET_ADDRESS_USING_GEOCODER" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine("                  Finished: GET_ADDRESS_USING_GEOCODER");
                                                    reverseGeocoding = null;
                                                    addressGeocoding = null;
                                                    revGCLoc = null;
                                                    matchFields = null;
                                                    shapeField = null;

                                                    reverseGeocodingProperties = null;
                                                    addressProperties = null;

                                                    addressInputs = null;
                                                    addressFields = null;
                                                    key = null;
                                                    value = null;
                                                }
                                                break;

                                            }

                                        case "GET_ADDRESS_USING_ARCGIS_SERVICE":  //ARGS: url

                                            try
                                            {
                                                IPoint revGCLoc = null;
                                                AAState.WriteLine("                  Trying GET_ADDRESS_USING_ARCGIS_SERVICE");
                                                if (fieldObj.Type == esriFieldType.esriFieldTypeString)
                                                {
                                                    if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty))
                                                    {
                                                        args = valData.Split('|');
                                                        revGCLoc = Globals.GetGeomCenter(inFeature)[0];
                                                        int wkid = inFeature.Shape.SpatialReference.FactoryCode;
                                                        if (revGCLoc != null)
                                                        {
                                                            //Test for user specified URL
                                                            if (valData.Trim() != "")
                                                            {
                                                                if (args.Length == 2)
                                                                {
                                                                    wkid = Convert.ToInt32(args[1]);
                                                                }
                                                                if (Globals.IsUrl(args[0]))
                                                                {
                                                                    locatorURL = args[0];
                                                                    /////locatorURL.TrimEnd(char[] );
                                                                    if (!(locatorURL.EndsWith(reverseGeocodeStr)))
                                                                    {
                                                                        if (!(locatorURL.EndsWith(GeocodeStr)))
                                                                        {
                                                                            if (!(locatorURL.EndsWith("/")))
                                                                            {
                                                                                locatorURL += "/" + GeocodeStr + "/" + reverseGeocodeStr;
                                                                            }
                                                                            else
                                                                            {
                                                                                locatorURL += GeocodeStr + "/" + reverseGeocodeStr;
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            if (!(locatorURL.EndsWith("/")))
                                                                            {
                                                                                locatorURL += "/" + reverseGeocodeStr;
                                                                            }
                                                                            else
                                                                            {
                                                                                locatorURL += reverseGeocodeStr;
                                                                            }
                                                                        }
                                                                    }
                                                                }

                                                                else if (args[0] == "TA_Streets_US_10")
                                                                {
                                                                    locatorURL = _agsOnlineLocators + args[0] + GeocodeStr + "/" + reverseGeocodeStr;
                                                                    //       wkid = 102100;
                                                                }
                                                                else if (args[0] == "TA_Address_NA_10" || args[0] == "TA_Address_EU")
                                                                {
                                                                    locatorURL = _agsOnlineLocators + args[0] + GeocodeStr + "/" + reverseGeocodeStr;
                                                                    //    wkid = 4326;
                                                                }
                                                                //Default to AGS Online USA geocode service
                                                                else if (_agsOnlineLocators.Substring(_agsOnlineLocators.LastIndexOf('/', _agsOnlineLocators.Length - 2)).Contains("Locator"))
                                                                {
                                                                    locatorURL = _agsOnlineLocators + "TA_Address_NA_10" + GeocodeStr + "/" + reverseGeocodeStr;
                                                                    //        wkid = 4326;
                                                                }
                                                                else
                                                                {
                                                                    locatorURL = _agsOnlineLocators + GeocodeStr + "/" + reverseGeocodeStr; ;
                                                                    //     wkid = 4326;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                if (_agsOnlineLocators.Substring(_agsOnlineLocators.LastIndexOf('/', _agsOnlineLocators.Length - 2)).Contains(GeocodeStr))
                                                                {
                                                                    locatorURL = _agsOnlineLocators + "/" + reverseGeocodeStr;
                                                                    //      wkid = 4326;
                                                                }
                                                                else
                                                                {
                                                                    _agsOnlineLocators = _agsOnlineLocators + "/" + GeocodeStr;
                                                                    locatorURL = _agsOnlineLocators + "/" + reverseGeocodeStr;
                                                                    // wkid = 4326;
                                                                }
                                                            }

                                                            if (!locatorURL.ToUpper().Contains("/REST/"))
                                                            {
                                                                AAState.WriteLine("                  ERROR: Thre url to the geocoder is not to the rest endpoint");
                                                            }
                                                            else
                                                            {
                                                                //Copy point from this current feature
                                                                _copyPoint = revGCLoc;//inFeature.ShapeCopy as IPoint;

                                                                //Project point to WGS84

                                                                StreamReader reader = null;
                                                                HttpWebRequest request = null;
                                                                try
                                                                {
                                                                    // Create the web request
                                                                    request = WebRequest.Create(_agsOnlineLocators) as HttpWebRequest;

                                                                    // Get response

                                                                    using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                                                                    {
                                                                        // Get the response stream
                                                                        reader = new StreamReader(response.GetResponseStream());
                                                                        string resp = reader.ReadToEnd();
                                                                        resp = resp.Substring(resp.IndexOf("Spatial Reference:"));
                                                                        resp = resp.Substring(0, resp.IndexOf("<br/>"));
                                                                        resp = resp.Substring(resp.IndexOf("</b>") + 4);
                                                                        wkid = Convert.ToInt32(resp.Split(' ')[0]);
                                                                        //XmlDictionaryReader xr = JsonReaderWriterFactory.CreateJsonReaderreader.ReadToEnd(), XmlDictionaryReaderQuotas.Max);
                                                                        //doc.Load(reader.ReadToEnd());
                                                                        // Console application output
                                                                        //   Console.WriteLine(reader.ReadToEnd());
                                                                    }
                                                                }
                                                                catch
                                                                {
                                                                    AAState.WriteLine("                  Error getting service projection information");
                                                                    wkid = 4326;
                                                                }
                                                                finally
                                                                {

                                                                    reader = null;
                                                                    request = null;
                                                                }

                                                                _copyPoint.Project(Globals.CreateSpatRef(wkid));
                                                                //Include location parameters in URL
                                                                string results = Globals.FormatLocationRequest(locatorURL, _copyPoint.X, _copyPoint.Y, 100);
                                                                //Send and receieve the request
                                                                WebRequest req = null;
                                                                WebResponse res = null;

                                                                XmlDictionaryReader xr = null;
                                                                XmlDocument doc = null;
                                                                try
                                                                {
                                                                    req = WebRequest.Create(results);
                                                                    res = req.GetResponse();

                                                                    //Convert response from JSON to XML
                                                                    doc = new XmlDocument();
                                                                    using (Stream s = res.GetResponseStream())
                                                                    {
                                                                        xr = JsonReaderWriterFactory.CreateJsonReader(s, XmlDictionaryReaderQuotas.Max);
                                                                        doc.Load(xr);
                                                                        xr.Close();
                                                                        s.Close();
                                                                        string val = "";

                                                                        for (int h = 0; h < doc.DocumentElement.FirstChild.ChildNodes.Count - 1; h++)
                                                                        {
                                                                            if (doc.DocumentElement.FirstChild.ChildNodes[h].Name.Contains("Match") == false)
                                                                            {
                                                                                if (val == "")
                                                                                {
                                                                                    val = doc.DocumentElement.FirstChild.ChildNodes[h].InnerText;
                                                                                }
                                                                                else
                                                                                {
                                                                                    val = val + ", " + doc.DocumentElement.FirstChild.ChildNodes[h].InnerText;
                                                                                }
                                                                            }

                                                                        }
                                                                        val = val.Trim();
                                                                        inFeature.set_Value(intFldIdxs[0], val);

                                                                    }
                                                                }
                                                                catch
                                                                {
                                                                }
                                                                finally
                                                                {
                                                                    req = null;
                                                                    res = null;

                                                                    xr = null;
                                                                    doc = null;
                                                                }

                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  Could not get location to Reverse Geocode");
                                                        }
                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: GET_ADDRESS_USING_ARCGIS_SERVICE: " + ex.Message);
                                            }

                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: GET_ADDRESS_USING_ARCGIS_SERVICE");
                                            }
                                            break;
                                        case "TIMESTAMP":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: TIMESTAMP");

                                                if (!String.IsNullOrEmpty(valData))
                                                {
                                                    args = valData.Split('|');
                                                    if (args.Length > 0)
                                                    {

                                                        try
                                                        {
                                                            //if (args[0].ToString() == "DATE")
                                                            //{
                                                            //    if (fieldObj.Type == esriFieldType.esriFieldTypeDate)
                                                            //        inObject.set_Value(intFldIdxs[0], DateTime.Now.Date);
                                                            //    else if (fieldObj.Type == esriFieldType.esriFieldTypeString)
                                                            //        inObject.set_Value(intFldIdxs[0], DateTime.Now.Date.ToString());
                                                            //}
                                                            //else if (args[0].ToString() == "TIME")

                                                            //{
                                                            //    if (fieldObj.Type == esriFieldType.esriFieldTypeDate)
                                                            //        inObject.set_Value(intFldIdxs[0], DateTime.Now.TimeOfDay);
                                                            //    else if (fieldObj.Type == esriFieldType.esriFieldTypeString)
                                                            //        inObject.set_Value(intFldIdxs[0], DateTime.Now.TimeOfDay.ToString());
                                                            //}
                                                            //else
                                                            //{
                                                            if (fieldObj.Type == esriFieldType.esriFieldTypeDate)
                                                                inObject.set_Value(intFldIdxs[0], DateTime.Now);
                                                            else if (fieldObj.Type == esriFieldType.esriFieldTypeString)
                                                                inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString(args[0]));
                                                            // }
                                                        }
                                                        catch
                                                        {
                                                            AAState.WriteLine("                  ERROR: Date/Time Format is invalid");
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  Value info is empty");
                                                        if (fieldObj.Type == esriFieldType.esriFieldTypeDate)
                                                            inObject.set_Value(intFldIdxs[0], DateTime.Now);
                                                        else if (fieldObj.Type == esriFieldType.esriFieldTypeString)
                                                            inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString());

                                                    }
                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  Value info is empty");
                                                    if (fieldObj.Type == esriFieldType.esriFieldTypeDate)
                                                        inObject.set_Value(intFldIdxs[0], DateTime.Now);
                                                    else if (fieldObj.Type == esriFieldType.esriFieldTypeString)
                                                        inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString());

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: TIMESTAMP " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: TIMESTAMP");
                                            }
                                            break;

                                        case "LAST_VALUE":
                                            try
                                            {

                                                AAState.WriteLine("                  Trying: LAST_VALUE");
                                                bool CheckForValue = false;
                                                if (!String.IsNullOrEmpty(valData))
                                                {
                                                    args = valData.Split('|');
                                                    if (args.Length > 0)
                                                    {
                                                        if (args[0].ToString().ToUpper() == "TRUE")
                                                        {
                                                            CheckForValue = true;
                                                        }
                                                    }
                                                    //if (args.Length != 2)
                                                    //{
                                                    //    AAState.WriteLine("                  ERROR: Format of valdata incorrect");
                                                    //    break;
                                                    //}
                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  Value info is empty");
                                                }
                                                if (CheckForValue && (inObject.get_Value(intFldIdxs[0]) != null && inObject.get_Value(intFldIdxs[0]) != DBNull.Value))
                                                {

                                                }
                                                else
                                                {
                                                    if (mode == "ON_CREATE")
                                                    {

                                                        lastValue = AAState.lastValueProperties.GetProperty(strFldNames[0]);
                                                        if (lastValue != null)
                                                        {

                                                            inObject.set_Value(intFldIdxs[0], lastValue);
                                                            AAState.WriteLine("                  " + strFldNames[0] + ": " + lastValue);
                                                        }
                                                        else
                                                        {
                                                            if (inObject.get_Value(intFldIdxs[0]) != null)
                                                            {
                                                                AAState.lastValueProperties.SetProperty(strFldNames[0], inObject.get_Value(intFldIdxs[0]));

                                                            }
                                                        }
                                                    }
                                                    else if (mode == "ON_CHANGE")//&& inObject.get_Value(intFldIdxs[0]) == null
                                                    {
                                                        IRowChanges pRowCh = inObject as IRowChanges;
                                                        changed = pRowCh.get_ValueChanged(intFldIdxs[0]);
                                                        if (!changed)
                                                        {
                                                            lastValue = AAState.lastValueProperties.GetProperty(strFldNames[0]);
                                                            if (lastValue != null)
                                                            {
                                                                inObject.set_Value(intFldIdxs[0], lastValue);
                                                                AAState.WriteLine("                  " + strFldNames[0] + ": " + lastValue);
                                                            }
                                                        }
                                                    }

                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                //if (mode == "ON_CREATE")
                                                //{
                                                //    if (inObject.get_Value(intFldIdxs[0]) != null)
                                                //    {
                                                //        AAState.lastValueProperties.SetProperty(strFldNames[0], inObject.get_Value(intFldIdxs[0]));

                                                //    }
                                                //}
                                                //else
                                                //{
                                                AAState.WriteLine("                  ERROR: LAST_VALUE " + ex.Message);
                                                // }

                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: LAST_VALUE");
                                            }
                                            break;

                                        case "X_COORDINATE":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: X_COORDINATE");
                                                if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty))
                                                {
                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
                                                    {
                                                        _copyPoint = inFeature.Shape as IPoint;
                                                        inFeature.set_Value(intFldIdxs[0], _copyPoint.X);
                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                    {
                                                        _copyPolyline = inFeature.Shape as IPolyline;
                                                        if (valData == "")
                                                        {
                                                            inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].X);
                                                        }
                                                        else
                                                        {
                                                            args = valData.Split('|');
                                                            if (args[0].ToUpper() == "S")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolyline.FromPoint.X);
                                                            }
                                                            else if (args[0].ToUpper() == "E")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolyline.ToPoint.X);
                                                            }
                                                            else
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].X);
                                                            }

                                                        }

                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                                                    {
                                                        inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolygon)[0].X);
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Unsupported Geometry");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: X_COORDINATE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: X_COORDINATE");
                                            }
                                            break;

                                        case "Y_COORDINATE":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: Y_COORDINATE");
                                                if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty))
                                                {
                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
                                                    {
                                                        _copyPoint = inFeature.Shape as IPoint;
                                                        inFeature.set_Value(intFldIdxs[0], _copyPoint.Y);
                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                    {
                                                        _copyPolyline = inFeature.Shape as IPolyline;
                                                        if (valData == "")
                                                        {
                                                            inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].Y);
                                                        }
                                                        else
                                                        {
                                                            args = valData.Split('|');
                                                            if (args[0].ToUpper() == "S")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolyline.FromPoint.Y);
                                                            }
                                                            else if (args[0].ToUpper() == "E")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolyline.ToPoint.Y);
                                                            }
                                                            else
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].Y);
                                                            }

                                                        }

                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                                                    {
                                                        _copyPolygon = inFeature.ShapeCopy as IPolygon;

                                                        inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolygon)[0].Y);
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Unsupported Geometry");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: Y_COORDINATE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: Y_COORDINATE");
                                            }
                                            break;

                                        case "LATITUDE":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: LATITUDE");
                                                if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty))
                                                {

                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
                                                    {
                                                        _copyPoint = inFeature.ShapeCopy as IPoint;
                                                        _copyPoint.Project(AAState._sr1);

                                                        inFeature.set_Value(intFldIdxs[0], _copyPoint.Y);
                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                    {
                                                        _copyPolyline = inFeature.ShapeCopy as IPolyline;
                                                        _copyPolyline.Project(AAState._sr1);

                                                        if (valData == "")
                                                        {
                                                            inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].Y);
                                                        }
                                                        else
                                                        {
                                                            args = valData.Split('|');
                                                            if (args[0].ToUpper() == "S")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolyline.FromPoint.Y);
                                                            }
                                                            else if (args[0].ToUpper() == "E")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolyline.ToPoint.Y);
                                                            }
                                                            else
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].Y);
                                                            }

                                                        }

                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                                                    {
                                                        _copyPolygon = inFeature.ShapeCopy as IPolygon;
                                                        _copyPolygon.Project(AAState._sr1);

                                                        inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolygon)[0].Y);
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Unsupported Geometry");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  Error: LATITUDE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: LATITUDE");
                                            }
                                            break;

                                        case "LONGITUDE":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: LONGITUDE");
                                                if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty))
                                                {

                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
                                                    {
                                                        _copyPoint = inFeature.ShapeCopy as IPoint;
                                                        _copyPoint.Project(AAState._sr1);

                                                        inFeature.set_Value(intFldIdxs[0], _copyPoint.X);
                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                    {
                                                        _copyPolyline = inFeature.Shape as IPolyline;
                                                        _copyPolyline.Project(AAState._sr1);

                                                        if (valData == "")
                                                        {
                                                            inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].X);
                                                        }
                                                        else
                                                        {
                                                            args = valData.Split('|');
                                                            if (args[0].ToUpper() == "S")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolyline.FromPoint.X);
                                                            }
                                                            else if (args[0].ToUpper() == "E")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolyline.ToPoint.X);
                                                            }
                                                            else
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].X);
                                                            }

                                                        }

                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                                                    {
                                                        _copyPolygon = inFeature.ShapeCopy as IPolygon;
                                                        _copyPolygon.Project(AAState._sr1);

                                                        inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolygon)[0].X);
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Unsupported Geometry");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: LONGITUDE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: LONGITUDE");
                                            }
                                            break;

                                        case "FIELD":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: Field");
                                                // verify that field to copy exists

                                                if (!String.IsNullOrEmpty(valData))
                                                {
                                                    args = valData.Split('|');
                                                    fieldCopy = inObject.Fields.FindField(args[0] as string);

                                                    if (fieldCopy > -1)
                                                    {
                                                        bool useDisplayValue = true;
                                                        if (args.Length == 2)
                                                        {
                                                            if (args[1].ToUpper() == "CODE")
                                                                useDisplayValue = false;
                                                        }
                                                        //if (mode == "ON_CREATE")
                                                        //{

                                                        try
                                                        {
                                                            if (useDisplayValue)
                                                            {

                                                                inObject.set_Value(intFldIdxs[0], Globals.GetDomainDisplay(inObject.get_Value(fieldCopy), inObject as IFeature, inObject.Fields.get_Field(fieldCopy)));
                                                                AAState.WriteLine("                  Value set");
                                                            }

                                                            else
                                                            {
                                                                inObject.set_Value(intFldIdxs[0], inObject.get_Value(fieldCopy));
                                                                AAState.WriteLine("                  Value set");
                                                            }
                                                        }
                                                        catch (Exception ex)
                                                        {
                                                            AAState.WriteLine("                  ERROR: " + ex.Message);
                                                        }
                                                        //if (mode == "ON_CHANGE")
                                                        //{
                                                        //    //copy value only if current field is empty
                                                        //    if (inObject.get_Value(intFldIdxs[0]).ToString() == "")
                                                        //        inObject.set_Value(intFldIdxs[0], inObject.get_Value(fieldCopy));
                                                        //}
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + valData + " is not found");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: Field: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: Field");
                                            }
                                            break;

                                        //CURRENT_USER
                                        //Value Data options:
                                        //U - windows username only
                                        //W or (blank) - full username including domain i.e. domain\username
                                        //D - database user if available and not dbo
                                        case "CURRENT_USER":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: CURRENT_USER");

                                                lastEditorName = AAState._currentUserInfo.GetCurrentUser(valData, fieldObj.Length);
                                                AAState.WriteLine("                  Usernmae: " + lastEditorName);

                                                if (!String.IsNullOrEmpty(lastEditorName))
                                                {
                                                    inObject.set_Value(intFldIdxs[0], lastEditorName);
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: CURRENT_USER: "******"                  Finished: CURRENT_USER");
                                            }
                                            break;

                                        case "JUNCTION_ROTATION":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: JUNCTION_ROTATION");
                                                if ((inFeature != null))
                                                {
                                                    AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolGeographic;
                                                    args = null;
                                                    AAState.rCalc.UseDiameter = false;
                                                    AAState.rCalc.DiameterFieldName = "";
                                                    AAState.rCalc.SpinAngle = 0;

                                                    if (!String.IsNullOrEmpty(valData))
                                                    {
                                                        args = valData.Split('|');
                                                        if (args.Length == 0)
                                                        {
                                                            // if (args[0].Substring(0, 1).ToLower() == "a")
                                                            AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolGeographic;
                                                        }
                                                        else if (args.Length == 1)
                                                        {
                                                            if (args[0].Substring(0, 1).ToLower() == "a")
                                                                AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolArithmetic;

                                                        }
                                                        else if (args.Length == 2)
                                                        {
                                                            if (args[0].Substring(0, 1).ToLower() == "a")
                                                                AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolArithmetic;
                                                            if (Globals.IsNumeric(args[1].ToString()))
                                                                AAState.rCalc.SpinAngle = Convert.ToDouble(args[1]);

                                                        }
                                                        else if (args.Length == 3)
                                                        {
                                                            if (args[0].Substring(0, 1).ToLower() == "a")
                                                                AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolArithmetic;
                                                            if (Globals.IsNumeric(args[1].ToString()))
                                                                AAState.rCalc.SpinAngle = Convert.ToDouble(args[1]);
                                                            AAState.rCalc.UseDiameter = true;
                                                            AAState.rCalc.DiameterFieldName = args[2].ToString();

                                                        }
                                                        else
                                                        {
                                                            AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolGeographic;
                                                        }

                                                    }
                                                    AAState.WriteLine("                  " + AAState.rCalc.RotationType.ToString() + " is being used");
                                                    rotationAngle = AAState.rCalc.GetRotationUsingConnectedEdges(inFeature);
                                                    if (rotationAngle == null)
                                                    {
                                                        AAState.WriteLine("                  Rotation Angle not found or errored out");
                                                        continue;
                                                    }

                                                    //Accept optional second argument to provide extra rotation
                                                    //if ((args != null) && (args.Length > 1) && (Globals.IsInteger(args[1])))
                                                    //    rotationAngle += System.Convert.ToInt32(args[1]);
                                                    if (rotationAngle != -1)
                                                    {
                                                        AAState.WriteLine("                  Rotation Angle set to: " + rotationAngle.ToString());

                                                        inObject.set_Value(intFldIdxs[0], rotationAngle);
                                                        AAState.WriteLine("                  Rotation Angle set");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: JUNCTION_ROTATION \r\n" + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: JUNCTION_ROTATION");
                                            }
                                            break;

                                        //For Release: 1.2
                                        //New Dynamic Value Method: Length - stores calculated length of line feature
                                        case "LENGTH":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: LENGTH");
                                                if (inFeature != null)
                                                {
                                                    curve = (ICurve)inFeature.Shape;
                                                    if (curve != null)
                                                    {
                                                        inObject.set_Value(intFldIdxs[0], curve.Length);
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: LENGTH: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: LENGTH");
                                            }
                                            break;

                                        //Release: 1.2
                                        //New Dynamic Value Method: SET_MEASURES - stores calculated M values (from 0 to length of line) for line feature
                                        //Value Data options:
                                        //P = Percent - Ms will be zero to 100
                                        //default - Ms will be zero to length of line
                                        case "SET_MEASURES":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: SET_MEASURES");
                                                if (inFeature != null)
                                                {
                                                    curve = inFeature.Shape as ICurve;
                                                    mseg = inFeature.Shape as IMSegmentation;
                                                    if (curve != null && mseg != null)
                                                        if (valData != null && valData != "" && valData.Substring(0, 1).ToUpper() == "P")
                                                            mseg.SetAndInterpolateMsBetween(0, 100);
                                                        else
                                                            mseg.SetAndInterpolateMsBetween(0, curve.Length);
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: SET_MEASURES: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: SET_MEASURES");
                                            }
                                            break;
                                        //case "EDGE_INTERSECT_SECOND":
                                        //    try
                                        //    {
                                        //        if (inFeature != null)
                                        //        {
                                        //            netFeat = inFeature as INetworkFeature;
                                        //            if (netFeat != null)
                                        //            {
                                        //                if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                        //                {

                                        //                    iJuncFeat = (IJunctionFeature)netFeat;
                                        //                    // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                        //                    ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                        //                    if (iSJunc == null)
                                        //                        break;
                                        //                    if (iSJunc.EdgeFeatureCount <= 1)
                                        //                        break;
                                        //                    iEdgeFeat = iSJunc.get_EdgeFeature(1);

                                        //                    // verify that field (in junction) to copy exists

                                        //                    IRow pRow = iEdgeFeat as IRow;

                                        //                    juncField = pRow.Fields.FindField(valData as string);
                                        //                    if (juncField > -1)
                                        //                    {
                                        //                        inObject.set_Value(intFldIdxs[0], pRow.get_Value(juncField));
                                        //                    }
                                        //                }
                                        //            }
                                        //        }
                                        //    }
                                        //    catch
                                        //    {
                                        //    }
                                        //    break;
                                        //case "EDGE_INTERSECT_FIRST":
                                        //    try
                                        //    {
                                        //        if (inFeature != null)
                                        //        {
                                        //            netFeat = inFeature as INetworkFeature;
                                        //            if (netFeat != null)
                                        //            {
                                        //                if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                        //                {

                                        //                    iJuncFeat = (IJunctionFeature)netFeat;
                                        //                    // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                        //                    ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                        //                    if (iSJunc == null)
                                        //                        break;
                                        //                    if (iSJunc.EdgeFeatureCount <= 0)
                                        //                        break;
                                        //                    iEdgeFeat = iSJunc.get_EdgeFeature(0);

                                        //                    IRow pRow = iEdgeFeat as IRow;

                                        //                    juncField = pRow.Fields.FindField(valData as string);
                                        //                    if (juncField > -1)
                                        //                    {
                                        //                        inObject.set_Value(intFldIdxs[0], pRow.get_Value(juncField));
                                        //                    }
                                        //                }
                                        //            }
                                        //        }
                                        //    }
                                        //    catch
                                        //    {
                                        //    }
                                        //    break;

                                        //Release: 2.0
                                        //New Dynamic Value Method: TO_EDGE_FIELD transfers a field value from a connected egde feature to a junction feature
                                        //Takes value from the frist edge whose "TO" point connects with this junction
                                        case "TO_EDGE_FIELD":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: TO_EDGE_FIELD");
                                                if (inFeature != null)
                                                {
                                                    if (valData == null)
                                                    {
                                                        AAState.WriteLine("                  Value info is null");
                                                        break;
                                                    }
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                        {
                                                            string netField = "";
                                                            string netRestrictFC = "";
                                                            string netRestrictField = "";
                                                            string netRestrictValue = "";
                                                            args = valData.Split('|');
                                                            switch (args.GetLength(0))
                                                            {
                                                                case 1:  // sequenceColumnName only
                                                                    netField = args[0].ToString().Trim();
                                                                    break;
                                                                case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    break;
                                                                case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    break;
                                                                case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    netRestrictValue = args[3].ToString().Trim();
                                                                    break;
                                                                default: break;
                                                            }

                                                            iJuncFeat = (IJunctionFeature)netFeat;
                                                            // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                            ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                            if (iSJunc == null)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount <= 0)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount > 0)
                                                            {
                                                                for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                {
                                                                    iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                    try
                                                                    {

                                                                        if (netRestrictFC != "")
                                                                        {
                                                                            string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class));

                                                                            AAState.WriteLine("                  Layer restriction found, Class name of junction is: " + strClsName);
                                                                            if (strClsName != netRestrictFC)
                                                                            {
                                                                                AAState.WriteLine("                  Layer restriction does not match, breaking");
                                                                                continue;
                                                                            }
                                                                            AAState.WriteLine("                  Layer restriction matches, checking for field restriction");
                                                                            if (netRestrictField != "" && netRestrictValue != "")
                                                                            {
                                                                                int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField);

                                                                                if (intTmpFld > -1)
                                                                                {
                                                                                    //IFeature pTest = ((IFeature)iEdgeFeat);

                                                                                    if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                                    {
                                                                                        AAState.WriteLine("                  Values Match");
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine("                  Values dont match Match");
                                                                                        continue;

                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  " + netRestrictField + " was not found");
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  Missing Field restriction and value info");
                                                                            }
                                                                        }

                                                                        iJuncFeat = (IJunctionFeature)iEdgeFeat.FromJunctionFeature;
                                                                        if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                        {
                                                                            IRow pRow = iEdgeFeat as IRow;

                                                                            // verify that field (in junction) to copy exists
                                                                            juncField = Globals.GetFieldIndex(pRow.Fields, netField);

                                                                            if (juncField > -1)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], pRow.get_Value(juncField));
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  " + netField + " field not found in edge");
                                                                            }
                                                                            pRow = null;
                                                                            break;

                                                                        }
                                                                    }
                                                                    catch
                                                                    {
                                                                    }
                                                                    iSJunc = null;

                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  No Connected Edges Found");
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  not an junction feature");
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  Not a Geometric Network Feature");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: TO_EDGE_FIELD: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: TO_EDGE_FIELD");
                                            }
                                            break;

                                        //Release: 2.0
                                        //New Dynamic Value Method: FROM_EDGE_FIELD transfers a field value from a connected egde feature to a junction feature
                                        //Takes value from the frist edge whose "FROM" point connects with this junction
                                        case "FROM_EDGE_FIELD":

                                            try
                                            {
                                                AAState.WriteLine("                  Trying: FROM_EDGE_FIELD");
                                                if (inFeature != null)
                                                {
                                                    if (valData == null)
                                                    {
                                                        AAState.WriteLine("                  Value info is null");
                                                        break;
                                                    }
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                        {

                                                            string netField = "";
                                                            string netRestrictFC = "";
                                                            string netRestrictField = "";
                                                            string netRestrictValue = "";
                                                            args = valData.Split('|');
                                                            switch (args.GetLength(0))
                                                            {
                                                                case 1:  // sequenceColumnName only
                                                                    netField = args[0].ToString().Trim();
                                                                    break;
                                                                case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    break;
                                                                case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    break;
                                                                case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    netRestrictValue = args[3].ToString().Trim();
                                                                    break;
                                                                default: break;
                                                            }

                                                            iJuncFeat = (IJunctionFeature)netFeat;
                                                            // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                            ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                            if (iSJunc == null)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount <= 0)
                                                                break;
                                                            for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                            {
                                                                iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                try
                                                                {
                                                                    if (netRestrictFC != "")
                                                                    {
                                                                        string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class));

                                                                        AAState.WriteLine("                  Layer restriction found, Class name of junction is: " + strClsName);
                                                                        if (strClsName != netRestrictFC)
                                                                        {
                                                                            AAState.WriteLine("                  Layer restriction does not match, breaking");
                                                                            continue;
                                                                        }
                                                                        AAState.WriteLine("                  Layer restriction matches, checking for field restriction");
                                                                        if (netRestrictField != "" && netRestrictValue != "")
                                                                        {
                                                                            int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField);

                                                                            if (intTmpFld > -1)
                                                                            {
                                                                                //IFeature pTest = ((IFeature)iEdgeFeat);

                                                                                if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                                {
                                                                                    AAState.WriteLine("                  Values Match");
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  Values dont match Match");
                                                                                    continue;

                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  " + netRestrictField + " was not found");
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  Missing Field restriction and value info");
                                                                        }
                                                                    }

                                                                    iJuncFeat = iEdgeFeat.ToJunctionFeature;
                                                                    if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                    {
                                                                        IRow pRow = iEdgeFeat as IRow;

                                                                        // verify that field (in junction) to copy exists
                                                                        juncField = Globals.GetFieldIndex(pRow.Fields, netField);

                                                                        if (juncField > -1)
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[0], pRow.get_Value(juncField));
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  " + iSJunc + " field not found");
                                                                        }
                                                                        pRow = null;

                                                                        break;

                                                                    }

                                                                }

                                                                catch
                                                                {
                                                                    AAState.WriteLine("                  error ");
                                                                }
                                                                iSJunc = null;

                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  not an junction feature");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  Not a Geometric Network Feature");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: FROM_EDGE_FIELD: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: FROM_EDGE_FIELD");
                                            }
                                            break;
                                        case "TO_EDGE_STATS":
                                            try
                                            {
                                                if (valData == null) break;
                                                args = valData.Split('|');
                                                string statType = "MAX";
                                                switch (args.GetLength(0))
                                                {
                                                    case 1:
                                                        sourceFieldName = args[0].ToString();
                                                        break;
                                                    case 2:
                                                        sourceFieldName = args[0].ToString();
                                                        statType = args[1].ToString();
                                                        break;

                                                    default: break;
                                                }

                                                AAState.WriteLine("                  Trying: TO_EDGE_STATS");

                                                int AverageCount = 0;
                                                double result = -999999.1;
                                                string textRes = "";
                                                if (inFeature != null)
                                                {
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        AAState.WriteLine("                  Feature is a network feature");
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                        {
                                                            AAState.WriteLine("                  Feature is a junction feature");
                                                            iJuncFeat = (IJunctionFeature)netFeat;
                                                            // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                            ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                            if (iSJunc == null)
                                                                break;
                                                            AAState.WriteLine("                  Edge Count: " + iSJunc.EdgeFeatureCount);
                                                            if (iSJunc.EdgeFeatureCount <= 0)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount > 0)
                                                            {
                                                                for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                {
                                                                    AAState.WriteLine("                  Edge Count: " + iSJunc.EdgeFeatureCount);

                                                                    iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                    try
                                                                    {
                                                                        AAState.WriteLine("                  Checking if Edge is From or To");

                                                                        iJuncFeat = iEdgeFeat.FromJunctionFeature;

                                                                        if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                        {
                                                                            AAState.WriteLine("                  Edge is a To-Edge");

                                                                            IRow pRow = iEdgeFeat as IRow;

                                                                            // verify that field (in junction) to copy exists
                                                                            AAState.WriteLine("                  Getting Field From To-Edge");
                                                                            juncField = pRow.Fields.FindField(sourceFieldName);
                                                                            string test = pRow.get_Value(juncField).ToString();
                                                                            if (Globals.IsNumeric(test))
                                                                            {

                                                                                double valToTest = Convert.ToDouble(test);
                                                                                if (result == -999999.1)
                                                                                {
                                                                                    result = valToTest;

                                                                                }
                                                                                else
                                                                                {
                                                                                    switch (statType.ToUpper())
                                                                                    {
                                                                                        case "MAX":
                                                                                            if (result < valToTest)
                                                                                            {
                                                                                                result = valToTest;

                                                                                            }
                                                                                            break;
                                                                                        case "MIN":
                                                                                            if (result > valToTest)
                                                                                            {
                                                                                                result = valToTest;

                                                                                            }
                                                                                            break;
                                                                                        case "SUM":
                                                                                            result += valToTest;

                                                                                            break;
                                                                                        case "AVERAGE":
                                                                                            result += valToTest;
                                                                                            AverageCount++;
                                                                                            break;
                                                                                        case "MEAN":
                                                                                            result += valToTest;
                                                                                            AverageCount++;

                                                                                            break;
                                                                                        case "CONCAT":
                                                                                            if (textRes.Contains(valToTest.ToString() + ConcatDelim))
                                                                                            {
                                                                                            }
                                                                                            else if (textRes.Contains(ConcatDelim + valToTest.ToString()))
                                                                                            {
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                if (textRes == "")
                                                                                                {
                                                                                                    textRes += valToTest.ToString();
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    textRes += ConcatDelim + valToTest.ToString();
                                                                                                }
                                                                                            }

                                                                                            break;
                                                                                        default:
                                                                                            AAState.WriteLine("                  ERROR: Unsupported stat type: " + test);
                                                                                            break;
                                                                                    }

                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                switch (statType.ToUpper())
                                                                                {

                                                                                    case "CONCAT":
                                                                                        if (textRes.Contains(test.ToString() + ConcatDelim))
                                                                                        {
                                                                                        }
                                                                                        else if (textRes.Contains(ConcatDelim + test.ToString()))
                                                                                        {
                                                                                        }
                                                                                        else
                                                                                        {

                                                                                            if (textRes == "")
                                                                                            {
                                                                                                textRes += test;
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                textRes += ConcatDelim + test;
                                                                                            }
                                                                                        }

                                                                                        break;
                                                                                    default:
                                                                                        AAState.WriteLine("                  ERROR/WARNING: Non numeric value returned: " + test);

                                                                                        AAState.WriteLine("                  ERROR: Unsupported stat type: " + test);
                                                                                        break;
                                                                                }

                                                                            }

                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  Checking if Edge is From Edge, skipping");

                                                                        }
                                                                    }
                                                                    catch
                                                                    {
                                                                    }
                                                                }//end loop
                                                                try
                                                                {
                                                                    if (textRes != "")
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], textRes);
                                                                    }
                                                                    else if (result != -999999.1)
                                                                    {
                                                                        if (AverageCount != 0)
                                                                        {
                                                                            result = result / AverageCount;
                                                                        }
                                                                        inObject.set_Value(intFldIdxs[0], result);

                                                                    }
                                                                    else
                                                                    {
                                                                        IField field = inObject.Fields.get_Field(intFldIdxs[0]);
                                                                        object newval = field.DefaultValue;
                                                                        if (newval == null)
                                                                        {
                                                                            if (field.IsNullable)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], null);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[0], newval);
                                                                        }
                                                                    }
                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    AAState.WriteLine("                  ERROR: Value was not set on feature: " + ex.Message);

                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  No Connected Edges Found");
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  not an junction feature");
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  Not a Geometric Network Feature");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: TO_EDGE_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: TO_EDGE_STATS");
                                            }
                                            break;

                                        case "FROM_EDGE_STATS":
                                            try
                                            {
                                                if (valData == null) break;
                                                args = valData.Split('|');
                                                string statType = "MAX";
                                                switch (args.GetLength(0))
                                                {
                                                    case 1:
                                                        sourceFieldName = args[0].ToString();
                                                        break;
                                                    case 2:
                                                        sourceFieldName = args[0].ToString();
                                                        statType = args[1].ToString();
                                                        break;

                                                    default: break;
                                                }

                                                AAState.WriteLine("                  Trying: FROM_EDGE_STATS");

                                                int AverageCount = 0;
                                                double result = -999999.1;
                                                string textRes = "";
                                                if (inFeature != null)
                                                {
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        AAState.WriteLine("                  Feature is a network feature");
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                        {
                                                            AAState.WriteLine("                  Feature is a junction feature");
                                                            iJuncFeat = (IJunctionFeature)netFeat;
                                                            // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                            ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                            if (iSJunc == null)
                                                                break;
                                                            AAState.WriteLine("                  Edge Count: " + iSJunc.EdgeFeatureCount);
                                                            if (iSJunc.EdgeFeatureCount <= 0)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount > 0)
                                                            {
                                                                for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                {
                                                                    AAState.WriteLine("                  Edge Count: " + iSJunc.EdgeFeatureCount);

                                                                    iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                    try
                                                                    {
                                                                        AAState.WriteLine("                  Checking if Edge is From or To");

                                                                        iJuncFeat = iEdgeFeat.ToJunctionFeature;

                                                                        if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                        {
                                                                            AAState.WriteLine("                  Edge is a From-Edge");

                                                                            IRow pRow = iEdgeFeat as IRow;

                                                                            // verify that field (in junction) to copy exists
                                                                            AAState.WriteLine("                  Getting Field From From-Edge");
                                                                            juncField = pRow.Fields.FindField(sourceFieldName);
                                                                            string test = pRow.get_Value(juncField).ToString();
                                                                            if (Globals.IsNumeric(test))
                                                                            {

                                                                                double valToTest = Convert.ToDouble(test);
                                                                                if (result == -999999.1)
                                                                                {
                                                                                    result = valToTest;

                                                                                }
                                                                                else
                                                                                {
                                                                                    switch (statType.ToUpper())
                                                                                    {
                                                                                        case "MAX":
                                                                                            if (result < valToTest)
                                                                                            {
                                                                                                result = valToTest;

                                                                                            }
                                                                                            break;
                                                                                        case "MIN":
                                                                                            if (result > valToTest)
                                                                                            {
                                                                                                result = valToTest;

                                                                                            }
                                                                                            break;
                                                                                        case "SUM":
                                                                                            result += valToTest;

                                                                                            break;
                                                                                        case "AVERAGE":
                                                                                            result += valToTest;
                                                                                            AverageCount++;
                                                                                            break;
                                                                                        case "MEAN":
                                                                                            result += valToTest;
                                                                                            AverageCount++;

                                                                                            break;
                                                                                        case "CONCAT":
                                                                                            if (textRes.Contains(valToTest.ToString() + ConcatDelim))
                                                                                            {
                                                                                            }
                                                                                            else if (textRes.Contains(ConcatDelim + valToTest.ToString()))
                                                                                            {
                                                                                            }
                                                                                            else
                                                                                            {

                                                                                                if (textRes == "")
                                                                                                {
                                                                                                    textRes += valToTest.ToString();
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    textRes += ConcatDelim + valToTest.ToString();
                                                                                                }

                                                                                            }

                                                                                            break;
                                                                                        default:
                                                                                            AAState.WriteLine("                  ERROR: Unsupported stat type: " + test);
                                                                                            break;
                                                                                    }

                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                switch (statType.ToUpper())
                                                                                {

                                                                                    case "CONCAT":
                                                                                        if (textRes.Contains(test.ToString() + ConcatDelim))
                                                                                        {
                                                                                        }
                                                                                        else if (textRes.Contains(ConcatDelim + test.ToString()))
                                                                                        {
                                                                                        }
                                                                                        else
                                                                                        {

                                                                                            if (textRes == "")
                                                                                            {
                                                                                                textRes += test;
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                textRes += ConcatDelim + test;
                                                                                            }

                                                                                        }

                                                                                        break;
                                                                                    default:
                                                                                        AAState.WriteLine("                  ERROR/WARNING: Non numeric value returned: " + test);

                                                                                        AAState.WriteLine("                  ERROR: Unsupported stat type: " + test);
                                                                                        break;
                                                                                }

                                                                            }

                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  Checking if Edge is To Edge, skipping");

                                                                        }
                                                                    }
                                                                    catch
                                                                    {
                                                                    }
                                                                }//end loop
                                                                try
                                                                {
                                                                    if (textRes != "")
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], textRes);
                                                                    }
                                                                    else if (result != -999999.1)
                                                                    {
                                                                        if (AverageCount != 0)
                                                                        {
                                                                            result = result / AverageCount;
                                                                        }
                                                                        inObject.set_Value(intFldIdxs[0], result);

                                                                    }
                                                                    else
                                                                    {
                                                                        IField field = inObject.Fields.get_Field(intFldIdxs[0]);
                                                                        object newval = field.DefaultValue;
                                                                        if (newval == null)
                                                                        {
                                                                            if (field.IsNullable)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], null);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[0], newval);
                                                                        }
                                                                    }
                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    AAState.WriteLine("                  ERROR: Value was not set on feature: " + ex.Message);

                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  No Connected Edges Found");
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  not an junction feature");
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  Not a Geometric Network Feature");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: TO_EDGE_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: TO_EDGE_STATS");
                                            }
                                            break;

                                        case "EDGE_STATS":
                                            try
                                            {
                                                if (valData == null) break;
                                                args = valData.Split('|');
                                                string statType = "MAX";
                                                switch (args.GetLength(0))
                                                {
                                                    case 1:
                                                        sourceFieldName = args[0].ToString();
                                                        break;
                                                    case 2:
                                                        sourceFieldName = args[0].ToString();
                                                        statType = args[1].ToString();
                                                        break;

                                                    default: break;
                                                }

                                                AAState.WriteLine("                  Trying: EDGE_STATS");

                                                int AverageCount = 0;
                                                double result = -999999.1;
                                                string textRes = "";
                                                if (inFeature != null)
                                                {
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        AAState.WriteLine("                  Feature is a network feature");
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                        {
                                                            AAState.WriteLine("                  Feature is a junction feature");
                                                            iJuncFeat = (IJunctionFeature)netFeat;
                                                            // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                            ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                            if (iSJunc == null)
                                                                break;
                                                            AAState.WriteLine("                  Edge Count: " + iSJunc.EdgeFeatureCount);
                                                            if (iSJunc.EdgeFeatureCount <= 0)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount > 0)
                                                            {
                                                                for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                {
                                                                    AAState.WriteLine("                  Edge Count: " + iSJunc.EdgeFeatureCount);

                                                                    iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                    try
                                                                    {

                                                                        IRow pRow = iEdgeFeat as IRow;

                                                                        // verify that field (in junction) to copy exists
                                                                        AAState.WriteLine("                  Getting Field From Edge");
                                                                        juncField = pRow.Fields.FindField(sourceFieldName);
                                                                        string test = pRow.get_Value(juncField).ToString();
                                                                        if (Globals.IsNumeric(test))
                                                                        {

                                                                            double valToTest = Convert.ToDouble(test);
                                                                            if (result == -999999.1)
                                                                            {
                                                                                result = valToTest;

                                                                            }
                                                                            else
                                                                            {
                                                                                switch (statType.ToUpper())
                                                                                {
                                                                                    case "MAX":
                                                                                        if (result < valToTest)
                                                                                        {
                                                                                            result = valToTest;

                                                                                        }
                                                                                        break;
                                                                                    case "MIN":
                                                                                        if (result > valToTest)
                                                                                        {
                                                                                            result = valToTest;

                                                                                        }
                                                                                        break;
                                                                                    case "SUM":
                                                                                        result += valToTest;

                                                                                        break;
                                                                                    case "AVERAGE":
                                                                                        result += valToTest;
                                                                                        AverageCount++;
                                                                                        break;
                                                                                    case "MEAN":
                                                                                        result += valToTest;
                                                                                        AverageCount++;

                                                                                        break;
                                                                                    case "CONCAT":
                                                                                        if (textRes.Contains(valToTest.ToString() + ConcatDelim))
                                                                                        {
                                                                                        }
                                                                                        else if (textRes.Contains(ConcatDelim + valToTest.ToString()))
                                                                                        {
                                                                                        }
                                                                                        else
                                                                                        {

                                                                                            if (textRes == "")
                                                                                            {
                                                                                                textRes += valToTest.ToString();
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                textRes += ConcatDelim + valToTest.ToString();
                                                                                            }

                                                                                        }

                                                                                        break;
                                                                                    default:
                                                                                        AAState.WriteLine("                  ERROR: Unsupported stat type: " + test);
                                                                                        break;
                                                                                }

                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            switch (statType.ToUpper())
                                                                            {

                                                                                case "CONCAT":
                                                                                    if (textRes.Contains(test.ToString() + ConcatDelim))
                                                                                    {
                                                                                    }
                                                                                    else if (textRes.Contains(ConcatDelim + test.ToString()))
                                                                                    {
                                                                                    }
                                                                                    else
                                                                                    {

                                                                                        if (textRes == "")
                                                                                        {
                                                                                            textRes += test;
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            textRes += ConcatDelim + test;
                                                                                        }
                                                                                    }

                                                                                    break;
                                                                                default:
                                                                                    AAState.WriteLine("                  ERROR/WARNING: Non numeric value returned: " + test);

                                                                                    AAState.WriteLine("                  ERROR: Unsupported stat type: " + test);
                                                                                    break;
                                                                            }

                                                                        }

                                                                    }
                                                                    catch
                                                                    {
                                                                    }
                                                                }//end loop
                                                                try
                                                                {
                                                                    if (textRes != "")
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], textRes);
                                                                    }
                                                                    else if (result != -999999.1)
                                                                    {
                                                                        if (AverageCount != 0)
                                                                        {
                                                                            result = result / AverageCount;
                                                                        }
                                                                        inObject.set_Value(intFldIdxs[0], result);

                                                                    }
                                                                    else
                                                                    {
                                                                        IField field = inObject.Fields.get_Field(intFldIdxs[0]);
                                                                        object newval = field.DefaultValue;
                                                                        if (newval == null)
                                                                        {
                                                                            if (field.IsNullable)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], null);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[0], newval);
                                                                        }
                                                                    }
                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    AAState.WriteLine("                  ERROR: Value was not set on feature: " + ex.Message);

                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  No Connected Edges Found");
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  not an junction feature");
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  Not a Geometric Network Feature");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: TO_EDGE_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: TO_EDGE_STATS");
                                            }
                                            break;
                                        case "TO_EDGE_MULTI_FIELD_INTERSECT":
                                            try
                                            {
                                                if (valData == null) break;

                                                sourceFieldName = "";
                                                sourceField = -1;
                                                found = false;
                                                //LayerToIntersect|Field To Elevate
                                                // Parse arguments
                                                args = valData.Split('|');
                                                int popFldIdx = 0;
                                                if (args.GetLength(0) >= 2)
                                                {
                                                    AAState.WriteLine("                  Parsing Valueinfo");

                                                    sourceFieldName = args[0].ToString();
                                                    string[] fieldsToPop = args[1].ToString().Split(',');

                                                    AAState.WriteLine("                  Trying: TO_EDGE_MULTI_FIELD_INTERSECT");

                                                    if (inFeature != null)
                                                    {
                                                        netFeat = inFeature as INetworkFeature;
                                                        if (netFeat != null)
                                                        {
                                                            AAState.WriteLine("                  Feature is a network feature");
                                                            if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                            {
                                                                AAState.WriteLine("                  Feature is a junction feature");
                                                                iJuncFeat = (IJunctionFeature)netFeat;
                                                                // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                                ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                                if (iSJunc == null)
                                                                    break;
                                                                AAState.WriteLine("                  Edge Count: " + iSJunc.EdgeFeatureCount);
                                                                if (iSJunc.EdgeFeatureCount <= 0)
                                                                    break;
                                                                if (iSJunc.EdgeFeatureCount > 0)
                                                                {
                                                                    for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                    {
                                                                        AAState.WriteLine("                  Edge Count: " + iSJunc.EdgeFeatureCount);

                                                                        iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                        try
                                                                        {
                                                                            AAState.WriteLine("                  Checking if Edge is From or To");

                                                                            iJuncFeat = iEdgeFeat.FromJunctionFeature;

                                                                            if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                            {
                                                                                AAState.WriteLine("                  Edge is a To-Edge");

                                                                                IRow pRow = iEdgeFeat as IRow;

                                                                                // verify that field (in junction) to copy exists
                                                                                AAState.WriteLine("                  Getting Field From To-Edge");
                                                                                juncField = pRow.Fields.FindField(sourceFieldName);
                                                                                string test = pRow.get_Value(juncField).ToString();
                                                                                if (fieldsToPop.Length == popFldIdx)
                                                                                    break;

                                                                                int tempFieldNum = inObject.Fields.FindField(fieldsToPop[popFldIdx]);

                                                                                if (tempFieldNum > -1)
                                                                                {
                                                                                    inObject.set_Value(tempFieldNum, test);
                                                                                    popFldIdx++;
                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  Checking if Edge is From Edge, skipping");

                                                                            }
                                                                        }
                                                                        catch
                                                                        {
                                                                        }
                                                                    }//end loop

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  No Connected Edges Found");
                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  not an junction feature");
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  Not a Geometric Network Feature");
                                                        }
                                                    }
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: TO_EDGE_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: TO_EDGE_STATS");
                                            }
                                            break;
                                        case "FROM_EDGE_MULTI_FIELD_INTERSECT":
                                            try
                                            {
                                                if (valData == null) break;
                                                sourceFieldName = "";
                                                sourceField = -1;
                                                found = false;
                                                //LayerToIntersect|Field To Elevate
                                                // Parse arguments
                                                args = valData.Split('|');
                                                int popFldIdx = 0;
                                                if (args.GetLength(0) >= 2)
                                                {
                                                    AAState.WriteLine("                  Parsing Valueinfo");

                                                    sourceFieldName = args[0].ToString();
                                                    string[] fieldsToPop = args[1].ToString().Split(',');

                                                    AAState.WriteLine("                  Trying: FROM_EDGE_MULTI_FIELD_INTERSECT");

                                                    if (inFeature != null)
                                                    {
                                                        netFeat = inFeature as INetworkFeature;
                                                        if (netFeat != null)
                                                        {
                                                            AAState.WriteLine("                  Feature is a network feature");
                                                            if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                            {
                                                                AAState.WriteLine("                  Feature is a junction feature");
                                                                iJuncFeat = (IJunctionFeature)netFeat;
                                                                // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                                ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                                if (iSJunc == null)
                                                                    break;
                                                                AAState.WriteLine("                  Edge Count: " + iSJunc.EdgeFeatureCount);
                                                                if (iSJunc.EdgeFeatureCount <= 0)
                                                                    break;
                                                                if (iSJunc.EdgeFeatureCount > 0)
                                                                {
                                                                    for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                    {
                                                                        AAState.WriteLine("                  Edge Count: " + iSJunc.EdgeFeatureCount);

                                                                        iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                        try
                                                                        {
                                                                            AAState.WriteLine("                  Checking if Edge is From or To");

                                                                            iJuncFeat = iEdgeFeat.ToJunctionFeature;

                                                                            if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                            {
                                                                                AAState.WriteLine("                  Edge is a From-Edge");

                                                                                IRow pRow = iEdgeFeat as IRow;

                                                                                // verify that field (in junction) to copy exists
                                                                                AAState.WriteLine("                  Getting Field From From-Edge");
                                                                                juncField = pRow.Fields.FindField(sourceFieldName);
                                                                                string test = pRow.get_Value(juncField).ToString();
                                                                                if (fieldsToPop.Length == popFldIdx)
                                                                                    break;

                                                                                int tempFieldNum = inObject.Fields.FindField(fieldsToPop[popFldIdx]);

                                                                                if (tempFieldNum > -1)
                                                                                {
                                                                                    inObject.set_Value(tempFieldNum, test);
                                                                                    popFldIdx++;
                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  Checking if Edge is To Edge, skipping");

                                                                            }
                                                                        }
                                                                        catch
                                                                        {
                                                                        }
                                                                    }//end loop

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  No Connected Edges Found");
                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  not an junction feature");
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  Not a Geometric Network Feature");
                                                        }
                                                    }
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: TO_EDGE_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: TO_EDGE_STATS");
                                            }
                                            break;

                                        case "FROM_JUNCTION_FIELD":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: FROM_JUNCTION_FIELD");
                                                if (valData == null)
                                                {
                                                    AAState.WriteLine("                  Value info is null");
                                                    break;
                                                }
                                                if (inFeature != null)
                                                {
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge)
                                                        {
                                                            string netField = "";
                                                            string netRestrictFC = "";
                                                            string netRestrictField = "";
                                                            string netRestrictValue = "";
                                                            args = valData.Split('|');
                                                            switch (args.GetLength(0))
                                                            {
                                                                case 1:  // sequenceColumnName only
                                                                    netField = args[0].ToString().Trim();
                                                                    break;
                                                                case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    break;
                                                                case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    break;
                                                                case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    netRestrictValue = args[3].ToString().Trim();
                                                                    break;
                                                                default: break;
                                                            }

                                                            iEdgeFeat = (IEdgeFeature)netFeat;
                                                            iJuncFeat = iEdgeFeat.FromJunctionFeature;
                                                            if (netRestrictFC != "")
                                                            {
                                                                string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class));

                                                                AAState.WriteLine("                  Layer restriction found, Class name of junction is: " + strClsName);
                                                                if (strClsName != netRestrictFC)
                                                                {
                                                                    AAState.WriteLine("                  Layer restriction does not match, breaking");
                                                                    break;
                                                                }
                                                                AAState.WriteLine("                  Layer restriction matches, checking for field restriction");
                                                                if (netRestrictField != "" && netRestrictValue != "")
                                                                {
                                                                    int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField);

                                                                    if (intTmpFld > -1)
                                                                    {
                                                                        if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                        {
                                                                            AAState.WriteLine("                  Values Match");
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  Values dont match Match");
                                                                            break;

                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + netRestrictField + " was not found");
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  Missing Field restriction and value info");
                                                                }
                                                            }
                                                            // verify that field (in junction) to copy exists
                                                            juncField = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netField);
                                                            if (juncField > -1)
                                                            {
                                                                inObject.set_Value(intFldIdxs[0], ((IFeature)iJuncFeat).get_Value(juncField));
                                                            }
                                                            else
                                                                AAState.WriteLine("                  " + netField + " field not found");
                                                        }
                                                        else
                                                            AAState.WriteLine("                  not an edge feature");
                                                    }
                                                    else
                                                        AAState.WriteLine("                  Not a network feature");
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: FROM_JUNCTION_FIELD: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: FROM_JUNCTION_FIELD");
                                            }
                                            break;

                                        //Release: 1.2
                                        //New Dynamic Value Method: TO_JUNCTION_FIELD transfers a field value from a junction connected at terminal end of a line feature
                                        case "TO_JUNCTION_FIELD":
                                            try
                                            {

                                                AAState.WriteLine("                  Trying: TO_JUNCTION_FIELD");
                                                if (valData == null)
                                                {
                                                    AAState.WriteLine("                  Value info is null");
                                                    break;
                                                }
                                                if (inFeature != null)
                                                {

                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge)
                                                        {

                                                            string netField = "";
                                                            string netRestrictFC = "";
                                                            string netRestrictField = "";
                                                            string netRestrictValue = "";
                                                            args = valData.Split('|');
                                                            switch (args.GetLength(0))
                                                            {
                                                                case 1:  // sequenceColumnName only
                                                                    netField = args[0].ToString().Trim();
                                                                    break;
                                                                case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    break;
                                                                case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    break;
                                                                case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    netRestrictValue = args[3].ToString().Trim();
                                                                    break;
                                                                default: break;
                                                            }

                                                            iEdgeFeat = (IEdgeFeature)netFeat;
                                                            iJuncFeat = iEdgeFeat.ToJunctionFeature;

                                                            if (netRestrictFC != "")
                                                            {
                                                                string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class));

                                                                AAState.WriteLine("                  Layer restriction found, Class name of junction is: " + strClsName);
                                                                if (strClsName != netRestrictFC)
                                                                {
                                                                    AAState.WriteLine("                  Layer restriction does not match, breaking");
                                                                    break;
                                                                }
                                                                AAState.WriteLine("                  Layer restriction matches, checking for field restriction");
                                                                if (netRestrictField != "" && netRestrictValue != "")
                                                                {
                                                                    int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField);

                                                                    if (intTmpFld > -1)
                                                                    {
                                                                        if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                        {
                                                                            AAState.WriteLine("                  Values Match");
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  Values dont match Match");
                                                                            break;

                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + netRestrictField + " was not found");
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  Missing Field restriction and value info");
                                                                }
                                                            }
                                                            // verify that field (in junction) to copy exists
                                                            juncField = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netField);

                                                            //juncField = ((IFeature)iJuncFeat).Fields.FindField(valData as string);
                                                            if (juncField > -1)
                                                            {
                                                                inObject.set_Value(intFldIdxs[0], ((IFeature)iJuncFeat).get_Value(juncField));
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + netField + " field not found");
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  not an edge feature");
                                                    }
                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  not an geometric network feature");
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: TO_JUNCTION_FIELD:" + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: TO_JUNCTION_FIELD");
                                            }
                                            break;

                                        //Release: 1.2
                                        //New Dynamic Value Method: GENERATE_ID - uses value in specificed table and increments it as specified
                                        case "GENERATE_ID":

                                            try
                                            {
                                                AAState.WriteLine("                  Trying: GENERATE_ID");
                                                if (AAState._gentab != null)
                                                {
                                                    sequenceColumnName = "";
                                                    sequenceColumnNum = -1;
                                                    sequenceValue = -1;
                                                    sequenceFixedWidth = "";
                                                    sequencePadding = 0;
                                                    formatString = "";

                                                    // Parse arguments
                                                    if (valData == null) break;
                                                    args = valData.Split('|');
                                                    switch (args.GetLength(0))
                                                    {
                                                        case 1:  // sequenceColumnName only
                                                            sequenceColumnName = args[0].ToString(); break;
                                                        case 2:  // sequenceColumnName|sequenceFixedWidth
                                                            sequenceColumnName = args[0].ToString();
                                                            sequenceFixedWidth = args[1].ToString();
                                                            break;
                                                        case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                            sequenceColumnName = args[0].ToString();
                                                            sequenceFixedWidth = args[1].ToString();
                                                            formatString = args[2].ToString();
                                                            break;
                                                        default: break;
                                                    }

                                                    //Check for requested zero padding of sequence number
                                                    if (sequenceFixedWidth != "")
                                                        int.TryParse(sequenceFixedWidth.ToString(), out sequencePadding);
                                                    if (sequencePadding > 25)
                                                    {

                                                        AAState.WriteLine("                  WARNING: you are trying to pad your id with a more than 25 - 0's");
                                                        AAState.WriteLine("                  WARNING: " + sequencePadding + " 0's is what you have");

                                                    }
                                                    else if (sequencePadding > 50)
                                                    {
                                                        MessageBox.Show("You are trying to add 50 places to your ID, this is not supported, please fix your dynamic value table");
                                                    }
                                                    qFilter = new QueryFilterClass();
                                                    qFilter.WhereClause = "SEQNAME = '" + sequenceColumnName + "'";
                                                    cCurs = AAState._gentab.Update(qFilter, false);
                                                    sequenceColumnNum = AAState._gentab.Fields.FindField("SEQCOUNTER");
                                                    //get value of first row, increment it, and return incremented value
                                                    for (int j = 0; j < 51; j++)
                                                    {
                                                        row = cCurs.NextRow();
                                                        if (row == null)
                                                        {
                                                            break;
                                                        }
                                                        if (row.get_Value(sequenceColumnNum) == null)
                                                        {
                                                            sequenceValue = 0;
                                                        }
                                                        else if (row.get_Value(sequenceColumnNum).ToString() == "")
                                                        {
                                                            sequenceValue = 0;
                                                        }
                                                        else
                                                            sequenceValue = Convert.ToInt32(row.get_Value(sequenceColumnNum));

                                                        sequenceValue += 1;
                                                        // _editEvents.OnChangeFeature -= OnChangeFeature;
                                                        // _editEvents.OnCreateFeature -= OnCreateFeature;

                                                        row.set_Value(sequenceColumnNum, sequenceValue);
                                                        AAState.WriteLine("                  " + row.Fields.get_Field(sequenceColumnNum).AliasName + " changed to " + sequenceValue);
                                                        //AAState.changeFeature -= OnChangeFeature;
                                                        //AAState.createFeature -= OnCreateFeature;

                                                        row.Store();
                                                        //AAState.changeFeature += OnChangeFeature;
                                                        //AAState.createFeature += OnCreateFeature;

                                                        //  _editEvents.OnChangeFeature += OnChangeFeature;
                                                        //  _editEvents.OnCreateFeature += OnCreateFeature;
                                                        if (Convert.ToInt32(row.get_Value(sequenceColumnNum)) == sequenceValue)
                                                            break;

                                                    }
                                                    if (sequenceValue == -1)
                                                    {
                                                        AAState.WriteLine("                  ERROR: GENERATE_ID: Sequence Not Found");
                                                    }

                                                    else
                                                    {
                                                        if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeString)
                                                            if (formatString == null || formatString == "" || formatString.ToLower().IndexOf("[seq]") == -1)
                                                            {
                                                                string setVal = (sequenceValue.ToString("D" + sequencePadding) + sequencePostfix).ToString();

                                                                if (inObject.Fields.get_Field(intFldIdxs[0]).Length < setVal.Length && inObject.Fields.get_Field(intFldIdxs[0]).Length != 0)
                                                                {
                                                                    AAState.WriteLine("                  ERROR: " + sequenceValue + " is to long for field " + row.Fields.get_Field(sequenceColumnNum).AliasName);
                                                                }
                                                                else
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], sequenceValue.ToString("D" + sequencePadding) + sequencePostfix);
                                                                    AAState.WriteLine("                  " + inObject.Fields.get_Field(intFldIdxs[0]).AliasName + " set to " + sequenceValue.ToString("D" + sequencePadding) + sequencePostfix);

                                                                }

                                                            }
                                                            else
                                                            {

                                                                int locIdx = formatString.ToUpper().IndexOf("[SEQ]");
                                                                if (locIdx >= 0)
                                                                {
                                                                    formatString = formatString.Remove(locIdx, 5);
                                                                    formatString = formatString.Insert(locIdx, sequenceValue.ToString("D" + sequencePadding));
                                                                }
                                                                //formatString = formatString.Replace("[seq]", sequenceValue.ToString("D" + sequencePadding));

                                                                if (inObject.Fields.get_Field(intFldIdxs[0]).Length < formatString.Length && inObject.Fields.get_Field(intFldIdxs[0]).Length != 0)
                                                                {
                                                                    AAState.WriteLine("                  ERROR: " + formatString + " is to long for field " + row.Fields.get_Field(sequenceColumnNum).AliasName);
                                                                }
                                                                else
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], formatString);
                                                                    AAState.WriteLine("                  " + inObject.Fields.get_Field(intFldIdxs[0]).AliasName + " set to " + formatString);
                                                                }

                                                            }
                                                        else
                                                        {

                                                            inObject.set_Value(intFldIdxs[0], sequenceValue);
                                                            AAState.WriteLine("                  " + sequenceColumnNum + " changed to " + sequenceValue);
                                                        }
                                                    }

                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  ERROR: GENERATE_ID table is not found");

                                                }

                                            }

                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: GENERATE_ID: " + ex.Message);
                                            }
                                            finally
                                            {
                                                if (cCurs != null)
                                                {
                                                    Marshal.ReleaseComObject(cCurs);
                                                    GC.Collect(300);
                                                    GC.WaitForFullGCComplete();
                                                    cCurs = null;

                                                }
                                                AAState.WriteLine("                  Finished: GENERATE_ID");
                                            }
                                            break;

                                        case "GENERATE_ID_BY_INTERSECT":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: GENERATE_ID_BY_INTERSECT");
                                                if (AAState._gentab != null && inFeature != null && !(inFeature.Shape.IsEmpty))
                                                {
                                                    sequenceColumnName = "";
                                                    sequenceColumnNum = -1;
                                                    sequenceValue = -1;
                                                    sequenceFixedWidth = "";
                                                    sequencePadding = 0;
                                                    //genIdAreaFieldName = "";
                                                    intersectLayerName = "";
                                                    intersectLayerFieldName = "";
                                                    formatString = "";
                                                    intersectFieldPos = -1;

                                                    // Parse arguments
                                                    if (valData == null) break;

                                                    args = valData.Split('|');
                                                    if (args.GetLength(0) < 3)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Improper value method");
                                                        break;
                                                    }
                                                    switch (args.GetLength(0))
                                                    {
                                                        case 3:  //columnName
                                                            intersectLayerName = args[0].ToString();
                                                            intersectLayerFieldName = args[1].ToString();
                                                            // genIdAreaFieldName = args[2].ToString();
                                                            sequenceColumnName = args[2].ToString();
                                                            break;
                                                        case 4:  // columnName|sequenceFixedWidth
                                                            //sequenceFixedWidth formats the sequence with leading zeros to create specified width
                                                            intersectLayerName = args[0].ToString();
                                                            intersectLayerFieldName = args[1].ToString();
                                                            //genIdAreaFieldName = args[2].ToString();
                                                            sequenceColumnName = args[2].ToString();
                                                            sequenceFixedWidth = Convert.ToString(0);
                                                            formatString = args[3].ToString();

                                                            break;
                                                        case 5:  // columnName|sequenceFixedWidth|formatString
                                                            //formatString must contain [seq] and [id]  and may contain [area] plus any desired text
                                                            intersectLayerName = args[0].ToString();
                                                            intersectLayerFieldName = args[1].ToString();
                                                            //genIdAreaFieldName = args[2].ToString();
                                                            sequenceColumnName = args[2].ToString();
                                                            sequenceFixedWidth = args[3].ToString();
                                                            formatString = args[4].ToString();
                                                            break;
                                                        default: break;
                                                    }

                                                    //Find Area Layer
                                                    // FindLayerByName(areaLayerName, out areaLayer);

                                                    boolLayerOrFC = true;
                                                    if (intersectLayerName.Contains("("))
                                                    {
                                                        string[] tempSplt = intersectLayerName.Split('(');
                                                        intersectLayerName = tempSplt[0];
                                                        intersectLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC);
                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        intersectLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC);

                                                    }
                                                    if (intersectLayer == null)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Intersecting feature Layer(" + intersectLayerName + ") not found");
                                                        break;
                                                    }
                                                    //Find Area Field
                                                    intersectFieldPos = intersectLayer.FeatureClass.FindField(intersectLayerFieldName);
                                                    if (intersectFieldPos < 0)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Intersecting feature Layer Field(" + intersectLayerFieldName + ") not found");
                                                        break;
                                                    }

                                                    //Find GenID Area Field
                                                    //genIdAreaFieldPos = areaLayer.FeatureClass.FindField(genIdAreaFieldName);
                                                    //if (genIdAreaFieldPos < 0) break;

                                                    //Perform spatial search
                                                    IGeometry pSearchGeo = (IGeometry)inFeature.ShapeCopy;
                                                    pSearchGeo.SpatialReference = (inFeature.Class as IGeoDataset).SpatialReference;
                                                    pSearchGeo.Project((intersectLayer as IGeoDataset).SpatialReference);
                                                    //sFilter = new SpatialFilterClass();
                                                    //sFilter.Geometry = pSearchGeo;
                                                    //sFilter.GeometryField = intersectLayer.FeatureClass.ShapeFieldName;
                                                    //sFilter.SubFields = intersectLayerFieldName;
                                                    //sFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                                    sFilter = Globals.createSpatialFilter(intersectLayer, inFeature, false);

                                                    //if (boolLayerOrFC)
                                                    //{
                                                    //    fCursor = intersectLayer.Search(sFilter, true);
                                                    //}
                                                    //else
                                                    //{
                                                    //    fCursor = intersectLayer.FeatureClass.Search(sFilter, true);
                                                    //}
                                                    pFS = (IFeatureSelection)intersectLayer;
                                                    if (boolLayerOrFC)
                                                    {
                                                        if (pFS.SelectionSet.Count > 0)
                                                        {
                                                            pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                            fCursor = cCurs as IFeatureCursor;

                                                        }
                                                        else
                                                        {
                                                            fCursor = intersectLayer.Search(sFilter, true);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        fCursor = intersectLayer.FeatureClass.Search(sFilter, true);
                                                    }

                                                    sourceFeature = fCursor.NextFeature();
                                                    intersectValue = "-9999.1";
                                                    if (sourceFeature == null)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Intersecting feature not found");
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        while (sourceFeature != null)
                                                        {
                                                            if (sourceFeature.Class != inFeature.Class)
                                                            {
                                                                intersectValue = sourceFeature.get_Value(intersectFieldPos).ToString();
                                                                break;
                                                            }
                                                            else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                            {
                                                                intersectValue = sourceFeature.get_Value(intersectFieldPos).ToString();
                                                                break;
                                                            }
                                                            sourceFeature = fCursor.NextFeature();
                                                        }
                                                    }
                                                    if (intersectValue == "-9999.1")
                                                    {
                                                        AAState.WriteLine("                  ERROR: Intersecting feature not found");
                                                        break;
                                                    }
                                                    //Check for requested zero padding of sequence number
                                                    if (sequenceFixedWidth != "")
                                                        int.TryParse(sequenceFixedWidth.ToString(), out sequencePadding);

                                                    if (sequencePadding > 25)
                                                    {
                                                        AAState.WriteLine("                  WARNING: you are trying to pad your id with a more than 25 - 0's");
                                                        AAState.WriteLine("                  WARNING: " + sequencePadding + " 0's is what you have");

                                                    }
                                                    sequenceColumnName = sequenceColumnName + intersectValue;
                                                    AAState.WriteLine("                  Looking for a field called " + sequenceColumnName + " in the generate ID table");

                                                    qFilter = new QueryFilterClass();
                                                    qFilter.WhereClause = "SEQNAME = '" + sequenceColumnName + "'";
                                                    cCurs = AAState._gentab.Update(qFilter, false);
                                                    sequenceColumnNum = AAState._gentab.Fields.FindField("SEQCOUNTER");

                                                    //get value of first row, increment it, and return incremented value
                                                    for (int j = 0; j < 51; j++)
                                                    {
                                                        row = cCurs.NextRow();
                                                        if (row == null)
                                                        {
                                                            break;
                                                        }
                                                        if (row.get_Value(sequenceColumnNum) == null)
                                                        {
                                                            sequenceValue = 0;
                                                        }
                                                        else if (row.get_Value(sequenceColumnNum).ToString() == "")
                                                        {
                                                            sequenceValue = 0;
                                                        }
                                                        else
                                                            sequenceValue = Convert.ToInt32(row.get_Value(sequenceColumnNum));

                                                        sequenceValue += 1;
                                                        row.set_Value(sequenceColumnNum, sequenceValue);
                                                        //AAState.changeFeature -= OnChangeFeature;
                                                        //AAState.createFeature -= OnCreateFeature;

                                                        row.Store();
                                                        //AAState.changeFeature += OnChangeFeature;
                                                        //AAState.createFeature += OnCreateFeature;

                                                        if (Convert.ToInt32(row.get_Value(sequenceColumnNum)) == sequenceValue)
                                                            break;

                                                    }
                                                    if (sequenceValue == -1)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Sequence number not found");
                                                    }
                                                    else
                                                    {
                                                        if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeString)
                                                            if (formatString == null || formatString == "" || (formatString.ToUpper().IndexOf("[SEQ]") == -1 && formatString.ToUpper().IndexOf("[ID]") == -1))
                                                                inObject.set_Value(intFldIdxs[0], intersectValue + sequenceValue.ToString("D" + sequencePadding) + sequencePostfix);
                                                            else
                                                            {

                                                                int locIdx = formatString.ToUpper().IndexOf("[ID]");
                                                                if (locIdx >= 0)
                                                                {
                                                                    formatString = formatString.Remove(locIdx, 4);
                                                                    formatString = formatString.Insert(locIdx, intersectValue);
                                                                }
                                                                //  formatString = formatString.Replace("[id]", intersectValue);
                                                                // formatString = formatString.Replace("[seq]", sequenceValue.ToString("D" + sequencePadding));
                                                                locIdx = formatString.ToUpper().IndexOf("[SEQ]");
                                                                if (locIdx >= 0)
                                                                {
                                                                    string sequenceValuePad = sequenceValue.ToString("D" + sequencePadding);
                                                                    formatString = formatString.Remove(locIdx, 5);
                                                                    formatString = formatString.Insert(locIdx, sequenceValuePad.ToString());
                                                                }
                                                                //
                                                                inObject.set_Value(intFldIdxs[0], formatString);
                                                            }
                                                        else
                                                            inObject.set_Value(intFldIdxs[0], sequenceValue);
                                                    }

                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  ERROR: GENERATE_ID table is not found");

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: GENERATE_ID_BY_INTERSECT: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: GENERATE_ID_BY_INTERSECT");
                                            }
                                            break;
                                        //Modified for Release 1.2  (No longer uses ICalculator)
                                        //Requires valid VBScript expression
                                        //Can include string, numeric, and date fields by name in square brackets []
                                        //Example: DateDiff("yyyy",[INSTALLDATE],Now())
                                        case "GENERATE_ID_OLD":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: GENERATE_ID");
                                                if (AAState._gentab != null)
                                                {
                                                    sequenceColumnName = "";
                                                    sequenceColumnNum = -1;
                                                    sequenceValue = -1;
                                                    sequenceFixedWidth = "";
                                                    sequencePadding = 0;
                                                    formatString = "";

                                                    // Parse arguments
                                                    if (valData == null) break;
                                                    args = valData.Split('|');
                                                    switch (args.GetLength(0))
                                                    {
                                                        case 1:  // sequenceColumnName only
                                                            sequenceColumnName = args[0].ToString(); break;
                                                        case 2:  // sequenceColumnName|sequenceFixedWidth
                                                            sequenceColumnName = args[0].ToString();
                                                            sequenceFixedWidth = args[1].ToString();
                                                            break;
                                                        case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                            sequenceColumnName = args[0].ToString();
                                                            sequenceFixedWidth = args[1].ToString();
                                                            formatString = args[2].ToString();
                                                            break;
                                                        default: break;
                                                    }

                                                    //Check for requested zero padding of sequence number
                                                    if (sequenceFixedWidth != "")
                                                        int.TryParse(sequenceFixedWidth.ToString(), out sequencePadding);
                                                    if (sequencePadding > 25)
                                                    {

                                                        AAState.WriteLine("                  WARNING: you are trying to pad your id with a more than 25 - 0's");
                                                        AAState.WriteLine("                  WARNING: " + sequencePadding + " 0's is what you have");

                                                    }
                                                    else if (sequencePadding > 50)
                                                    {
                                                        MessageBox.Show("You are trying to add 50 places to your ID, this is not supported, please fix your dynamic value table");
                                                    }

                                                    //Check for sequence column in generate id table
                                                    sequenceColumnNum = AAState._gentab.FindField(sequenceColumnName);
                                                    if (AAState._gentab.FindField(sequenceColumnName) >= 0)
                                                    {
                                                        //get value of first row, increment it, and return incremented value
                                                        for (int j = 0; j < 51; j++)
                                                        {
                                                            row = AAState._gentab.Update(null, false).NextRow();
                                                            if (row == null)
                                                            {
                                                                break;
                                                            }
                                                            if (row.get_Value(sequenceColumnNum) == null)
                                                            {
                                                                sequenceValue = 0;
                                                            }
                                                            else if (row.get_Value(sequenceColumnNum).ToString() == "")
                                                            {
                                                                sequenceValue = 0;
                                                            }
                                                            else
                                                                sequenceValue = Convert.ToInt32(row.get_Value(sequenceColumnNum));

                                                            sequenceValue += 1;
                                                            // _editEvents.OnChangeFeature -= OnChangeFeature;
                                                            // _editEvents.OnCreateFeature -= OnCreateFeature;

                                                            row.set_Value(sequenceColumnNum, sequenceValue);
                                                            AAState.WriteLine("                  " + row.Fields.get_Field(sequenceColumnNum).AliasName + " changed to " + sequenceValue);
                                                            //AAState.changeFeature -= OnChangeFeature;
                                                            //AAState.createFeature -= OnCreateFeature;

                                                            row.Store();
                                                            //AAState.changeFeature += OnChangeFeature;
                                                            //AAState.createFeature += OnCreateFeature;

                                                            //  _editEvents.OnChangeFeature += OnChangeFeature;
                                                            //  _editEvents.OnCreateFeature += OnCreateFeature;
                                                            if (Convert.ToInt32(row.get_Value(sequenceColumnNum)) == sequenceValue)
                                                                break;

                                                        }
                                                        if (sequenceValue == -1)
                                                        {
                                                            AAState.WriteLine("                  ERROR: GENERATE_ID: Sequence Not Found");
                                                        }

                                                        else
                                                        {
                                                            if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeString)
                                                                if (formatString == null || formatString == "" || formatString.ToLower().IndexOf("[seq]") == -1)
                                                                {
                                                                    string setVal = (sequenceValue.ToString("D" + sequencePadding) + sequencePostfix).ToString();

                                                                    if (inObject.Fields.get_Field(intFldIdxs[0]).Length < setVal.Length && inObject.Fields.get_Field(intFldIdxs[0]).Length != 0)
                                                                    {
                                                                        AAState.WriteLine("                  ERROR: " + sequenceValue + " is to long for field " + row.Fields.get_Field(sequenceColumnNum).AliasName);
                                                                    }
                                                                    else
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], sequenceValue.ToString("D" + sequencePadding) + sequencePostfix);
                                                                        AAState.WriteLine("                  " + inObject.Fields.get_Field(intFldIdxs[0]).AliasName + " set to " + sequenceValue.ToString("D" + sequencePadding) + sequencePostfix);

                                                                    }

                                                                }
                                                                else
                                                                {

                                                                    int locIdx = formatString.ToUpper().IndexOf("[SEQ]");
                                                                    if (locIdx >= 0)
                                                                    {
                                                                        formatString = formatString.Remove(locIdx, 5);
                                                                        formatString = formatString.Insert(locIdx, sequenceValue.ToString("D" + sequencePadding));
                                                                    }
                                                                    //formatString = formatString.Replace("[seq]", sequenceValue.ToString("D" + sequencePadding));

                                                                    if (inObject.Fields.get_Field(intFldIdxs[0]).Length < formatString.Length && inObject.Fields.get_Field(intFldIdxs[0]).Length != 0)
                                                                    {
                                                                        AAState.WriteLine("                  ERROR: " + formatString + " is to long for field " + row.Fields.get_Field(sequenceColumnNum).AliasName);
                                                                    }
                                                                    else
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], formatString);
                                                                        AAState.WriteLine("                  " + inObject.Fields.get_Field(intFldIdxs[0]).AliasName + " set to " + formatString);
                                                                    }

                                                                }
                                                            else
                                                            {

                                                                inObject.set_Value(intFldIdxs[0], sequenceValue);
                                                                AAState.WriteLine("                  " + sequenceColumnNum + " changed to " + sequenceValue);
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  Sequence Field not found");
                                                    }
                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  ERROR: GENERATE_ID table is not found");

                                                }

                                            }

                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: GENERATE_ID: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: GENERATE_ID");
                                            }
                                            break;

                                        case "GENERATE_ID_BY_INTERSECT_OLD":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: GENERATE_ID_BY_INTERSECT");
                                                if (AAState._gentab != null && inFeature != null && !(inFeature.Shape.IsEmpty))
                                                {
                                                    sequenceColumnName = "";
                                                    sequenceColumnNum = -1;
                                                    sequenceValue = -1;
                                                    sequenceFixedWidth = "";
                                                    sequencePadding = 0;
                                                    //genIdAreaFieldName = "";
                                                    intersectLayerName = "";
                                                    intersectLayerFieldName = "";
                                                    formatString = "";
                                                    intersectFieldPos = -1;

                                                    // Parse arguments
                                                    if (valData == null) break;

                                                    args = valData.Split('|');
                                                    if (args.GetLength(0) < 3)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Improper value method");
                                                        break;
                                                    }
                                                    switch (args.GetLength(0))
                                                    {
                                                        case 3:  //columnName
                                                            intersectLayerName = args[0].ToString();
                                                            intersectLayerFieldName = args[1].ToString();
                                                            // genIdAreaFieldName = args[2].ToString();
                                                            sequenceColumnName = args[2].ToString();
                                                            break;
                                                        case 4:  // columnName|sequenceFixedWidth
                                                            //sequenceFixedWidth formats the sequence with leading zeros to create specified width
                                                            intersectLayerName = args[0].ToString();
                                                            intersectLayerFieldName = args[1].ToString();
                                                            //genIdAreaFieldName = args[2].ToString();
                                                            sequenceColumnName = args[2].ToString();
                                                            sequenceFixedWidth = Convert.ToString(0);
                                                            formatString = args[3].ToString();

                                                            break;
                                                        case 5:  // columnName|sequenceFixedWidth|formatString
                                                            //formatString must contain [seq] and [id]  and may contain [area] plus any desired text
                                                            intersectLayerName = args[0].ToString();
                                                            intersectLayerFieldName = args[1].ToString();
                                                            //genIdAreaFieldName = args[2].ToString();
                                                            sequenceColumnName = args[2].ToString();
                                                            sequenceFixedWidth = args[3].ToString();
                                                            formatString = args[4].ToString();
                                                            break;
                                                        default: break;
                                                    }

                                                    //Find Area Layer
                                                    // FindLayerByName(areaLayerName, out areaLayer);

                                                    boolLayerOrFC = true;
                                                    if (intersectLayerName.Contains("("))
                                                    {
                                                        string[] tempSplt = intersectLayerName.Split('(');
                                                        intersectLayerName = tempSplt[0];
                                                        intersectLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC);

                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                    }

                                                    else
                                                    {
                                                        intersectLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC);
                                                    }
                                                    if (intersectLayer == null)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Intersecting feature Layer(" + intersectLayerName + ") not found");
                                                        break;
                                                    }
                                                    //Find Area Field
                                                    intersectFieldPos = intersectLayer.FeatureClass.FindField(intersectLayerFieldName);
                                                    if (intersectFieldPos < 0)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Intersecting feature Layer Field(" + intersectLayerFieldName + ") not found");
                                                        break;
                                                    }

                                                    //Find GenID Area Field
                                                    //genIdAreaFieldPos = areaLayer.FeatureClass.FindField(genIdAreaFieldName);
                                                    //if (genIdAreaFieldPos < 0) break;

                                                    //Perform spatial search
                                                    IGeometry pSearchGeo = (IGeometry)inFeature.ShapeCopy;
                                                    pSearchGeo.SpatialReference = (inFeature.Class as IGeoDataset).SpatialReference;
                                                    pSearchGeo.Project((intersectLayer as IGeoDataset).SpatialReference);
                                                    //sFilter = new SpatialFilterClass();
                                                    //sFilter.Geometry = pSearchGeo;
                                                    //sFilter.GeometryField = intersectLayer.FeatureClass.ShapeFieldName;
                                                    //sFilter.SubFields = intersectLayerFieldName;
                                                    //sFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                                    sFilter = Globals.createSpatialFilter(intersectLayer, inFeature, false);

                                                    //if (boolLayerOrFC)
                                                    //{
                                                    //    fCursor = intersectLayer.Search(sFilter, true);
                                                    //}
                                                    //else
                                                    //{
                                                    //    fCursor = intersectLayer.FeatureClass.Search(sFilter, true);
                                                    //}
                                                    pFS = (IFeatureSelection)intersectLayer;
                                                    if (boolLayerOrFC)
                                                    {
                                                        if (pFS.SelectionSet.Count > 0)
                                                        {
                                                            pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                            fCursor = cCurs as IFeatureCursor;

                                                        }
                                                        else
                                                        {
                                                            fCursor = intersectLayer.Search(sFilter, true);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        fCursor = intersectLayer.FeatureClass.Search(sFilter, true);
                                                    }

                                                    sourceFeature = fCursor.NextFeature();
                                                    intersectValue = "-9999.1";
                                                    if (sourceFeature == null)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Intersecting feature not found");
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        while (sourceFeature != null)
                                                        {
                                                            if (sourceFeature.Class != inFeature.Class)
                                                            {
                                                                intersectValue = sourceFeature.get_Value(intersectFieldPos).ToString();
                                                                break;
                                                            }
                                                            else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                            {
                                                                intersectValue = sourceFeature.get_Value(intersectFieldPos).ToString();
                                                                break;
                                                            }
                                                            sourceFeature = fCursor.NextFeature();
                                                        }
                                                    }
                                                    if (intersectValue == "-9999.1")
                                                    {
                                                        AAState.WriteLine("                  ERROR: Intersecting feature not found");
                                                        break;
                                                    }

                                                    //Check for requested zero padding of sequence number
                                                    if (sequenceFixedWidth != "")
                                                        int.TryParse(sequenceFixedWidth.ToString(), out sequencePadding);

                                                    if (sequencePadding > 25)
                                                    {
                                                        AAState.WriteLine("                  WARNING: you are trying to pad your id with a more than 25 - 0's");
                                                        AAState.WriteLine("                  WARNING: " + sequencePadding + " 0's is what you have");

                                                    }

                                                    sequenceColumnName = sequenceColumnName + intersectValue;
                                                    AAState.WriteLine("                  Looking for a field called " + sequenceColumnName + " in the generate ID table");
                                                    sequenceColumnNum = AAState._gentab.FindField(sequenceColumnName);
                                                    if (sequenceColumnNum > -1)
                                                    {
                                                        AAState.WriteLine("                  Field Found");

                                                        //get value of first row, increment it, and return incremented value
                                                        for (int j = 0; j < 51; j++)
                                                        {
                                                            row = AAState._gentab.Update(qFilter, false).NextRow();
                                                            if (row.get_Value(sequenceColumnNum) == null)
                                                            {
                                                                sequenceValue = 0;
                                                            }
                                                            else if (row.get_Value(sequenceColumnNum).ToString() == "")
                                                            {
                                                                sequenceValue = 0;
                                                            }
                                                            else
                                                                sequenceValue = Convert.ToInt32(row.get_Value(sequenceColumnNum));
                                                            sequenceValue += 1;
                                                            row.set_Value(sequenceColumnNum, sequenceValue);
                                                            //AAState.changeFeature -= OnChangeFeature;
                                                            //AAState.createFeature -= OnCreateFeature;

                                                            row.Store();
                                                            //AAState.changeFeature += OnChangeFeature;
                                                            //AAState.createFeature += OnCreateFeature;

                                                            if (Convert.ToInt32(row.get_Value(sequenceColumnNum)) == sequenceValue)
                                                                break;

                                                        }
                                                        if (sequenceValue == -1)
                                                        {
                                                            AAState.WriteLine("                  ERROR: Sequence number not found");
                                                        }
                                                        else
                                                        {
                                                            if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeString)
                                                                if (formatString == null || formatString == "" || (formatString.ToUpper().IndexOf("[SEQ]") == -1 && formatString.ToUpper().IndexOf("[ID]") == -1))
                                                                    inObject.set_Value(intFldIdxs[0], intersectValue + sequenceValue.ToString("D" + sequencePadding) + sequencePostfix);
                                                                else
                                                                {

                                                                    int locIdx = formatString.ToUpper().IndexOf("[ID]");
                                                                    if (locIdx >= 0)
                                                                    {
                                                                        formatString = formatString.Remove(locIdx, 4);
                                                                        formatString = formatString.Insert(locIdx, intersectValue);
                                                                    }
                                                                    //  formatString = formatString.Replace("[id]", intersectValue);
                                                                    // formatString = formatString.Replace("[seq]", sequenceValue.ToString("D" + sequencePadding));
                                                                    locIdx = formatString.ToUpper().IndexOf("[SEQ]");
                                                                    if (locIdx >= 0)
                                                                    {
                                                                        formatString = formatString.Remove(locIdx, 5);
                                                                        formatString = formatString.Insert(locIdx, sequenceValue.ToString());
                                                                    }
                                                                    //
                                                                    inObject.set_Value(intFldIdxs[0], formatString);
                                                                }
                                                            else
                                                                inObject.set_Value(intFldIdxs[0], sequenceValue);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Field NOT Found");
                                                    }
                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  ERROR: GENERATE_ID table is not found");

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: GENERATE_ID_BY_INTERSECT: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: GENERATE_ID_BY_INTERSECT");
                                            }
                                            break;
                                        //Modified for Release 1.2  (No longer uses ICalculator)
                                        //Requires valid VBScript expression
                                        //Can include string, numeric, and date fields by name in square brackets []
                                        //Example: DateDiff("yyyy",[INSTALLDATE],Now())
                                        case "GENERATE_ID_BY_AREA":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: GENERATE_ID_BY_AREA");
                                                if (AAState._gentab != null && inFeature != null && !(inFeature.Shape.IsEmpty))
                                                {
                                                    sequenceColumnName = "";
                                                    sequenceColumnNum = -1;
                                                    sequenceValue = -1;
                                                    sequenceFixedWidth = "";
                                                    sequencePadding = 0;
                                                    genIdAreaFieldName = "";
                                                    areaLayerName = "";
                                                    areaLayerFieldName = "";
                                                    formatString = "";

                                                    // Parse arguments
                                                    if (valData == null) break;

                                                    args = valData.Split('|');
                                                    if (args.GetLength(0) < 3)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Improper Value Method");
                                                        break;
                                                    }
                                                    switch (args.GetLength(0))
                                                    {
                                                        case 4:  //columnName
                                                            areaLayerName = args[0].ToString();
                                                            areaLayerFieldName = args[1].ToString();
                                                            genIdAreaFieldName = args[2].ToString();
                                                            sequenceColumnName = args[3].ToString();
                                                            break;
                                                        case 5:  // columnName|sequenceFixedWidth
                                                            //sequenceFixedWidth formats the sequence with leading zeros to create specified width
                                                            areaLayerName = args[0].ToString();
                                                            areaLayerFieldName = args[1].ToString();
                                                            genIdAreaFieldName = args[2].ToString();
                                                            sequenceColumnName = args[3].ToString();
                                                            sequenceFixedWidth = args[4].ToString();
                                                            break;
                                                        case 6:  // columnName|sequenceFixedWidth|formatString
                                                            //formatString must contain [seq] and may contain [area] plus any desired text
                                                            areaLayerName = args[0].ToString();
                                                            areaLayerFieldName = args[1].ToString();
                                                            genIdAreaFieldName = args[2].ToString();
                                                            sequenceColumnName = args[3].ToString();
                                                            sequenceFixedWidth = args[4].ToString();
                                                            formatString = args[5].ToString();
                                                            break;
                                                        default: break;
                                                    }

                                                    //Find Area Layer
                                                    // FindLayerByName(areaLayerName, out areaLayer);

                                                    boolLayerOrFC = true;
                                                    if (areaLayerName.Contains("("))
                                                    {
                                                        string[] tempSplt = areaLayerName.Split('(');
                                                        areaLayerName = tempSplt[0];
                                                        areaLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, areaLayerName, ref boolLayerOrFC);
                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        areaLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, areaLayerName, ref boolLayerOrFC);
                                                    }
                                                    if (areaLayer == null)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Area Layer not found: " + areaLayerName);
                                                        break;
                                                    }

                                                    //Find Area Field
                                                    areaFieldPos = areaLayer.FeatureClass.FindField(areaLayerFieldName);
                                                    if (areaFieldPos < 0)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Area Layer field not found: " + areaLayerFieldName);
                                                        break;
                                                    }

                                                    //Find GenID Area Field
                                                    //genIdAreaFieldPos = areaLayer.FeatureClass.FindField(genIdAreaFieldName);
                                                    //if (genIdAreaFieldPos < 0) break;

                                                    //Perform spatial search
                                                    //sFilter = new SpatialFilterClass();
                                                    //sFilter.Geometry = (IGeometry)inFeature.ShapeCopy;
                                                    //sFilter.GeometryField = areaLayer.FeatureClass.ShapeFieldName;
                                                    //sFilter.SubFields = areaLayerFieldName;
                                                    //sFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                                    Globals.createSpatialFilter(areaLayer, inFeature, false);

                                                    //if (boolLayerOrFC)
                                                    //{
                                                    //    fCursor = areaLayer.Search(sFilter, true);
                                                    //}
                                                    //else
                                                    //{
                                                    //    fCursor = areaLayer.FeatureClass.Search(sFilter, true);
                                                    //}
                                                    pFS = (IFeatureSelection)areaLayer;
                                                    if (boolLayerOrFC)
                                                    {
                                                        if (pFS.SelectionSet.Count > 0)
                                                        {
                                                            pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                            fCursor = cCurs as IFeatureCursor;

                                                        }
                                                        else
                                                        {
                                                            fCursor = areaLayer.Search(sFilter, true);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        fCursor = areaLayer.FeatureClass.Search(sFilter, true);
                                                    }

                                                    sourceFeature = fCursor.NextFeature();
                                                    areaValue = "-9999.1";
                                                    if (sourceFeature == null)
                                                    {
                                                        AAState.WriteLine("                  ERROR: Intersecting feature not found");
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        while (sourceFeature != null)
                                                        {
                                                            if (sourceFeature.Class != inFeature.Class)
                                                            {
                                                                areaValue = sourceFeature.get_Value(areaFieldPos).ToString();
                                                                break;
                                                            }
                                                            if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                            {
                                                                areaValue = sourceFeature.get_Value(areaFieldPos).ToString();
                                                                break;
                                                            }
                                                            sourceFeature = fCursor.NextFeature();
                                                        }
                                                    }
                                                    if (areaValue == "-9999.1")
                                                    {
                                                        AAState.WriteLine("                  ERROR: Intersecting feature not found");
                                                        break;
                                                    }

                                                    //Check for requested zero padding of sequence number
                                                    if (sequenceFixedWidth != "")
                                                        int.TryParse(sequenceFixedWidth.ToString(), out sequencePadding);

                                                    sequenceColumnNum = AAState._gentab.FindField(sequenceColumnName);
                                                    if (sequenceColumnNum > -1)
                                                    {
                                                        qFilter = new QueryFilterClass();
                                                        qFilter.SubFields = areaLayerFieldName + "," + sequenceColumnName;

                                                        ISQLSyntax sqlSyntax = (ISQLSyntax)AAState._editor.EditWorkspace;
                                                        char[] charBuf = sqlSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix).ToCharArray();
                                                        string strSC = new string(charBuf);
                                                        switch (strSC)
                                                        {
                                                            case "":
                                                                qFilter.WhereClause = genIdAreaFieldName + " = '" + areaValue + "'";
                                                                break;
                                                            case "[":
                                                                qFilter.WhereClause = "[" + genIdAreaFieldName + "]" + " = '" + areaValue + "'";
                                                                break;
                                                            default:
                                                                qFilter.WhereClause = "\"" + genIdAreaFieldName + "\" = '" + areaValue + "'";
                                                                break;
                                                        }

                                                        //get value of first row, increment it, and return incremented value
                                                        for (int j = 0; j < 51; j++)
                                                        {
                                                            row = AAState._gentab.Update(qFilter, false).NextRow();
                                                            if (row.get_Value(sequenceColumnNum) == null)
                                                            {
                                                                sequenceValue = 0;
                                                            }
                                                            else if (row.get_Value(sequenceColumnNum).ToString() == "")
                                                            {
                                                                sequenceValue = 0;
                                                            }
                                                            else
                                                                sequenceValue = Convert.ToInt32(row.get_Value(sequenceColumnNum));
                                                            sequenceValue += 1;
                                                            sequenceValue += 1;
                                                            row.set_Value(sequenceColumnNum, sequenceValue);
                                                            //AAState.changeFeature -= OnChangeFeature;
                                                            //AAState.createFeature -= OnCreateFeature;

                                                            row.Store();
                                                            //AAState.changeFeature += OnChangeFeature;
                                                            //AAState.createFeature += OnCreateFeature;

                                                            if (Convert.ToInt32(row.get_Value(sequenceColumnNum)) == sequenceValue)
                                                                break;

                                                        }
                                                        if (sequenceValue == -1)
                                                        {
                                                            //TODO raise error
                                                        }
                                                        else
                                                        {
                                                            if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeString)
                                                                if (formatString == null || formatString == "" || formatString.IndexOf("[seq]") == -1)
                                                                    inObject.set_Value(intFldIdxs[0], areaValue + sequenceValue.ToString("D" + sequencePadding) + sequencePostfix);
                                                                else
                                                                {
                                                                    formatString = formatString.Replace("[area]", areaValue);
                                                                    formatString = formatString.Replace("[seq]", sequenceValue.ToString("D" + sequencePadding));
                                                                    inObject.set_Value(intFldIdxs[0], formatString);
                                                                }
                                                            else
                                                                inObject.set_Value(intFldIdxs[0], sequenceValue);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  ERROR: GENERATE_ID table is not found");

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: GENERATE_ID_BY_AREA: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: GENERATE_ID_BY_AREA");
                                            }

                                            break;
                                        //Modified for Release 1.2  (No longer uses ICalculator)
                                        //Requires valid VBScript expression
                                        //Can include string, numeric, and date fields by name in square brackets []
                                        //Example: DateDiff("yyyy",[INSTALLDATE],Now())
                                        case "EXPRESSION":
                                            try
                                            {

                                                AAState.WriteLine("                  Trying: EXPRESSION");
                                                if (inObject != null & valData != null)
                                                {
                                                    int intTargetFld = -1;
                                                    if (intFldIdxs.Count == 0)
                                                    {

                                                    }
                                                    else
                                                    {
                                                        intTargetFld = intFldIdxs[0];
                                                    }

                                                    newValue = valData;
                                                    for (int i = 0; i <= inObject.Fields.FieldCount; i++)
                                                    {

                                                        string strTmpFldName;
                                                        int intTmpIdx;
                                                        if (i == inObject.Fields.FieldCount)
                                                        {
                                                            testField = inObject.Fields.get_Field(intFldIdxs[0]);
                                                            strTmpFldName = "#";
                                                            intTmpIdx = intFldIdxs[0];
                                                        }
                                                        else
                                                        {
                                                            testField = inObject.Fields.get_Field(i);
                                                            strTmpFldName = testField.Name;
                                                            intTmpIdx = i;
                                                        }

                                                        int indFld = newValue.ToUpper().IndexOf("[" + strTmpFldName.ToUpper() + "]");
                                                        while (indFld >= 0)
                                                        {
                                                            AAState.WriteLine("                  replace field: " + testField.Name + " with a value");
                                                            int fldLen = strTmpFldName.Length;
                                                            string tmpStr1 = newValue.Substring(0, indFld + 1);
                                                            string tmpStr2 = newValue.Substring(indFld + fldLen + 1);
                                                            newValue = tmpStr1 + "_REPLACE_VAL_" + tmpStr2;

                                                            switch (testField.Type)
                                                            {
                                                                case esriFieldType.esriFieldTypeString:

                                                                    if (inObject.get_Value(intTmpIdx) == null || inObject.get_Value(intTmpIdx).ToString() == "")
                                                                    {
                                                                        if (newValue.Contains("IsNull"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("isNull"))
                                                                        {
                                                                            newValue = newValue.Replace("isNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("ISNULL"))
                                                                        {
                                                                            newValue = newValue.Replace("ISNULL([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == null)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == DBNull.Value)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx).ToString() == "")
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                        else
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        if (newValue.Contains("IsNull"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False");
                                                                        }

                                                                        else
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                    }

                                                                    // newValue = newValue.Replace("[" + testField.Name + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                    break;
                                                                case esriFieldType.esriFieldTypeDate:

                                                                    if (inObject.get_Value(intTmpIdx) == null || inObject.get_Value(intTmpIdx).ToString() == "" || inObject.get_Value(intTmpIdx) == DBNull.Value)
                                                                    {
                                                                        if (newValue.Contains("IsNull([" + "_REPLACE_VAL_" + "])"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("isNull([" + "_REPLACE_VAL_" + "])"))
                                                                        {
                                                                            newValue = newValue.Replace("isNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("ISNULL([" + "_REPLACE_VAL_" + "])"))
                                                                        {
                                                                            newValue = newValue.Replace("ISNULL([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == null)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == DBNull.Value)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");//"\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx).ToString() == "")
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                        else
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "CDATE(\"" + inObject.get_Value(intTmpIdx).ToString() + "\")");
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        if (newValue.Contains("IsNull"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False");
                                                                        }

                                                                        else
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "CDATE(\"" + inObject.get_Value(intTmpIdx).ToString() + "\")");
                                                                        }
                                                                    }

                                                                    // newValue = newValue.Replace("[" + testField.Name + "]", "CDATE(\"" + inObject.get_Value(intTmpIdx).ToString() + "\")");
                                                                    break;

                                                                default:
                                                                    if (inObject.get_Value(intTmpIdx) == null || inObject.get_Value(intTmpIdx).ToString() == "")
                                                                    {
                                                                        if (newValue.Contains("IsNull"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("isNull"))
                                                                        {
                                                                            newValue = newValue.Replace("isNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("ISNULL"))
                                                                        {
                                                                            newValue = newValue.Replace("ISNULL([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == null)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == DBNull.Value)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx).ToString() == "")
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");// "\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                        else
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "" + inObject.get_Value(intTmpIdx).ToString() + "");
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        if (newValue.Contains("IsNull"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False");
                                                                        }

                                                                        else
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", inObject.get_Value(intTmpIdx).ToString());
                                                                        }
                                                                    }
                                                                    //  newValue = newValue.Replace("[" + testField.Name + "]", inObject.get_Value(intTmpIdx).ToString());
                                                                    break;
                                                            }
                                                            indFld = newValue.ToUpper().IndexOf("[" + testField.Name.ToUpper() + "]");
                                                        }
                                                    }
                                                    //MessageBox.Show(newValue);

                                                    try
                                                    {
                                                        AAState.WriteLine("                  Checking to verify there is a field to store the expression");
                                                        if (intTargetFld > -1)
                                                        {
                                                            newValue = script.Eval(newValue).ToString();
                                                            if (newValue.ToUpper() == "<Null>".ToUpper())
                                                            {
                                                                AAState.WriteLine("                  Setting Null");
                                                                inObject.set_Value(intTargetFld, DBNull.Value);
                                                            }
                                                            else if (inObject.get_Value(intTargetFld).ToString() != newValue)
                                                            {
                                                                AAState.WriteLine("                  Setting Value to: " + newValue.Trim());
                                                                inObject.set_Value(intTargetFld, newValue.Trim());
                                                            }
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        AAState.WriteLine("                  ERROR: evaluating the expression for feature in " + inObject.Class.AliasName + " with OID of " + inObject.OID);
                                                        AAState.WriteLine("                         " + ex.Message);
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: EXPRESSION: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: EXPRESSION");
                                            }
                                            break;

                                        // GUID values are calculated into text fields or into native GUID field types
                                        // When using text field you have an optional argument (valdata) to specify the format
                                        // N-none 32 chars, D-dash 36, B-braces 38, P-Parenthesis 38
                                        case "GUID":
                                            try
                                            {
                                                if (inObject != null)
                                                {
                                                    if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeGUID)
                                                        inObject.set_Value(intFldIdxs[0], System.Guid.NewGuid().ToString("B"));
                                                    else if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeString &&
                                                             inObject.Fields.get_Field(intFldIdxs[0]).Length >= 32)
                                                    {

                                                        valData = valData.Trim();
                                                        if (valData != "N" && valData != "D" && valData != "B" && valData != "P")
                                                            if (inObject.Fields.get_Field(intFldIdxs[0]).Length >= 38)
                                                                valData = "B";  //Default to braces
                                                            else if (inObject.Fields.get_Field(intFldIdxs[0]).Length < 36)
                                                                valData = "N";
                                                            else
                                                                valData = "D";
                                                        inObject.set_Value(intFldIdxs[0], System.Guid.NewGuid().ToString(valData));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: EXPRESSION: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: EXPRESSION");
                                            }
                                            break;

                                        case "CREATE_LINKED_RECORD"://Feature Layer|Field To Copy|Field To Populate|Primary Key Field|Foreign Key Field
                                            {
                                                try
                                                {
                                                    AAState.WriteLine("                  Trying: CREATE_LINKED_RECORD");
                                                    if (!String.IsNullOrEmpty(valData))
                                                    {
                                                        args = valData.Split('|');
                                                        if (args.Length != 5)
                                                        {
                                                            AAState.WriteLine("                  ERROR: Format of valdata incorrect");
                                                            break;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Format of valdata incorrect");
                                                        break;
                                                    }
                                                    if (inFeature == null)
                                                    {
                                                        AAState.WriteLine("                  ERROR: The input features is null");
                                                        break;
                                                    }
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    sourceField = -1;
                                                    found = false;
                                                    AAState.WriteLine("                  Getting Value Info");
                                                    sourceLayerNames = args[0].ToString().Split(',');
                                                    sourceFieldName = args[1].ToString();
                                                    string targetFieldName = args[2].ToString();
                                                    string sourceIDFieldName = args[3].ToString();
                                                    string targetIDFieldName = args[4].ToString();
                                                    AAState.WriteLine("                  Checking values");
                                                    if (sourceFieldName != null)
                                                    {
                                                        AAState.WriteLine("                  Checking Fields in Source Layer");
                                                        int fldValToCopyIdx = inObject.Fields.FindField(sourceFieldName);
                                                        int fldIDToCopyIdx = inObject.Fields.FindField(sourceIDFieldName);
                                                        if (fldValToCopyIdx > -1 && fldIDToCopyIdx > -1)
                                                        {

                                                            for (int i = 0; i < sourceLayerNames.Length; i++)
                                                            {
                                                                sourceLayerName = sourceLayerNames[i].ToString();

                                                                if (sourceLayerName != "")
                                                                {

                                                                    // Get layer
                                                                    AAState.WriteLine("                  Checking for table to populate");
                                                                    bool FCorLayerSource = true;
                                                                    sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref FCorLayerSource);

                                                                    if (sourceLayer != null)
                                                                    {

                                                                    }
                                                                    else
                                                                    {
                                                                        ITable pTable = Globals.FindTable(AAState._editor.Map, sourceLayerName);
                                                                        if (pTable != null)
                                                                        {
                                                                            int fldValToPopIdx = pTable.Fields.FindField(targetFieldName);
                                                                            int fldIDToPopIdx = pTable.Fields.FindField(targetIDFieldName);
                                                                            if (fldValToPopIdx > -1 && fldIDToPopIdx > -1)
                                                                            {
                                                                                AAState.WriteLine("                  Trying to create a row in the target table");
                                                                                IRow pNewRow = pTable.CreateRow();
                                                                                AAState.WriteLine("                  Row Created");
                                                                                AAState.WriteLine("                  Trying to Copy ID");
                                                                                try
                                                                                {
                                                                                    pNewRow.set_Value(fldIDToPopIdx, inObject.get_Value(fldIDToCopyIdx));

                                                                                }
                                                                                catch
                                                                                {
                                                                                    AAState.WriteLine("                  ERROR: Could not Copy: " + inObject.get_Value(fldIDToCopyIdx) + " to field: " + targetIDFieldName);
                                                                                }
                                                                                AAState.WriteLine("                  ID successfully copied");
                                                                                AAState.WriteLine("                  Trying to Copy Value");
                                                                                try
                                                                                {
                                                                                    pNewRow.set_Value(fldValToPopIdx, inObject.get_Value(fldValToCopyIdx));

                                                                                }
                                                                                catch
                                                                                {
                                                                                    AAState.WriteLine("                  ERROR: Could not Copy: " + inObject.get_Value(fldValToCopyIdx) + " to field: " + targetFieldName);
                                                                                }
                                                                                //AAState.WriteLine("                  Value successfully copied");
                                                                                ////}
                                                                                //AAState.WriteLine("                  INFO: New feature being store, AA rules will fire on it now");
                                                                                //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                //AAState.indent = AAState.indent + "                                  ";
                                                                                //string rowFiltPre = AAState._dv.RowFilter;

                                                                                //pNewRow.Store();
                                                                                //AAState._dv.RowFilter = rowFiltPre;
                                                                                //AAState.indent = AAState.indent.Substring(0, AAState.indent.Length - "                                  ".Length);
                                                                                //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                //AAState.WriteLine("                  INFO: New Feature Complete");
                                                                                if (NewFeatureList == null)
                                                                                {
                                                                                    NewFeatureList = new List<IObject>();
                                                                                }
                                                                                IObject featobj = pNewRow as IObject;

                                                                                if (featobj != null)
                                                                                {
                                                                                    NewFeatureList.Add(featobj);
                                                                                }
                                                                                //featobj.Store();
                                                                                AAState.WriteLine("                  Row successfully stored");
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  ERROR: ID or Field to populate was not found");
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  ERROR: Table to populate not found: " + sourceLayerName);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR: ID or Field to Copy was not found");
                                                        }

                                                        //if ((!found) && (inObject.Fields.get_Field(intFldIdxs[0]).IsNullable))
                                                        //{
                                                        //    inObject.set_Value(intFldIdxs[0], null);
                                                        //}
                                                    }

                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: CREATE_LINKED_RECORD" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine("                  Finished: CREATE_LINKED_RECORD");
                                                    // intFldIdxs[0] = -1;

                                                }
                                                break;

                                            }

                                        case "UPDATE_INTERSECTING_FEATURE"://Intersected Feature|FieldIntersectingFeatureToChange|FromFieldinModifiedFeature
                                            {
                                                try
                                                {
                                                    IFeatureCursor fLocalCursor = null;
                                                    IFeature sourceFeatureLocal = null;
                                                    AAState.WriteLine("                  Trying: UPDATE_INTERSECTING_FEATURE");
                                                    if (!String.IsNullOrEmpty(valData))
                                                    {
                                                        args = valData.Split('|');
                                                        if (args.Length != 3)
                                                        {
                                                            AAState.WriteLine("                  ERROR: Format of valdata incorrect");
                                                            break;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Format of valdata incorrect");
                                                        break;
                                                    }
                                                    if (inFeature == null)
                                                    {
                                                        AAState.WriteLine("                  ERROR: The input features is null");
                                                        break;
                                                    }
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    sourceField = -1;
                                                    found = false;
                                                    AAState.WriteLine("                  Getting Value Info");
                                                    sourceLayerNames = args[0].ToString().Split(',');
                                                    sourceFieldName = args[1].ToString();
                                                    string targetFieldName = args[2].ToString();
                                                    AAState.WriteLine("                  Checking values");
                                                    if (sourceFieldName != null)
                                                    {
                                                        for (int i = 0; i < sourceLayerNames.Length; i++)
                                                        {
                                                            sourceLayerName = sourceLayerNames[i].ToString();
                                                            if (sourceLayerName != "")
                                                            {

                                                                boolLayerOrFC = true;
                                                                if (sourceLayerName.Contains("("))
                                                                {
                                                                    string[] tempSplt = sourceLayerName.Split('(');
                                                                    sourceLayerName = tempSplt[0];
                                                                    sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                    if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                    {
                                                                        boolLayerOrFC = true;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                    {
                                                                        boolLayerOrFC = true;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                    {
                                                                        boolLayerOrFC = false;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                    {
                                                                        boolLayerOrFC = false;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                    {
                                                                        boolLayerOrFC = false;
                                                                    }
                                                                    else
                                                                    {
                                                                        boolLayerOrFC = true;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                }
                                                                if (sourceLayer != null)
                                                                {

                                                                    if (Globals.IsEditable(ref sourceLayer, ref AAState._editor))
                                                                    {

                                                                        if (inObject.Class.ObjectClassID != sourceLayer.FeatureClass.ObjectClassID)
                                                                        {
                                                                            sourceField = sourceLayer.FeatureClass.FindField(sourceFieldName);

                                                                            if (sourceField > -1)
                                                                            {
                                                                                //sFilter = new SpatialFilterClass();
                                                                                sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false);

                                                                                int fldIdx = inFeature.Fields.FindField(targetFieldName);
                                                                                AAState.WriteLine("                  " + targetFieldName + " at index " + fldIdx);
                                                                                string test = targetFieldName;
                                                                                if (fldIdx > -1)
                                                                                {
                                                                                    test = inFeature.get_Value(fldIdx).ToString();
                                                                                    AAState.WriteLine("                  Value Found " + test);
                                                                                }
                                                                                AAState.WriteLine("                  Value used " + test);

                                                                                //if (boolLayerOrFC)
                                                                                //{
                                                                                //    fLocalCursor = sourceLayer.Search(sFilter, false);
                                                                                //}
                                                                                //else
                                                                                //{
                                                                                //    fLocalCursor = sourceLayer.FeatureClass.Search(sFilter, false);
                                                                                //}
                                                                                pFS = (IFeatureSelection)sourceLayer;
                                                                                if (boolLayerOrFC)
                                                                                {
                                                                                    if (pFS.SelectionSet.Count > 0)
                                                                                    {
                                                                                        pFS.SelectionSet.Search(sFilter, false, out cCurs);
                                                                                        fLocalCursor = cCurs as IFeatureCursor;

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        fLocalCursor = sourceLayer.Search(sFilter, false);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    fLocalCursor = sourceLayer.FeatureClass.Search(sFilter, false);
                                                                                }

                                                                                while ((sourceFeatureLocal = fLocalCursor.NextFeature()) != null)
                                                                                {
                                                                                    try
                                                                                    {
                                                                                        if (sourceFeatureLocal.Class.ObjectClassID != inFeature.Class.ObjectClassID)
                                                                                        {
                                                                                            if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeString)
                                                                                            {
                                                                                                sourceFeatureLocal.set_Value(sourceField, test);
                                                                                                //}
                                                                                                //AAState.WriteLine("                  INFO: New feature being store, AA rules will fire on it now");
                                                                                                //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                //AAState.indent = AAState.indent + "                                  ";
                                                                                                //string rowFiltPre = AAState._dv.RowFilter;
                                                                                                //sourceFeatureLocal.Store();
                                                                                                //AAState._dv.RowFilter = rowFiltPre;
                                                                                                //AAState.indent = AAState.indent.Substring(0, AAState.indent.Length - "                                  ".Length);
                                                                                                ////AAState.indent = AAState.indent.Substring(0, AAState.indent.Length-13);
                                                                                                //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                //AAState.WriteLine("                  INFO: New Feature Complete");

                                                                                                //AAState.changeFeature -= OnChangeFeature;
                                                                                                //AAState.createFeature -= OnCreateFeature;
                                                                                                //sourceFeatureLocal.Store();
                                                                                                //AAState.changeFeature += OnChangeFeature;
                                                                                                //AAState.createFeature += OnCreateFeature;

                                                                                                if (ChangeFeatureList == null)
                                                                                                {
                                                                                                    ChangeFeatureList = new List<IObject>();
                                                                                                }
                                                                                                ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                found = true;
                                                                                                //break;
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                if (Globals.IsNumeric(test))
                                                                                                {
                                                                                                    if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeSmallInteger ||
                                                                                                        sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeInteger)
                                                                                                    {

                                                                                                        sourceFeatureLocal.set_Value(sourceField, Convert.ToInt32(test));
                                                                                                        //AAState.WriteLine("                  INFO: New feature being store, AA rules will fire on it now");
                                                                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                        //AAState.indent = AAState.indent + "                                  ";
                                                                                                        //string rowFiltPre = AAState._dv.RowFilter;
                                                                                                        //sourceFeatureLocal.Store();
                                                                                                        //AAState._dv.RowFilter = rowFiltPre;
                                                                                                        //AAState.indent = AAState.indent.Substring(0, AAState.indent.Length - "                                  ".Length);
                                                                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");

                                                                                                        //AAState.WriteLine("                  INFO: New Feature Complete");

                                                                                                        //AAState.changeFeature -= OnChangeFeature;
                                                                                                        //AAState.createFeature -= OnCreateFeature;
                                                                                                        //sourceFeatureLocal.Store();
                                                                                                        //AAState.changeFeature += OnChangeFeature;
                                                                                                        //AAState.createFeature += OnCreateFeature;

                                                                                                        if (ChangeFeatureList == null)
                                                                                                        {
                                                                                                            ChangeFeatureList = new List<IObject>();
                                                                                                        }
                                                                                                        ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                        found = true;
                                                                                                        //break;
                                                                                                    }
                                                                                                    else if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeDouble ||
                                                                                                        sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeSingle)
                                                                                                    {
                                                                                                        sourceFeatureLocal.set_Value(sourceField, Convert.ToDouble(test));

                                                                                                        //AAState.WriteLine("                  INFO: New feature being store, AA rules will fire on it now");
                                                                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                        //AAState.indent = AAState.indent + "                                  ";
                                                                                                        //string rowFiltPre = AAState._dv.RowFilter;
                                                                                                        //sourceFeatureLocal.Store();
                                                                                                        //AAState._dv.RowFilter = rowFiltPre;
                                                                                                        //AAState.indent = AAState.indent.Substring(0, AAState.indent.Length - "                                  ".Length);
                                                                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                        //AAState.WriteLine("                  INFO: New Feature Complete");

                                                                                                        //AAState.changeFeature -= OnChangeFeature;
                                                                                                        //AAState.createFeature -= OnCreateFeature;
                                                                                                        //sourceFeatureLocal.Store();
                                                                                                        //AAState.changeFeature += OnChangeFeature;
                                                                                                        //AAState.createFeature += OnCreateFeature;

                                                                                                        if (ChangeFeatureList == null)
                                                                                                        {
                                                                                                            ChangeFeatureList = new List<IObject>();
                                                                                                        }
                                                                                                        ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                        found = true;
                                                                                                        //break;
                                                                                                    }
                                                                                                    else
                                                                                                    {
                                                                                                        sourceFeatureLocal.set_Value(sourceField, test as object);
                                                                                                        //AAState.WriteLine("                  INFO: New feature being store, AA rules will fire on it now");
                                                                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                        //AAState.indent = AAState.indent + "                                  ";
                                                                                                        //string rowFiltPre = AAState._dv.RowFilter;
                                                                                                        //sourceFeatureLocal.Store();
                                                                                                        //AAState._dv.RowFilter = rowFiltPre;
                                                                                                        //AAState.indent = AAState.indent.Substring(0, AAState.indent.Length - "                                  ".Length);
                                                                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                        //AAState.WriteLine("                  INFO: New Feature Complete");

                                                                                                        //AAState.changeFeature -= OnChangeFeature;
                                                                                                        //AAState.createFeature -= OnCreateFeature;
                                                                                                        //sourceFeatureLocal.Store();
                                                                                                        //AAState.changeFeature += OnChangeFeature;
                                                                                                        //AAState.createFeature += OnCreateFeature;

                                                                                                        if (ChangeFeatureList == null)
                                                                                                        {
                                                                                                            ChangeFeatureList = new List<IObject>();
                                                                                                        }
                                                                                                        ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                        found = true;
                                                                                                        //  break;
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    sourceFeatureLocal.set_Value(sourceField, test as object);
                                                                                                    //AAState.WriteLine("                  INFO: New feature being store, AA rules will fire on it now");
                                                                                                    //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                    //AAState.indent = AAState.indent + "                                  ";
                                                                                                    //string rowFiltPre = AAState._dv.RowFilter;
                                                                                                    //sourceFeatureLocal.Store();
                                                                                                    //AAState._dv.RowFilter = rowFiltPre;
                                                                                                    //AAState.indent = AAState.indent.Substring(0, AAState.indent.Length - "                                  ".Length);
                                                                                                    //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                    //AAState.WriteLine("                  INFO: New Feature Complete");

                                                                                                    //AAState.changeFeature -= OnChangeFeature;
                                                                                                    //AAState.createFeature -= OnCreateFeature;
                                                                                                    //sourceFeatureLocal.Store();
                                                                                                    //AAState.changeFeature += OnChangeFeature;
                                                                                                    //AAState.createFeature += OnCreateFeature;

                                                                                                    if (ChangeFeatureList == null)
                                                                                                    {
                                                                                                        ChangeFeatureList = new List<IObject>();
                                                                                                    }
                                                                                                    ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                    found = true;
                                                                                                    // break;
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                        else if (sourceFeatureLocal.Class == inFeature.Class && sourceFeatureLocal.OID != inFeature.OID)
                                                                                        {
                                                                                            if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeString)
                                                                                            {
                                                                                                sourceFeatureLocal.set_Value(sourceField, test);
                                                                                                //AAState.WriteLine("                  INFO: New feature being store, AA rules will fire on it now");
                                                                                                //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                //AAState.indent = AAState.indent + "                                  ";
                                                                                                //string rowFiltPre = AAState._dv.RowFilter;
                                                                                                //sourceFeatureLocal.Store();
                                                                                                //AAState._dv.RowFilter = rowFiltPre;
                                                                                                //AAState.indent = AAState.indent.Substring(0, AAState.indent.Length - "                                  ".Length);
                                                                                                //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                //AAState.WriteLine("                  INFO: New Feature Complete");

                                                                                                //AAState.changeFeature -= OnChangeFeature;
                                                                                                //AAState.createFeature -= OnCreateFeature;
                                                                                                //sourceFeatureLocal.Store();
                                                                                                //AAState.changeFeature += OnChangeFeature;
                                                                                                //AAState.createFeature += OnCreateFeature;

                                                                                                if (ChangeFeatureList == null)
                                                                                                {
                                                                                                    ChangeFeatureList = new List<IObject>();
                                                                                                }
                                                                                                ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                found = true;
                                                                                                //break;
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                if (Globals.IsNumeric(test))
                                                                                                {
                                                                                                    if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeSmallInteger ||
                                                                                                        sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeInteger)
                                                                                                    {

                                                                                                        sourceFeatureLocal.set_Value(sourceField, Convert.ToInt32(test));
                                                                                                        //AAState.WriteLine("                  INFO: New feature being store, AA rules will fire on it now");
                                                                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                        //AAState.indent = AAState.indent + "                                  ";
                                                                                                        //string rowFiltPre = AAState._dv.RowFilter;
                                                                                                        //sourceFeatureLocal.Store();
                                                                                                        //AAState._dv.RowFilter = rowFiltPre;
                                                                                                        //AAState.indent = AAState.indent.Substring(0, AAState.indent.Length - "                                  ".Length);
                                                                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                        //AAState.WriteLine("                  INFO: New Feature Complete");

                                                                                                        //AAState.changeFeature -= OnChangeFeature;
                                                                                                        //AAState.createFeature -= OnCreateFeature;
                                                                                                        //sourceFeatureLocal.Store();
                                                                                                        //AAState.changeFeature += OnChangeFeature;
                                                                                                        //AAState.createFeature += OnCreateFeature;

                                                                                                        if (ChangeFeatureList == null)
                                                                                                        {
                                                                                                            ChangeFeatureList = new List<IObject>();
                                                                                                        }
                                                                                                        ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                        found = true;
                                                                                                        //break;
                                                                                                    }
                                                                                                    else if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeDouble ||
                                                                                                        sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeSingle)
                                                                                                    {
                                                                                                        sourceFeatureLocal.set_Value(sourceField, Convert.ToDouble(test));

                                                                                                        //AAState.WriteLine("                  INFO: New feature being store, AA rules will fire on it now");
                                                                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                        //AAState.indent = AAState.indent + "                                  ";
                                                                                                        //string rowFiltPre = AAState._dv.RowFilter;
                                                                                                        //sourceFeatureLocal.Store();
                                                                                                        //AAState._dv.RowFilter = rowFiltPre;
                                                                                                        //AAState.indent = AAState.indent.Substring(0, AAState.indent.Length - "                                  ".Length);
                                                                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                        //AAState.WriteLine("                  INFO: New Feature Complete");

                                                                                                        //AAState.changeFeature -= OnChangeFeature;
                                                                                                        //AAState.createFeature -= OnCreateFeature;
                                                                                                        //sourceFeatureLocal.Store();
                                                                                                        //AAState.changeFeature += OnChangeFeature;
                                                                                                        //AAState.createFeature += OnCreateFeature;

                                                                                                        if (ChangeFeatureList == null)
                                                                                                        {
                                                                                                            ChangeFeatureList = new List<IObject>();
                                                                                                        }
                                                                                                        ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                        found = true;
                                                                                                        // break;
                                                                                                    }
                                                                                                    else
                                                                                                    {
                                                                                                        sourceFeatureLocal.set_Value(sourceField, test as object);
                                                                                                        //AAState.WriteLine("                  INFO: New feature being store, AA rules will fire on it now");
                                                                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                        //AAState.indent = AAState.indent + "                                  ";
                                                                                                        //string rowFiltPre = AAState._dv.RowFilter;
                                                                                                        //sourceFeatureLocal.Store();
                                                                                                        //AAState._dv.RowFilter = rowFiltPre;
                                                                                                        //AAState.indent = AAState.indent.Substring(0, AAState.indent.Length - "                                  ".Length);
                                                                                                        //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                        //AAState.WriteLine("                  INFO: New Feature Complete");

                                                                                                        //AAState.changeFeature -= OnChangeFeature;
                                                                                                        //AAState.createFeature -= OnCreateFeature;
                                                                                                        //sourceFeatureLocal.Store();
                                                                                                        //AAState.changeFeature += OnChangeFeature;
                                                                                                        //AAState.createFeature += OnCreateFeature;

                                                                                                        if (ChangeFeatureList == null)
                                                                                                        {
                                                                                                            ChangeFeatureList = new List<IObject>();
                                                                                                        }
                                                                                                        ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                        found = true;
                                                                                                        //break;
                                                                                                    }
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    sourceFeatureLocal.set_Value(sourceField, test as object);
                                                                                                    //AAState.WriteLine("                  INFO: New feature being store, AA rules will fire on it now");
                                                                                                    //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                    //AAState.indent = AAState.indent + "                                  ";
                                                                                                    //string rowFiltPre = AAState._dv.RowFilter;
                                                                                                    //sourceFeatureLocal.Store();
                                                                                                    //AAState._dv.RowFilter = rowFiltPre;
                                                                                                    //AAState.indent = AAState.indent.Substring(0, AAState.indent.Length - "                                  ".Length);
                                                                                                    //AAState.WriteLine("                  _|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_");
                                                                                                    //AAState.WriteLine("                  INFO: New Feature Complete");

                                                                                                    //AAState.changeFeature -= OnChangeFeature;
                                                                                                    //AAState.createFeature -= OnCreateFeature;
                                                                                                    //sourceFeatureLocal.Store();
                                                                                                    //AAState.changeFeature += OnChangeFeature;
                                                                                                    //AAState.createFeature += OnCreateFeature;

                                                                                                    if (ChangeFeatureList == null)
                                                                                                    {
                                                                                                        ChangeFeatureList = new List<IObject>();
                                                                                                    }
                                                                                                    ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                    found = true;
                                                                                                    //break;
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    catch
                                                                                    {
                                                                                        AAState.WriteLine("                  ERROR setting value");
                                                                                    }
                                                                                    finally
                                                                                    {

                                                                                    }
                                                                                    //if (found)
                                                                                    //{
                                                                                    //    break;

                                                                                    //}

                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  ERROR: Source field not found: " + sourceFieldName);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  ERROR: Source field not found: " + sourceFieldName);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  ERROR/WARNING: Source Layer is not editable: " + sourceLayerName);
                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  ERROR/WARNING: Source Layer not found: " + sourceLayerName);
                                                                }
                                                            }
                                                        }
                                                        if (found)
                                                        {
                                                            break;

                                                        }
                                                        //if ((!found) && (inObject.Fields.get_Field(intFldIdxs[0]).IsNullable))
                                                        //{
                                                        //    inObject.set_Value(intFldIdxs[0], null);
                                                        //}
                                                    }
                                                    fLocalCursor = null;
                                                    sourceFeatureLocal = null;

                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine("                  ERROR: UPDATE_INTERSECTING_FEATURE" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine("                  Finished: UPDATE_INTERSECTING_FEATURE");
                                                    // intFldIdxs[0] = -1;

                                                }
                                                break;

                                            }
                                        case "MULTI_FIELD_INTERSECT":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: MULTI_FIELD_INTERSECT");
                                                if (inFeature != null & valData != null)
                                                {
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    sourceField = -1;
                                                    found = false;
                                                    //LayerToIntersect|Field To Elevate
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    int popFldIdx = 0;
                                                    if (args.GetLength(0) > 2)
                                                    {
                                                        AAState.WriteLine("                  Parsing Valueinfo");

                                                        sourceLayerNames = args[0].ToString().Split(',');
                                                        sourceFieldName = args[1].ToString();
                                                        string[] fieldsToPop = args[2].ToString().Split(',');
                                                        if (args.GetLength(0) == 4)
                                                        {
                                                            AAState.WriteLine("                  Search distance specified");

                                                            if (Globals.IsDouble(args[3]))
                                                            {
                                                                searchDistance = Convert.ToDouble(args[3]);
                                                            }
                                                            else
                                                            {
                                                                searchDistance = 0.0;
                                                            }
                                                        }
                                                        else
                                                        {

                                                            searchDistance = 0.0;
                                                        }

                                                        if (sourceFieldName != null)
                                                        {
                                                            AAState.WriteLine("                  Looping Through Layers");

                                                            for (int i = 0; i < sourceLayerNames.Length; i++)
                                                            {
                                                                if (fieldsToPop.Length == popFldIdx)
                                                                    break;

                                                                sourceLayerName = sourceLayerNames[i].ToString();
                                                                if (sourceLayerName != "")
                                                                {

                                                                    boolLayerOrFC = true;
                                                                    if (sourceLayerName.Contains("("))
                                                                    {
                                                                        string[] tempSplt = sourceLayerName.Split('(');
                                                                        sourceLayerName = tempSplt[0];
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                    }

                                                                    else
                                                                    {
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                    }
                                                                    if (sourceLayer != null)
                                                                    {
                                                                        if (sourceLayer.FeatureClass != null)
                                                                        {
                                                                            sourceField = sourceLayer.FeatureClass.FindField(sourceFieldName);

                                                                            if (sourceField > -1)
                                                                            {
                                                                                //sFilter = new SpatialFilterClass();
                                                                                //if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
                                                                                //{

                                                                                //searchEnvelope = Globals.CalcSearchExtent(sourceLayer, inFeature, searchDistance);

                                                                                //    sFilter.Geometry = searchEnvelope;

                                                                                //}
                                                                                //else
                                                                                //{
                                                                                //    sFilter.Geometry = inFeature.ShapeCopy;
                                                                                //}
                                                                                //sFilter.GeometryField = sourceLayer.FeatureClass.ShapeFieldName;
                                                                                //sFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                                                                sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false);

                                                                                //if (boolLayerOrFC)
                                                                                //{
                                                                                //    fCursor = sourceLayer.Search(sFilter, true);
                                                                                //}
                                                                                //else
                                                                                //{
                                                                                //    fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                                //}
                                                                                pFS = (IFeatureSelection)sourceLayer;
                                                                                if (boolLayerOrFC)
                                                                                {
                                                                                    if (pFS.SelectionSet.Count > 0)
                                                                                    {
                                                                                        pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                                        fCursor = cCurs as IFeatureCursor;

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        fCursor = sourceLayer.Search(sFilter, true);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                                }

                                                                                while ((sourceFeature = fCursor.NextFeature()) != null)
                                                                                {
                                                                                    if (sourceFeature.Class != inFeature.Class)
                                                                                    {
                                                                                        if (fieldsToPop.Length == popFldIdx)
                                                                                            break;

                                                                                        string test = sourceFeature.get_Value(sourceField).ToString();

                                                                                        int tempFieldNum = inObject.Fields.FindField(fieldsToPop[popFldIdx]);
                                                                                        popFldIdx++;
                                                                                        if (tempFieldNum > -1)
                                                                                        {
                                                                                            inObject.set_Value(tempFieldNum, sourceFeature.get_Value(sourceField));
                                                                                        }

                                                                                    }
                                                                                    else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                                    {
                                                                                        if (fieldsToPop.Length == popFldIdx)
                                                                                            break;

                                                                                        string test = sourceFeature.get_Value(sourceField).ToString();

                                                                                        int tempFieldNum = inObject.Fields.FindField(fieldsToPop[popFldIdx]);
                                                                                        popFldIdx++;
                                                                                        if (tempFieldNum > -1)
                                                                                        {
                                                                                            inObject.set_Value(tempFieldNum, sourceFeature.get_Value(sourceField));
                                                                                        }

                                                                                    }
                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  ERROR: Source field not found: " + sourceFieldName);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  ERROR/WARNING: Datasource is invalid: " + sourceLayerName);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  ERROR/WARNING: Source Layer not found: " + sourceLayerName);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  ERROR/WARNING: Source Layer string is empty");

                                                                }
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR: Field name is invalid");

                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Invalid Value method definition");

                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: MULTI_FIELD_INTERSECT: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: MULTI_FIELD_INTERSECT");
                                            }
                                            break;
                                        case "INTERSECT_STATS":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: INTERSECT_STATS");
                                                if (inFeature != null & valData != null)
                                                {
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    sourceField = -1;
                                                    found = false;
                                                    //LayerToIntersect|Field To Elevate
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    int AverageCount = 0;
                                                    if (args.GetLength(0) > 2)
                                                    {
                                                        AAState.WriteLine("                  Parsing Valueinfo");

                                                        sourceLayerNames = args[0].ToString().Split(',');
                                                        sourceFieldName = args[1].ToString();
                                                        string statType = args[2].ToString();
                                                        if (args.GetLength(0) == 4)
                                                        {
                                                            AAState.WriteLine("                  Search distance specified");

                                                            if (Globals.IsDouble(args[3]))
                                                                searchDistance = Convert.ToDouble(args[3]);
                                                            else
                                                                searchDistance = 0.0;
                                                        }
                                                        else
                                                        {

                                                            searchDistance = 0.0;
                                                        }
                                                        double result = -999999.1;
                                                        string textRes = "";
                                                        if (sourceFieldName != null)
                                                        {
                                                            AAState.WriteLine("                  Looping Through Layers");

                                                            for (int i = 0; i < sourceLayerNames.Length; i++)
                                                            {

                                                                sourceLayerName = sourceLayerNames[i].ToString();
                                                                if (sourceLayerName != "")
                                                                {
                                                                    boolLayerOrFC = true;
                                                                    if (sourceLayerName.Contains("("))
                                                                    {
                                                                        string[] tempSplt = sourceLayerName.Split('(');
                                                                        sourceLayerName = tempSplt[0];
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                    }

                                                                    else
                                                                    {
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                    }

                                                                    if (sourceLayer != null)
                                                                    {
                                                                        if (sourceLayer.FeatureClass != null)
                                                                        {
                                                                            sourceField = sourceLayer.FeatureClass.FindField(sourceFieldName);

                                                                            if (sourceField > -1)
                                                                            {

                                                                                sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false);

                                                                                //if (boolLayerOrFC)
                                                                                //{
                                                                                //    fCursor = sourceLayer.Search(sFilter, true);
                                                                                //}
                                                                                //else
                                                                                //{
                                                                                //    fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                                //}

                                                                                pFS = (IFeatureSelection)sourceLayer;
                                                                                if (boolLayerOrFC)
                                                                                {
                                                                                    if (pFS.SelectionSet.Count > 0)
                                                                                    {
                                                                                        pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                                        fCursor = cCurs as IFeatureCursor;

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        fCursor = sourceLayer.Search(sFilter, true);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                                }
                                                                                sourceFeature = fCursor.NextFeature();
                                                                                while (sourceFeature != null)
                                                                                {
                                                                                    if (sourceFeature.Class != inFeature.Class)
                                                                                    {
                                                                                        string test = sourceFeature.get_Value(sourceField).ToString();
                                                                                        if (Globals.IsNumeric(test))
                                                                                        {

                                                                                            double valToTest = Convert.ToDouble(test);
                                                                                            if (result == -999999.1)
                                                                                            {
                                                                                                result = valToTest;

                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                switch (statType.ToUpper())
                                                                                                {
                                                                                                    case "MAX":
                                                                                                        if (result < valToTest)
                                                                                                        {
                                                                                                            result = valToTest;

                                                                                                        }
                                                                                                        break;
                                                                                                    case "MIN":
                                                                                                        if (result > valToTest)
                                                                                                        {
                                                                                                            result = valToTest;

                                                                                                        }
                                                                                                        break;
                                                                                                    case "SUM":
                                                                                                        result += valToTest;

                                                                                                        break;
                                                                                                    case "AVERAGE":
                                                                                                        result += valToTest;
                                                                                                        AverageCount++;
                                                                                                        break;
                                                                                                    case "MEAN":
                                                                                                        result += valToTest;
                                                                                                        AverageCount++;

                                                                                                        break;
                                                                                                    case "CONCAT":
                                                                                                        if (textRes.Contains(valToTest.ToString() + ConcatDelim))
                                                                                                        {
                                                                                                        }
                                                                                                        else if (textRes.Contains(ConcatDelim + valToTest.ToString()))
                                                                                                        {
                                                                                                        }
                                                                                                        else
                                                                                                        {

                                                                                                            if (textRes == "")
                                                                                                            {
                                                                                                                textRes += valToTest.ToString();
                                                                                                            }
                                                                                                            else
                                                                                                            {
                                                                                                                textRes += ConcatDelim + valToTest.ToString();
                                                                                                            }

                                                                                                        }

                                                                                                        break;
                                                                                                    default:
                                                                                                        AAState.WriteLine("                  ERROR: Unsupported stat type: " + test);
                                                                                                        break;
                                                                                                }

                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            switch (statType.ToUpper())
                                                                                            {

                                                                                                case "CONCAT":
                                                                                                    if (textRes.Contains(test.ToString() + ConcatDelim))
                                                                                                    {
                                                                                                    }
                                                                                                    else if (textRes.Contains(ConcatDelim + test.ToString()))
                                                                                                    {
                                                                                                    }
                                                                                                    else
                                                                                                    {

                                                                                                        if (textRes == "")
                                                                                                        {
                                                                                                            textRes += test;
                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            textRes += ConcatDelim + test;
                                                                                                        }
                                                                                                    }

                                                                                                    break;
                                                                                                default:
                                                                                                    AAState.WriteLine("                  ERROR/WARNING: Non numeric value returned: " + test);

                                                                                                    AAState.WriteLine("                  ERROR: Unsupported stat type: " + test);
                                                                                                    break;
                                                                                            }

                                                                                        }

                                                                                    }
                                                                                    else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                                    {
                                                                                        string test = sourceFeature.get_Value(sourceField).ToString();
                                                                                        if (Globals.IsNumeric(test))
                                                                                        {

                                                                                            double valToTest = Convert.ToDouble(test);
                                                                                            if (result == -999999.1)
                                                                                            {
                                                                                                result = valToTest;

                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                switch (statType.ToUpper())
                                                                                                {
                                                                                                    case "MAX":
                                                                                                        if (result < valToTest)
                                                                                                        {
                                                                                                            result = valToTest;

                                                                                                        }
                                                                                                        break;
                                                                                                    case "MIN":
                                                                                                        if (result > valToTest)
                                                                                                        {
                                                                                                            result = valToTest;

                                                                                                        }
                                                                                                        break;
                                                                                                    case "SUM":
                                                                                                        result += valToTest;

                                                                                                        break;
                                                                                                    case "AVERAGE":
                                                                                                        result += valToTest;
                                                                                                        AverageCount++;
                                                                                                        break;
                                                                                                    case "MEAN":
                                                                                                        result += valToTest;
                                                                                                        AverageCount++;

                                                                                                        break;
                                                                                                    case "CONCAT":
                                                                                                        if (textRes.Contains(valToTest.ToString() + ConcatDelim))
                                                                                                        {
                                                                                                        }
                                                                                                        else if (textRes.Contains(ConcatDelim + valToTest.ToString()))
                                                                                                        {
                                                                                                        }
                                                                                                        else
                                                                                                        {

                                                                                                            if (textRes == "")
                                                                                                            {
                                                                                                                textRes += valToTest.ToString();
                                                                                                            }
                                                                                                            else
                                                                                                            {
                                                                                                                textRes += ConcatDelim + valToTest.ToString();
                                                                                                            }

                                                                                                        }
                                                                                                        break;
                                                                                                    default:
                                                                                                        AAState.WriteLine("                  ERROR: Unsupported stat type: " + test);
                                                                                                        break;
                                                                                                }

                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            switch (statType.ToUpper())
                                                                                            {

                                                                                                case "CONCAT":
                                                                                                    if (textRes.Contains(test.ToString() + ConcatDelim))
                                                                                                    {
                                                                                                    }
                                                                                                    else if (textRes.Contains(ConcatDelim + test.ToString()))
                                                                                                    {
                                                                                                    }
                                                                                                    else
                                                                                                    {

                                                                                                        if (textRes == "")
                                                                                                        {
                                                                                                            textRes += test;
                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            textRes += ConcatDelim + test;
                                                                                                        }

                                                                                                    }
                                                                                                    break;
                                                                                                default:
                                                                                                    AAState.WriteLine("                  ERROR/WARNING: Non numeric value returned: " + test);

                                                                                                    AAState.WriteLine("                  ERROR: Unsupported stat type: " + test);
                                                                                                    break;
                                                                                            }

                                                                                        }
                                                                                    }
                                                                                    sourceFeature = fCursor.NextFeature();

                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  ERROR: Source field not found: " + sourceFieldName);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  ERROR/WARNING: Datasource is invalid: " + sourceLayerName);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  ERROR/WARNING: Source Layer not found: " + sourceLayerName);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  ERROR/WARNING: Source Layer string is empty");

                                                                }
                                                            }
                                                            try
                                                            {
                                                                if (textRes != "")
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], textRes);
                                                                }
                                                                else if (result != -999999.1)
                                                                {
                                                                    if (AverageCount != 0)
                                                                    {
                                                                        result = result / AverageCount;
                                                                    }
                                                                    inObject.set_Value(intFldIdxs[0], result);

                                                                }
                                                                else
                                                                {
                                                                    IField field = inObject.Fields.get_Field(intFldIdxs[0]);
                                                                    object newval = field.DefaultValue;
                                                                    if (newval == null)
                                                                    {
                                                                        if (field.IsNullable)
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[0], null);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], newval);
                                                                    }
                                                                }
                                                            }
                                                            catch (Exception ex)
                                                            {
                                                                AAState.WriteLine("                  ERROR: Value was not set on feature: " + ex.Message);

                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR: Field name is invalid");

                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Invalid Value method definition");

                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: INTERSECT_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: INTERSECT_STATS");
                                            }
                                            break;
                                        case "FEATURE_STATS":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: FEATURE_STATS");
                                                if (inFeature != null & valData != null)
                                                {

                                                    sourceFieldName = "";
                                                    sourceField = -1;
                                                    found = false;
                                                    //LayerToIntersect|Field To Elevate
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    int AverageCount = 0;
                                                    if (args.GetLength(0) > 1)
                                                    {
                                                        AAState.WriteLine("                  Parsing Valueinfo");

                                                        string[] sourceFieldNames = args[0].ToString().Split(',');
                                                        string statType = args[1].ToString();

                                                        double result = -999999.1;
                                                        string textRes = "";
                                                        if (sourceFieldNames != null)
                                                        {
                                                            AAState.WriteLine("                  Looping Through Fields");

                                                            for (int i = 0; i < sourceFieldNames.Length; i++)
                                                            {

                                                                sourceFieldName = sourceFieldNames[i].ToString();
                                                                if (sourceFieldName != "")
                                                                {

                                                                    sourceField = inObject.Fields.FindField(sourceFieldName);

                                                                    if (sourceField > -1)
                                                                    {
                                                                        string test = inObject.get_Value(sourceField).ToString();
                                                                        if (Globals.IsNumeric(test))
                                                                        {

                                                                            double valToTest = Convert.ToDouble(test);
                                                                            if (result == -999999.1)
                                                                            {
                                                                                result = valToTest;

                                                                            }
                                                                            else
                                                                            {
                                                                                switch (statType.ToUpper())
                                                                                {
                                                                                    case "MAX":
                                                                                        if (result < valToTest)
                                                                                        {
                                                                                            result = valToTest;

                                                                                        }
                                                                                        break;
                                                                                    case "MIN":
                                                                                        if (result > valToTest)
                                                                                        {
                                                                                            result = valToTest;

                                                                                        }
                                                                                        break;
                                                                                    case "SUM":
                                                                                        result += valToTest;

                                                                                        break;
                                                                                    case "AVERAGE":
                                                                                        result += valToTest;
                                                                                        AverageCount++;
                                                                                        break;
                                                                                    case "MEAN":
                                                                                        result += valToTest;
                                                                                        AverageCount++;

                                                                                        break;
                                                                                    case "CONCAT":
                                                                                        if (textRes.Contains(valToTest.ToString() + ConcatDelim))
                                                                                        {
                                                                                        }
                                                                                        else if (textRes.Contains(ConcatDelim + valToTest.ToString()))
                                                                                        {
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            if (textRes == "")
                                                                                            {
                                                                                                textRes += valToTest.ToString();
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                textRes += ConcatDelim + valToTest.ToString();
                                                                                            }
                                                                                        }

                                                                                        break;
                                                                                    default:
                                                                                        AAState.WriteLine("                  ERROR: Unsupported stat type: " + test);
                                                                                        break;
                                                                                }

                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            switch (statType.ToUpper())
                                                                            {

                                                                                case "CONCAT":
                                                                                    if (textRes.Contains(test.ToString() + ConcatDelim))
                                                                                    {
                                                                                    }
                                                                                    else if (textRes.Contains(ConcatDelim + test.ToString()))
                                                                                    {
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        if (textRes == "")
                                                                                        {
                                                                                            textRes += test;
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            textRes += ConcatDelim + test;
                                                                                        }
                                                                                    }

                                                                                    break;
                                                                                default:
                                                                                    AAState.WriteLine("                  ERROR/WARNING: Non numeric value returned: " + test);

                                                                                    AAState.WriteLine("                  ERROR: Unsupported stat type: " + test);
                                                                                    break;
                                                                            }
                                                                        }
                                                                    }
                                                                }

                                                            }
                                                            try
                                                            {
                                                                if (textRes != "")
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], textRes);
                                                                }
                                                                else if (result != -999999.1)
                                                                {
                                                                    if (AverageCount != 0)
                                                                    {
                                                                        result = result / AverageCount;
                                                                    }
                                                                    inObject.set_Value(intFldIdxs[0], result);

                                                                }
                                                                else
                                                                {
                                                                    IField field = inObject.Fields.get_Field(intFldIdxs[0]);
                                                                    object newval = field.DefaultValue;
                                                                    if (newval == null)
                                                                    {
                                                                        if (field.IsNullable)
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[0], null);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], newval);
                                                                    }
                                                                }
                                                            }
                                                            catch (Exception ex)
                                                            {
                                                                AAState.WriteLine("                  ERROR: Value was not set on feature: " + ex.Message);

                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR: Field name is invalid");

                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Invalid Value method definition");

                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: FEATURE_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: FEATURE_STATS");
                                            }
                                            break;
                                        case "INTERSECTING_EDGE":
                                            try
                                            {
                                                if (valData == null) break;
                                                args = valData.Split('|');
                                                switch (args.GetLength(0))
                                                {
                                                    case 1:
                                                        sourceFieldName = args[0].ToString();
                                                        break;
                                                    case 2:
                                                        sourceFieldName = args[1].ToString();
                                                        break;

                                                    default: break;
                                                }

                                                AAState.WriteLine("                  Trying: INTERSECTING_EDGE");

                                                if (inFeature != null)
                                                {
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        AAState.WriteLine("                  Feature is a network feature");
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                        {
                                                            AAState.WriteLine("                  Feature is a junction feature");
                                                            iJuncFeat = (IJunctionFeature)netFeat;

                                                            ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                            if (iSJunc == null)
                                                                break;
                                                            AAState.WriteLine("                  Edge Count: " + iSJunc.EdgeFeatureCount);
                                                            if (iSJunc.EdgeFeatureCount <= 0)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount > 0)
                                                            {
                                                                for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                {

                                                                    iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                    try
                                                                    {

                                                                        IRow pRow = iEdgeFeat as IRow;

                                                                        // verify that field (in junction) to copy exists
                                                                        AAState.WriteLine("                  Getting Field From Edge");
                                                                        juncField = pRow.Fields.FindField(sourceFieldName);
                                                                        string test = pRow.get_Value(juncField).ToString();
                                                                        AAState.WriteLine("                  Attempting to store: " + test);
                                                                        inObject.set_Value(intFldIdxs[0], test);
                                                                        continue;
                                                                    }
                                                                    catch
                                                                    {
                                                                    }
                                                                }//end loop
                                                                try
                                                                {

                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    AAState.WriteLine("                  ERROR: Value was not set on feature: " + ex.Message);

                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  No Connected Edges Found");
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  not an junction feature");
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  Not a Geometric Network Feature");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: INTERSECTING_EDGE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: INTERSECTING_EDGE");
                                            }
                                            break;
                                        case "INTERSECTING_FEATURE":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: INTERSECTING_FEATURE");
                                                if (inFeature != null & valData != null)
                                                {
                                                    AAState.WriteLine("                  Starting to process rule");
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    sourceField = -1;
                                                    found = false;
                                                    AAState.WriteLine("                  Value Info is: " + valData);
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    //if (args.GetLength(0) >= 2)
                                                    if (args.Length >= 2)
                                                    {
                                                        AAState.intersectOptions strOpt = AAState.intersectOptions.First;
                                                        switch (args.Length)
                                                        {
                                                            case 2:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                sourceFieldName = args[1].ToString();
                                                                break;
                                                            case 3:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                sourceFieldName = args[1].ToString();
                                                                switch (args[2].ToString().ToUpper())
                                                                {
                                                                    case "PROMPT":
                                                                        strOpt = AAState.intersectOptions.PromptMulti;
                                                                        break;
                                                                    case "P":
                                                                        strOpt = AAState.intersectOptions.PromptMulti;
                                                                        break;
                                                                    case "CENTROID":
                                                                        strOpt = AAState.intersectOptions.Centroid;
                                                                        break;
                                                                    case "C":
                                                                        strOpt = AAState.intersectOptions.Centroid;
                                                                        break;
                                                                    case "F":
                                                                        strOpt = AAState.intersectOptions.First;
                                                                        break;
                                                                    case "FIRST":
                                                                        strOpt = AAState.intersectOptions.First;
                                                                        break;
                                                                }
                                                                break;
                                                            default: break;
                                                        }

                                                        if (sourceFieldName != null)
                                                        {
                                                            List<Globals.OptionsToPresent> pFoundFeat = new List<Globals.OptionsToPresent>();

                                                            for (int i = 0; i < sourceLayerNames.Length; i++)
                                                            {
                                                                sourceLayerName = sourceLayerNames[i].ToString();
                                                                if (sourceLayerName != "")
                                                                {
                                                                    boolLayerOrFC = true;

                                                                    if (sourceLayerName.Contains("("))
                                                                    {
                                                                        string[] tempSplt = sourceLayerName.Split('(');
                                                                        sourceLayerName = tempSplt[0];
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }

                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }

                                                                    }
                                                                    else
                                                                    {
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                                    }
                                                                    // Get layer

                                                                    if (sourceLayer != null)
                                                                    {
                                                                        AAState.WriteLine("                  Layer Found: " + sourceLayer.Name);

                                                                        sourceField = sourceLayer.FeatureClass.FindField(sourceFieldName);
                                                                        AAState.WriteLine("                  " + sourceFieldName + ": at " + sourceField);
                                                                        if (sourceField > -1)
                                                                        {

                                                                            sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, strOpt == AAState.intersectOptions.Centroid);
                                                                            if (sFilter == null)
                                                                            {
                                                                                AAState.WriteLine("                  Filter is null, this will cause an error");
                                                                                continue;
                                                                            }
                                                                            //if (boolLayerOrFC)
                                                                            //{
                                                                            //    fCursor = sourceLayer.Search(sFilter, true);
                                                                            //}
                                                                            //else
                                                                            //{
                                                                            //    fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                            //}

                                                                            pFS = (IFeatureSelection)sourceLayer;
                                                                            if (boolLayerOrFC)
                                                                            {
                                                                                AAState.WriteLine("                  Searching on Layer");
                                                                                if (pFS.SelectionSet.Count > 0)
                                                                                {
                                                                                    AAState.WriteLine("                  Searching on Selection Set");
                                                                                    pFS.SelectionSet.Search(sFilter, true, out cCurs);

                                                                                    fCursor = cCurs as IFeatureCursor;

                                                                                    AAState.WriteLine("                  Cursor created");
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  No Selected Features");
                                                                                    fCursor = sourceLayer.Search(sFilter, true);
                                                                                    AAState.WriteLine("                  Cursor created");
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  Searching on feature Class");
                                                                                fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                                AAState.WriteLine("                  Cursor created");
                                                                            }
                                                                            if (fCursor == null)
                                                                            {
                                                                                AAState.WriteLine("                  Cursor is null");
                                                                                continue;
                                                                            }
                                                                            AAState.WriteLine("                  Starring Loop of found features");
                                                                            while ((sourceFeature = fCursor.NextFeature()) != null)
                                                                            {
                                                                                AAState.WriteLine("                  Checking Class");
                                                                                if (sourceFeature.Class != inFeature.Class)
                                                                                {
                                                                                    AAState.WriteLine("                  Different FCs");
                                                                                    if (strOpt == AAState.intersectOptions.PromptMulti)
                                                                                    {

                                                                                        Globals.OptionsToPresent pOp = new Globals.OptionsToPresent();
                                                                                        pOp.Display = sourceFeature.get_Value(sourceFeature.Fields.FindField(sourceLayer.DisplayField)).ToString();
                                                                                        if (pOp.Display.Trim() != "")
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + pOp.Display;

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID;

                                                                                        }
                                                                                        pOp.OID = sourceFeature.OID;
                                                                                        pOp.LayerName = sourceLayer.Name;

                                                                                        pFoundFeat.Add(pOp);
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        string test = sourceFeature.get_Value(sourceField).ToString();
                                                                                        AAState.WriteLine("                  Setting Value: " + test);
                                                                                        inObject.set_Value(intFldIdxs[0], sourceFeature.get_Value(sourceField));
                                                                                        AAState.WriteLine("                  Value Set");
                                                                                        found = true;
                                                                                    }
                                                                                }
                                                                                else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                                {
                                                                                    AAState.WriteLine("                  Same FC");
                                                                                    if (strOpt == AAState.intersectOptions.PromptMulti)
                                                                                    {
                                                                                        //pFoundFeat.Add(sourceFeature.OID.ToString());
                                                                                        Globals.OptionsToPresent pOp = new Globals.OptionsToPresent();
                                                                                        pOp.Display = sourceFeature.get_Value(sourceFeature.Fields.FindField(sourceLayer.DisplayField)).ToString();
                                                                                        if (pOp.Display.Trim() != "")
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + pOp.Display;

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID;

                                                                                        }
                                                                                        pOp.OID = sourceFeature.OID;
                                                                                        pOp.LayerName = sourceLayer.Name;

                                                                                        pFoundFeat.Add(pOp);
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        string test = sourceFeature.get_Value(sourceField).ToString();
                                                                                        AAState.WriteLine("                  Setting Value: " + test);

                                                                                        inObject.set_Value(intFldIdxs[0], sourceFeature.get_Value(sourceField));
                                                                                        AAState.WriteLine("                  Value Set");

                                                                                        found = true;
                                                                                    }
                                                                                }
                                                                                if (found == true)
                                                                                    break;

                                                                            }

                                                                            if (found == false && AAState._CheckEnvelope && pFoundFeat.Count == 0)
                                                                            {
                                                                                sFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects;
                                                                                //  sFilter.SpatialRelDescription = "T*T***T*T";
                                                                                //if (boolLayerOrFC)
                                                                                //{
                                                                                //    fCursor = sourceLayer.Search(sFilter, true);
                                                                                //}
                                                                                //else
                                                                                //{
                                                                                //    fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                                //}

                                                                                pFS = (IFeatureSelection)sourceLayer;
                                                                                if (boolLayerOrFC)
                                                                                {
                                                                                    if (pFS.SelectionSet.Count > 0)
                                                                                    {
                                                                                        pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                                        fCursor = cCurs as IFeatureCursor;

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        fCursor = sourceLayer.Search(sFilter, true);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                                }
                                                                                sourceFeature = fCursor.NextFeature();
                                                                                while (sourceFeature != null)
                                                                                {
                                                                                    if (strOpt == AAState.intersectOptions.PromptMulti)
                                                                                    {
                                                                                        Globals.OptionsToPresent pOp = new Globals.OptionsToPresent();
                                                                                        pOp.Display = sourceFeature.get_Value(sourceFeature.Fields.FindField(sourceLayer.DisplayField)).ToString();
                                                                                        if (pOp.Display.Trim() != "")
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + pOp.Display;

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID;

                                                                                        }
                                                                                        pOp.OID = sourceFeature.OID;
                                                                                        pOp.LayerName = sourceLayer.Name;

                                                                                        pFoundFeat.Add(pOp);
                                                                                        //pFoundFeat.Add(sourceFeature.OID.ToString());
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        if (found)
                                                                                        {
                                                                                            break;
                                                                                        }
                                                                                        string test = sourceFeature.get_Value(sourceField).ToString();
                                                                                        AAState.WriteLine("                  Setting Value: " + test);

                                                                                        inObject.set_Value(intFldIdxs[0], sourceFeature.get_Value(sourceField));
                                                                                        AAState.WriteLine("                  Value Set");

                                                                                        found = true;

                                                                                    }
                                                                                    sourceFeature = fCursor.NextFeature();
                                                                                }

                                                                            }

                                                                            if (found)
                                                                            {
                                                                                break;
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  ERROR: Source field not found: " + sourceFieldName);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  ERROR/WARNING: Source Layer not found: " + sourceLayerName);
                                                                    }
                                                                }

                                                            }
                                                            if (pFoundFeat.Count > 0 && strOpt == AAState.intersectOptions.PromptMulti)
                                                            {
                                                                Globals.OptionsToPresent strRetVal = Globals.showOptionsForm(pFoundFeat, "Select A feature", "Select A feature", ComboBoxStyle.DropDownList);
                                                                if (strRetVal != null)
                                                                {
                                                                    sourceFeature = sourceLayer.FeatureClass.GetFeature(strRetVal.OID);

                                                                    string test = sourceFeature.get_Value(sourceField).ToString();
                                                                    AAState.WriteLine("                  Setting Value: " + test);

                                                                    inObject.set_Value(intFldIdxs[0], sourceFeature.get_Value(sourceField));
                                                                    AAState.WriteLine("                  Value Set");

                                                                    found = true;

                                                                }
                                                            }

                                                            //if (!found)
                                                            //{
                                                            //    //IField field = inObject.Fields.get_Field(intFldIdxs[0]);
                                                            //    //object newval = field.DefaultValue;
                                                            //    //if (newval == null)
                                                            //    //{
                                                            //    //    if (field.IsNullable)
                                                            //    //    {
                                                            //    //        AAState.WriteLine("                  Setting Value default null value");

                                                            //    //        inObject.set_Value(intFldIdxs[0], null);
                                                            //    //        AAState.WriteLine("                  Value Set");

                                                            //    //    }
                                                            //    //}
                                                            //    //else
                                                            //    //{
                                                            //    //    AAState.WriteLine("                  Setting Value default value");

                                                            //    //    inObject.set_Value(intFldIdxs[0], newval);
                                                            //    //    AAState.WriteLine("                  Value Set");

                                                            //    //}
                                                            //}
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  ERROR: INTERSECTING_FEATURE: source field name is null");
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: INTERSECTING_FEATURE: Value Info is not in the expected format");
                                                    }
                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  ERROR: INTERSECTING_FEATURE: Input Feature or Value Info is null");
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: INTERSECTING_FEATURE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: INTERSECTING_FEATURE");
                                            }
                                            break;
                                        case "INTERSECTING_RASTER":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: INTERSECTING_RASTER");
                                                if (inFeature != null & valData != null)
                                                {

                                                    sourceLayerName = "";
                                                    formatString = "";
                                                    found = false;

                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    if (args.Length < 1) break;
                                                    switch (args.Length)
                                                    {
                                                        case 1:
                                                            sourceLayerNames = args[0].ToString().Split(',');
                                                            break;
                                                        case 2:
                                                            sourceLayerNames = args[0].ToString().Split(',');
                                                            formatString = args[1].ToString();
                                                            break;
                                                        default: break;
                                                    }

                                                    // Get layer
                                                    for (int i = 0; i < sourceLayerNames.Length; i++)
                                                    {
                                                        sourceLayerName = sourceLayerNames[i].ToString();
                                                        IPoint pLoc = Globals.GetGeomCenter(inFeature)[0];

                                                        if (pLoc != null)
                                                        {
                                                            string cellVal = GetCellValue(sourceLayerName, pLoc, AAState._editor.Map);// Globals.GetCellValue(sourceLayerName, pLoc, _editor.Map);
                                                            AAState.WriteLine("                  ERROR/WARING: No cell value or raster was found: " + sourceLayerName);
                                                            if (cellVal != null && cellVal != "" && cellVal != "No Raster")
                                                            {

                                                                if (formatString == null || formatString == "" || (inObject.Fields.get_Field(intFldIdxs[0]).Type != esriFieldType.esriFieldTypeString))
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], cellVal);
                                                                    found = true;
                                                                    break;
                                                                }
                                                                else
                                                                {
                                                                    // formatString = formatString.Replace("[value]",cellVal);
                                                                    formatString = formatString + cellVal;
                                                                    inObject.set_Value(intFldIdxs[0], formatString);

                                                                    found = true;
                                                                    break;
                                                                }

                                                            }

                                                        }
                                                    }
                                                    if (!(found) && inObject.Fields.get_Field(intFldIdxs[0]).IsNullable)
                                                        inObject.set_Value(intFldIdxs[0], null);
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: INTERSECTING_RASTER: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: INTERSECTING_RASTER");
                                            }
                                            break;
                                        case "INTERSECTING_LAYER_DETAILS":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: INTERSECTING_LAYER_DETAILS");
                                                if (inFeature != null & valData != null)
                                                {

                                                    sourceLayerName = "";
                                                    formatString = "";
                                                    found = false;
                                                    List<string> matchPattern = null;
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    if (args.Length >= 1)
                                                    {
                                                        AAState.intersectOptions strOpt = AAState.intersectOptions.First;

                                                        switch (args.Length)
                                                        {
                                                            case 1:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                formatString = "P";
                                                                break;
                                                            case 2:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                formatString = args[1].ToString();
                                                                break;
                                                            case 3:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                formatString = args[1].ToString();
                                                                switch (args[2].ToString().ToUpper())
                                                                {
                                                                    case "PROMPT":
                                                                        strOpt = AAState.intersectOptions.PromptMulti;
                                                                        break;
                                                                    case "P":
                                                                        strOpt = AAState.intersectOptions.PromptMulti;
                                                                        break;
                                                                    case "CENTROID":
                                                                        strOpt = AAState.intersectOptions.Centroid;
                                                                        break;
                                                                    case "C":
                                                                        strOpt = AAState.intersectOptions.Centroid;
                                                                        break;
                                                                    case "F":
                                                                        strOpt = AAState.intersectOptions.First;
                                                                        break;
                                                                    case "FIRST":
                                                                        strOpt = AAState.intersectOptions.First;
                                                                        break;
                                                                }
                                                                break;
                                                            case 4:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                formatString = args[1].ToString();
                                                                switch (args[2].ToString().ToUpper())
                                                                {
                                                                    case "PROMPT":
                                                                        strOpt = AAState.intersectOptions.PromptMulti;
                                                                        break;
                                                                    case "P":
                                                                        strOpt = AAState.intersectOptions.PromptMulti;
                                                                        break;
                                                                    case "CENTROID":
                                                                        strOpt = AAState.intersectOptions.Centroid;
                                                                        break;
                                                                    case "C":
                                                                        strOpt = AAState.intersectOptions.Centroid;
                                                                        break;
                                                                    case "F":
                                                                        strOpt = AAState.intersectOptions.First;
                                                                        break;
                                                                    case "FIRST":
                                                                        strOpt = AAState.intersectOptions.First;
                                                                        break;
                                                                }
                                                                matchPattern = new List<string>(args[3].ToString().Split(','));
                                                                //matchPattern = .ToList<string>();
                                                                break;
                                                            default: break;

                                                        }
                                                        List<Globals.OptionsToPresent> strFiles = new List<Globals.OptionsToPresent>();
                                                        // Get layer
                                                        for (int i = 0; i < sourceLayerNames.Length; i++)
                                                        {
                                                            sourceLayerName = sourceLayerNames[i].ToString();
                                                            //AAState.WriteLine("                  Getting Features Centeroid");

                                                            //IPoint pLoc = Globals.GetGeomCenter(inFeature);
                                                            IGeometry pGeo = inFeature.ShapeCopy;
                                                            List<IGeometry> pGeos = new List<IGeometry>();

                                                            if (pGeo != null)
                                                            {
                                                                if (strOpt == AAState.intersectOptions.Centroid)
                                                                {
                                                                    List<IPoint> pGeoPnts = Globals.GetGeomCenter(pGeo);
                                                                    pGeos = pGeoPnts.ConvertAll(new Converter<IPoint, IGeometry>(Globals.PointToGeometry));

                                                                }
                                                                else
                                                                {
                                                                    pGeos.Add(pGeo);
                                                                }
                                                                // AAState.WriteLine("                  Centroid Found");
                                                                AAState.WriteLine("                  Getting list of " + sourceLayerName + " Layers");
                                                                IEnumLayer pEnum = Globals.GetLayers(AAState._editor.Map, sourceLayerName);

                                                                if (pEnum != null)
                                                                {
                                                                    AAState.WriteLine("                  List retrieved of " + sourceLayerName + " Layers");
                                                                    AAState.WriteLine("                  Starting Loop");
                                                                    ILayer pLay = pEnum.Next();
                                                                    //ISpatialFilter pSpatFilt;

                                                                    while (pLay != null)
                                                                    {

                                                                        intersectLayerDetailsFunctions(pLay, pGeos, strOpt, ref found, ref strFiles, ref inObject, intFldIdxs[0], matchPattern);

                                                                        if (found)
                                                                        {
                                                                            AAState.WriteLine("                  Exiting Layer Loop");
                                                                            break;
                                                                        }

                                                                        pLay = pEnum.Next();
                                                                    }
                                                                    pLay = null;
                                                                    pEnum = null;
                                                                }
                                                                else
                                                                {
                                                                    bool FCorLayerTemp = true;
                                                                    ILayer pLay = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref FCorLayerTemp);
                                                                    if (pLay != null)
                                                                    {

                                                                        intersectLayerDetailsFunctions(pLay, pGeos, strOpt, ref found, ref strFiles, ref inObject, intFldIdxs[0], matchPattern);

                                                                    }
                                                                    pLay = null;
                                                                }

                                                                if (pEnum != null)
                                                                    Marshal.ReleaseComObject(pEnum);
                                                                pEnum = null;
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  ERROR: Geo not Found");
                                                            }
                                                            if (found)
                                                            {
                                                                AAState.WriteLine("                  Exiting Layer Loop");
                                                                break;
                                                            }
                                                            pGeo = null;
                                                            pGeos = null;
                                                        }
                                                        if (strOpt == AAState.intersectOptions.PromptMulti && strFiles.Count > 0)
                                                        {
                                                            Globals.OptionsToPresent strRetVal = Globals.showOptionsForm(strFiles, "Select a intersect layer", "Select a intersect layer", ComboBoxStyle.DropDownList);
                                                            if (strRetVal != null)
                                                            {
                                                                try
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], strRetVal.Display);
                                                                }
                                                                catch
                                                                {
                                                                    MessageBox.Show("Error Setting the value in the Intersecting_Layer_Details");

                                                                }
                                                                found = true;
                                                            }
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  ERROR: Value info is not correct");
                                                    }
                                                    //if (!(found) && inObject.Fields.get_Field(intFldIdxs[0]).IsNullable)
                                                    //    inObject.set_Value(intFldIdxs[0], null);
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: INTERSECTING_LAYER_DETAILS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: INTERSECTING_LAYER_DETAILS");
                                            }
                                            break;
                                        case "INTERSECTING_FEATURE_DISTANCE":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: INTERSECTING_FEATURE_DISTANCE");
                                                if (inFeature != null & valData != null)
                                                {
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    sourceField = -1;

                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    if (args.GetLength(0) >= 2)
                                                    {
                                                        //    sourceLayerName = args[0].ToString();
                                                        sourceLayerNames = args[0].ToString().Split(',');
                                                        sourceFieldName = args[1].ToString();
                                                    }
                                                    // Get layer

                                                    if (sourceFieldName != null)
                                                    {
                                                        for (int i = 0; i < sourceLayerNames.Length; i++)
                                                        {
                                                            sourceLayerName = sourceLayerNames[i].ToString();
                                                            if (sourceLayerName != "")

                                                                sourceLayerName = args[i].ToString();
                                                            if (i == 0)
                                                                i++;
                                                            boolLayerOrFC = true;

                                                            if (sourceLayerName.Contains("("))
                                                            {
                                                                string[] tempSplt = sourceLayerName.Split('(');
                                                                sourceLayerName = tempSplt[0];
                                                                sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                                if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                            }
                                                            if (sourceLayer == null)
                                                            {
                                                                AAState.WriteLine("                  ERROR/WARNING: " + sourceLayerName + " was not found");
                                                                continue;
                                                            }

                                                            IFeatureClass iFC = inFeature.Class as IFeatureClass;
                                                            if (sourceLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                                                            {
                                                                AAState.WriteLine("                  ERROR: " + sourceLayer + " is a polygon layer");

                                                                break;
                                                            }
                                                            if (sourceLayer != null)
                                                            {
                                                                sourceField = sourceLayer.FeatureClass.FindField(sourceFieldName);

                                                                if (sourceField > -1)
                                                                {
                                                                    sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false);

                                                                    pFS = (IFeatureSelection)sourceLayer;
                                                                    if (boolLayerOrFC)
                                                                    {
                                                                        if (pFS.SelectionSet.Count > 0)
                                                                        {
                                                                            pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                            fCursor = cCurs as IFeatureCursor;

                                                                        }
                                                                        else
                                                                        {
                                                                            fCursor = sourceLayer.Search(sFilter, true);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                    }

                                                                    while ((sourceFeature = fCursor.NextFeature()) != null)
                                                                    {
                                                                        if (sourceFeature.Class != inFeature.Class)
                                                                        {
                                                                            IPoint pIntPnt;
                                                                            if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                                            {
                                                                                pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint;

                                                                            }
                                                                            else
                                                                                pIntPnt = inFeature.ShapeCopy as IPoint;
                                                                            IPoint snapPnt = null;

                                                                            double dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt);
                                                                            snapPnt = null;

                                                                            string strUnit = Globals.GetSpatRefUnitName(Globals.GetLayersCoordinateSystem(sourceLayer.FeatureClass), true);
                                                                            if (strUnit == "Foot" && dAlong != 1)
                                                                            {
                                                                                strUnit = "Feet";
                                                                            }
                                                                            else if (strUnit == "Meter" && dAlong != 1)
                                                                            {
                                                                                strUnit = "Meters";
                                                                            }
                                                                            string strDis = dAlong + " " + strUnit + " along " + sourceLayer.Name + " with " + sourceLayer.FeatureClass.Fields.get_Field(sourceField).AliasName + " of " + sourceFeature.get_Value(sourceField);

                                                                            if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                            {

                                                                                strDis = dAlong + " " + strUnit + ": " + sourceFeature.get_Value(sourceField);
                                                                                AAState.WriteLine("                  Text is to long, defaulting to length along: " + strDis);

                                                                                if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                                {

                                                                                    if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                                    {
                                                                                        strDis = dAlong.ToString();
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    strDis = dAlong.ToString();
                                                                                    AAState.WriteLine("                  Text is to long, defaulting to length along: " + strDis);
                                                                                    if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                                    {
                                                                                        strDis = dAlong.ToString();
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  Value set to: " + strDis);
                                                                                inObject.set_Value(intFldIdxs[0], strDis);
                                                                                break;
                                                                            }
                                                                        }

                                                                        else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                        {
                                                                            IPoint pIntPnt;
                                                                            if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                                            {
                                                                                pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint;

                                                                            }
                                                                            else
                                                                                pIntPnt = inFeature.ShapeCopy as IPoint;
                                                                            IPoint snapPnt = null;

                                                                            double dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt);
                                                                            snapPnt = null;

                                                                            string strUnit = Globals.GetSpatRefUnitName(Globals.GetLayersCoordinateSystem(sourceLayer.FeatureClass), true);
                                                                            if (strUnit == "Foot" && dAlong != 1)
                                                                            {
                                                                                strUnit = "Feet";
                                                                            }
                                                                            else if (strUnit == "Meter" && dAlong != 1)
                                                                            {
                                                                                strUnit = "Meters";
                                                                            }
                                                                            string strDis = dAlong + " " + strUnit + " along " + sourceLayer.Name + " with " + sourceLayer.FeatureClass.Fields.get_Field(sourceField).AliasName + " of " + sourceFeature.get_Value(sourceField);

                                                                            if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                            {

                                                                                strDis = dAlong + " " + strUnit + ": " + sourceFeature.get_Value(sourceField);
                                                                                AAState.WriteLine("                  Text is to long, defaulting to length along: " + strDis);

                                                                                if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                                {

                                                                                    if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                                    {
                                                                                        strDis = dAlong.ToString();
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    strDis = dAlong.ToString();
                                                                                    AAState.WriteLine("                  Text is to long, defaulting to length along: " + strDis);
                                                                                    if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                                    {
                                                                                        strDis = dAlong.ToString();
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  Value set to: " + strDis);
                                                                                inObject.set_Value(intFldIdxs[0], strDis);
                                                                                break;
                                                                            }
                                                                        }
                                                                    }
                                                                    //else if (inObject.Fields.get_Field(intFldIdxs[0]).IsNullable)
                                                                    //    inObject.set_Value(intFldIdxs[0], null);
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  ERROR: " + sourceLayer + ": field: " + sourceFieldName + " was not found");
                                                                }
                                                            }
                                                            else { }
                                                        }
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: INTERSECTING_FEATURE_DISTANCE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: INTERSECTING_FEATURE_DISTANCE");
                                            }
                                            break;

                                        //Release: 1.2
                                        //New Dynamic Value Method: NEARSET_FEATURE - similiar to INTERSECTING_FEATURE but requires a search distance.

                                        case "NEAREST_FEATURE":
                                            try
                                            {
                                                AAState.WriteLine("                  Trying: NEAREST_FEATURE");
                                                if (inFeature != null & valData != null)
                                                {
                                                    string sourceMatField = "";
                                                    string targetMatField = "";
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    searchDistance = 0;
                                                    found = false;
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    switch (args.Length)
                                                    {
                                                        case 2:
                                                            sourceLayerNames = args[0].ToString().Split(',');
                                                            sourceFieldName = args[1].ToString();
                                                            break;
                                                        case 3:
                                                            sourceLayerNames = args[0].ToString().Split(',');
                                                            sourceFieldName = args[1].ToString();

                                                            Double.TryParse(args[2], out searchDistance);
                                                            break;
                                                        case 4:
                                                            AAState.WriteLine("                  ERROR: Incorrect value method");
                                                            break;

                                                        case 5:
                                                            sourceLayerNames = args[0].ToString().Split(',');
                                                            sourceFieldName = args[1].ToString();
                                                            Double.TryParse(args[2], out searchDistance);
                                                            sourceMatField = args[3].ToString();
                                                            targetMatField = args[4].ToString();
                                                            break;
                                                        default:
                                                            AAState.WriteLine("                  ERROR: Incorrect value method");
                                                            break;

                                                    }

                                                    if (sourceLayerNames.Length > 0 & sourceFieldName != null)
                                                    {
                                                        for (int i = 0; i < sourceLayerNames.Length; i++)
                                                        {
                                                            sourceLayerName = sourceLayerNames[i].ToString();
                                                            if (sourceLayerName != "")
                                                            {
                                                                bool FCorLayerSource = true;
                                                                sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref FCorLayerSource) as IFeatureLayer;
                                                                if (sourceLayer != null)
                                                                {
                                                                    sourceField = sourceLayer.FeatureClass.FindField(sourceFieldName);

                                                                    if (sourceField > -1)
                                                                    {
                                                                        //sFilter = new SpatialFilterClass();
                                                                        //if (searchDistance > 0)
                                                                        //{
                                                                        //    searchEnvelope = inFeature.ShapeCopy.Envelope;
                                                                        //    searchEnvelope.Expand(searchDistance, searchDistance, false);
                                                                        //    sFilter.Geometry = searchEnvelope;
                                                                        //}
                                                                        //else
                                                                        //    sFilter.Geometry = inFeature.ShapeCopy;

                                                                        //sFilter.GeometryField = sourceLayer.FeatureClass.ShapeFieldName;
                                                                        //sFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                                                        sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false);
                                                                        pFS = (IFeatureSelection)sourceLayer;
                                                                        if (boolLayerOrFC)
                                                                        {
                                                                            AAState.WriteLine("                  Searching the layer");
                                                                            if (pFS.SelectionSet.Count > 0)
                                                                            {
                                                                                AAState.WriteLine("                  There is a seleciton set, only checking selected features");
                                                                                pFS.SelectionSet.Search(sFilter, false, out cCurs);
                                                                                fCursor = cCurs as IFeatureCursor;

                                                                            }
                                                                            else
                                                                            {

                                                                                fCursor = sourceLayer.Search(sFilter, false);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  Searching the feature class");
                                                                            fCursor = sourceLayer.FeatureClass.Search(sFilter, false);
                                                                        }

                                                                        nearestFeature = null;

                                                                        proxOp = (IProximityOperator)inFeature.ShapeCopy;
                                                                        lastDistance = searchDistance;
                                                                        while ((sourceFeature = fCursor.NextFeature()) != null)
                                                                        {
                                                                            if (sourceFeature.Class != inFeature.Class)
                                                                            {
                                                                                AAState.WriteLine("                  Feature Classes are different");
                                                                                if (targetMatField == "" && sourceMatField == "")
                                                                                {

                                                                                    AAState.WriteLine("                  No matching fields specified");
                                                                                    try
                                                                                    {
                                                                                        IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                        pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                        distance = proxOp.ReturnDistance(pTempGeo);
                                                                                        pTempGeo = null;

                                                                                        if (distance <= lastDistance)
                                                                                        {
                                                                                            nearestFeature = sourceFeature;
                                                                                            lastDistance = distance;
                                                                                        }
                                                                                    }
                                                                                    catch
                                                                                    {
                                                                                        MessageBox.Show("Error in the Nearest Feature - Proximity Operator.  This may be caused by corrupt data in the layer, Please run Check/Repair Geometry GP tool on your layer");
                                                                                        return false;

                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  matching fields specified");
                                                                                    int idxTargetFld = Globals.GetFieldIndex(sourceLayer, targetMatField);
                                                                                    int idxSourceFld = Globals.GetFieldIndex(inObject.Fields, sourceMatField);
                                                                                    if (idxSourceFld >= 0 && idxTargetFld >= 0)
                                                                                    {
                                                                                        AAState.WriteLine("                  Fields Found");
                                                                                        if (inObject.get_Value(idxSourceFld).ToString() == sourceFeature.get_Value(idxTargetFld).ToString())
                                                                                        {
                                                                                            AAState.WriteLine("                  Values Match");
                                                                                            //distance = proxOp.ReturnDistance(sourceFeature.Shape);
                                                                                            IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                            pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                            distance = proxOp.ReturnDistance(pTempGeo);
                                                                                            pTempGeo = null;

                                                                                            if (distance <= lastDistance)
                                                                                            {
                                                                                                nearestFeature = sourceFeature;
                                                                                                lastDistance = distance;
                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            AAState.WriteLine("                  Values does not Match: " + inObject.get_Value(idxSourceFld).ToString() + " - " + sourceFeature.get_Value(idxTargetFld).ToString());

                                                                                        }

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine("                  Fields Not Found");
                                                                                        IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                        pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                        distance = proxOp.ReturnDistance(pTempGeo);
                                                                                        pTempGeo = null;
                                                                                        //distance = proxOp.ReturnDistance(sourceFeature.Shape);
                                                                                        if (distance <= lastDistance)
                                                                                        {
                                                                                            nearestFeature = sourceFeature;
                                                                                            lastDistance = distance;
                                                                                        }
                                                                                    }

                                                                                }
                                                                            }
                                                                            else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                            {
                                                                                AAState.WriteLine("                  matching fields specified");
                                                                                int idxTargetFld = Globals.GetFieldIndex(sourceLayer, targetMatField);
                                                                                int idxSourceFld = Globals.GetFieldIndex(inObject.Fields, sourceMatField);
                                                                                if (idxSourceFld >= 0 && idxTargetFld >= 0)
                                                                                {
                                                                                    AAState.WriteLine("                  Fields Found");
                                                                                    if (inObject.get_Value(idxSourceFld).ToString() == sourceFeature.get_Value(idxTargetFld).ToString())
                                                                                    {
                                                                                        AAState.WriteLine("                  Values Match");
                                                                                        // distance = proxOp.ReturnDistance(sourceFeature.Shape);
                                                                                        IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                        pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                        distance = proxOp.ReturnDistance(pTempGeo);
                                                                                        pTempGeo = null;

                                                                                        if (distance <= lastDistance)
                                                                                        {
                                                                                            nearestFeature = sourceFeature;
                                                                                            lastDistance = distance;
                                                                                        }
                                                                                    }

                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  Fields Not Found");
                                                                                    //distance = proxOp.ReturnDistance(sourceFeature.Shape);
                                                                                    IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                    pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                    distance = proxOp.ReturnDistance(pTempGeo);
                                                                                    pTempGeo = null;

                                                                                    if (distance <= lastDistance)
                                                                                    {
                                                                                        nearestFeature = sourceFeature;
                                                                                        lastDistance = distance;
                                                                                    }
                                                                                }

                                                                            }
                                                                            // sourceFeature = fCursor.NextFeature();
                                                                        }

                                                                        if (nearestFeature != null)
                                                                        {
                                                                            AAState.WriteLine("                  Feature found: " + nearestFeature.Class.AliasName + ":" + nearestFeature.OID);
                                                                            inObject.set_Value(intFldIdxs[0], nearestFeature.get_Value(sourceField));
                                                                            found = true;
                                                                            break;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  ERROR: " + sourceLayer + ": field: " + sourceFieldName + " was not found");
                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  ERROR: " + sourceLayer + " was not found");
                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  ERROR: Empty source layer name");
                                                            }

                                                        }
                                                        if (!found)
                                                        {
                                                            //IField field = inObject.Fields.get_Field(intFldIdxs[0]);
                                                            //object newval = field.DefaultValue;
                                                            //if (newval == null)
                                                            //{
                                                            //    if (field.IsNullable)
                                                            //    {
                                                            //        inObject.set_Value(intFldIdxs[0], null);
                                                            //    }
                                                            //}
                                                            //else
                                                            //{
                                                            //    inObject.set_Value(intFldIdxs[0], newval);
                                                            //}
                                                        }
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine("                  ERROR: NEAREST_FEATURE: " + ex.Message);

                                            }
                                            finally
                                            {
                                                AAState.WriteLine("                  Finished: NEAREST_FEATURE");
                                            }
                                            break;

                                        default:
                                            //    MessageBox.Show(valMethod + " for layer " + tableName + " is not a valid method, check the dynamic value table", "Attribute Assistant");
                                            AAState.WriteLine("ERROR: " + valMethod + " for layer " + tableName + " is not a valid method, check the dynamic value table");

                                            break;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show("TableName:" + tableName + "  FieldName:" + strFldNames[0] + System.Environment.NewLine + "ValueMethod:" + valMethod + "  ValueData:" + valData + System.Environment.NewLine + "Message: " + ex.Message, "Attribute Assistant Message");
                                    AAState.WriteLine("ERROR: TableName:" + tableName + "  FieldName:" + strFldNames[0] + System.Environment.NewLine + "ValueMethod:" + valMethod + "  ValueData:" + valData + System.Environment.NewLine + "Message: " + ex.Message);
                                }
                            }
                            else
                            {
                                AAState.WriteLine("      Rule not processed");

                            }

                            try
                            {
                                if (intFldIdxs.Count > 0 && strFldNames.Count > 0)
                                {
                                    for (int p = 0; p < strFldNames.Count; p++)
                                    {
                                        // string fldname = strFldNames[p];

                                        IRowChanges inChanges = inObject as IRowChanges;
                                        bool changed = inChanges.get_ValueChanged(intFldIdxs[p]);
                                        if (changed)
                                            //  if (fieldName.ToUpper() != "SHAPE")
                                            try
                                            {
                                                //  if (AAState.lastValueProperties.
                                                // AAState.WriteLine("                      Setting Last Value");

                                                if (AAState.lastValueProperties.GetProperty(strFldNames[p]) != null)
                                                {
                                                    AAState.WriteLine("                      Setting Last Value");
                                                    if (mode == "ON_CREATE" && (inObject.get_Value(intFldIdxs[p]) == null || inObject.get_Value(intFldIdxs[p]).ToString() == ""))
                                                    {
                                                        AAState.WriteLine("                           Null Value in the create Method, not storing in last value array");

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                           " + strFldNames[p] + ": " + inObject.get_Value(intFldIdxs[p]).ToString());
                                                        AAState.lastValueProperties.SetProperty(strFldNames[p], inObject.get_Value(intFldIdxs[p]));
                                                    }
                                                }

                                                else
                                                {
                                                    if (mode == "ON_CREATE" && (inObject.get_Value(intFldIdxs[p]) == null || inObject.get_Value(intFldIdxs[p]).ToString() == ""))
                                                    {
                                                        AAState.WriteLine("                           Null Value in the create Method, not storing in last value array");

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                      Setting Last Value");
                                                        AAState.WriteLine("                           " + strFldNames[p] + ": " + inObject.get_Value(intFldIdxs[p]).ToString());

                                                        AAState.lastValueProperties.SetProperty(strFldNames[p], inObject.get_Value(intFldIdxs[p]));
                                                    }
                                                }

                                            }
                                            catch
                                            {
                                                //AAState.WriteLine("        Error Setting Last Value " + inObject.Fields.get_Field(intFldIdxs[0]).Name);

                                            }

                                    }
                                }
                            }
                            catch
                            {
                                AAState.WriteLine("        Error Setting Last Value");

                            }

                            //if (inObject != null)
                            //{

                            //    inChanges = inObject as IRowChanges;
                            //    if (intFldIdxs.Count > 0)
                            //    {
                            //        if (intFldIdxs[0] > -1)
                            //        {
                            //            changed = inChanges.get_ValueChanged(intFldIdxs[0]);
                            //            if (changed)
                            //                //  if (fieldName.ToUpper() != "SHAPE")
                            //                try
                            //                {
                            //                    //  if (AAState.lastValueProperties.
                            //                    // AAState.WriteLine("                      Setting Last Value");
                            //                    if (AAState.lastValueProperties.GetProperty(strFldNames[0]) != null)
                            //                    {
                            //                        AAState.WriteLine("                      Setting Last Value");
                            //                        AAState.WriteLine("                           " + strFldNames[0] + ": " + inObject.get_Value(intFldIdxs[0]).ToString());
                            //                        AAState.lastValueProperties.SetProperty(strFldNames[0], inObject.get_Value(intFldIdxs[0]));
                            //                    }

                            //                    else
                            //                    {
                            //                        AAState.WriteLine("                      Setting Last Value");
                            //                        AAState.WriteLine("                           " + strFldNames[0] + ": " + inObject.get_Value(intFldIdxs[0]).ToString());

                            //                        AAState.lastValueProperties.SetProperty(strFldNames[0], inObject.get_Value(intFldIdxs[0]));
                            //                    }

                            //                }
                            //                catch
                            //                {
                            //                    //AAState.WriteLine("        Error Setting Last Value " + inObject.Fields.get_Field(intFldIdxs[0]).Name);

                            //                }

                            //        }
                            //    }
                            //}

                            AAState.WriteLine("    ------------------------------------------------");

                        }

                    }
                    //for (int intFldIdxs[0] = 0; intFldIdxs[0] <= inObject.Fields.FieldCount; intFldIdxs[0]++)
                    //{

                    //    stepProgressor.Step();
                    //    bool editable = true;
                    //    if (intFldIdxs[0] == inObject.Fields.FieldCount)
                    //    {
                    //        fieldObj = null;

                    //        fieldName = "";
                    //        stepProgressor.Message = "Checking rules for field null fields in" + inObject.Class.AliasName;
                    //        progressDialog.Description = "Checking rules for field null fields in" + inObject.Class.AliasName;
                    //        AAState.WriteLine("***********************************************************");
                    //        AAState.WriteLine("");

                    //        AAState.WriteLine("############ " + DateTime.Now + " ################");
                    //        editable = true;
                    //        //  intFldIdxs[0]++;

                    //    }
                    //    else
                    //    {
                    //        fieldObj = inObject.Fields.get_Field(intFldIdxs[0]);

                    //        fieldName = fieldObj.Name;
                    //        stepProgressor.Message = "Checking rules for field " + fieldName + " in " + inObject.Class.AliasName;
                    //        progressDialog.Description = "Checking rules for field " + fieldName + " in " + inObject.Class.AliasName;
                    //        AAState.WriteLine("***********************************************************");
                    //        AAState.WriteLine("");
                    //        AAState.WriteLine("############ " + fieldName + " ################");
                    //        AAState.WriteLine("############ " + DateTime.Now + " ################");
                    //        AAState.WriteLine("Is field -  " + fieldName + " Editable = " + fieldObj.Editable);
                    //        editable = fieldObj.Editable;
                    //    }
                    //    bool proc = false;
                    //    if (editable == true && fieldObj != null)
                    //    {
                    //        AAState.WriteLine("Checking rules for field " + fieldName + " in " + inObject.Class.AliasName);

                    //        AAState._dv.RowFilter = "(TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') And FIELDNAME = '" + fieldName + "' and " + modeVal;
                    //        //AAState._dv.rw
                    //        AAState.WriteLine("    Row Query: " + "TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') And FIELDNAME = '" + fieldName + "' and " + modeVal);
                    //        if (AAState._dv.Count == 0)
                    //        {
                    //            AAState._dv.RowFilter = "TABLENAME = '*' And FIELDNAME = '" + fieldName + "' and " + modeVal;

                    //            AAState.WriteLine("    Query using " + fieldName + " did not produce any results, trying all fields");
                    //            AAState.WriteLine("    Row Query: " + "TABLENAME = '*' And FIELDNAME = '" + fieldName + "' and " + modeVal);
                    //        }
                    //        if (AAState._dv.Count == 0)
                    //        {
                    //            AAState.WriteLine("    No entries found");
                    //            proc = false;
                    //        }
                    //        else
                    //        {
                    //            proc = true;
                    //        }

                    //    }

                    //    else if (editable && fieldObj == null)
                    //    {
                    //        fieldName = "";
                    //        AAState._dv.RowFilter = "(TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') And (FIELDNAME = '" + fieldName + "' or FIELDNAME IS NULL) and " + modeVal;
                    //        //AAState._dv.rw
                    //        AAState.WriteLine("    Row Query: " + "TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') And (FIELDNAME = '" + fieldName + "' or FIELDNAME IS NULL) and " + modeVal);
                    //        if (AAState._dv.Count == 0)
                    //        {
                    //            AAState._dv.RowFilter = "TABLENAME = '*' And (FIELDNAME = '" + fieldName + "' or FIELDNAME IS NULL) and " + modeVal;

                    //            AAState.WriteLine("    Query using " + fieldName + " did not produce any results, trying all fields");
                    //            AAState.WriteLine("    Row Query: " + "TABLENAME = '*' And And (FIELDNAME = '" + fieldName + "' or FIELDNAME IS NULL) and " + modeVal);
                    //        }
                    //        if (AAState._dv.Count == 0)
                    //        {
                    //            AAState.WriteLine("    No entries found");
                    //            proc = false;
                    //        }
                    //        else
                    //        {
                    //            proc = true;
                    //        }
                    //    }

                    //}
                }
                return false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Problem in setup." + System.Environment.NewLine + "Message:" + ex.Message, "Attribute Assistant Message");
                AAState.WriteLine("Error in setup");
                return false;

            }
            finally
            {
                if (AAState._tab == inObject.Class || AAState._gentab == inObject.Class)
                {
                    AAState.reInitExt();

                }
                if (progressDialog != null)
                {
                    progressDialog.HideDialog();
                }
                AAState.WriteLine("DONE");
                AAState.WriteLine("---------------------------------------");
                if (fCursor != null)
                {
                    Marshal.ReleaseComObject(fCursor);
                    GC.Collect(300);
                    GC.WaitForFullGCComplete();
                }
                inFeature = null;

                mseg = null;
                netFeat = null;
                iEdgeFeat = null;

                iJuncFeat = null;

                progressDialogFactory = null;
                stepProgressor = null;
                progressDialog = null;
                trackCancel = null;

            }
        }
示例#12
0
        public DataTable DoQuery(DF2DFeatureClass dffc, IGeometry pGeo)
        {
            List <int>       intlist        = new List <int>();
            DataTable        dt             = new DataTable();
            IFeatureClass    fc             = dffc.GetFeatureClass();
            FacilityClass    fac            = dffc.GetFacilityClass();
            List <FieldInfo> ficol          = fac.FieldInfoCollection;
            ISpatialFilter   pSpatialFilter = new SpatialFilterClass();

            pSpatialFilter.Geometry   = pGeo;
            pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
            IFeatureCursor featureCursor = fc.Search(pSpatialFilter, false);
            IFeature       pfeature      = featureCursor.NextFeature();

            if (fc == null || pfeature == null)
            {
                return(null);
            }

            for (int i = 0; i < fc.Fields.FieldCount; i++)
            {
                IField pField = fc.Fields.get_Field(i);
                foreach (FieldInfo f in ficol)
                {
                    if (pField.Name == f.Name && f.CanQuery)
                    {
                        DataColumn dc = new DataColumn(pField.AliasName, Type.GetType("System.String"));

                        intlist.Add(i);
                        //pfname.Add(pField.Name);
                        dt.Columns.Add(dc);
                    }
                }
            }
            while (pfeature != null)
            {
                if (dt.Columns.Count > 0 && intlist.Count == dt.Columns.Count)
                {
                    DataRow dr = dt.NewRow();
                    string  str;

                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        //int index = pfeature.Fields.FindField(pfname[i]);
                        if (pfeature.get_Value(intlist[i]) == null)
                        {
                            continue;
                        }
                        else
                        {
                            str = pfeature.get_Value(intlist[i]).ToString();
                        }
                        dr[dt.Columns[i].ColumnName] = str;
                    }
                    dt.Rows.Add(dr);
                }



                pfeature = featureCursor.NextFeature();
            }
            return(dt);
        }
示例#13
0
        public DataTable DoQueryByMajorClass(string whereclause, IFeatureClass fc, FacilityClass facc)
        {
            List <FieldInfo> ficol        = facc.FieldInfoCollection;
            List <int>       intlist      = new List <int>();
            DataTable        dt           = new DataTable();
            IQueryFilter     pQueryFilter = new QueryFilterClass();

            pQueryFilter.WhereClause = whereclause;
            if (fc == null)
            {
                return(null);
            }
            IFeatureCursor featureCursor = fc.Search(pQueryFilter, false);

            IFeature pfeature = featureCursor.NextFeature();

            if (pfeature == null)
            {
                return(null);
            }

            for (int i = 0; i < fc.Fields.FieldCount; i++)
            {
                IField pField = fc.Fields.get_Field(i);
                foreach (FieldInfo f in ficol)
                {
                    if (pField.Name == f.Name && f.CanQuery)
                    {
                        DataColumn dc = new DataColumn(pField.AliasName, Type.GetType("System.String"));

                        intlist.Add(i);
                        //pfname.Add(pField.Name);
                        dt.Columns.Add(dc);
                    }
                }
            }

            while (pfeature != null)
            {
                if (dt.Columns.Count > 0 && intlist.Count == dt.Columns.Count)
                {
                    DataRow dr = dt.NewRow();
                    string  str;

                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        //int index = pfeature.Fields.FindField(pfname[i]);
                        if (pfeature.get_Value(intlist[i]) == null)
                        {
                            continue;
                        }
                        else
                        {
                            str = pfeature.get_Value(intlist[i]).ToString();
                        }
                        dr[dt.Columns[i].ColumnName] = str;
                    }
                    dt.Rows.Add(dr);
                }

                pfeature = featureCursor.NextFeature();
            }
            return(dt);
        }
示例#14
0
        public void LinkElevation()
        {
            if (_pointClassInfo == null || _lineClassInfo == null)
            {
                return;
            }
            IDataset        pDS            = _lineClassInfo.PipeClass as IDataset;
            IWorkspace2     pWorkspace2    = pDS.Workspace as IWorkspace2;
            IWorkspaceEdit2 pWorkspaceEdit = pWorkspace2 as IWorkspaceEdit2;

            if (pWorkspaceEdit == null)
            {
                return;
            }
            pWorkspaceEdit.StartEditing(false);
            pWorkspaceEdit.StartEditOperation();
            try
            {
                IFeatureCursor pCursor       = _lineClassInfo.PipeClass.Search(null, false);
                IFeature       pLineFeature  = null;
                ISpatialFilter pSearchFilter = new SpatialFilterClass();

                while ((pLineFeature = pCursor.NextFeature()) != null)
                {
                    IPolyline pLine = pLineFeature.Shape as IPolyline;
                    if (pLine == null)
                    {
                        continue;
                    }
                    IPoint pStartPoint = pLine.FromPoint;
                    IPoint pEndPoint   = pLine.ToPoint;
                    //开始发现起点的点
                    IEnvelope envelope = pStartPoint.Envelope;
                    envelope.Expand(_searchTolerance, _searchTolerance, false);
                    pSearchFilter.Geometry   = envelope;
                    pSearchFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects;
                    IFeatureCursor pFindCursor   = _pointClassInfo.PipeClass.Search(((IQueryFilter)pSearchFilter), false);
                    IFeature       pPointFeature = pFindCursor.NextFeature();
                    if (pPointFeature != null)
                    {
                        double elevation = Convert.ToDouble(pPointFeature.Value[_pointClassInfo.PointElevationField.Index] is DBNull ? 0 : pPointFeature.Value[_pointClassInfo.PointElevationField.Index]);
                        double depth     =
                            Convert.ToDouble(pLineFeature.Value[_lineClassInfo.StartUnderGroundElevationField.Index] is DBNull ? 0 : pLineFeature.Value[_lineClassInfo.StartUnderGroundElevationField.Index]);
                        pLineFeature.Value[_lineClassInfo.StartGroundElevationField.Index] = elevation - depth;
                    }
                    Marshal.ReleaseComObject(pFindCursor);
                    envelope = pEndPoint.Envelope;
                    envelope.Expand(_searchTolerance, _searchTolerance, false);
                    pSearchFilter.Geometry   = envelope;
                    pSearchFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects;
                    pFindCursor   = _pointClassInfo.PipeClass.Search(((IQueryFilter)pSearchFilter), false);
                    pPointFeature = pFindCursor.NextFeature();
                    if (pPointFeature != null)
                    {
                        double elevation = Convert.ToDouble(pPointFeature.Value[_pointClassInfo.PointElevationField.Index] is DBNull ? 0 : pPointFeature.Value[_pointClassInfo.PointElevationField.Index]);
                        double depth     =
                            Convert.ToDouble(pLineFeature.Value[_lineClassInfo.EndUnderGroundElevationField.Index] is DBNull ? 0 : pLineFeature.Value[_lineClassInfo.EndUnderGroundElevationField.Index]);
                        pLineFeature.Value[_lineClassInfo.EndGroundElevationField.Index] = elevation - depth;
                    }
                    pLineFeature.Store();
                    Marshal.ReleaseComObject(pFindCursor);
                }
                Marshal.ReleaseComObject(pCursor);
            }
            finally
            {
                pWorkspaceEdit.StopEditOperation();
                pWorkspaceEdit.StopEditing(true);
            }
        }
示例#15
0
        private string strSrcFiled       = null; //源图层的字段名
        public override bool Check(ref List <Error> checkResult)
        {
            IFeatureClass  pResultFc  = null;
            IFeatureCursor pResultCur = null;

            try{
                string path = string.Format("{0}\\{1}", System.IO.Path.GetDirectoryName(m_QueryWorkspace.PathName), COMMONCONST.DB_Name_Temp);
                //创建临时操作tempdist.mdb,防止把所有结果库数据存储到query库,引起query库超限
                if (File.Exists(path))
                {
                    Hy.Common.Utility.Esri.AEAccessFactory.OpenPGDB(ref TempWorkspace, path);
                }
                else
                {
                    Hy.Common.Utility.Esri.AEAccessFactory.CreatePGDB(System.IO.Path.GetDirectoryName(m_QueryWorkspace.PathName), COMMONCONST.DB_Name_Temp, ref TempWorkspace);
                }
                if (TempWorkspace == null)
                {
                    SendMessage(enumMessageType.RuleError, "创建临时操作数据库失败!无法执行检查!");
                    return(false);
                }
                // 生成中间结果图层
                // 线物不能穿越地类图斑的检查使用Identity进行,其余都使用Intersect
                // 仅适用于二调质检
                string     Resultlayer = strSrcLayer + "_Intersect";
                IGPProcess gpProcess   = null;
                string     strKey      = strSrcLayer.ToUpper();
                string     inputtables = string.Format(@"""{0}\{1}\{2}"";""{0}\{1}\{3}""", m_BaseWorkspace.PathName, "Dataset", strSrcLayer, strRelLayer);
                Intersect  spIntersect = new Intersect();
                spIntersect.in_features       = inputtables;
                spIntersect.cluster_tolerance = "0.001 Meters";
                spIntersect.join_attributes   = "ALL";
                spIntersect.out_feature_class = TempWorkspace.PathName + "\\" + Resultlayer;
                spIntersect.output_type       = "INPUT";

                gpProcess = spIntersect;
                m_gp      = new Geoprocessor();
                Execute(gpProcess);

                // 等待gp
                int counter = 0;
                while (counter++ < 100)
                {
                    if ((TempWorkspace as IWorkspace2).get_NameExists(esriDatasetType.esriDTFeatureClass, Resultlayer))
                    {
                        break;
                    }

                    System.Threading.Thread.Sleep(100);
                }
                if (m_gp != null)
                {
                    gpProcess = null;
                    m_gp      = null;
                    GC.Collect();
                }
                // 从结果图层中取出错误
                pResultFc = ((IFeatureWorkspace)TempWorkspace).OpenFeatureClass(Resultlayer);
                IQueryFilter pQry = new QueryFilterClass();

                switch (strKey)
                {
                case "LXDW":
                    pQry.WhereClause = "ZLTBBH<>TBBH";
                    break;

                case "XZDW":        //线物不能穿越地类图斑、线物要素的扣除检查
                    if (m_pPara.strAlias.IndexOf("线物不能穿越地类图斑") > -1)
                    {
                        string strClause = " and Avg(len_dist)-sum(shape_length)< " + (1 * this.m_UnitScale).ToString("N7");
                        TempWorkspace.ExecuteSQL(string.Format("delete from XZDW_Intersect where  fid_XZDW in (SELECT fid_xzdw FROM xzdw_Intersect GROUP BY fid_xzdw,fid_dltb having count(0)>1 {0}) and fid_dltb in (SELECT fid_dltb FROM xzdw_Intersect GROUP BY fid_xzdw,fid_dltb having count(0)>1 {0})", strClause));

                        pQry.SubFields   = " Distinct BSM,FID_XZDW,BSM_1";
                        pQry.WhereClause = "len_dist-shape_length>" + (1 * this.m_UnitScale).ToString("N7") + " and shape_length>" + (0.2 * this.m_UnitScale).ToString("N7");
//                            pQry.WhereClause = "len_dist-shape_length>" + (1 * this.m_UnitScale).ToString("N7") + " and shape_length>" + (0.2 * this.m_UnitScale).ToString("N7") + @" and
//                                                    fid_xzdw in
//                                                    (
//                                                    select a.fid_xzdw from
//                                                    (select fid_xzdw from xzdw_Intersect group by fid_xzdw having count(0)>1) as a,
//                                                    (SELECT fid_xzdw FROM xzdw_Intersect GROUP BY fid_xzdw,fid_dltb having count(0)=1) as b
//                                                    where a.fid_xzd9w=b.fid_xzdw
//                                                    )";
                    }
                    else
                    {
                        if (m_pPara.strAlias.IndexOf("线物要素的扣除检查") > -1)
                        {
                            pQry.WhereClause = getkcblsql();
                        }
                    }
                    break;

                default:
                    pQry.WhereClause = "left(ZLDWDM,12)<>XZQDM and shape_Area>" + (400 * this.m_UnitScale).ToString("N7");
                    break;
                }
                pResultCur  = pResultFc.Search(pQry, true);
                checkResult = GetResult(pResultCur as ICursor);

                // 更新状态
                string _strSql = "update LR_ResultEntryRule set TargetFeatClass1= '" + m_pPara.strGeographyObject +
                                 "',TargetFeatClass2='" + m_pPara.strGraphSpeckle +
                                 "|' where RuleInstID='" + this.m_InstanceID + "'";

                Hy.Common.Utility.Data.AdoDbHelper.ExecuteSql(this.m_ResultConnection, _strSql);
                // 释放资源,删除中间结果
                if (pResultCur != null)
                {
                    Marshal.ReleaseComObject(pResultCur);
                    pResultCur = null;
                }
                ((IDataset)pResultFc).Delete();

                return(true);
            }
            catch (Exception ex)
            {
                SendMessage(enumMessageType.Exception, ex.ToString());
                return(false);
            }
            finally
            {
                if (m_gp != null)
                {
                    m_gp = null;
                }
                // 释放资源,删除中间结果
                if (pResultCur != null)
                {
                    Marshal.ReleaseComObject(pResultCur);
                    pResultCur = null;
                }
                if (pResultFc != null)
                {
                    Marshal.ReleaseComObject(pResultFc);
                    pResultFc = null;
                }
                //压缩临时数据库
                IDatabaseCompact databaseCompact = TempWorkspace as IDatabaseCompact;
                if (databaseCompact != null)
                {
                    if (databaseCompact.CanCompact())
                    {
                        databaseCompact.Compact();
                    }
                }
                if (TempWorkspace != null)
                {
                    Marshal.ReleaseComObject(TempWorkspace);
                    TempWorkspace = null;
                }
                GC.Collect();
            }
        }
        public override void OnClick()
        {
            if (m_Hook == null)
            {
                return;
            }
            if (m_Hook.MapControl == null)
            {
                return;
            }
            if (m_Hook.MapControl.Map == null)
            {
                return;
            }
            IMap pMap = m_Hook.MapControl.Map;

            if (pMap.LayerCount == 0)
            {
                return;
            }
            string        strZLDJ       = "";
            IFeatureClass pZLDJFeaClass = null;
            string        ZLDJLayerName = "";

            SysCommon.ModSysSetting.CopyConfigXml(Plugin.ModuleCommon.TmpWorkSpace, "统计配置", ModQuery.m_StatisticsPath); //added by chulili 20111110先从业务库拷贝配置文件
            try
            {                                                                                                           //获取地名地物类
                ModQuery.GetPlaceNameStatisticsConfig(out pZLDJFeaClass, out ZLDJLayerName, out strZLDJ, "林地质量等级分布");
                if (pZLDJFeaClass == null)
                {
                    MessageBox.Show("林地图斑数据,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                if (pZLDJFeaClass != null)
                {
                    if (pZLDJFeaClass.FindField(strZLDJ) < 0)
                    {
                        MessageBox.Show("找不到林地图斑数据质量等级属性,请检查配置文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        pZLDJFeaClass = null;
                        return;
                    }
                }
                frmSetStatistic pfrmSetStatistic = new frmSetStatistic();
                if (pfrmSetStatistic.ShowDialog() == DialogResult.OK)
                {
                    ExportToExcel  pExportToExcel = new ExportToExcel();
                    IFeatureCursor pFeatureCursor = null;
                    if (pfrmSetStatistic.bIsCheck)
                    {
                        if (pMap.SelectionCount == 0)
                        {
                            MessageBox.Show("请在当前地图上选择林地图斑数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return;
                        }
                        //IFeatureLayer pFeatureLayer = GetLayerByName(ZLDJLayerName, pMap) as IFeatureLayer;
                        //if (pFeatureLayer == null)
                        //{
                        //    MessageBox.Show("找不到林地图斑数据,请先加载该数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        //    return;
                        //}
                        //IFeatureSelection pFeatureSelection = pFeatureLayer as IFeatureSelection;
                        //ISelectionSet pFeatSet = pFeatureSelection.SelectionSet;

                        //pFeatSet.Search(null, true, out pCursor);
                        //pFeatureCursor = pCursor as IFeatureCursor;
                        IGeometry      pGeo           = ModDBOperate.GetSelectFeatureGeom(pMap);
                        ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                        pSpatialFilter.GeometryField = "SHAPE";
                        pSpatialFilter.Geometry      = pGeo;
                        pSpatialFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
                        pFeatureCursor = pZLDJFeaClass.Search(pSpatialFilter, false);
                    }
                    else
                    {
                        pFeatureCursor = pZLDJFeaClass.Search(null, false);
                    }
                    pExportToExcel.Export(pZLDJFeaClass, pFeatureCursor, "林地质量等级分布", "林地质量等级", strZLDJ);
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
                }
                if (this.WriteLog)
                {
                    Plugin.LogTable.Writelog("专题图统计-林地质量等级统计");
                }
            }
            catch (Exception ex)
            {
                ErrorHandle.ShowFrmErrorHandle("提示", ex.Message);
            }
        }
        // this method is run when the user clicks the run button
        private void btnRun_Click(object sender, EventArgs e)
        {
            try
            {
                //show busy mouse
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

                // loop through the map get access to the layers in the combo boxes
                if (cboCountyName.SelectedIndex != -1 & cboCountyStreets.SelectedIndex != -1 & cboDFC_RESULT.SelectedIndex != -1 & cboIgnoredFC.SelectedIndex != -1 & cboUtransStreets.SelectedIndex != -1)
                {
                    //loop through the map's layer and get access to the layer in the census combobox
                    for (int i = 0; i < arcMapp.LayerCount; i++)
                    {
                        if (arcMapp.get_Layer(i).Name == cboCountyStreets.Text)
                        {
                            arcFL_CountyStreets = arcMapp.get_Layer(i) as IFeatureLayer;
                        }
                        if (arcMapp.get_Layer(i).Name == cboDFC_RESULT.Text)
                        {
                            arcFL_DFC = arcMapp.get_Layer(i) as IFeatureLayer;
                        }
                        if (arcMapp.get_Layer(i).Name == cboIgnoredFC.Text)
                        {
                            arcFL_IgnoreFGDB = arcMapp.get_Layer(i) as IFeatureLayer;
                        }
                        if (arcMapp.get_Layer(i).Name == cboUtransStreets.Text)
                        {
                            arcFL_UtransStreet = arcMapp.get_Layer(i) as IFeatureLayer;
                        }
                    }


                    //make sure we have access to all the needed layers
                    if (arcFL_CountyStreets == null)
                    {
                        MessageBox.Show("Please select the correct layer for COUNTY_STREETS", "Layer Name Issue", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (arcFL_DFC == null)
                    {
                        MessageBox.Show("Please select the correct layer for DFC_RESULT", "Layer Name Issue", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (arcFL_IgnoreFGDB == null)
                    {
                        MessageBox.Show("Please select the correct layer for the FGDB Ignore feature class", "Layer Name Issue", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    if (arcFL_UtransStreet == null)
                    {
                        MessageBox.Show("Please select the correct layer for UTRANS.Roads_Edit", "Layer Name Issue", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }


                    // split the COUNTY_L value to get out the number
                    string   strCOUNTY_L_Combobox = null;
                    string[] strCOUNTY_L_Array    = null;
                    string   strCOUNTY_L_Number   = null;
                    strCOUNTY_L_Combobox = cboCountyName.Text;
                    strCOUNTY_L_Array    = strCOUNTY_L_Combobox.Split('-');
                    strCOUNTY_L_Number   = strCOUNTY_L_Array[0].ToString().Trim();


                    // set up feature cursor for getting the ignore records from the dfc
                    IQueryFilter arcQF_DFC_Ignore = new QueryFilter();
                    arcQF_DFC_Ignore.WhereClause = "CURRENT_NOTES in ('NOTIFY AND IGNORE', 'IGNORE')";
                    IFeatureCursor arcFeatCursor_DFC = arcFL_DFC.Search(arcQF_DFC_Ignore, false);

                    // loop through the dfc_result layer's "ignore" and 'notify and ignore' features
                    while ((arcFeat_DFC = arcFeatCursor_DFC.NextFeature()) != null)
                    {
                        //create a new feature in the ignore fgdb feature class and give it the geometry of the current dfc_result feature
                        IFeature arcNewFeature = arcFL_IgnoreFGDB.FeatureClass.CreateFeature();
                        arcNewFeature.Shape = arcFeat_DFC.Shape;

                        string strUtransOID      = null;
                        string strCountyRoadsOID = null;
                        string strCurrentNotes   = null;
                        string strPrevNotes      = null;
                        string strChangeType     = null;


                        // get the field values from the dfc_result layer
                        strUtransOID      = arcFeat_DFC.get_Value(arcFeat_DFC.Fields.FindField("BASE_FID")).ToString();
                        strCountyRoadsOID = arcFeat_DFC.get_Value(arcFeat_DFC.Fields.FindField("UPDATE_FID")).ToString();
                        strCurrentNotes   = arcFeat_DFC.get_Value(arcFeat_DFC.Fields.FindField("CURRENT_NOTES")) as string;
                        strPrevNotes      = arcFeat_DFC.get_Value(arcFeat_DFC.Fields.FindField("PREV__NOTES")) as string;
                        strChangeType     = arcFeat_DFC.get_Value(arcFeat_DFC.Fields.FindField("CHANGE_TYPE")) as string;

                        // set field values for new feature
                        arcNewFeature.set_Value(arcFL_IgnoreFGDB.FeatureClass.Fields.FindField("UPDATE_FID"), strCountyRoadsOID);
                        arcNewFeature.set_Value(arcFL_IgnoreFGDB.FeatureClass.Fields.FindField("BASE_FID"), strUtransOID);
                        arcNewFeature.set_Value(arcFL_IgnoreFGDB.FeatureClass.Fields.FindField("CHANGE_TYPE"), strChangeType);
                        arcNewFeature.set_Value(arcFL_IgnoreFGDB.FeatureClass.Fields.FindField("CURRENT_NOTES"), strCurrentNotes);
                        arcNewFeature.set_Value(arcFL_IgnoreFGDB.FeatureClass.Fields.FindField("PREV__NOTES"), strPrevNotes);
                        arcNewFeature.set_Value(arcFL_IgnoreFGDB.FeatureClass.Fields.FindField("Date_Ignored"), dateTimePickerExportIgnores.Value.ToShortDateString());
                        arcNewFeature.set_Value(arcFL_IgnoreFGDB.FeatureClass.Fields.FindField("COUNTY_L"), strCOUNTY_L_Number);

                        // set up query filters and cursors for the utrans segment to get values from
                        if (strUtransOID != "-1")
                        {
                            IQueryFilter arcQF_Utrans = new QueryFilter();
                            arcQF_Utrans.WhereClause = "OBJECTID = " + strUtransOID;
                            IFeatureCursor arcFeatCursor_Utrans = arcFL_UtransStreet.Search(arcQF_Utrans, false);
                            IFeature       arcFeat_Utrans       = arcFeatCursor_Utrans.NextFeature();

                            if (arcFeat_Utrans != null)
                            {
                                //populate the utrans segment with the needed values
                                arcNewFeature.set_Value(arcFL_IgnoreFGDB.FeatureClass.Fields.FindField("UtransSegment"), "| " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("FROMADDR_L")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("TOADDR_L")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("FROMADDR_R")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("TOADDR_R")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("PREDIR")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("NAME")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("POSTTYPE")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("POSTDIR")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("A1_NAME")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("A1_POSTTYPE")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("A2_NAME")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("A2_POSTTYPE")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("AN_NAME")).ToString().Trim() + " | " +
                                                        arcFeat_Utrans.get_Value(arcFeat_Utrans.Fields.FindField("AN_POSTDIR")).ToString().Trim() + " |");

                                //null out query filter and feature cursor
                                System.Runtime.InteropServices.Marshal.ReleaseComObject(arcFeatCursor_Utrans);
                                GC.Collect();
                                arcFeatCursor_Utrans = null;
                                arcQF_Utrans         = null;
                            }
                            else
                            {
                                //utrans segment not found
                                arcNewFeature.set_Value(arcFL_IgnoreFGDB.FeatureClass.Fields.FindField("UtransSegment"), "None Found");
                            }
                        }
                        else
                        {
                            //utrans segment not found
                            arcNewFeature.set_Value(arcFL_IgnoreFGDB.FeatureClass.Fields.FindField("UtransSegment"), "None Found");
                        }



                        // get the values from the county_streets layer
                        IQueryFilter arcQF_CountyStreets = new QueryFilter();
                        arcQF_CountyStreets.WhereClause = "OBJECTID = " + strCountyRoadsOID;
                        IFeatureCursor arcFeatCursor_CountyStreets = arcFL_CountyStreets.Search(arcQF_CountyStreets, false);
                        IFeature       arcFeat_CountyStreets       = arcFeatCursor_CountyStreets.NextFeature();

                        if (arcFeat_CountyStreets != null)
                        {
                            //populate the utrans segment with the needed values
                            arcNewFeature.set_Value(arcFL_IgnoreFGDB.FeatureClass.Fields.FindField("CountySegment"), "| " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("FROMADDR_L")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("TOADDR_L")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("FROMADDR_R")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("TOADDR_R")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("PREDIR")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("NAME")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("POSTTYPE")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("POSTDIR")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("A1_NAME")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("A1_POSTTYPE")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("A2_NAME")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("A2_POSTTYPE")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("AN_NAME")).ToString().Trim() + " | " +
                                                    arcFeat_CountyStreets.get_Value(arcFeat_CountyStreets.Fields.FindField("AN_POSTDIR")).ToString().Trim() + " |");

                            //null out query filter and feature cursor
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(arcFeat_CountyStreets);
                            GC.Collect();
                            arcFeat_CountyStreets = null;
                            arcQF_CountyStreets   = null;
                        }
                        else
                        {
                            arcNewFeature.set_Value(arcFL_IgnoreFGDB.FeatureClass.Fields.FindField("CountySegment"), "None Found");
                        }


                        // store the new row/feature
                        arcNewFeature.Store();
                    }

                    //null out query filter and feature cursor
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(arcQF_DFC_Ignore);
                    GC.Collect();

                    MessageBox.Show("Done exporting Ignores from " + strCOUNTY_L_Array[1].ToString().Trim() + " County's DFC_RESULT layer.", "Finished!", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    //close the form
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Make sure all the dropdown menus have been choosen.", "Missing Selections", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine +
                                "Error Source: " + Environment.NewLine + ex.Source + Environment.NewLine + Environment.NewLine +
                                "Error Location:" + Environment.NewLine + ex.StackTrace,
                                "UTRANS Editor tool error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
示例#18
0
文件: KML.cs 项目: jugstalt/gview5
 static public Task <Stream> ToKml(IFeatureCursor cursor)
 {
     return(ToKml(cursor, int.MaxValue));
 }
		public void Draw(IFeatureCursor cursor, esriDrawPhase DrawPhase, IDisplay Display, ITrackCancel trackCancel)
		{
			string ActiveErrorHandler = null;

	try
	{
			// loop through and draw each feature

			IFeature pFeat = null;
			IFeatureRenderer pRend = null;

			bool bContinue = false;

			// do not draw features if no display
			if (Display == null)
				return;

			// we can't draw without somewhere to get our base symbols from
			if (m_pMainRend == null)
				return;

			if (m_pSizeRend != null)
			{
				// size varies
				if (m_ShapeType == esriGeometryType.esriGeometryPoint | m_ShapeType == esriGeometryType.esriGeometryPolyline)
				{
					if (DrawPhase == esriDrawPhase.esriDPGeography)
					{
						// draw symbols in order from large to small
						DrawSymbolsInOrder(cursor, DrawPhase, Display, trackCancel);
					}
				}
				else if (m_ShapeType == esriGeometryType.esriGeometryPolygon)
				{
					if (DrawPhase == esriDrawPhase.esriDPAnnotation)
					{
						// draw primary symbology from large to small
						DrawSymbolsInOrder(cursor, DrawPhase, Display, trackCancel);
					}
					else if (DrawPhase == esriDrawPhase.esriDPGeography)
					{
						// draw background symbology
						pFeat = cursor.NextFeature();
						bContinue = true;

						// while there are still more features and drawing has not been cancelled
                        IFillSymbol pBackFillSym;

                        
						while ((pFeat != null) & (bContinue == true))
						{
							// draw the feature
                            IFeatureDraw pFeatDraw = pFeat as IFeatureDraw;
							if (m_pSizeRend is IClassBreaksRenderer)
							{
                                IClassBreaksRenderer pCBRend = m_pSizeRend as IClassBreaksRenderer;
								pBackFillSym = pCBRend.BackgroundSymbol;
							}
							else
							{
                                IProportionalSymbolRenderer pPropRend = m_pSizeRend as IProportionalSymbolRenderer;
								pBackFillSym = pPropRend.BackgroundSymbol;
							}
							Display.SetSymbol(pBackFillSym as ISymbol);

              //implementation of IExportSupport
              BeginFeature(pFeat, Display);
              
							pFeatDraw.Draw(DrawPhase, Display, pBackFillSym as ISymbol, true, null, esriDrawStyle.esriDSNormal);

              //implementation of IExportSupport
							GenerateExportInfo(pFeat, Display);
							EndFeature(Display);
							
							pFeat = cursor.NextFeature();
              if (trackCancel != null)
                bContinue = trackCancel.Continue();
						}
					}
					else
					{
                        Marshal.ThrowExceptionForHR(147500037); //E_FAIL
					}
				}

			}
			else
			{
				// size does not vary
				if (DrawPhase != esriDrawPhase.esriDPGeography)
				{
                    Marshal.ThrowExceptionForHR(147500037); //E_FAIL
				}
				else
					DrawSymbols(cursor, DrawPhase, Display, trackCancel);
			}

}

catch
{
}
		}
示例#20
0
        /// <summary>
        /// 空值检查
        /// </summary>
        /// <param name="hook"></param>
        /// <param name="pFeatureDataset"></param>
        /// <param name="FeaClsNameDic">图层名和属性非空的字段名对</param>
        /// <param name="outError"></param>
        public void IsNullableCheck(IArcgisDataCheckHook hook, IFeatureDataset pFeatureDataset, Dictionary <string, List <string> > FeaClsNameDic, out Exception outError)
        {
            outError = null;
            try
            {
                //设置进度条
                ProgressChangeEvent eInfo = new ProgressChangeEvent();
                eInfo.Max = FeaClsNameDic.Count;
                int pValue = 0;

                foreach (KeyValuePair <string, List <string> > item in FeaClsNameDic)
                {
                    IFeatureClass pFeaCls = (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(item.Key.Trim());
                    for (int i = 0; i < item.Value.Count; i++)
                    {
                        string fieldName = item.Value[i].Trim();
                        int    index     = pFeaCls.Fields.FindField(fieldName);
                        if (index == -1)
                        {
                            outError = new Exception("找不到字段名为" + fieldName + "的字段");
                            return;
                        }
                        if (pFeaCls.Fields.get_Field(index).IsNullable == true)
                        {
                            //字段属性为空,与标准不一致,将结果保存起来
                            List <object> ErrorLst = new List <object>();
                            ErrorLst.Add("要素属性检查");                                         //功能组名称
                            ErrorLst.Add("空值检查");                                           //功能名称
                            ErrorLst.Add((pFeatureDataset as IDataset).Workspace.PathName); //数据文件名
                            ErrorLst.Add(enumErrorType.空值检查.GetHashCode());                 //错误id;
                            ErrorLst.Add("图层" + item.Key + "的字段" + fieldName + "属性值不允许为空"); //错误描述
                            ErrorLst.Add(0);                                                //...
                            ErrorLst.Add(0);                                                //...
                            ErrorLst.Add(item.Key);
                            ErrorLst.Add(-1);
                            ErrorLst.Add("");
                            ErrorLst.Add(-1);
                            ErrorLst.Add(false);
                            ErrorLst.Add(System.DateTime.Now.ToString());

                            //传递错误日志
                            IDataErrInfo      dataErrInfo       = new DataErrInfo(ErrorLst);
                            DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                            DataErrTreat(hook.DataCheckParaSet as object, dataErrTreatEvent);
                        }
                        else
                        {
                            IFeatureCursor pFeaCusor = pFeaCls.Search(null, false);
                            if (pFeaCusor == null)
                            {
                                return;
                            }
                            IFeature pFeature = pFeaCusor.NextFeature();
                            if (pFeature == null)
                            {
                                continue;
                            }
                            while (pFeature != null)
                            {
                                object fieldValue = pFeature.get_Value(index);
                                if (fieldValue == null || fieldValue.ToString() == "")
                                {
                                    //字段值不能为空,将检查结果保存起来
                                    double pMapx  = 0.0;
                                    double pMapy  = 0.0;
                                    IPoint pPoint = new PointClass();
                                    if (pFeaCls.ShapeType != esriGeometryType.esriGeometryPoint)
                                    {
                                        pPoint = TopologyCheckClass.GetPointofFeature(pFeature);
                                    }
                                    else
                                    {
                                        pPoint = pFeature.Shape as IPoint;
                                    }
                                    pMapx = pPoint.X;
                                    pMapy = pPoint.Y;
                                    List <object> ErrorLst = new List <object>();
                                    ErrorLst.Add("要素属性检查");                                         //功能组名称
                                    ErrorLst.Add("空值检查");                                           //功能名称
                                    ErrorLst.Add((pFeatureDataset as IDataset).Workspace.PathName); //数据文件名
                                    ErrorLst.Add(enumErrorType.空值检查.GetHashCode());                 //错误id;
                                    ErrorLst.Add("图层" + item.Key + "的字段" + fieldName + "的值不能为空");   //错误描述
                                    ErrorLst.Add(pMapx);                                            //...
                                    ErrorLst.Add(pMapy);                                            //...
                                    ErrorLst.Add(item.Key);
                                    ErrorLst.Add(pFeature.OID);
                                    ErrorLst.Add("");
                                    ErrorLst.Add(-1);
                                    ErrorLst.Add(false);
                                    ErrorLst.Add(System.DateTime.Now.ToString());

                                    //传递错误日志
                                    IDataErrInfo      dataErrInfo       = new DataErrInfo(ErrorLst);
                                    DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                                    DataErrTreat(hook.DataCheckParaSet as object, dataErrTreatEvent);
                                }
                                pFeature = pFeaCusor.NextFeature();
                            }

                            //释放cursor
                            System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCusor);
                        }
                    }


                    //进度条加1
                    pValue++;
                    eInfo.Value = pValue;
                    GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);
                }
            }
            catch (Exception ex)
            {
                outError = ex;
            }
        }
        private static bool LoadCursor()
        {
            if (v_ViewerLayer == null )return false;

            IQueryFilter pQFilt = default(IQueryFilter);
            IFeature pFeat = default(IFeature);
            try
            {
                if (v_ViewerLayerCursorArray == null)
                {
                    v_ViewerLayerCursorArray = new ArrayList();
                }
                else
                {
                    v_ViewerLayerCursorArray.Clear();
                }

                pQFilt = new QueryFilter();
                string[] pstr = s_cboLayers.SelectedValue.ToString().Split(',');

                pQFilt.WhereClause = pstr[0];
                s_txtScale.Text = pstr[1];
                s_txtQuery.Text = pstr[0];

                if (v_ViewerLayer.FeatureClass.FeatureCount(pQFilt) == 0)
                    return false;

                v_ViewerLayerCursor = v_ViewerLayer.Search(pQFilt, false);

                pFeat = v_ViewerLayerCursor.NextFeature();

                while (!(pFeat == null))
                {

                    v_ViewerLayerCursorArray.Add(pFeat);
                    pFeat = v_ViewerLayerCursor.NextFeature();
                }
                pQFilt = null;
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in LayerWindow - LoadCursor" + Environment.NewLine + ex.Message);

                return false;
            }
            finally
            {
                pQFilt = null;
                pFeat = null;
            }
        }
 private void 取消编辑ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     this.gdvAttribute.DataSource = null;
     this.gdvAttribute.ReadOnly = true;
     pFCuror = pFClass.Search(null, false);
     RefreshDataGridViewDataSource(gdvAttribute, GetAttributeTable(pFClass, pFCuror));
 }
 private void 字段运算ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FormFieldCalculation formcalfield = new FormFieldCalculation(pFLayer, gdvAttribute, curColumnName);
     formcalfield.Show();
     pFCuror = pFClass.Search(null, false);
     RefreshDataGridViewDataSource(gdvAttribute, GetAttributeTable(pFClass, pFCuror));
 }
        /// <summary>
        ///     Insert a row into the feature class.
        /// </summary>
        /// <param name="featureClass">
        ///     The feature class that will have rows inserted
        /// </param>
        /// <param name="key">
        ///     The key.
        /// </param>
        /// <param name="insertCur">
        ///     The insert cur.
        /// </param>
        /// <param name="resultDictionary">
        ///     The result dictionary.
        /// </param>
        /// <param name="uniqueFieldNames">
        ///     The unique field names.
        /// </param>
        private void InsertRow(
            IFeatureClass featureClass,
            string key,
            IFeatureCursor insertCur,
            Dictionary<string, Dictionary<string, double>> resultDictionary,
            Dictionary<string, string> uniqueFieldNames)
        {
            try
            {
                // get the polygon of the geohash
                var poly = this.GetGeoHashPoly(key);
                var buffer = featureClass.CreateFeatureBuffer();

                // Setup the features geometry.
                buffer.Shape = (IGeometry)poly;
                buffer.Value[featureClass.FindField("GeoHash")] = key;
                foreach (var subKey in resultDictionary[key].Keys)
                {
                    var field = uniqueFieldNames[subKey];
                    var value = resultDictionary[key][subKey];
                    var index = featureClass.FindField("DG_" + field);

                    if (index != -1)
                    {
                        buffer.Value[index] = value;
                    }
                }

                // Feature has been created so add to the feature class.
                insertCur.InsertFeature(buffer);
            }
            catch (Exception error)
            {
                Jarvis.Logger.Error(error);
            }
        }
示例#25
0
        private void bttCK_Click(object sender, EventArgs e)
        {
            try
            {
                string[]         strMapNo     = GetMapNo().Split(new char[] { ',' });
                IList <IFeature> pListFeature = new List <IFeature>();
                if (strMapNo == null)
                {
                    return;
                }
                Exception eError;
                string    NodeKey = "";
                if (strMapNo[0].Length == 3)//1:100万 接图表NodeKey
                {
                    NodeKey = GetNodeKey(1).ToString();
                }
                else
                {
                    switch (strMapNo[0].ToString().Substring(3, 1).ToUpper())
                    {
                    case "C":    //1:25万 接图表NodeKey
                        NodeKey = GetNodeKey(2).ToString();
                        break;

                    case "E":                               //1:5万 接图表NodeKey
                        NodeKey = GetNodeKey(3).ToString(); //不同比例尺的接图表的ID号
                        break;
                    }
                }
                if (NodeKey == "")
                {
                    MessageBox.Show("未加载对应图层", "提示!");
                }

                IFeatureClass pFeatureClass = GeoModule.GetFeatureClassByNodeKey(NodeKey);
                if (pFeatureClass == null)
                {
                    return;
                }
                for (int i = 0; i < strMapNo.Length; i++)
                {
                    IQueryFilter   pQueryFilter   = new QueryFilterClass();
                    IFeature       pFeature       = null;
                    IFeatureCursor pFeatureCursor = null;
                    //ZQ 20110807   add
                    ITable  pTable  = pFeatureClass as ITable;
                    IFields pFields = pTable.Fields;
                    IField  pField  = pFields.get_Field(pFields.FindField(GetMapNoField(NodeKey)));
                    if (pField.Type.ToString() == "esriFieldTypeString")
                    {
                        pQueryFilter.WhereClause = GetMapNoField(NodeKey).ToString() + "='" + strMapNo[i].ToString().ToUpper() + "'";
                    }
                    else if (pField.Type.ToString() == "esriFieldTypeDouble")
                    {
                        pQueryFilter.WhereClause = GetMapNoField(NodeKey).ToString() + "=" + strMapNo[i].ToString().ToUpper();
                    }
                    //end
                    pFeatureCursor = pFeatureClass.Search(pQueryFilter, false);
                    pFeature       = pFeatureCursor.NextFeature();
                    while (pFeature != null)
                    {
                        pListFeature.Add(pFeature);
                        pFeature = pFeatureCursor.NextFeature();
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeatureCursor);
                }

                IGeometry pGeometry = GetLyrUnionPlygon(pListFeature);
                if (pGeometry == null)
                {
                    MessageBox.Show("不存在相关图幅信息,请认真核对图幅信息!", "提示!"); return;
                }
                this.WindowState    = FormWindowState.Minimized;
                m_MapControl.Extent = pGeometry.Envelope;
                m_MapControl.ActiveView.Refresh();
            }
            catch { }
        }
示例#26
0
        async public Task Run()
        {
            if (_dataset == null || !(_fdb is IFeatureDatabaseReplication) || _edgeFcs == null)
            {
                return;
            }

            IFeatureDatabaseReplication db = (IFeatureDatabaseReplication)_fdb;

            if (_dataset.Element(_networkName) != null)
            {
                MessageBox.Show("Featureclass '" + _networkName + "' already exists!");
                return;
            }
            bool       succeeded = false;
            List <int> FcIds     = new List <int>();

            try
            {
                ProgressReport report = new ProgressReport();

                int datasetId = await _fdb.DatasetID(_dataset.DatasetName);

                if (datasetId == -1)
                {
                    return;
                }

                NetworkBuilder networkBuilder = new NetworkBuilder(await _dataset.Envelope(), _tolerance);
                if (ReportProgress != null)
                {
                    networkBuilder.reportProgress += new ProgressReporterEvent(networkBuilder_reportProgress);
                }

                #region Spatial Index
                BinaryTreeDef edgeTreeDef = null, nodeTreeDef = null;
                foreach (IFeatureClass fc in _edgeFcs)
                {
                    BinaryTreeDef treeDef = await _fdb.BinaryTreeDef(fc.Name);

                    if (treeDef == null)
                    {
                        IEnvelope bounds = fc.Envelope;
                        if (Envelope.IsNull(bounds))
                        {
                            continue;
                        }
                        treeDef = new BinaryTreeDef(fc.Envelope, 10);
                    }
                    if (edgeTreeDef == null)
                    {
                        edgeTreeDef = new BinaryTreeDef(treeDef.Bounds, Math.Min(treeDef.MaxLevel, 10));
                    }
                    else
                    {
                        Envelope bounds = edgeTreeDef.Bounds;
                        bounds.Union(treeDef.Bounds);
                        edgeTreeDef = new BinaryTreeDef(bounds, Math.Min(Math.Max(edgeTreeDef.MaxLevel, treeDef.MaxLevel), 10));
                    }
                }
                foreach (IFeatureClass fc in _nodeFcs)
                {
                    BinaryTreeDef treeDef = await _fdb.BinaryTreeDef(fc.Name);

                    if (treeDef == null)
                    {
                        IEnvelope bounds = fc.Envelope;
                        if (Envelope.IsNull(bounds))
                        {
                            continue;
                        }
                        treeDef = new BinaryTreeDef(fc.Envelope, 10);
                    }
                    if (nodeTreeDef == null)
                    {
                        nodeTreeDef = new BinaryTreeDef(treeDef.Bounds, Math.Min(treeDef.MaxLevel, 10));
                    }
                    else
                    {
                        Envelope bounds = nodeTreeDef.Bounds;
                        bounds.Union(treeDef.Bounds);
                        nodeTreeDef = new BinaryTreeDef(bounds, Math.Min(Math.Max(nodeTreeDef.MaxLevel, treeDef.MaxLevel), 10));
                    }
                }
                #endregion

                #region Add Edges
                foreach (IFeatureClass fc in _edgeFcs)
                {
                    int fcId = await _fdb.FeatureClassID(datasetId, fc.Name);

                    if (fcId == -1)
                    {
                        continue;
                    }
                    FcIds.Add(fcId);

                    bool        useOneway = false;
                    QueryFilter filter    = new QueryFilter();
                    filter.AddField(fc.IDFieldName);
                    filter.AddField(fc.ShapeFieldName);
                    if (!String.IsNullOrEmpty(_onewayFieldName) && fc.FindField(_onewayFieldName) != null)
                    {
                        filter.AddField(_onewayFieldName);
                        useOneway = true;
                    }
                    Dictionary <Guid, IGraphWeightFeatureClass> gwfcs = new Dictionary <Guid, IGraphWeightFeatureClass>();
                    if (_graphWeights != null)
                    {
                        foreach (IGraphWeight weight in _graphWeights)
                        {
                            foreach (IGraphWeightFeatureClass gwfc in weight.FeatureClasses)
                            {
                                if (gwfc.FcId == fcId && !String.IsNullOrEmpty(gwfc.FieldName))
                                {
                                    gwfcs.Add(weight.Guid, gwfc);
                                    filter.AddField(gwfc.FieldName);
                                }
                            }
                        }
                    }
                    if (gwfcs.Keys.Count == 0)
                    {
                        gwfcs = null;
                    }

                    bool useWithComplexEdges = false;
                    if (_complexEdgeFcs != null &&
                        (_complexEdgeFcs.Contains(fcId) || _complexEdgeFcs.Contains(-1)))
                    {
                        useWithComplexEdges = true;
                    }

                    using (IFeatureCursor cursor = await fc.GetFeatures(filter))
                    {
                        #region Report
                        report.Message    = "Analize Edges: " + fc.Name;
                        report.featureMax = await fc.CountFeatures();

                        report.featurePos = 0;
                        if (ReportProgress != null)
                        {
                            ReportProgress(report);
                        }
                        #endregion

                        IFeature feature;
                        while ((feature = await cursor.NextFeature()) != null)
                        {
                            bool oneway = false;
                            if (useOneway)
                            {
                                int ow = Convert.ToInt32(feature[_onewayFieldName]);
                                oneway = (ow != 0);
                            }
                            Hashtable gw = null;
                            if (gwfcs != null)
                            {
                                foreach (Guid weightGuid in gwfcs.Keys)
                                {
                                    IGraphWeightFeatureClass gwfc = gwfcs[weightGuid];
                                    object objVal = feature[gwfc.FieldName];

                                    double val = (objVal == DBNull.Value) ? 0.0 : Convert.ToDouble(feature[gwfc.FieldName]);
                                    if (gwfc.SimpleNumberCalculation != null)
                                    {
                                        val = gwfc.SimpleNumberCalculation.Calculate(val);
                                    }
                                    if (gw == null)
                                    {
                                        gw = new Hashtable();
                                    }
                                    gw.Add(weightGuid, val);
                                }
                            }
                            networkBuilder.AddEdgeFeature(fcId, feature, oneway, gw, useWithComplexEdges);

                            #region Report
                            report.featurePos++;
                            if (report.featurePos % 1000 == 0)
                            {
                                if (ReportProgress != null)
                                {
                                    ReportProgress(report);
                                }
                            }
                            #endregion
                        }
                    }
                }
                #endregion

                #region Calculate ComplexEdges
                if (_complexEdgeFcs != null && _complexEdgeFcs.Count > 0)
                {
                    List <NetworkNode> networkNodes = networkBuilder.NetworkNodes.ToList();

                    #region Report
                    report.Message    = "Create Complex Edges...";
                    report.featureMax = networkNodes.Count;
                    report.featurePos = 0;
                    if (ReportProgress != null)
                    {
                        ReportProgress(report);
                    }
                    #endregion

                    foreach (NetworkNode node in networkNodes)
                    {
                        networkBuilder.SplitToComplexEdges(node);

                        #region Report
                        report.featurePos++;
                        if (report.featurePos % 1000 == 0)
                        {
                            if (ReportProgress != null)
                            {
                                ReportProgress(report);
                            }
                        }
                        #endregion
                    }
                }
                #endregion

                #region Add Nodes
                if (_nodeFcs != null)
                {
                    foreach (IFeatureClass fc in _nodeFcs)
                    {
                        int fcId = await _fdb.FeatureClassID(datasetId, fc.Name);

                        if (fcId == -1)
                        {
                            continue;
                        }
                        FcIds.Add(fcId);

                        bool   isSwitchable         = false;
                        string switchStateFieldname = String.Empty;
                        if (_switchNodeFcs != null && _switchNodeFcs.ContainsKey(fcId))
                        {
                            isSwitchable         = true;
                            switchStateFieldname = _switchNodeFcs[fcId];
                        }
                        NetworkNodeType nodeType = NetworkNodeType.Unknown;
                        if (_nodeTypeFcs != null && _nodeTypeFcs.ContainsKey(fcId))
                        {
                            nodeType = _nodeTypeFcs[fcId];
                        }

                        QueryFilter filter = new QueryFilter();
                        filter.AddField(fc.IDFieldName);
                        filter.AddField(fc.ShapeFieldName);
                        filter.AddField(switchStateFieldname);

                        using (IFeatureCursor cursor = await fc.GetFeatures(filter))
                        {
                            #region Report
                            report.Message    = "Analize Nodes: " + fc.Name;
                            report.featureMax = await fc.CountFeatures();

                            report.featurePos = 0;
                            if (ReportProgress != null)
                            {
                                ReportProgress(report);
                            }
                            #endregion

                            IFeature feature;
                            while ((feature = await cursor.NextFeature()) != null)
                            {
                                bool switchState = isSwitchable;
                                if (isSwitchable && !String.IsNullOrEmpty(switchStateFieldname))
                                {
                                    object so = feature[switchStateFieldname];
                                    if (so != null)
                                    {
                                        if (so is bool)
                                        {
                                            switchState = (bool)so;
                                        }
                                        else
                                        {
                                            try
                                            {
                                                switchState = Convert.ToInt32(so) > 0;
                                            }
                                            catch { switchState = false; }
                                        }
                                    }
                                }
                                networkBuilder.AddNodeFeature(fcId, feature, isSwitchable, switchState, nodeType);

                                #region Report
                                report.featurePos++;
                                if (report.featurePos % 1000 == 0)
                                {
                                    if (ReportProgress != null)
                                    {
                                        ReportProgress(report);
                                    }
                                }
                                #endregion
                            }
                        }
                    }
                }
                #endregion

                #region CreateGraph
                #region Report
                report.Message    = "Create Graph";
                report.featurePos = 0;
                if (ReportProgress != null)
                {
                    ReportProgress(report);
                }
                #endregion

                networkBuilder.CreateGraph();
                #endregion

                #region Create Edge Featureclass

                #region Simple Edges Table
                Fields fields = new Fields();
                fields.Add(new Field("Page", FieldType.integer));
                fields.Add(new Field("Data", FieldType.binary));
                await db.CreateIfNotExists(_networkName + "_Edges", fields);

                #endregion

                #region Edge Index Table
                fields = new Fields();
                fields.Add(new Field("EID", FieldType.integer));
                fields.Add(new Field("FCID", FieldType.integer));
                fields.Add(new Field("OID", FieldType.integer));
                fields.Add(new Field("ISCOMPLEX", FieldType.boolean));
                await db.CreateIfNotExists(_networkName + "_EdgeIndex", fields);

                #endregion

                #region Complex Edges FeatureClass
                fields = new Fields();
                fields.Add(new Field("EID", FieldType.integer));
                fields.Add(new Field("N1", FieldType.integer));
                fields.Add(new Field("N2", FieldType.integer));
                fields.Add(new Field("FCID", FieldType.integer));
                fields.Add(new Field("OID", FieldType.integer));
                //fields.Add(new Field("Length", FieldType.integer));
                //fields.Add(new Field("GeoLength", FieldType.integer));

                await _fdb.ReplaceFeatureClass(_dataset.DatasetName,
                                               _networkName + "_ComplexEdges",
                                               new GeometryDef(geometryType.Polyline),
                                               fields);

                IDatasetElement element = await _dataset.Element(_networkName + "_ComplexEdges");

                if (element == null || !(element.Class is IFeatureClass))
                {
                    return;
                }
                if (edgeTreeDef != null)
                {
                    await _fdb.SetSpatialIndexBounds(_networkName + "_ComplexEdges", "BinaryTree2", edgeTreeDef.Bounds, edgeTreeDef.SplitRatio, edgeTreeDef.MaxPerNode, edgeTreeDef.MaxLevel);
                }
                #endregion

                int             edge_page = 0;
                List <IFeature> features = new List <IFeature>(), features2 = new List <IFeature>();
                List <IRow>     rows   = new List <IRow>();
                IFeatureClass   edgeFc = (IFeatureClass)element.Class;
                IFeatureCursor  c      = networkBuilder.Edges;
                IFeature        f;

                #region Report
                report.Message = "Create Edges";
                if (c is ICount)
                {
                    report.featureMax = ((ICount)c).Count;
                }
                report.featurePos = 0;
                if (ReportProgress != null)
                {
                    ReportProgress(report);
                }
                #endregion

                string tabEdgesName     = _fdb.TableName(_networkName + "_Edges");
                string tabEdgeIndexName = _fdb.TableName(_networkName + "_EdgeIndex");

                while ((f = await c.NextFeature()) != null)
                {
                    int eid = (int)f["EID"];
                    if ((bool)f["ISCOMPLEX"] == true)
                    {
                        #region Complex Edges
                        features.Add(f);

                        report.featurePos++;
                        if (features.Count > 0 && features.Count % 1000 == 0)
                        {
                            if (ReportProgress != null)
                            {
                                ReportProgress(report);
                            }
                            await _fdb.Insert(edgeFc, features);

                            features.Clear();
                        }
                        #endregion
                    }
                    #region Edges Table
                    features2.Add(f);
                    if (NetworkObjectSerializer.Page(eid + 1) > edge_page)
                    {
                        IRow row = new Row();
                        row.Fields.Add(new FieldValue("Page", edge_page++));
                        row.Fields.Add(new FieldValue("Data", NetworkObjectSerializer.SerializeEdges(features2)));
                        db.InsertRow(tabEdgesName, row, null);
                        features2.Clear();
                    }
                    #endregion
                    #region Edge Index
                    IRow eir = new Row();
                    eir.Fields.Add(new FieldValue("EID", (int)f["EID"]));
                    eir.Fields.Add(new FieldValue("FCID", (int)f["FCID"]));
                    eir.Fields.Add(new FieldValue("OID", (int)f["OID"]));
                    eir.Fields.Add(new FieldValue("ISCOMPLEX", (bool)f["ISCOMPLEX"]));
                    rows.Add(eir);
                    if (rows.Count > 0 && rows.Count % 1000 == 0)
                    {
                        _fdb.InsertRows(tabEdgeIndexName, rows, null);
                        rows.Clear();
                    }

                    #endregion
                }
                if (rows.Count > 0)
                {
                    _fdb.InsertRows(tabEdgeIndexName, rows, null);
                    rows.Clear();
                }
                if (features2.Count > 0)
                {
                    IRow row = new Row();
                    row.Fields.Add(new FieldValue("Page", edge_page));
                    row.Fields.Add(new FieldValue("Data", NetworkObjectSerializer.SerializeEdges(features2)));
                    db.InsertRow(tabEdgesName, row, null);
                    features2.Clear();
                }
                if (features.Count > 0)
                {
                    if (ReportProgress != null)
                    {
                        ReportProgress(report);
                    }
                    await _fdb.Insert(edgeFc, features);
                }
                await _fdb.CalculateExtent(edgeFc);

                #endregion
                #region Create Weights
                if (_graphWeights != null)
                {
                    foreach (IGraphWeight weight in _graphWeights)
                    {
                        fields = new Fields();
                        fields.Add(new Field("Page", FieldType.integer));
                        fields.Add(new Field("Data", FieldType.binary));
                        await db.CreateIfNotExists(_networkName + "_Weights_" + weight.Guid.ToString("N").ToLower(), fields);

                        string tabWeightName = _fdb.TableName(_networkName + "_Weights_" + weight.Guid.ToString("N").ToLower());

                        NetworkEdges edges       = networkBuilder.NetworkEdges;
                        int          weight_page = 0;
                        int          counter     = 0;
                        BinaryWriter bw          = NetworkObjectSerializer.GetBinaryWriter();
                        foreach (NetworkEdge edge in edges)
                        {
                            counter++;
                            if (NetworkObjectSerializer.Page(counter) > weight_page)
                            {
                                IRow row = new Row();
                                row.Fields.Add(new FieldValue("Page", weight_page++));
                                row.Fields.Add(new FieldValue("Data", NetworkObjectSerializer.GetBuffer(bw)));
                                db.InsertRow(tabWeightName, row, null);
                                bw = NetworkObjectSerializer.GetBinaryWriter();
                            }

                            if (edge.Weights != null && edge.Weights.ContainsKey(weight.Guid))
                            {
                                NetworkObjectSerializer.WriteWeight(bw, weight, (double)edge.Weights[weight.Guid]);
                            }
                            else
                            {
                                NetworkObjectSerializer.WriteWeight(bw, weight, (double)0.0);
                            }
                        }

                        if (bw.BaseStream.Position > 0)
                        {
                            IRow row = new Row();
                            row.Fields.Add(new FieldValue("Page", weight_page++));
                            row.Fields.Add(new FieldValue("Data", NetworkObjectSerializer.GetBuffer(bw)));
                            db.InsertRow(tabWeightName, row, null);
                        }
                    }
                }
                #endregion
                #region Create Node Featureclass
                fields = new Fields();
                //fields.Add(new Field("NID", FieldType.integer));
                //fields.Add(new Field("G1", FieldType.integer));
                //fields.Add(new Field("G2", FieldType.integer));
                fields.Add(new Field("SWITCH", FieldType.boolean));
                fields.Add(new Field("STATE", FieldType.boolean));
                fields.Add(new Field("FCID", FieldType.integer));
                fields.Add(new Field("OID", FieldType.integer));
                fields.Add(new Field("NODETYPE", FieldType.integer));

                await _fdb.ReplaceFeatureClass(_dataset.DatasetName,
                                               _networkName + "_Nodes",
                                               new GeometryDef(geometryType.Point),
                                               fields);

                element = await _dataset.Element(_networkName + "_Nodes");

                if (element == null || !(element.Class is IFeatureClass))
                {
                    return;
                }
                if (nodeTreeDef != null)
                {
                    await _fdb.SetSpatialIndexBounds(_networkName + "_Nodes", "BinaryTree2", nodeTreeDef.Bounds, nodeTreeDef.SplitRatio, nodeTreeDef.MaxPerNode, nodeTreeDef.MaxLevel);
                }
                else if (edgeTreeDef != null)
                {
                    await _fdb.SetSpatialIndexBounds(_networkName + "_Nodes", "BinaryTree2", edgeTreeDef.Bounds, edgeTreeDef.SplitRatio, edgeTreeDef.MaxPerNode, edgeTreeDef.MaxLevel);
                }

                features.Clear();
                IFeatureClass nodeFc = (IFeatureClass)element.Class;
                c = networkBuilder.Nodes;

                #region Report
                report.Message = "Create Nodes";
                if (c is ICount)
                {
                    report.featureMax = ((ICount)c).Count;
                }
                report.featurePos = 0;
                if (ReportProgress != null)
                {
                    ReportProgress(report);
                }
                #endregion

                while ((f = await c.NextFeature()) != null)
                {
                    features.Add(f);

                    report.featurePos++;
                    if (features.Count > 0 && features.Count % 1000 == 0)
                    {
                        if (ReportProgress != null)
                        {
                            ReportProgress(report);
                        }
                        await _fdb.Insert(nodeFc, features);

                        features.Clear();
                    }
                }
                if (features.Count > 0)
                {
                    if (ReportProgress != null)
                    {
                        ReportProgress(report);
                    }
                    await _fdb.Insert(nodeFc, features);
                }
                await _fdb.CalculateExtent(nodeFc);

                #endregion
                #region Create Graph Class
                int graph_page = 0;
                fields = new Fields();
                fields.Add(new Field("Page", FieldType.integer));
                fields.Add(new Field("Data", FieldType.binary));
                //fields.Add(new Field("N1", FieldType.integer));
                //fields.Add(new Field("N2", FieldType.integer));
                //fields.Add(new Field("EID", FieldType.integer));
                //fields.Add(new Field("LENGTH", FieldType.Double));
                //fields.Add(new Field("GEOLENGTH", FieldType.Double));

                await _fdb.ReplaceFeatureClass(_dataset.DatasetName,
                                               _networkName,
                                               new GeometryDef(geometryType.Network),
                                               fields);

                element = await _dataset.Element(_networkName);

                if (element == null || !(element.Class is IFeatureClass))
                {
                    return;
                }

                features.Clear();
                IFeatureClass networkFc = (IFeatureClass)element.Class;
                c = networkBuilder.Graph;

                #region Report
                report.Message = "Create Network";
                if (c is ICount)
                {
                    report.featureMax = ((ICount)c).Count;
                }
                report.featurePos = 0;
                if (ReportProgress != null)
                {
                    ReportProgress(report);
                }
                #endregion

                string fcNetworkName = _fdb.TableName("FC_" + _networkName);

                while ((f = await c.NextFeature()) != null)
                {
                    report.featurePos++;

                    // Wenn aktuelles Feature in neue Page gehört ->
                    // bestehende, vor neuem Einfügen speichern und pageIndex erhöhen (graph_page++)
                    if (NetworkObjectSerializer.Page((int)f["N1"]) > graph_page)
                    {
                        if (ReportProgress != null)
                        {
                            ReportProgress(report);
                        }
                        IRow row = new Row();
                        row.Fields.Add(new FieldValue("Page", graph_page++));
                        row.Fields.Add(new FieldValue("Data", NetworkObjectSerializer.SerializeGraph(features)));
                        db.InsertRow(fcNetworkName, row, null);
                        features.Clear();
                    }

                    features.Add(f);
                }

                if (features.Count > 0)
                {
                    IRow row = new Row();
                    row.Fields.Add(new FieldValue("Page", graph_page));
                    row.Fields.Add(new FieldValue("Data", NetworkObjectSerializer.SerializeGraph(features)));
                    db.InsertRow(fcNetworkName, row, null);
                    features.Clear();
                }
                #endregion

                #region Create FDB_Networks
                int netId = await _fdb.GetFeatureClassID(_networkName);

                fields = new Fields();
                fields.Add(new Field("ID", FieldType.integer));
                fields.Add(new Field("Properties", FieldType.binary));
                await db.CreateIfNotExists("FDB_Networks", fields);

                NetworkObjectSerializer.NetworkProperties networkProps = new NetworkObjectSerializer.NetworkProperties(
                    NetworkObjectSerializer.PageSize, _tolerance);

                IRow row2 = new Row();
                row2.Fields.Add(new FieldValue("ID", netId));
                row2.Fields.Add(new FieldValue("Properties", networkProps.Serialize()));
                db.InsertRow(_fdb.TableName("FDB_Networks"), row2, null);
                #endregion

                #region Create FDB_NetworkClasses
                fields = new Fields();
                fields.Add(new Field("NetworkId", FieldType.integer));
                fields.Add(new Field("FCID", FieldType.integer));
                fields.Add(new Field("Properties", FieldType.binary));

                await db.CreateIfNotExists("FDB_NetworkClasses", fields);

                foreach (int fcId in FcIds)
                {
                    bool   isSwitchable         = (_switchNodeFcs != null && _switchNodeFcs.ContainsKey(fcId));
                    string switchStateFieldname = (isSwitchable ? _switchNodeFcs[fcId] : String.Empty);

                    NetworkObjectSerializer.NetworkClassProperties nwclsProps = new NetworkObjectSerializer.NetworkClassProperties(
                        _complexEdgeFcs.Contains(fcId),
                        isSwitchable, switchStateFieldname);

                    IRow row = new Row();
                    row.Fields.Add(new FieldValue("NetworkId", netId));
                    row.Fields.Add(new FieldValue("FCID", fcId));
                    row.Fields.Add(new FieldValue("Properties", nwclsProps.Serialize()));
                    db.InsertRow(_fdb.TableName("FDB_NetworkClasses"), row, null);
                }
                #endregion

                #region FDB_NetworkWeighs
                fields = new Fields();
                fields.Add(new Field("NetworkId", FieldType.integer));
                fields.Add(new Field("Name", FieldType.String));
                fields.Add(new Field("WeightGuid", FieldType.guid));
                fields.Add(new Field("Properties", FieldType.binary));

                await db.CreateIfNotExists("FDB_NetworkWeights", fields);

                if (_graphWeights != null)
                {
                    foreach (IGraphWeight weight in _graphWeights)
                    {
                        IRow row = new Row();
                        row.Fields.Add(new FieldValue("NetworkId", netId));
                        row.Fields.Add(new FieldValue("Name", weight.Name));
                        row.Fields.Add(new FieldValue("WeightGuid", weight.Guid));
                        row.Fields.Add(new FieldValue("Properties", NetworkObjectSerializer.SerializeWeight(weight)));
                        db.InsertRow(_fdb.TableName("FDB_NetworkWeights"), row, null);
                    }
                }
                #endregion

                succeeded = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                if (!succeeded)
                {
                    if (_fdb is IAlterDatabase)
                    {
                        ((IAlterDatabase)_fdb).DropTable(_networkName + "_Edges");
                    }
                    await _fdb.DeleteFeatureClass(_networkName + "_ComplexEdges");

                    await _fdb.DeleteFeatureClass(_networkName + "_Nodes");

                    await _fdb.DeleteFeatureClass(_networkName);
                }
            }
        }
        private void UpdateAttributesAction(IFeatureCursor updateCursor,
            string[] historyColumns, List<int> updateFieldOrdinals, List<object> updateValues)
        {
            // write history field names and types to pipe
            int[] historyFieldOrdinals = HistorySchema(historyColumns);

            // start workspace edit session and operation
            StartEditing();

            try
            {
                IFeature feature = null;
                while ((feature = updateCursor.NextFeature()) != null)
                {
                    _pipeData.Add(History(feature, historyFieldOrdinals, null));

                    for (int i = 0; i < updateFieldOrdinals.Count; i++)
                        feature.set_Value(updateFieldOrdinals[i], updateValues[i]);

                    feature.Store();
                }

                Marshal.ReleaseComObject(updateCursor);

                CommitEdits();
            }
            catch
            {
                Marshal.ReleaseComObject(updateCursor);
                DiscardEdits();
                throw;
            }
        }
示例#28
0
        /// <summary>
        /// 根据离散点数据动态生成featureclass点图层
        /// </summary>
        /// <params name="vectors"></params>
        /// <returns></returns>
        private static IFeatureClass GetFeatureCLass(LibGeometry.Vector3_DW[] vectors, ESRI.ArcGIS.Controls.AxMapControl map)
        {
            IWorkspaceFactory pWorkspaceFactory = new InMemoryWorkspaceFactoryClass();
            IWorkspaceName    pWorkspaceName    = pWorkspaceFactory.Create("", "pWorkspace", null, 0);
            IName             pName             = (IName)pWorkspaceName;
            IWorkspace        pWorkspace        = (IWorkspace)pName.Open();
            IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
            IFields           pFields           = new FieldsClass();
            IFieldsEdit       pFieldsEdit       = pFields as IFieldsEdit;
            IField            pField            = new FieldClass();
            IFieldEdit        pFieldEdit        = pField as IFieldEdit;

            pFieldEdit.Name_2 = "SHAPE";
            pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
            IGeometryDef     pGeometryDef     = new GeometryDefClass();
            IGeometryDefEdit pGeometryDefEdit = pGeometryDef as IGeometryDefEdit;

            pGeometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
            //为FeatureClass赋参考系,不写会出错***************************************

            pGeometryDefEdit.SpatialReference_2 = map.SpatialReference;
            //************************************************************************
            pFieldEdit.GeometryDef_2 = pGeometryDef;
            pFieldsEdit.AddField(pField);
            pField                 = new FieldClass();//不要省略写!容易出问题
            pFieldEdit             = pField as IFieldEdit;
            pFieldEdit.AliasName_2 = "高程";
            pFieldEdit.Name_2      = "CoordinateZ";
            pFieldEdit.Type_2      = esriFieldType.esriFieldTypeDouble;
            pFieldsEdit.AddField(pField);
            pFeatureWorkspace = pWorkspaceFactory.OpenFromFile(Application.StartupPath + "\\tempRaster", 0) as IFeatureWorkspace;
            IFeatureClass pFeatureClass = pFeatureWorkspace.CreateFeatureClass("points", pFields, null, null, esriFeatureType.esriFTSimple, "Shape", "");



            //IWorkspaceFactory pWorkSpaceFac = new ShapefileWorkspaceFactoryClass();
            //IFeatureWorkspace pFeatureWorkSpace = pWorkSpaceFac.OpenFromFile(shpfolder, 0) as IFeatureWorkspace;

            ////创建字段集2
            //IFeatureClassDescription fcDescription = new FeatureClassDescriptionClass();
            //IObjectClassDescription ocDescription = (IObjectClassDescription)fcDescription;//创建必要字段
            //IFields fields = ocDescription.RequiredFields;
            //int shapeFieldIndex = fields.FindField(fcDescription.ShapeFieldName);
            //IField field = fields.get_Field(shapeFieldIndex);
            //IGeometryDef geometryDef = field.GeometryDef;
            //IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef;
            ////geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPoint;
            ////geometryDefEdit.SpatialReference_2 = spatialReference;

            //geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            //ISpatialReferenceFactory pSpatialRefFac = new SpatialReferenceEnvironmentClass();
            //IProjectedCoordinateSystem pcsSys = pSpatialRefFac.CreateProjectedCoordinateSystem((int)esriSRProjCS4Type.esriSRProjCS_Xian1980_3_Degree_GK_Zone_39);
            //geometryDefEdit.SpatialReference_2 = pcsSys;

            //IFieldChecker fieldChecker = new FieldCheckerClass();
            //IEnumFieldError enumFieldError = null;
            //IFields validatedFields = null; //将传入字段 转成 validatedFields
            //fieldChecker.ValidateWorkspace = (IWorkspace)pFeatureWorkSpace;
            //fieldChecker.Validate(fields, out enumFieldError, out validatedFields);

            //pFeatureWorkSpace.CreateFeatureClass(shpname, validatedFields, ocDescription.InstanceCLSID, ocDescription.ClassExtensionCLSID, esriFeatureType.esriFTSimple, fcDescription.ShapeFieldName, "");



            //从vectors中获取散点值
            Dictionary <int, IPoint> pointDictionary = new Dictionary <int, IPoint>();

            for (int i = 0; i < vectors.Length; i++)
            {
                IPoint pPoint = new PointClass();
                pPoint.X = vectors[i].X;
                pPoint.Y = vectors[i].Y;
                pPoint.Z = vectors[i].Z;
                if (pPoint.Z.ToString() != "非数字")
                {
                    pointDictionary.Add(i, pPoint);
                }
            }

            //插入到新建的FeatureClass中
            IWorkspaceEdit pWorkspaceEdit = pWorkspace as IWorkspaceEdit;

            pWorkspaceEdit.StartEditing(true);
            pWorkspaceEdit.StartEditOperation();
            IFeatureBuffer pFeatureBuffer = pFeatureClass.CreateFeatureBuffer();
            IFeatureCursor pFeatureCursor = pFeatureClass.Insert(true);

            for (int featureNum = 4; featureNum < pointDictionary.Count; featureNum++)
            {
                pFeatureBuffer.Shape = pointDictionary[featureNum] as IPoint; //出错点,在于新建字段的错误
                pFeatureBuffer.set_Value(pFeatureClass.Fields.FindField("CoordinateZ"), pointDictionary[featureNum].Z);
                pFeatureCursor.InsertFeature(pFeatureBuffer);
            }
            pFeatureCursor.Flush();

            pWorkspaceEdit.StopEditOperation();
            pWorkspaceEdit.StopEditing(true);
            return(pFeatureClass);
        }
        public bool SetDynamicValues(IObject inObject, string mode, out List<IObject> ChangeFeatureList, out List<IObject> NewFeatureList, out List<IObject> ChangeFeatureGeoList)
        {
            NumberFormatInfo nfi = new CultureInfo(A4LGSharedFunctions.Localizer.GetString("AA_CultureInfo"), false).NumberFormat;
            nfi.NumberGroupSeparator = "";

            ChangeFeatureList = null;
            NewFeatureList = null;
            ChangeFeatureGeoList = null;

            IMSegmentation mseg = null;
            INetworkFeature netFeat = null;

            IJunctionFeature iJuncFeat = null;
            IEdgeFeature iEdgeFeat = null;

            //ProgressBar
            //ESRI.ArcGIS.Framework.IProgressDialogFactory progressDialogFactory = null;
            //ESRI.ArcGIS.esriSystem.IStepProgressor stepProgressor = null;
            //ESRI.ArcGIS.Framework.IProgressDialog2 progressDialog = null;
            //// Create a CancelTracker
            //ESRI.ArcGIS.esriSystem.ITrackCancel trackCancel = new ESRI.ArcGIS.Display.CancelTrackerClass();
            //trackCancel.CancelOnKeyPress = true;
            // trackCancel.CancelOnClick = true;

            try
            {
                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14d"));
                if (AAState.PerformUpdates == false)
                {
                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14a"));

                }
                if (AAState.PerformUpdates && AAState._dv == null)
                {

                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14b") + AAState._defaultsTableName);

                    AAState.PerformUpdates = false;
                    return false;
                }

                if (AAState.PerformUpdates && AAState._dv != null)
                {
                    if (AAState._dv.Table == null)
                    {

                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14c"));

                        return false;
                    }

                    if (inObject == null)
                    {
                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14e"));

                        return false;
                    }
                    if (inObject.Table == AAState._tab)
                    {

                        if (inObject.get_Value(inObject.Fields.FindField("VALUEMETHOD")).ToString().ToUpper() == "LAST_VALUE")
                        {
                            if (inObject.get_Value(inObject.Fields.FindField("FIELDNAME")) != null)
                            {
                                if (inObject.get_Value(inObject.Fields.FindField("FIELDNAME")) != DBNull.Value)
                                {
                                    try
                                    {
                                        LastValueEntry lstVal = AAState.lastValueProperties.GetProperty(inObject.get_Value(inObject.Fields.FindField("FIELDNAME")).ToString()) as LastValueEntry;
                                        if (lstVal != null)
                                        {
                                            lstVal.On_Manual = Globals.toBoolean(inObject.get_Value(inObject.Fields.FindField("ON_MANUAL")).ToString());
                                            lstVal.On_Create = Globals.toBoolean(inObject.get_Value(inObject.Fields.FindField("ON_CREATE")).ToString());
                                            lstVal.On_ChangeAtt = Globals.toBoolean(inObject.get_Value(inObject.Fields.FindField("ON_CHANGE")).ToString());

                                            if (inObject.Fields.FindField("ON_CHANGEGEO") >= 0)
                                            {
                                                lstVal.On_ChangeGeo = Globals.toBoolean(inObject.get_Value(inObject.Fields.FindField("ON_CHANGEGEO")).ToString());
                                            }
                                        }
                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14f"));
                                    }
                                    catch
                                    {
                                        //property does not exist

                                    }
                                }
                            }

                        }
                        else
                        {
                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14g"));
                        }
                        return false;
                    }

                    string modeVal;

                    if (AAState._dv.Table.Columns[mode] == null)
                    {
                        AAState.WriteLine(mode + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14h"));
                        mode = mode.Replace("GEO", "");

                    }
                    if (AAState._dv.Table.Columns[mode].DataType == System.Type.GetType("System.String"))
                    {
                        modeVal = "(" + mode + " = '1' or " + mode + " = 'Yes' or " + mode + " = 'YES' or " + mode + " = 'True' or " + mode + " = 'TRUE')";

                    }
                    else
                    {
                        modeVal = mode + " = 1";
                    }

                    //System.Int32 int32_hWnd = ArcMap.Application.hWnd;

                    //progressDialogFactory = new ESRI.ArcGIS.Framework.ProgressDialogFactoryClass();
                    //stepProgressor = progressDialogFactory.Create(trackCancel, int32_hWnd);

                    //stepProgressor.MinRange = 0;
                    //stepProgressor.MaxRange = inObject.Fields.FieldCount;
                    //stepProgressor.StepValue = 1;
                    //stepProgressor.Message = "Attribute Assistant Progress";
                    //// Create the ProgressDialog. This automatically displays the dialog
                    //progressDialog = (ESRI.ArcGIS.Framework.IProgressDialog2)stepProgressor; // Explict Cast

                    //// Set the properties of the ProgressDialog
                    //progressDialog.CancelEnabled = true;
                    ArcMap.Application.StatusBar.set_Message(0, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14i") + inObject.Class.AliasName);
                    //progressDialog.Description = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14i") + inObject.Class.AliasName;
                    //progressDialog.Title = "Attribute Assistant Progress";
                    //progressDialog.Animation = ESRI.ArcGIS.Framework.esriProgressAnimationTypes.esriProgressGlobe;
                    //progressDialog.ShowDialog();

                    //Optional skip junctions feature class
                    //if (Globals.isOrpanJunction(inFeature))
                    //    return false;

                    //Get table name for this feature
                    _currentDataset = inObject.Class as IDataset;
                    _currentDatasetNameItems = _currentDataset.Name.Split('.');
                    tableName = _currentDatasetNameItems[_currentDatasetNameItems.GetLength(0) - 1];

                    ArcMap.Application.StatusBar.set_Message(0, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain10") + inObject.Class.AliasName);
                    //stepProgressor.Message = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain10") + inObject.Class.AliasName;
                    // progressDialog.Description = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain10") + inObject.Class.AliasName;
                    AAState.WriteLine("***********************************************************");
                    AAState.WriteLine("############ " + DateTime.Now + " ################");

                    AAState.WriteLine("");
                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain11"));

                    if (AAState._dv.Table.Columns.Contains("RUN_WEIGHT"))
                        AAState._dv.Sort = "RUN_WEIGHT DESC";

                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14j") + inObject.Class.AliasName);
                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14k") + "(TABLENAME = '*' OR TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') AND VALUEMETHOD = 'Last_Value'");
                    AAState._dv.RowFilter = "(TABLENAME = '*' OR TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') AND VALUEMETHOD = 'Last_Value'";
                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14l")  + AAState._dv.Count.ToString());

                    if (AAState._dv.Count > 0)
                    {
                        IRowChanges pRowChLast = inObject as IRowChanges;
                        for (int retRows = 0; retRows < AAState._dv.Count; retRows++)
                        {
                            DataRowView drv = AAState._dv[retRows];
                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14m")  + drv["FIELDNAME"].ToString());

                            int fldLoc = inObject.Fields.FindField(drv["FIELDNAME"].ToString());

                            if (fldLoc > 0)
                            {
                                AAState.WriteLine("       " + drv["FIELDNAME"].ToString() + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14n")  + fldLoc);

                                if (pRowChLast.get_ValueChanged(fldLoc))
                                {
                                    AAState.WriteLine("       " + drv["FIELDNAME"].ToString() + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14o") );

                                    try
                                    {
                                        LastValueEntry lstVal = (AAState.lastValueProperties.GetProperty(drv["FIELDNAME"].ToString()) as LastValueEntry);

                                        if (lstVal != null)
                                        {

                                            if (inObject.get_Value(fldLoc) != null)
                                            {
                                                if (inObject.get_Value(fldLoc) != DBNull.Value)
                                                {

                                                    if (lstVal.Value != null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14p") );
                                                        AAState.WriteLine("                           " + drv["FIELDNAME"].ToString() + ": " + inObject.get_Value(fldLoc).ToString());
                                                        lstVal.Value = inObject.get_Value(fldLoc);

                                                        AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstVal);
                                                    }

                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14p") );
                                                        AAState.WriteLine("                           " + drv["FIELDNAME"].ToString() + ": " + inObject.get_Value(fldLoc));
                                                        lstVal.Value = inObject.get_Value(fldLoc);

                                                        AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstVal);
                                                    }

                                                }
                                                else
                                                {
                                                    if (mode == "ON_CREATE")
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14q") );

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14p") );
                                                        AAState.WriteLine("                           " + drv["FIELDNAME"].ToString() + ": NULL");
                                                        lstVal.Value = null;
                                                        AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstVal);
                                                    }

                                                }
                                            }
                                            else
                                            {
                                                if (mode == "ON_CREATE")
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14q") );

                                                }
                                                else
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14p") );
                                                    AAState.WriteLine("                           " + drv["FIELDNAME"].ToString() + ": NULL");
                                                    lstVal.Value = null;
                                                    AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstVal);

                                                }
                                            }

                                        }
                                        else
                                        {
                                            lstVal = new LastValueEntry();
                                            lstVal.Value = inObject.get_Value(fldLoc);

                                            lstVal.On_Manual = Globals.toBoolean(drv["ON_MANUAL"].ToString());
                                            lstVal.On_Create = Globals.toBoolean(drv["ON_CREATE"].ToString());
                                            lstVal.On_ChangeAtt = Globals.toBoolean(drv["ON_CHANGE"].ToString());
                                            if (drv["ON_CHANGEGEO"] != null)
                                            {
                                                lstVal.On_ChangeGeo = Globals.toBoolean(drv["ON_CHANGEGEO"].ToString());
                                            }
                                            AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstVal);

                                        }

                                    }
                                    catch
                                    {

                                    }

                                }
                                else
                                {
                                    AAState.WriteLine("       " + drv["FIELDNAME"].ToString() + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14r") );

                                }
                            }
                        }

                        pRowChLast = null;

                    }

                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14s")  + inObject.Class.AliasName);
                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14k") + "(TABLENAME = '*' OR TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') AND " + modeVal);
                    AAState._dv.RowFilter = "(TABLENAME = '*' OR TABLENAME = '" + tableName + "' OR TABLENAME like '" + tableName + "|*' OR TABLENAME like '" + tableName + "|%') AND " + modeVal;
                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14l")  + AAState._dv.Count.ToString());
                    if (AAState._processCount > 2)
                    {
                        System.Threading.Thread.Sleep(400);
                    }
                    if (AAState._processCount > 15)
                    {
                        MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14t") );

                        return false;

                    }
                    if (AAState._dv.Count > 0)
                    {
                        bool proc = false;
                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14u") );

                        for (int retRows = 0; retRows < AAState._dv.Count; retRows++)
                        {
                            DataRowView drv = AAState._dv[retRows];

                            AAState.WriteLine("    ------------------------------------------------");
                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14v") );
                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14w")  + (retRows + 1).ToString());
                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14x")  + drv["TABLENAME"].ToString());
                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14y")  + drv["FIELDNAME"].ToString());
                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14z")  + drv["VALUEINFO"].ToString());
                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14aa")  + drv["VALUEMETHOD"].ToString());
                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ab")  + drv["ON_CREATE"].ToString());
                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ac")  + drv["ON_CHANGE"].ToString());
                            if (AAState._dv.Table.Columns.Contains("RUNORDER"))
                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ad")  + drv["RUNORDER"].ToString());

                            AAState.WriteLine("");

                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ae") );
                            valFC = drv["TABLENAME"].ToString().Trim();
                            if (valFC.Contains("|"))
                            {
                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14af") );
                                string[] spliVal = valFC.Split('|');
                                List<string> validSubtypes = new List<string>(spliVal[1].Split(','));
                                List<string> inValidSubtypes;
                                if (spliVal.GetLength(0) == 3)
                                {
                                    inValidSubtypes = new List<string>(spliVal[2].Split(','));
                                }
                                else
                                {
                                    inValidSubtypes = new List<string>();
                                }

                                int obSubVal;
                                ISubtypes pSub = inObject.Class as ISubtypes;
                                if (pSub != null)
                                {
                                    if (pSub.HasSubtype)
                                    {
                                        if (inObject.get_Value(pSub.SubtypeFieldIndex).ToString() != "")
                                        {
                                            obSubVal = Convert.ToInt32(inObject.get_Value(pSub.SubtypeFieldIndex).ToString());
                                            if (validSubtypes.Contains("*"))
                                            {
                                                if (inValidSubtypes.Contains(obSubVal.ToString()))
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ag") );
                                                    proc = false;
                                                    continue;
                                                }
                                                else
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ah") );
                                                }
                                            }

                                            else if (validSubtypes.Contains(obSubVal.ToString()))
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ah") );
                                            }
                                            else
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ag") );
                                                proc = false;
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ai") );
                                            proc = false;
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14aj") );
                                    }
                                }
                                else
                                {
                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14aj") );
                                }

                            }
                            valMethod = drv["VALUEMETHOD"].ToString().ToUpper().Trim();
                            valData = drv["VALUEINFO"].ToString().Trim();
                            if (valData.Contains(Environment.NewLine))
                            {
                                valData = valData.Substring(0, valData.IndexOf(Environment.NewLine));

                            }
                            List<string> strFldNames = new List<string>();
                            List<string> strFldAlias = new List<string>();
                            List<int> intFldIdxs = new List<int>();
                            fieldObj = null;
                            if (drv["FIELDNAME"] != null && drv["FIELDNAME"].ToString().Trim() != "" && drv["FIELDNAME"].ToString().Trim() != "*" && drv["FIELDNAME"].ToString().Trim() != "#")
                            {
                                strFldNames = new List<string>(drv["FIELDNAME"].ToString().Trim().Split(','));
                                foreach (string strFldName in strFldNames)
                                {
                                    if (inObject.Fields.FindField(strFldName) >= 0)
                                    {
                                        strFldAlias.Add(inObject.Fields.get_Field(inObject.Fields.FindField(strFldName)).AliasName);

                                        int tem = inObject.Fields.FindField(strFldName);
                                        intFldIdxs.Add(tem);
                                        fieldObj = inObject.Fields.get_Field(tem);
                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ak")  + inObject.Fields.get_Field(inObject.Fields.FindField(strFldName)).AliasName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14al")  + tem);

                                        proc = true;
                                    }
                                    else if (inObject.Fields.FindFieldByAliasName(strFldName) >= 0)
                                    {
                                        int tem = inObject.Fields.FindFieldByAliasName(strFldName);
                                        intFldIdxs.Add(tem);
                                        strFldAlias.Add(inObject.Fields.get_Field(tem).AliasName);

                                        fieldObj = inObject.Fields.get_Field(tem);

                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ak")  + strFldName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14al")  + tem);

                                        proc = true;
                                    }
                                    else
                                    {
                                        intFldIdxs.Add(-1);
                                        strFldAlias.Add("{Not Found}");

                                        AAState.WriteLine("      " + strFldName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") );

                                        fieldObj = null;
                                        proc = false;
                                    }
                                }
                            }
                            else if (drv["FIELDNAME"].ToString() == "#")
                            {
                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14an") );
                                IRowChanges pRowCh = null;
                                IField pTmpFld = null;
                                pRowCh = inObject as IRowChanges;

                                for (int i = 0; i < inObject.Fields.FieldCount; i++)
                                {
                                    pTmpFld = inObject.Fields.get_Field(i);

                                    if (pTmpFld.Type != esriFieldType.esriFieldTypeGlobalID &&
                                                               pTmpFld.Type != esriFieldType.esriFieldTypeOID &&
                                                               pTmpFld.Type != esriFieldType.esriFieldTypeGeometry &&
                                                                pTmpFld.Name.ToUpper() != "SHAPE_LENGTH" &&
                                                               pTmpFld.Name.ToUpper() != "SHAPE.LEN" &&
                                                               pTmpFld.Name.ToUpper() != "SHAPE_AREA" &&
                                                               pTmpFld.Name.ToUpper() != "SHAPE.AREA")
                                    {
                                        if (pRowCh.get_ValueChanged(i) == true)
                                        {
                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ao")  + pTmpFld.Name + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ap") );
                                            strFldNames.Add(pTmpFld.Name);
                                            intFldIdxs.Add(i);
                                            proc = true;

                                        }
                                    }

                                }
                                pRowCh = null;
                                pTmpFld = null;
                            }
                            else
                            {
                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14aq") );
                                fieldObj = null;
                                proc = true;
                            }

                            if (proc)
                            {

                                try
                                {
                                    switch (valMethod)
                                    {

                                        case "FIELD_TRIGGER"://Value|FieldToChange|Value

                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FIELD_TRIGGER" );
                                                if (inFeature != null & valData != null)
                                                {

                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    string valToCheck = "";
                                                    string fldToChange = "";
                                                    string valToSet = "";
                                                    if (args.GetLength(0) == 3)
                                                    {
                                                        valToCheck = args[0];
                                                        fldToChange = args[1];
                                                        valToSet = args[2];

                                                    }

                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14av"));
                                                        continue;
                                                    }

                                                    IRowChanges pRowCh = null;

                                                    pRowCh = inObject as IRowChanges;

                                                    if (intFldIdxs.Count == 0)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14aw"));
                                                        continue;
                                                    }
                                                    if (intFldIdxs[0] == -1)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am"));
                                                        continue;
                                                    }
                                                    if (pRowCh.get_ValueChanged(intFldIdxs[0]))
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ax"));
                                                        if (inObject.get_Value(intFldIdxs[0]).ToString() == valToCheck)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                            int chngFldIdx = Globals.GetFieldIndex(inObject.Fields, fldToChange);
                                                            if (chngFldIdx == -1)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am"));
                                                                continue;
                                                            }
                                                            try
                                                            {
                                                                inObject.set_Value(chngFldIdx, valToSet);
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az"));
                                                            }
                                                            catch
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14c") + valToSet);
                                                            }

                                                        }
                                                    }
                                                    pRowCh = null;

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "FIELD_TRIGGER: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "FIELD_TRIGGER");
                                            }
                                            break;
                                        case "VALIDATE_ATTRIBUTE_LOOKUP":
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "VALIDATE_ATTRIBUTE_LOOKUP");
                                                IRowChanges pRowCh = null;
                                                ISQLSyntax sqlSyntax = null;
                                                IQueryFilter pQFilt = null;
                                                try
                                                {
                                                    if ((valData != null) && (inObject != null))
                                                    {

                                                        pRowCh = inObject as IRowChanges;
                                                        bool valueChanged = false;
                                                        for (int i = 0; i < intFldIdxs.Count; i++)
                                                        {
                                                            if (pRowCh.get_ValueChanged(intFldIdxs[i]) == true)
                                                            {
                                                                valueChanged = true;
                                                                break;

                                                            }
                                                        }
                                                        if (valueChanged == false)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain12"));
                                                            continue;
                                                        }
                                                        sourceLayerName = "";
                                                        string[] sourceFieldNames = null;

                                                        // Parse arguments
                                                        args = valData.Split('|');
                                                        if (args.Length == 2)
                                                        {
                                                            sourceLayerName = args[0].ToString().Trim();
                                                            sourceFieldNames = args[1].ToString().Split(',');

                                                        }

                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14d"));
                                                            continue;

                                                        }

                                                        if ((sourceFieldNames != null) &&
                                                            (sourceFieldNames.Length > 0))
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain13") + sourceLayerName);

                                                            boolLayerOrFC = true;
                                                            if (sourceLayerName.Contains("("))
                                                            {
                                                                string[] tempSplt = sourceLayerName.Split('(');
                                                                sourceLayerName = tempSplt[0];
                                                                sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                                if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                            }
                                                            else
                                                            {

                                                                sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                            }

                                                            IFields pFlds = null;

                                                            IDataset pDs = null;
                                                            string layNameFnd = "";
                                                            bool matchingLayFnd = false;
                                                            IStandaloneTable pTbl = null;
                                                            if (sourceLayer != null)
                                                            {
                                                                if (sourceLayer.FeatureClass != null)
                                                                {
                                                                    pFlds = sourceLayer.FeatureClass.Fields;
                                                                    pDs = sourceLayer.FeatureClass as IDataset;
                                                                    layNameFnd = sourceLayer.Name;
                                                                    matchingLayFnd = true;
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + sourceLayerName + " data source is not set");
                                                                    continue;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                pTbl = Globals.FindStandAloneTable(AAState._editor.Map, sourceLayerName) as IStandaloneTable;

                                                                if (pTbl != null)
                                                                {
                                                                    if (pTbl.Table != null)
                                                                    {
                                                                        pFlds = pTbl.Table.Fields;
                                                                        pDs = pTbl.Table as IDataset;
                                                                        layNameFnd = pTbl.Name;

                                                                        matchingLayFnd = true;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + sourceLayerName + " data source is not set");
                                                                    continue;
                                                                }

                                                            }
                                                            if (matchingLayFnd == false)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                continue;
                                                            }
                                                            sqlSyntax = (ISQLSyntax)(pDs.Workspace);
                                                            string specChar = sqlSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_WildcardManyMatch);

                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain14") + layNameFnd + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain15") + sourceLayerName);

                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain16"));

                                                            if (sourceFieldNames.Length != intFldIdxs.Count)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain17"));
                                                                continue;

                                                            }
                                                            int[] sourceFieldNums = new int[sourceFieldNames.Length];

                                                            pQFilt = new QueryFilterClass();
                                                            string sqlString = "";
                                                            string sqlStringUpper = "";
                                                            string sqlUpp = "";
                                                            if (sqlSyntax.GetStringComparisonCase())
                                                            {
                                                                sqlUpp = "UPPER";
                                                            }
                                                            for (int i = 0; i < sourceFieldNames.Length; i++)
                                                            {
                                                                sourceFieldNums[i] = Globals.GetFieldIndex(pFlds, sourceFieldNames[i].Trim());
                                                                if (sourceFieldNums[i] < 0)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain18") + sourceFieldName[i]);
                                                                    break;

                                                                }
                                                                if (pFlds.get_Field(sourceFieldNums[i]).Type == esriFieldType.esriFieldTypeString)
                                                                {
                                                                    if (sqlString == "")
                                                                    {
                                                                        sqlString = pFlds.get_Field(sourceFieldNums[i]).Name + "" + " = '" + inObject.get_Value(intFldIdxs[i]).ToString() + "'";
                                                                        sqlStringUpper = sqlUpp + "(" + pFlds.get_Field(sourceFieldNums[i]).Name + ")" + " LIKE '" + specChar + inObject.get_Value(intFldIdxs[i]).ToString().ToUpper().Replace(" ", specChar) + specChar + "'";
                                                                    }
                                                                    else
                                                                    {
                                                                        sqlString = sqlString + " AND " + pFlds.get_Field(sourceFieldNums[i]).Name + "" + " = '" + inObject.get_Value(intFldIdxs[i]).ToString() + "'";
                                                                        sqlStringUpper = sqlStringUpper + " AND " + sqlUpp + "(" + pFlds.get_Field(sourceFieldNums[i]).Name + ")" + " LIKE '" + specChar + inObject.get_Value(intFldIdxs[i]).ToString().ToUpper().Replace(" ", specChar) + specChar + "'";
                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    if (sqlString == "")
                                                                    {
                                                                        sqlString = pFlds.get_Field(sourceFieldNums[i]).Name + " = " + inObject.get_Value(intFldIdxs[i]);
                                                                        sqlStringUpper = pFlds.get_Field(sourceFieldNums[i]).Name + " LIKE " + specChar + inObject.get_Value(intFldIdxs[i]) + specChar;
                                                                    }
                                                                    else
                                                                    {
                                                                        sqlString = sqlString + " AND " + pFlds.get_Field(sourceFieldNums[i]).Name + " = " + inObject.get_Value(intFldIdxs[i]);
                                                                        sqlStringUpper = sqlStringUpper + " AND " + pFlds.get_Field(sourceFieldNums[i]).Name + " LIKE " + specChar + inObject.get_Value(intFldIdxs[i]) + specChar;
                                                                    }
                                                                }

                                                            }
                                                            pQFilt.WhereClause = sqlString;

                                                            AAState.WriteLine("                  " + pQFilt.WhereClause + " used to search for matching record");
                                                            int intRecFound = 0;
                                                            if (sourceLayer == null)
                                                            {
                                                                intRecFound = pTbl.Table.RowCount(pQFilt);
                                                            }
                                                            else
                                                            {
                                                                intRecFound = sourceLayer.FeatureClass.FeatureCount(pQFilt);
                                                            }

                                                            AAState.WriteLine("                  " + intRecFound + " rows found using " + sqlString);

                                                            if (intRecFound != 1)
                                                            {

                                                                pQFilt.WhereClause = sqlStringUpper;

                                                                AAState.WriteLine("                  " + pQFilt.WhereClause + " used to search for matching record");
                                                                if (sourceLayer == null)
                                                                {
                                                                    intRecFound = pTbl.Table.RowCount(pQFilt);
                                                                }
                                                                else
                                                                {
                                                                    intRecFound = sourceLayer.FeatureClass.FeatureCount(pQFilt);
                                                                }
                                                                AAState.WriteLine("                  " + intRecFound + " rows found");

                                                                if (intRecFound == 0)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19"));
                                                                    AAState._editor.AbortOperation();
                                                                    return false;

                                                                }

                                                                else
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain20"));
                                                                    ICursor pCurs = null;
                                                                    if (sourceLayer == null)
                                                                    {
                                                                        pCurs = pTbl.Table.Search(pQFilt, true);
                                                                    }
                                                                    else
                                                                    {
                                                                        pCurs = sourceLayer.FeatureClass.Search(pQFilt, true) as ICursor;
                                                                    }

                                                                    pQFilt = null;

                                                                    List<string> pLst = Globals.CursorToList(ref pCurs, sourceFieldNums);
                                                                    if (pCurs != null)
                                                                        Marshal.ReleaseComObject(pCurs);
                                                                    pCurs = null;

                                                                    string disFld = "";
                                                                    for (int j = 0; j < sourceFieldNames.Length - 1; j++)
                                                                    {
                                                                        disFld = disFld == "" ? sourceFieldNames[j] : disFld + "|" + sourceFieldNames[j];

                                                                    }
                                                                    string selectVal = Globals.showOptionsForm(pLst, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain21") + disFld, ComboBoxStyle.DropDownList);
                                                                    if (selectVal == "||Cancelled||")
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19"));
                                                                        AAState._editor.AbortOperation();
                                                                        return false;

                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain22") + selectVal);
                                                                        string[] strVals = selectVal.Split('|');

                                                                        for (int i = 0; i < sourceFieldNums.Length; i++)
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[i], (strVals[i].Trim()));
                                                                        }

                                                                    }

                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain23"));
                                                            }
                                                            pQFilt = null;

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14e") + valData);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14f"));
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "VALIDATE_ATTRIBUTE_LOOKUP" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    pQFilt = null;
                                                    sqlSyntax = null;
                                                    pRowCh = null;
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "VALIDATE_ATTRIBUTE_LOOKUP");
                                                }
                                                break;
                                            }

                                        case "PREVIOUS_VALUE":
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "PREVIOUS_VALUE");
                                                IRowChanges pRowCh = null;
                                                try
                                                {
                                                    if ((valData != null) && (inObject != null))
                                                    {

                                                        pRowCh = inObject as IRowChanges;
                                                        bool valueChanged = false;
                                                        for (int i = 0; i < intFldIdxs.Count; i++)
                                                        {
                                                            if (pRowCh.get_ValueChanged(intFldIdxs[i]) == true)
                                                            {
                                                                valueChanged = true;
                                                                break;

                                                            }
                                                        }
                                                        if (valueChanged == false)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain24"));
                                                            continue;
                                                        }

                                                        string[] sourceFieldNames = null;

                                                        // Parse arguments
                                                        args = valData.Split('|');
                                                        if (args.Length == 1)
                                                        {

                                                            sourceFieldNames = args[0].ToString().Split(',');

                                                        }

                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14d"));
                                                            continue;

                                                        }

                                                        if ((sourceFieldNames != null) &&
                                                            (sourceFieldNames.Length > 0))
                                                        {
                                                            int flx = inObject.Fields.FindField(sourceFieldNames[0]);
                                                            if (flx > 0)
                                                            {
                                                                inObject.set_Value(flx, pRowCh.get_OriginalValue(intFldIdxs[0]));
                                                                inObject.Store();

                                                            }
                                                        }
                                                        else
                                                        {

                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14e") + valData);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14f"));
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "PREVIOUS_VALUE" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {

                                                    pRowCh = null;
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "PREVIOUS_VALUE");
                                                }
                                                break;
                                            }

                                        case "ANGLE":

                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "ANGLE");
                                                if (inFeature != null)
                                                {
                                                    if (intFldIdxs.Count == 0)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain25"));
                                                        continue;

                                                    }
                                                    if ((inFeature.Class as IFeatureClass).ShapeType != esriGeometryType.esriGeometryPolyline)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain26"));
                                                        continue;
                                                    }

                                                    bool boolGeo = true;
                                                    if (valData.Trim() != "")
                                                    {
                                                        if (valData.ToUpper() == "A")
                                                        {
                                                            boolGeo = false;
                                                        }
                                                    }
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain27"));
                                                    IPolyline pLyLine = inFeature.Shape as IPolyline;

                                                    ILine pLine = new LineClass();
                                                    pLine.ToPoint = pLyLine.FromPoint;
                                                    pLine.FromPoint = pLyLine.ToPoint;

                                                    double angArth = pLine.Angle * 180 / Math.PI;
                                                    if (angArth < 0)
                                                    {
                                                        angArth = 360 + angArth;
                                                    }

                                                    double angGeo = 270 - angArth;
                                                    if (angGeo < 0)
                                                    {
                                                        angGeo = 360 + angGeo;
                                                    }
                                                    double ang;
                                                    if (boolGeo)
                                                    {
                                                        ang = angGeo;
                                                    }
                                                    else
                                                    {
                                                        ang = angArth;
                                                    }
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain28") + ang);
                                                    try
                                                    {
                                                        inObject.set_Value(intFldIdxs[0], ang);
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain29"));

                                                    }
                                                    catch
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain30"));
                                                    }

                                                    pLine = null;
                                                    pLyLine = null;

                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain31"));

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "ANGLE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "ANGLE");
                                            }
                                            break;

                                        case "CREATE_PERP_LINE"://Layer to Search For|Offset Distante or Field|Search distance to look for a line|UseSnapPoint|TargetLayer|TargetLayerTemplate

                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "CREATE_PERP_LINE");
                                                if (inFeature != null & valData != null)
                                                {
                                                    sourceLayerName = "";
                                                    double offsetVal = 5;
                                                    bool useSnapPnt = false;
                                                    string targetLayerName = "";
                                                    IFeatureLayer targetLayer = null;
                                                    string targetLayerTemp = "";

                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    int fldOff = -1;
                                                    if (args.GetLength(0) == 6)
                                                    {

                                                        sourceLayerNames = args[0].ToString().Split(',');

                                                        if (Globals.IsNumeric(args[1]))
                                                            Double.TryParse(args[1], out offsetVal);
                                                        else
                                                        {
                                                            fldOff = Globals.GetFieldIndex(inObject.Fields, args[1]);

                                                        }

                                                        Double.TryParse(args[2], out searchDistance);
                                                        Boolean.TryParse(args[3], out useSnapPnt);
                                                        targetLayerName = args[4];
                                                        targetLayerTemp = args[5];

                                                    }
                                                    else if (args.GetLength(0) == 5)
                                                    {

                                                        sourceLayerNames = args[0].ToString().Split(',');

                                                        if (Globals.IsNumeric(args[1]))
                                                            Double.TryParse(args[1], out offsetVal);
                                                        else
                                                        {
                                                            fldOff = Globals.GetFieldIndex(inObject.Fields, args[1]);

                                                        }

                                                        Double.TryParse(args[2], out searchDistance);
                                                        Boolean.TryParse(args[3], out useSnapPnt);
                                                        targetLayerName = args[4];
                                                        targetLayerTemp = "";
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14av"));
                                                        continue;
                                                    }
                                                    if (intFldIdxs.Count > 0)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain32"));
                                                        continue;
                                                    }

                                                    targetLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, targetLayerName, ref boolLayerOrFC);
                                                    if (targetLayer == null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14g") + targetLayerName);
                                                        continue;
                                                    }
                                                    if (targetLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolyline)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14h") + targetLayerName);
                                                        continue;
                                                    }
                                                    if (targetLayer is ICadastralFabricSubLayer2)
                                                    {
                                                      AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14i") + targetLayerName);
                                                      continue;
                                                    }

                                                    for (int i = 0; i < sourceLayerNames.Length; i++)
                                                    {
                                                        sourceLayerName = sourceLayerNames[i].ToString();
                                                        if (sourceLayerName != "")

                                                            sourceLayerName = args[i].ToString();
                                                        if (i == 0)
                                                            i++;
                                                        boolLayerOrFC = true;

                                                        if (sourceLayerName.Contains("("))
                                                        {
                                                            string[] tempSplt = sourceLayerName.Split('(');
                                                            sourceLayerName = tempSplt[0];
                                                            sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                            if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                            {
                                                                boolLayerOrFC = true;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                            {
                                                                boolLayerOrFC = true;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                            {
                                                                boolLayerOrFC = false;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                            {
                                                                boolLayerOrFC = false;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                            {
                                                                boolLayerOrFC = false;
                                                            }
                                                            else
                                                            {
                                                                boolLayerOrFC = true;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                        }
                                                        if (sourceLayer == null)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14b") + sourceLayer + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                            continue;
                                                        }
                                                        if (fldOff != -1)
                                                        {
                                                            try
                                                            {
                                                                string temp = inObject.get_Value(fldOff).ToString();
                                                                if (Globals.IsNumeric(temp))
                                                                {
                                                                    Double.TryParse(temp, out offsetVal);
                                                                }
                                                            }
                                                            catch
                                                            {
                                                            }

                                                        }

                                                        IPolyline pTempLine = new PolylineClass();
                                                        pTempLine = Globals.CreateAngledLineFromLocationOnLine((IPoint)inFeature.Shape, sourceLayer,
                                                            boolLayerOrFC, Globals.ConvertDegToRads(90), offsetVal, "true", true, false);

                                                        IEditTemplate pTemp = null;
                                                        IFeature pFeat = null;

                                                        if (targetLayerTemp != "")
                                                            pTemp = Globals.GetEditTemplate(targetLayerTemp, targetLayer);
                                                        if (pTemp != null)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain33"));
                                                            pFeat = Globals.CreateFeature(pTempLine, pTemp, AAState._editor, ArcMap.Application, false, false, false);

                                                        }
                                                        else
                                                        {

                                                            pFeat = Globals.CreateFeature(pTempLine, targetLayer, AAState._editor, ArcMap.Application, false, false, false);
                                                        }

                                                        if (NewFeatureList == null)
                                                        {
                                                            NewFeatureList = new List<IObject>();
                                                        }
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain34"));
                                                        NewFeatureList.Add(pFeat);

                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CREATE_PERP_LINE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "CREATE_PERP_LINE");
                                            }
                                            break;
                                        case "AUTONUMBER"://Layer to Search For|Offset Distante or Field|Search distance to look for a line

                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "AUTONUMBER");
                                                if (inObject != null)
                                                {
                                                    if (intFldIdxs.Count == 0)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain25"));
                                                        continue;

                                                    }
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain35") + strFldNames[0]);
                                                    string res = Globals.GetFieldStats(inObject.Class as IFeatureClass, strFldNames[0], Globals.statsType.Max);
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain36") + res);
                                                    if (res == "External component has thrown an exception.")
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain37"));

                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cm"));
                                                        long val = 1;

                                                        try
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14co"));
                                                            inObject.set_Value(intFldIdxs[0], val);
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az"));

                                                        }
                                                        catch (Exception ex)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14j") + ex.Message.ToString());
                                                        }
                                                    }
                                                    else
                                                    {

                                                        if (Globals.IsNumeric(res))
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cs"));

                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cr") + res);
                                                            try
                                                            {
                                                                long val = (Convert.ToInt64(res) + 1);

                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cq") + res);
                                                                try
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14co") + res);
                                                                    inObject.set_Value(intFldIdxs[0], val);
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az") + res);

                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14j") + ex.Message.ToString());
                                                                }

                                                            }

                                                            catch (Exception ex)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14j") + ex.Message.ToString());
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cp"));
                                                                long val = 1;

                                                                inObject.set_Value(intFldIdxs[0], val);
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az"));

                                                            }

                                                        }

                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cn") + res);

                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cm"));
                                                            long val = 1;

                                                            try
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14co") + res);
                                                                inObject.set_Value(intFldIdxs[0], val);
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az") + res);

                                                            }
                                                            catch (Exception ex)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14j") + ex.Message.ToString());
                                                            }

                                                        }
                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "AUTONUMBER: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "AUTONUMBER");
                                            }
                                            break;

                                        case "COPY_LINKED_RECORD"://Feature Layer|Field To Copy|Primary Key Field|Foreign Key Field
                                            {
                                                try
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "COPY_LINKED_RECORD");
                                                    if (!String.IsNullOrEmpty(valData))
                                                    {
                                                        args = valData.Split('|');
                                                        if (args.Length != 4)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad"));
                                                            break;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad"));
                                                        break;
                                                    }
                                                    if (inObject == null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ak"));
                                                        break;
                                                    }
                                                    string[] targetLayerNames;
                                                    string targetFieldName = "";

                                                    found = false;
                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bs"));
                                                    targetLayerNames = args[0].ToString().Split(',');
                                                    targetFieldName = args[1].ToString();
                                                    string targetLayerName = "";
                                                    string sourceIDFieldName = args[2].ToString();
                                                    string targetIDFieldName = args[3].ToString();
                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bt"));
                                                    if (targetFieldName != null)
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cj"));

                                                        int fldIDSourecIdx = Globals.GetFieldIndex(inObject.Fields, sourceIDFieldName);
                                                        if (fldIDSourecIdx > -1 && intFldIdxs.Count > 0)
                                                        {
                                                            if (inObject.get_Value(fldIDSourecIdx) != null && inObject.get_Value(fldIDSourecIdx) != DBNull.Value)
                                                            {
                                                                if (inObject.get_Value(fldIDSourecIdx).ToString() != "")
                                                                {

                                                                    for (int i = 0; i < targetLayerNames.Length; i++)
                                                                    {
                                                                        targetLayerName = targetLayerNames[i].ToString().Trim();

                                                                        if (targetLayerName != "")
                                                                        {

                                                                            // Get layer
                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cl"));
                                                                            bool FCorLayerSource = true;
                                                                            sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, targetLayerName, ref FCorLayerSource);

                                                                            if (sourceLayer != null)
                                                                            {

                                                                                int fldValToCopyIdx = sourceLayer.FeatureClass.Fields.FindField(targetFieldName);
                                                                                int fldIDTargetIdx = sourceLayer.FeatureClass.Fields.FindField(targetIDFieldName);
                                                                                if (fldIDTargetIdx > -1 && fldValToCopyIdx > -1)
                                                                                {
                                                                                    IQueryFilter pQFilt = Globals.createQueryFilter();
                                                                                    if (sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeString)
                                                                                    {
                                                                                        pQFilt.WhereClause = "" + sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString() + "'";

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        pQFilt.WhereClause = sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx);

                                                                                    }
                                                                                    IFeatureCursor pCurs;

                                                                                    pCurs = sourceLayer.FeatureClass.Search(pQFilt, true);
                                                                                    IFeature pRow;
                                                                                    while ((pRow = pCurs.NextFeature()) != null)
                                                                                    {
                                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cf"));
                                                                                        try
                                                                                        {
                                                                                            inObject.set_Value(intFldIdxs[0], pRow.get_Value(fldValToCopyIdx));
                                                                                            break;

                                                                                        }
                                                                                        catch
                                                                                        {
                                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + inObject.get_Value(fldValToCopyIdx) + " to field: " + strFldNames[0]);
                                                                                        }

                                                                                        pRow = null;
                                                                                    }
                                                                                    pRow = null;

                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cd"));

                                                                                    if (pCurs != null)
                                                                                        Marshal.ReleaseComObject(pCurs);
                                                                                    pCurs = null;

                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14k"));
                                                                                }

                                                                            }
                                                                            else
                                                                            {

                                                                                ITable pTable = Globals.FindTable(AAState._editor.Map, targetLayerName);
                                                                                if (pTable != null)
                                                                                {
                                                                                    int fldValToCopyIdx = Globals.GetFieldIndex(pTable.Fields, targetFieldName);
                                                                                    int fldIDTargetIdx = Globals.GetFieldIndex(pTable.Fields, targetIDFieldName);
                                                                                    if (fldIDTargetIdx > -1 && fldValToCopyIdx > -1)
                                                                                    {
                                                                                        IQueryFilter pQFilt = Globals.createQueryFilter();
                                                                                        if (pTable.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeString)
                                                                                        {
                                                                                            pQFilt.WhereClause = "" + pTable.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString() + "'";

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            pQFilt.WhereClause = pTable.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx);

                                                                                        }
                                                                                        ICursor pCurs;

                                                                                        pCurs = pTable.Search(pQFilt, true);
                                                                                        IRow pRow;
                                                                                        bool valSet = false;
                                                                                        pRow = pCurs.NextRow();
                                                                                        while (pRow != null)
                                                                                        {
                                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cf"));
                                                                                            try
                                                                                            {
                                                                                                inObject.set_Value(intFldIdxs[0], pRow.get_Value(fldValToCopyIdx));

                                                                                                AAState.WriteLine("                  " + pRow.get_Value(fldValToCopyIdx).ToString() + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ch"));
                                                                                                valSet = true;
                                                                                                break;

                                                                                            }
                                                                                            catch
                                                                                            {
                                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + inObject.get_Value(fldValToCopyIdx) + " to field: " + strFldNames[0]);
                                                                                            }

                                                                                            pRow = pCurs.NextRow();

                                                                                        }
                                                                                        pRow = null;
                                                                                        if (valSet)
                                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cd"));
                                                                                        else
                                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ce"));

                                                                                        if (pCurs != null)
                                                                                            Marshal.ReleaseComObject(pCurs);
                                                                                        pCurs = null;

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14k"));
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ax") + sourceLayerName);
                                                                                }
                                                                                pTable = null;

                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ck"));
                                                        }

                                                    }

                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_LINKED_RECORD" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "COPY_LINKED_RECORD");

                                                }
                                                break;

                                            }
                                        case "UPDATE_LINKED_RECORD"://Feature Layer|Field To Copy|Primary Key Field|Foreign Key Field
                                            {
                                                try
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "UPDATE_LINKED_RECORD");
                                                    if (!String.IsNullOrEmpty(valData))
                                                    {
                                                        args = valData.Split('|');
                                                        if (args.Length != 4)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad"));
                                                            break;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad"));
                                                        break;
                                                    }
                                                    if (inObject == null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ak"));
                                                        break;
                                                    }

                                                    IRowChanges pRowCh = inObject as IRowChanges;

                                                    if (pRowCh.get_ValueChanged(intFldIdxs[0]) == false && mode != "ON_CREATE")
                                                    {
                                                        AAState.WriteLine("                  PROMPT: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ck"));
                                                        pRowCh = null;
                                                        continue;
                                                    }
                                                    else
                                                    {
                                                        pRowCh = null;
                                                        string[] targetLayerNames;
                                                        string targetFieldName = "";

                                                        found = false;
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bs"));
                                                        targetLayerNames = args[0].ToString().Split(',');
                                                        targetFieldName = args[1].ToString();
                                                        string targetLayerName = "";
                                                        string sourceIDFieldName = args[2].ToString();
                                                        string targetIDFieldName = args[3].ToString();
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bt"));
                                                        if (targetFieldName != null)
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cj"));

                                                            int fldIDSourecIdx = Globals.GetFieldIndex(inObject.Fields, sourceIDFieldName);
                                                            if (fldIDSourecIdx > -1 && intFldIdxs.Count > 0)
                                                            {
                                                                if (inObject.get_Value(fldIDSourecIdx) != null && inObject.get_Value(fldIDSourecIdx) != DBNull.Value)
                                                                {
                                                                    if (inObject.get_Value(fldIDSourecIdx).ToString() != "")
                                                                    {

                                                                        for (int i = 0; i < targetLayerNames.Length; i++)
                                                                        {
                                                                            targetLayerName = targetLayerNames[i].ToString().Trim();

                                                                            if (targetLayerName != "")
                                                                            {

                                                                                // Get layer
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ci"));
                                                                                bool FCorLayerSource = true;
                                                                                sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, targetLayerName, ref FCorLayerSource);

                                                                                if (sourceLayer != null)
                                                                                {

                                                                                    int fldValToCopyIdx = sourceLayer.FeatureClass.Fields.FindField(targetFieldName);
                                                                                    int fldIDTargetIdx = sourceLayer.FeatureClass.Fields.FindField(targetIDFieldName);
                                                                                    if (fldIDTargetIdx > -1 && fldValToCopyIdx > -1)
                                                                                    {
                                                                                        IQueryFilter pQFilt = Globals.createQueryFilter();
                                                                                        if (sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeString)
                                                                                        {
                                                                                            pQFilt.WhereClause = "" + sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString() + "'";

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            pQFilt.WhereClause = sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx);

                                                                                        }
                                                                                        IFeatureCursor pCurs;

                                                                                        pCurs = sourceLayer.FeatureClass.Search(pQFilt, true);
                                                                                        IFeature pRow;
                                                                                        bool valSet = false;
                                                                                        while ((pRow = pCurs.NextFeature()) != null)
                                                                                        {
                                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cg"));
                                                                                            try
                                                                                            {
                                                                                                pRow.set_Value(fldValToCopyIdx, inObject.get_Value(intFldIdxs[0]));
                                                                                                pRow.Store();
                                                                                                AAState.WriteLine("                  " + inObject.get_Value(intFldIdxs[0]).ToString() + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ch"));
                                                                                                valSet = true;

                                                                                            }
                                                                                            catch
                                                                                            {
                                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + inObject.get_Value(intFldIdxs[0]).ToString() + " to field: " + targetFieldName);
                                                                                            }

                                                                                            pRow = null;
                                                                                        }
                                                                                        pRow = null;

                                                                                        if (valSet)
                                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cd"));
                                                                                        else
                                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ce"));

                                                                                        if (pCurs != null)
                                                                                            Marshal.ReleaseComObject(pCurs);
                                                                                        pCurs = null;

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14k"));
                                                                                    }

                                                                                }
                                                                                else
                                                                                {

                                                                                    ITable pTable = Globals.FindTable(AAState._editor.Map, targetLayerName);
                                                                                    if (pTable != null)
                                                                                    {
                                                                                        int fldValToCopyIdx = Globals.GetFieldIndex(pTable.Fields, targetFieldName);
                                                                                        int fldIDTargetIdx = Globals.GetFieldIndex(pTable.Fields, targetIDFieldName);
                                                                                        if (fldIDTargetIdx > -1 && fldValToCopyIdx > -1)
                                                                                        {
                                                                                            IQueryFilter pQFilt = Globals.createQueryFilter();
                                                                                            if (pTable.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeString)
                                                                                            {
                                                                                                pQFilt.WhereClause = "" + pTable.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString() + "'";

                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                pQFilt.WhereClause = pTable.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx);

                                                                                            }
                                                                                            ICursor pCurs;

                                                                                            pCurs = pTable.Search(pQFilt, false);
                                                                                            IRow pRow;
                                                                                            bool valSet = false;
                                                                                            pRow = pCurs.NextRow();
                                                                                            while (pRow != null)
                                                                                            {
                                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cf"));
                                                                                                try
                                                                                                {
                                                                                                    pRow.set_Value(fldValToCopyIdx, inObject.get_Value(intFldIdxs[0]));
                                                                                                    pRow.Store();

                                                                                                    AAState.WriteLine("                  " + inObject.get_Value(intFldIdxs[0]).ToString() + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ch"));
                                                                                                    valSet = true;

                                                                                                }
                                                                                                catch
                                                                                                {
                                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + inObject.get_Value(fldValToCopyIdx) + " to field: " + strFldNames[0]);
                                                                                                }

                                                                                                pRow = pCurs.NextRow();

                                                                                            }
                                                                                            pRow = null;
                                                                                            if (valSet)
                                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cd"));
                                                                                            else
                                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ce"));

                                                                                            if (pCurs != null)
                                                                                                Marshal.ReleaseComObject(pCurs);
                                                                                            pCurs = null;

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14k"));
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ax") + sourceLayerName);
                                                                                    }
                                                                                    pTable = null;

                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ay"));
                                                            }

                                                        }

                                                    }

                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "UPDATE_LINKED_RECORD" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_LINKED_RECORD");

                                                }
                                                break;

                                            }

                                        case "OFFSET"://Layer to Search For|Offset Distante or Field|Search distance to look for a line

                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "OFFSET");
                                                if (inFeature != null & valData != null)
                                                {
                                                    sourceLayerName = "";
                                                    double offsetVal = 5;

                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    int fldOff = -1;
                                                    if (args.GetLength(0) >= 3)
                                                    {

                                                        sourceLayerNames = args[0].ToString().Split(',');

                                                        if (Globals.IsNumeric(args[1]))
                                                            Double.TryParse(args[1], out offsetVal);
                                                        else
                                                        {
                                                            fldOff = Globals.GetFieldIndex(inObject.Fields, args[1]);

                                                        }

                                                        Double.TryParse(args[2], out searchDistance);
                                                    }
                                                    else if (args.GetLength(0) >= 2)
                                                    {

                                                        sourceLayerNames = args[0].ToString().Split(',');

                                                        if (Globals.IsNumeric(args[1]))
                                                            Double.TryParse(args[1], out offsetVal);
                                                        else
                                                        {
                                                            fldOff = Globals.GetFieldIndex(inObject.Fields, args[1]);

                                                        }

                                                        Double.TryParse("1", out searchDistance);
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14av"));
                                                        continue;
                                                    }
                                                    if (intFldIdxs.Count != 2)
                                                    {
                                                        AAState.WriteLine( A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bn"));
                                                        continue;
                                                    }

                                                    // Get layer

                                                    for (int i = 0; i < sourceLayerNames.Length; i++)
                                                    {
                                                        sourceLayerName = sourceLayerNames[i].ToString();
                                                        if (sourceLayerName != "")

                                                            sourceLayerName = args[i].ToString();
                                                        if (i == 0)
                                                            i++;
                                                        boolLayerOrFC = true;

                                                        if (sourceLayerName.Contains("("))
                                                        {
                                                            string[] tempSplt = sourceLayerName.Split('(');
                                                            sourceLayerName = tempSplt[0];
                                                            sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                            if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                            {
                                                                boolLayerOrFC = true;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                            {
                                                                boolLayerOrFC = true;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                            {
                                                                boolLayerOrFC = false;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                            {
                                                                boolLayerOrFC = false;
                                                            }
                                                            else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                            {
                                                                boolLayerOrFC = false;
                                                            }
                                                            else
                                                            {
                                                                boolLayerOrFC = true;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                        }
                                                        if (sourceLayer == null)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14b") + sourceLayer + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                            continue;
                                                        }

                                                        IFeatureClass iFC = inFeature.Class as IFeatureClass;
                                                        if (sourceLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + sourceLayer + " is a polygon layer");

                                                            break;
                                                        }
                                                        if (sourceLayer != null)
                                                        {

                                                            sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false);

                                                            pFS = (IFeatureSelection)sourceLayer;
                                                            if (boolLayerOrFC)
                                                            {
                                                                if (pFS.SelectionSet.Count > 0)
                                                                {
                                                                    pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                    fCursor = cCurs as IFeatureCursor;

                                                                }
                                                                else
                                                                {
                                                                    fCursor = sourceLayer.Search(sFilter, true);
                                                                }
                                                            }
                                                            else
                                                            {
                                                                fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                            }

                                                            while ((sourceFeature = fCursor.NextFeature()) != null)
                                                            {
                                                                double dAlong = 0;
                                                                if (sourceFeature.Class != inFeature.Class)
                                                                {
                                                                    IPoint pIntPnt;
                                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                                    {
                                                                        pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint;

                                                                    }
                                                                    else
                                                                        pIntPnt = inFeature.ShapeCopy as IPoint;
                                                                    IPoint snapPnt = null;

                                                                    dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt);

                                                                    snapPnt = null;
                                                                    pIntPnt = null;

                                                                }

                                                                else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                {
                                                                    IPoint pIntPnt;
                                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                                    {
                                                                        pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint;

                                                                    }
                                                                    else
                                                                        pIntPnt = inFeature.ShapeCopy as IPoint;
                                                                    IPoint snapPnt = null;

                                                                    dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt);
                                                                    snapPnt = null;

                                                                    pIntPnt = null;

                                                                }
                                                                AAState.WriteLine("                     " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cc") + dAlong);
                                                                IPoint pNewPt = new PointClass();
                                                                IConstructPoint2 pConsPoint = pNewPt as IConstructPoint2;

                                                                if (fldOff != -1)
                                                                {
                                                                    string temp = inObject.get_Value(fldOff).ToString();
                                                                    if (Globals.IsNumeric(temp))
                                                                    {
                                                                        Double.TryParse(temp, out offsetVal);
                                                                    }

                                                                }
                                                                pConsPoint.ConstructOffset
                                                                    (sourceFeature.Shape as ICurve, esriSegmentExtension.esriNoExtension, dAlong, false, offsetVal);

                                                                inObject.set_Value(intFldIdxs[0], pNewPt.X);
                                                                inObject.set_Value(intFldIdxs[1], pNewPt.Y);

                                                                pNewPt = null;
                                                                pConsPoint = null;
                                                            }

                                                        }

                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "OFFSET: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "OFFSET");
                                            }
                                            break;

                                        case "SIDE":
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "SIDE");

                                                try
                                                {
                                                    //Layer|IDField|IDField source

                                                    if ((valData != null) && (inFeature != null))
                                                    {
                                                        AAState.WriteLine("                     " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cb"));

                                                        AAState.WriteLine("                     " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ca") + valData);
                                                        sourceLayerName = "";
                                                        sourceFieldName = "";
                                                        sourceField = -1;
                                                        string inputFieldName = "";
                                                        args = valData.Split('|');
                                                        if (args.Length < 2)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + "SIDE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bm"));
                                                            continue;
                                                        }

                                                        switch (args.Length)
                                                        {
                                                            case 3:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                sourceFieldName = args[1].ToString();
                                                                inputFieldName = args[2].ToString();
                                                                break;
                                                            default:
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + "SIDE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bm"));
                                                                continue;

                                                        }
                                                        int fldValToCopyIdx = inObject.Fields.FindField(inputFieldName);

                                                        if (fldValToCopyIdx > -1)
                                                        {

                                                            for (int i = 0; i < sourceLayerNames.Length; i++)
                                                            {
                                                                sourceLayerName = sourceLayerNames[i].ToString();

                                                                if (sourceLayerName != "")
                                                                {

                                                                    boolLayerOrFC = true;
                                                                    if (sourceLayerName.Contains("("))
                                                                    {
                                                                        string[] tempSplt = sourceLayerName.Split('(');
                                                                        sourceLayerName = tempSplt[0];
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                    }
                                                                    if (sourceLayer != null)
                                                                    {

                                                                        // Get layer
                                                                        AAState.WriteLine("                  " + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bz"));
                                                                        int fldValTargetJoinIdx = Globals.GetFieldIndex(sourceLayer, sourceFieldName);
                                                                        if (fldValTargetJoinIdx > -1)
                                                                        {
                                                                            IQueryFilter pQFilt = Globals.createQueryFilter();

                                                                            if (sourceLayer.FeatureClass.Fields.get_Field(fldValTargetJoinIdx).Type == esriFieldType.esriFieldTypeString)
                                                                            {
                                                                                pQFilt.WhereClause = "" + sourceLayer.FeatureClass.Fields.get_Field(fldValTargetJoinIdx).Name + "" + " = '" + inObject.get_Value(fldValToCopyIdx).ToString() + "'";

                                                                            }
                                                                            else
                                                                            {
                                                                                pQFilt.WhereClause = sourceLayer.FeatureClass.Fields.get_Field(fldValTargetJoinIdx).Name + " = " + inObject.get_Value(fldValToCopyIdx);

                                                                            }
                                                                            AAState.WriteLine("                     " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bx") + pQFilt.WhereClause);
                                                                            int cnt = sourceLayer.FeatureClass.FeatureCount(pQFilt);
                                                                            AAState.WriteLine("                     " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14by") + cnt);
                                                                            if (cnt > 0)
                                                                            {

                                                                                fCursor = sourceLayer.FeatureClass.Search(pQFilt, true);
                                                                                while ((sourceFeature = fCursor.NextFeature()) != null)
                                                                                {
                                                                                    bool side = false;
                                                                                    if (Globals.GetPointOnLine(inFeature.Shape, sourceFeature.Shape, 450, out side) != null)
                                                                                    {

                                                                                        if (side)
                                                                                        {
                                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain38"));

                                                                                            inFeature.set_Value(intFldIdxs[0], "Right");
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain39"));
                                                                                            inFeature.set_Value(intFldIdxs[0], "Left");
                                                                                        }
                                                                                        if (fCursor != null)
                                                                                            Marshal.ReleaseComObject(fCursor);
                                                                                        fCursor = null;
                                                                                        continue;
                                                                                    }

                                                                                }
                                                                                if (fCursor != null)
                                                                                    Marshal.ReleaseComObject(fCursor);
                                                                                fCursor = null;
                                                                            }
                                                                            pQFilt = null;

                                                                        }

                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "SIDE" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    if (fCursor != null)
                                                        Marshal.ReleaseComObject(fCursor);
                                                    fCursor = null;

                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "SIDE");

                                                }
                                                break;

                                            }

                                        case "PROMPT":
                                            {
                                                //Loop through all fields list in the fieldname
                                                //If blank or null, prompt user for value
                                                //Store Value

                                                IDomain pDom = default(IDomain);
                                                ISubtypes pSubType = null;
                                                List<Globals.DomSubList> lst = null;

                                                Globals.DomSubList dmRetVal = null;

                                                try
                                                {
                                                    if ((inObject != null))
                                                    {

                                                        pSubType = (ISubtypes)inObject.Class;

                                                        if (pSubType.HasSubtype)
                                                        {
                                                            int intSub;
                                                            if (intFldIdxs.Contains(pSubType.SubtypeFieldIndex))
                                                            {
                                                                lst = Globals.SubtypeToList(pSubType);
                                                                if (inObject.get_Value(pSubType.SubtypeFieldIndex) == null || inObject.get_Value(pSubType.SubtypeFieldIndex) == "" || inObject.get_Value(pSubType.SubtypeFieldIndex) == DBNull.Value)
                                                                {
                                                                    dmRetVal = Globals.showValuesOptionsForm(lst, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + inObject.Class.AliasName + ":" + pSubType.SubtypeFieldName, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + inObject.Class.AliasName + ":" + pSubType.SubtypeFieldName, ComboBoxStyle.DropDownList);
                                                                    inObject.set_Value(pSubType.SubtypeFieldIndex, dmRetVal.Value);

                                                                    intSub = Convert.ToInt32(dmRetVal.Value);
                                                                }
                                                                else
                                                                {
                                                                    intSub = Convert.ToInt32(inObject.get_Value(pSubType.SubtypeFieldIndex));
                                                                }

                                                                for (int l = 0; l < strFldNames.Count; l++)
                                                                {
                                                                    if (intFldIdxs[l] == pSubType.SubtypeFieldIndex)
                                                                        continue;

                                                                    if (intFldIdxs[l] != -1)
                                                                    {
                                                                        pDom = pSubType.get_Domain(intSub, inObject.Fields.get_Field(intFldIdxs[l]).Name);

                                                                        if (pDom == null)
                                                                        {
                                                                            if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                            {
                                                                                IList<string> pVals = new List<string>();

                                                                                string strRetVal = Globals.showValuesOptionsForm(pVals, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + inObject.Class.AliasName + ":" + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + inObject.Class.AliasName + ":" + strFldAlias[l], ComboBoxStyle.DropDown);

                                                                                try
                                                                                {
                                                                                    inObject.set_Value(intFldIdxs[l], strRetVal);
                                                                                }
                                                                                catch
                                                                                {

                                                                                }
                                                                                pVals = null;
                                                                            }

                                                                        }
                                                                        else
                                                                        {

                                                                            if (pDom is CodedValueDomain)
                                                                            {

                                                                                lst = Globals.DomainToList(pDom);
                                                                                if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                                {

                                                                                    dmRetVal = Globals.showValuesOptionsForm(lst, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDownList);
                                                                                    try
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[l], dmRetVal.Value);
                                                                                    }
                                                                                    catch
                                                                                    {

                                                                                    }

                                                                                    lst = null;
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                                {

                                                                                    IList<string> pVals = new List<string>();
                                                                                    string strRetVal = Globals.showValuesOptionsForm(pVals, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDown);

                                                                                    try
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[l], strRetVal);
                                                                                    }
                                                                                    catch
                                                                                    {

                                                                                    }

                                                                                    pVals = null;
                                                                                }
                                                                            }

                                                                        }

                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  PROMPT: " + strFldNames[l] + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                    }
                                                                }

                                                            }
                                                            else
                                                            {
                                                                if (inObject.get_Value(pSubType.SubtypeFieldIndex) == null)
                                                                    intSub = pSubType.DefaultSubtypeCode;
                                                                else

                                                                    intSub = Convert.ToInt32(inObject.get_Value(pSubType.SubtypeFieldIndex));
                                                                for (int l = 0; l < strFldNames.Count; l++)
                                                                {
                                                                    if (intFldIdxs[l] != -1)
                                                                    {
                                                                        pDom = pSubType.get_Domain(intSub, inObject.Fields.get_Field(intFldIdxs[l]).Name);

                                                                        if (pDom == null)
                                                                        {
                                                                            if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                            {

                                                                                IList<string> pVals = new List<string>();
                                                                                string strRetVal = Globals.showValuesOptionsForm(pVals, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDown);

                                                                                try
                                                                                {
                                                                                    inObject.set_Value(intFldIdxs[l], strRetVal);
                                                                                }
                                                                                catch
                                                                                {

                                                                                }

                                                                                pVals = null;
                                                                            }
                                                                        }
                                                                        else
                                                                        {

                                                                            if (pDom is CodedValueDomain)
                                                                            {
                                                                                if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                                {

                                                                                    lst = Globals.DomainToList(pDom);

                                                                                    dmRetVal = Globals.showValuesOptionsForm(lst, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDownList);
                                                                                    try
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[l], dmRetVal.Value);
                                                                                    }
                                                                                    catch
                                                                                    {

                                                                                    }

                                                                                    lst = null;
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                                {

                                                                                    IList<string> pVals = new List<string>();
                                                                                    string strRetVal = Globals.showValuesOptionsForm(pVals, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDown);

                                                                                    try
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[l], strRetVal);
                                                                                    }
                                                                                    catch
                                                                                    {

                                                                                    }

                                                                                    pVals = null;
                                                                                }
                                                                            }

                                                                        }

                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  PROMPT: " + strFldNames[l] + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                    }
                                                                }

                                                            }
                                                        }
                                                        else
                                                        {
                                                            for (int l = 0; l < strFldNames.Count; l++)
                                                            {

                                                                if (intFldIdxs[l] != -1)
                                                                {

                                                                    pDom = inObject.Fields.get_Field(intFldIdxs[l]).Domain;
                                                                    if (pDom == null)
                                                                    {
                                                                        if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                        {

                                                                            IList<string> pVals = new List<string>();
                                                                            string strRetVal = Globals.showValuesOptionsForm(pVals, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDown);
                                                                            try
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[l], strRetVal);
                                                                            }
                                                                            catch
                                                                            {

                                                                            }

                                                                            pVals = null;
                                                                        }
                                                                    }
                                                                    else
                                                                    {

                                                                        if (pDom is CodedValueDomain)
                                                                        {
                                                                            if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                            {

                                                                                lst = Globals.DomainToList(pDom);

                                                                                dmRetVal = Globals.showValuesOptionsForm(lst, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDownList);
                                                                                try
                                                                                {
                                                                                    inObject.set_Value(intFldIdxs[l], dmRetVal.Value);
                                                                                }
                                                                                catch
                                                                                {

                                                                                }

                                                                                lst = null;
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            if (inObject.get_Value(intFldIdxs[l]) == null || inObject.get_Value(intFldIdxs[l]) == "" || inObject.get_Value(intFldIdxs[l]) == DBNull.Value)
                                                                            {

                                                                                IList<string> pVals = new List<string>();
                                                                                string strRetVal = Globals.showValuesOptionsForm(pVals, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bw") + strFldAlias[l], ComboBoxStyle.DropDown);
                                                                                try
                                                                                {
                                                                                    inObject.set_Value(intFldIdxs[l], strRetVal);
                                                                                }
                                                                                catch
                                                                                {

                                                                                }
                                                                                pVals = null;
                                                                            }
                                                                        }

                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  PROMPT: " + strFldNames[l] + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                }
                                                            }
                                                        }

                                                    }
                                                }

                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "PROMPT" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {

                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "PROMPT");
                                                    pDom = null;
                                                    pSubType = null;
                                                    lst = null;

                                                    dmRetVal = null;
                                                }
                                                break;
                                            }

                                        case "CASCADE_ATTRIBUTE":
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "CASCADE_ATTRIBUTE");

                                                string flds;
                                                string targetLayer;
                                                IRowChanges pRowCh = null;

                                                try
                                                {

                                                    if ((valData != null) && (inObject != null))
                                                    {
                                                        AAState.WriteLine("                     " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cb"));

                                                        AAState.WriteLine("                     " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ca") + valData);
                                                        //field name is the field to Check
                                                        //value|Layer|tempalte|Cut or Copy|field-toField
                                                        args = valData.Split('|');
                                                        if (args.Length < 2)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CASCADE_ATTRIBUTE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bl"));
                                                            continue;
                                                        }

                                                        targetLayer = args[0];
                                                        flds = args[1];
                                                        bool bPrompt;
                                                        if (args.Length == 3)
                                                        {
                                                            if (args[2].ToUpper() == "T" || args[2].ToUpper() == "TRUE" || args[2].ToUpper() == "YES")
                                                            {
                                                                bPrompt = true;
                                                            }
                                                            else
                                                            {
                                                                bPrompt = false;
                                                            }

                                                        }
                                                        else
                                                        {
                                                            bPrompt = true;
                                                        }
                                                        pRowCh = inObject as IRowChanges;
                                                        if (pRowCh.get_ValueChanged(intFldIdxs[0]) == false)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CASCADE_ATTRIBUTE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bk"));
                                                            continue;
                                                        }

                                                        bool boolFoundAsLayer = true;

                                                        sourceLayer = Globals.FindLayer(ArcMap.Application, args[0].ToString(), ref boolFoundAsLayer) as IFeatureLayer;
                                                        if (sourceLayer == null)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CASCADE_ATTRIBUTE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bj"));
                                                            continue;
                                                        }
                                                        int intTargFld = -1;
                                                        intTargFld = sourceLayer.FeatureClass.Fields.FindField(flds);
                                                        if (intTargFld == -1)
                                                        {
                                                            intTargFld = sourceLayer.FeatureClass.Fields.FindFieldByAliasName(flds);
                                                            if (intTargFld != -1)
                                                            {
                                                                flds = sourceLayer.FeatureClass.Fields.get_Field(intTargFld).Name;

                                                            }
                                                        }
                                                        if (intTargFld > -1)
                                                        {
                                                            bool proceed = true;

                                                            if (pRowCh.get_OriginalValue(intFldIdxs[0]).ToString().Trim() == "")
                                                                continue;
                                                            IQueryFilter pQFilt = new QueryFilterClass();
                                                            if (sourceLayer.FeatureClass.Fields.get_Field(intTargFld).Type == esriFieldType.esriFieldTypeString)
                                                            {
                                                                pQFilt.WhereClause = flds + " = '" + pRowCh.get_OriginalValue(intFldIdxs[0]) + "'";

                                                            }
                                                            else
                                                            {
                                                                pQFilt.WhereClause = flds + " = " + pRowCh.get_OriginalValue(intFldIdxs[0]) + "";

                                                            }

                                                            int featCnt = sourceLayer.FeatureClass.FeatureCount(pQFilt);
                                                            if (featCnt == 0)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain40"));

                                                            }
                                                            else
                                                            {
                                                                string promptLayname;

                                                                promptLayname = Globals.getClassName(sourceLayer);

                                                                if (bPrompt)
                                                                {
                                                                    if (MessageBox.Show("You are about to change " + featCnt + " rows in the " + promptLayname + " Feature Class, proceed?", "Cascade", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain41"));

                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain42"));
                                                                        proceed = false;

                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain43"));
                                                                }
                                                                if (proceed)
                                                                {
                                                                    IFeatureCursor pCalcCursor = sourceLayer.FeatureClass.Update(pQFilt, false);
                                                                    IFeature updateFeat;
                                                                    if (ChangeFeatureList == null)
                                                                    {
                                                                        ChangeFeatureList = new List<IObject>();
                                                                    }
                                                                    while ((updateFeat = pCalcCursor.NextFeature()) != null)
                                                                    {

                                                                        updateFeat.set_Value(intTargFld, inObject.get_Value(intFldIdxs[0]));
                                                                        ChangeFeatureList.Add(updateFeat);

                                                                        //if (!trackCancel.Continue())
                                                                        //{
                                                                        //    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19"));
                                                                        //    AAState._editor.AbortOperation();
                                                                        //    return false;
                                                                        //}
                                                                    }
                                                                    updateFeat = null;

                                                                    if (pCalcCursor != null)
                                                                    {
                                                                        Marshal.ReleaseComObject(pCalcCursor);
                                                                    }
                                                                    pCalcCursor = null;

                                                                    pQFilt = null;
                                                                }
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CASCADE_ATTRIBUTE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bi"));
                                                        }

                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CASCADE_ATTRIBUTE" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    sourceLayer = null;

                                                    pRowCh = null;
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "CASCADE_ATTRIBUTE");
                                                }
                                                break;
                                            }

                                        case "COPY_FEATURE":
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "COPY_FEATURE");
                                                IFeatureLayer pTargetFL;
                                                string[] FldPairs;
                                                string targetValue;
                                                IRowChanges pRowCh = null;
                                                IFeature pNewFeat = null;
                                                try
                                                {

                                                    if ((valData != null) && (inFeature != null))
                                                    {
                                                        AAState.WriteLine("                     " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cb"));

                                                        AAState.WriteLine("                     " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ca") + valData);
                                                        //field name is the field to Check
                                                        //value|Layer|tempalte|Cut or Copy|field-toField
                                                        args = valData.Split('|');
                                                        if (args.Length < 2)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bh"));
                                                            continue;
                                                        }

                                                        targetValue = args[0];
                                                        pRowCh = inObject as IRowChanges;

                                                        if (intFldIdxs.Count > 0)
                                                        {
                                                       if (pRowCh.get_ValueChanged(intFldIdxs[0]) == false && mode != "ON_CREATE")
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain44"));
                                                            continue;
                                                        }

                                                            if (inFeature.get_Value(intFldIdxs[0]).ToString() != targetValue.ToString())
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain45"));
                                                                continue;
                                                            }
                                                        }

                                                        bool FCorLayerTarget = true;

                                                        pTargetFL = Globals.FindLayer(ArcMap.Application, args[1].ToString(), ref FCorLayerTarget) as IFeatureLayer;
                                                        if (pTargetFL == null)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bg"));
                                                            continue;
                                                        }
                                                        if (Globals.IsEditable(ref pTargetFL, ref AAState._editor) == false)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14be"));
                                                            continue;
                                                        }

                                                        if (pTargetFL.FeatureClass.ShapeType != (inFeature.Class as IFeatureClass).ShapeType)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bf"));
                                                            continue;
                                                        }

                                                        FldPairs = null;
                                                        //value|Layer|tempalte|Cut or Copy|field-toField

                                                        IEditTemplate pEditTemp = null;
                                                        string sourceAction = "COPY";
                                                        string fldMatching = null;

                                                        switch (args.Length)
                                                        {
                                                            //case 2:

                                                            //    break;
                                                            case 3:
                                                                if (args[2].Trim() != "")
                                                                {
                                                                    pEditTemp = Globals.PromptAndGetEditTemplateGraphic(pTargetFL, args[2].Trim());

                                                                }
                                                                else
                                                                {
                                                                    pEditTemp = null;
                                                                }
                                                                break;
                                                            case 4:
                                                                if (args[2].Trim() != "")
                                                                {

                                                                    pEditTemp = Globals.PromptAndGetEditTemplateGraphic(pTargetFL, args[2].Trim());
                                                                }
                                                                else
                                                                {
                                                                    pEditTemp = null;
                                                                }
                                                                sourceAction = args[3].ToUpper().Trim();

                                                                break;
                                                            case 5:
                                                                if (args[2].Trim() != "")
                                                                {

                                                                    pEditTemp = Globals.PromptAndGetEditTemplateGraphic(pTargetFL, args[2].Trim());
                                                                }
                                                                else
                                                                {
                                                                    pEditTemp = null;
                                                                }
                                                                sourceAction = args[3].ToUpper().Trim();
                                                                fldMatching = args[4].Trim();
                                                                break;
                                                        }

                                                        if (pEditTemp != null)
                                                        {

                                                            pNewFeat = Globals.CreateFeature(inFeature.ShapeCopy, pEditTemp, AAState._editor, ArcMap.Application, false, false, false);

                                                        }
                                                        else
                                                        {
                                                            pNewFeat = Globals.CreateFeature(inFeature.ShapeCopy, pTargetFL, AAState._editor, ArcMap.Application, false, false, false);

                                                        }
                                                        pEditTemp = null;
                                                        if (fldMatching != null)
                                                        {
                                                            if (fldMatching == "")
                                                            {
                                                                FldPairs = new string[] { };
                                                            }
                                                            else
                                                            {
                                                                FldPairs = fldMatching.Split(',');
                                                            }
                                                        }
                                                        else
                                                        {
                                                            FldPairs = new string[] { };

                                                        }

                                                        List<string> targFilds = new List<string>();

                                                        foreach (string strFlpPair in FldPairs)
                                                        {
                                                            string[] fldMatch = strFlpPair.Split('-');
                                                            if (fldMatch.Length != 2)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bd"));
                                                            }
                                                            else
                                                            {
                                                                string strSrcFldName = fldMatch[0];
                                                                string strTarFldName = fldMatch[1];
                                                                int intSrcFldIdx = Globals.GetFieldIndex((inFeature.Class as IFeatureClass).Fields, (strSrcFldName));
                                                                int intTarFldIdx = Globals.GetFieldIndex(pTargetFL.FeatureClass.Fields, strTarFldName);
                                                                if (intSrcFldIdx == -1 || intTarFldIdx == -1)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bc"));
                                                                }
                                                                else
                                                                {
                                                                    targFilds.Add(strTarFldName.ToUpper());

                                                                    try
                                                                    {
                                                                        pNewFeat.set_Value(intTarFldIdx, inFeature.get_Value(intSrcFldIdx));
                                                                    }
                                                                    catch
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bb") + strFlpPair);

                                                                    }
                                                                }

                                                            }
                                                        }
                                                        IFields pTarFields = pTargetFL.FeatureClass.Fields;
                                                        IField pTarField = null;
                                                        for (int i = 0; i < pTarFields.FieldCount; i++)
                                                        {
                                                            pTarField = pTarFields.get_Field(i);
                                                            if (pTarField.Type != esriFieldType.esriFieldTypeGlobalID &&
                                                                pTarField.Type != esriFieldType.esriFieldTypeOID &&
                                                                pTarField.Type != esriFieldType.esriFieldTypeGeometry &&
                                                                 pTarField.Name.ToUpper() != "SHAPE_LENGTH" &&
                                                                pTarField.Name.ToUpper() != "SHAPE.LEN" &&
                                                                pTarField.Name.ToUpper() != "SHAPE_AREA" &&
                                                                pTarField.Name.ToUpper() != "SHAPE.AREA")
                                                            {
                                                                if (targFilds.Contains(pTarField.Name.ToUpper()) == false)
                                                                {
                                                                    int fldIdx = inFeature.Fields.FindField(pTarField.Name);
                                                                    if (fldIdx > 0)
                                                                    {
                                                                        try
                                                                        {
                                                                            pNewFeat.set_Value(i, inFeature.get_Value(fldIdx));
                                                                        }
                                                                        catch
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain46") + pTarField.Name);

                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }

                                                        pTarFields = null;
                                                        pTarField = null;
                                                        if (NewFeatureList == null)
                                                        {
                                                            NewFeatureList = new List<IObject>();
                                                        }

                                                        NewFeatureList.Add(pNewFeat);

                                                        if (sourceAction == "CUT")
                                                        {
                                                            MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain47"));

                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain48"));

                                                    }
                                                }

                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    pTargetFL = null;

                                                    pRowCh = null;
                                                    pNewFeat = null;
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "COPY_FEATURE");
                                                }
                                                break;
                                            }

                                        case "VALIDATE_CONNECTIVITY":
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "VALIDATE_CONNECTIVITY");

                                                try
                                                {

                                                    if ((valData != null) && (inFeature != null))
                                                    {
                                                        AAState.WriteLine("                     " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cb"));

                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain49"));
                                                        bool validFeat = false;
                                                        if (inFeature is INetworkFeature)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain50"));

                                                            AAState.WriteLine("                     " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ca") + valData);

                                                            args = valData.Split('|');
                                                            int connectionCnt = Globals.getConnectionCount(inFeature);

                                                            foreach (string fldConPair in args)
                                                            {

                                                                string[] fldCon = fldConPair.Split(',');
                                                                if (fldCon.Length == 1)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain51"));
                                                                    if (Globals.IsNumeric(fldCon[0]))
                                                                    {
                                                                        if (connectionCnt == Convert.ToInt32(fldCon[0]))
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52"));
                                                                            validFeat = true;
                                                                            break;

                                                                        }

                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain53"));
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    if (intFldIdxs.Count == 0)
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain51"));
                                                                        if (fldCon.Length == 2)
                                                                        {
                                                                            if (connectionCnt == Convert.ToInt32(fldCon[1]))
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52"));
                                                                                validFeat = true;
                                                                                break;

                                                                            }
                                                                        }
                                                                        if (fldCon.Length > 2)
                                                                        {
                                                                            if (connectionCnt >= Convert.ToInt32(fldCon[1]) && connectionCnt <= Convert.ToInt32(fldCon[2]))
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52"));
                                                                                validFeat = true;
                                                                                break;

                                                                            }
                                                                        }

                                                                    }

                                                                    else if (inFeature.get_Value(intFldIdxs[0]).ToString() == fldCon[0])
                                                                    {

                                                                        if (fldCon.Length == 2)
                                                                        {
                                                                            if (connectionCnt == Convert.ToInt32(fldCon[1]))
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52"));
                                                                                validFeat = true;
                                                                                break;

                                                                            }
                                                                        }
                                                                        if (fldCon.Length > 2)
                                                                        {
                                                                            if (connectionCnt >= Convert.ToInt32(fldCon[1]) && connectionCnt <= Convert.ToInt32(fldCon[2]))
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52"));
                                                                                validFeat = true;
                                                                                break;

                                                                            }
                                                                        }

                                                                    }

                                                                }

                                                            }
                                                            if (validFeat == false)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19"));
                                                                AAState._editor.AbortOperation();
                                                                return false;

                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain54"));

                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain48"));

                                                    }
                                                }

                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "VALIDATE_CONNECTIVITY" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "VALIDATE_CONNECTIVITY");
                                                }
                                                break;
                                            }

                                        case "VALIDATE_ATTRIBUTES":
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "VALIDATE_ATTRIBUTES");

                                                try
                                                {
                                                    if ((valData != null) && (inFeature != null))
                                                    {

                                                        AAState.WriteLine("                     " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cb"));
                                                        IRowChanges pRowCh = inObject as IRowChanges;
                                                        changed = true;
                                                        if (intFldIdxs != null && intFldIdxs.Count > 0 && mode != "ON_CREATE")
                                                        {
                                                            for (int fldIdx = 0; fldIdx < intFldIdxs.Count; fldIdx++)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain55"));
                                                                changed = pRowCh.get_ValueChanged(intFldIdxs[fldIdx]);
                                                                AAState.WriteLine("                     " + strFldNames[fldIdx] + " changed value was " + changed);
                                                                if (changed)
                                                                    break;
                                                            }

                                                        }
                                                        if (changed)
                                                        {
                                                            args = valData.Split('|');
                                                            args = args[0].Split(',');
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain56") + args);
                                                            if (args.Length > 0)
                                                            {

                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain57"));
                                                                IList<ILayer> pLayList = Globals.FindLayersByClassID(((IMxDocument)ArcMap.Application.Document).FocusMap, inObject.Class.ObjectClassID);
                                                                if (pLayList != null)
                                                                {
                                                                    if (pLayList.Count > 0)
                                                                    {

                                                                        AAState.WriteLine("                     " + pLayList.Count + " Layers found");
                                                                        bool ValidComb = false;

                                                                        foreach (ILayer pLay in pLayList)
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain58") + pLay.Name);
                                                                            if (pLay is IFeatureLayer)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain59"));

                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain60"));
                                                                                IEditTemplateManager pEdTmpManager = Globals.GetEditTemplateManager((IFeatureLayer)pLay);
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain61"));
                                                                                ValidComb = Globals.FeatureIsValidTemplate(pEdTmpManager, inFeature, args);
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain62") + ValidComb.ToString());
                                                                                if (ValidComb == true)
                                                                                    break;

                                                                            }

                                                                        }
                                                                        if (ValidComb == false)
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19"));
                                                                            AAState._editor.AbortOperation();
                                                                            return false;

                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain63"));

                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain63"));

                                                                }

                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain64"));

                                                        }
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "VALIDATE_ATTRIBUTES" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "VALIDATE_ATTRIBUTES");
                                                }
                                                break;
                                            }

                                        case "SPLIT_INTERSECTING_FEATURE":
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "SPLIT_INTERSECTING_FEATURE");

                                                try
                                                {
                                                    if ((valData != null) && (inFeature != null))
                                                    {
                                                        intersectLayerName = "";
                                                        intersectLayer = null;
                                                        args = valData.Split('|');
                                                        if (args.Length > 0)
                                                        {
                                                            AAState.WriteLine("                  " + args.Length + " Layers listed ");

                                                            for (int i = 0; i < args.Length; i++)
                                                            {

                                                                intersectLayerName = args[i].Trim();
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain65") + intersectLayerName);
                                                                boolLayerOrFC = true;
                                                                if (intersectLayerName.Contains("("))
                                                                {
                                                                    string[] tempSplt = intersectLayerName.Split('(');
                                                                    intersectLayerName = tempSplt[0];
                                                                    intersectLayer = Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                                    if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                    {
                                                                        boolLayerOrFC = true;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                    {
                                                                        boolLayerOrFC = true;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                    {
                                                                        boolLayerOrFC = false;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                    {
                                                                        boolLayerOrFC = false;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                    {
                                                                        boolLayerOrFC = false;
                                                                    }
                                                                    else
                                                                    {
                                                                        boolLayerOrFC = true;
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    intersectLayer = Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                                }
                                                                if (intersectLayer != null)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain66") + intersectLayerName);
                                                                    if (intersectLayer.FeatureClass != null)
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain67") + intersectLayerName);
                                                                        double snapTol = Globals.GetXYTolerance(intersectLayer);
                                                                        sFilter = Globals.createSpatialFilter(intersectLayer, inFeature, false);

                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain68"));

                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain69") + intersectLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain70"));

                                                                        pFS = (IFeatureSelection)intersectLayer;
                                                                        if (boolLayerOrFC)
                                                                        {
                                                                            if (pFS.SelectionSet.Count > 0)
                                                                            {
                                                                                pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                                fCursor = cCurs as IFeatureCursor;

                                                                            }
                                                                            else
                                                                            {
                                                                                fCursor = intersectLayer.Search(sFilter, true);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            fCursor = intersectLayer.FeatureClass.Search(sFilter, true);
                                                                        }

                                                                        IFeature intsersectFeature;
                                                                        int idx = 1;
                                                                        while ((intsersectFeature = fCursor.NextFeature()) != null)
                                                                        {
                                                                            if (intsersectFeature.Class != inFeature.Class)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain71") + idx);
                                                                                idx++;

                                                                                if (intsersectFeature is INetworkFeature)
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain72"));
                                                                                }
                                                                                else
                                                                                {
                                                                                    ISet featset = Globals.splitLineWithPoint(intsersectFeature, inFeature.ShapeCopy as IPoint, snapTol, null, "{0:0.00}", ArcMap.Application);

                                                                                    if (featset != null)
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain73"));

                                                                                        if (featset.Count > 0)
                                                                                        {
                                                                                            if (NewFeatureList == null)
                                                                                            {
                                                                                                NewFeatureList = new List<IObject>();
                                                                                            }
                                                                                            object featobj;
                                                                                            while ((featobj = featset.Next()) != null)
                                                                                            {
                                                                                                IFeature feature = featobj as IFeature;

                                                                                                if (feature != null)
                                                                                                {
                                                                                                    NewFeatureList.Add(feature as IObject);
                                                                                                }
                                                                                                feature = null;
                                                                                            }

                                                                                        }
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain74") + intersectLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain75") + featset.Count);
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain76"));

                                                                                    }
                                                                                    featset = null;
                                                                                }
                                                                            }
                                                                            if (intsersectFeature != null)
                                                                            {
                                                                                Marshal.ReleaseComObject(intsersectFeature);
                                                                            }

                                                                            else if (intsersectFeature.Class == inFeature.Class && intsersectFeature.OID != inFeature.OID)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain71") + idx);
                                                                                idx++;
                                                                                if (intsersectFeature is INetworkFeature)
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain72"));
                                                                                }
                                                                                else
                                                                                {
                                                                                    ISet featset = Globals.splitLineWithPoint(intsersectFeature, inFeature.ShapeCopy as IPoint, snapTol, null, "{0:0.00}", ArcMap.Application);

                                                                                    if (featset == null)
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain77"));

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain73"));

                                                                                        if (featset.Count > 0)
                                                                                        {
                                                                                            if (NewFeatureList == null)
                                                                                            {
                                                                                                NewFeatureList = new List<IObject>();
                                                                                            }
                                                                                            object featobj;
                                                                                            while ((featobj = featset.Next()) != null)
                                                                                            {
                                                                                                IFeature feature = featobj as IFeature;
                                                                                                if (feature != null)
                                                                                                {
                                                                                                    NewFeatureList.Add(feature as IObject);
                                                                                                }
                                                                                                feature = null;

                                                                                            }

                                                                                        }
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain74") + intersectLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain75") + featset.Count);
                                                                                    }
                                                                                    featset = null;

                                                                                }
                                                                                if (intsersectFeature != null)
                                                                                {
                                                                                    Marshal.ReleaseComObject(intsersectFeature);
                                                                                }

                                                                            }

                                                                        }
                                                                        intsersectFeature = null;
                                                                    }
                                                                }

                                                                else
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain78") + intersectLayerName);
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14l") + valData);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14m"));
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "SPLIT_INTERSECTING_FEATURE" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "SPLIT_INTERSECTING_FEATURE");
                                                }
                                                break;
                                            }

                                        case "NEAREST_FEATURE_ATTRIBUTES":
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "NEAREST_FEATURE_ATTRIBUTES");
                                                try
                                                {
                                                    if ((valData != null) && (inFeature != null))
                                                    {
                                                        sourceLayerName = "";
                                                        string[] sourceFieldNames = null;
                                                        string[] destFieldNames = null;
                                                        searchDistance = 0;

                                                        // Parse arguments
                                                        args = valData.Split('|');
                                                        if (args.Length == 3)
                                                        {
                                                            sourceLayerName = args[0].ToString().Trim();
                                                            sourceFieldNames = args[1].ToString().Split(',');
                                                            destFieldNames = args[2].ToString().Split(',');
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain79"));

                                                        }
                                                        else if (args.Length == 4)
                                                        {
                                                            sourceLayerName = args[0].ToString().Trim();
                                                            sourceFieldNames = args[1].ToString().Split(',');
                                                            destFieldNames = args[2].ToString().Split(',');
                                                            Double.TryParse(args[3], out searchDistance);
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14d"));
                                                            continue;

                                                        }

                                                        if ((sourceFieldNames != null) && (destFieldNames != null) &&
                                                            (sourceFieldNames.Length > 0) && (destFieldNames.Length > 0) &&
                                                            (sourceFieldNames.Length == destFieldNames.Length))
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain13") + sourceLayerName);

                                                            boolLayerOrFC = true;
                                                            if (sourceLayerName.Contains("("))
                                                            {
                                                                string[] tempSplt = sourceLayerName.Split('(');
                                                                sourceLayerName = tempSplt[0];
                                                                sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                                if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                            }

                                                            else
                                                            {
                                                                sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IFeatureLayer;
                                                            }
                                                            if (sourceLayer != null)
                                                            {
                                                                if (sourceLayer.FeatureClass != null)
                                                                {
                                                                    AAState.WriteLine("                  " + sourceLayer.Name + " layer Found: " + sourceLayerName);

                                                                    string missingFieldMess = null;
                                                                    int[] sourceFieldNums = new int[sourceFieldNames.Length];
                                                                    int[] destFieldNums = new int[destFieldNames.Length];
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain80"));

                                                                    for (int i = 0; i < sourceFieldNums.Length; i++)
                                                                    {
                                                                        int fnum = sourceLayer.FeatureClass.FindField(sourceFieldNames[i].Trim());
                                                                        if (fnum < 0)
                                                                        {
                                                                            missingFieldMess = sourceFieldNames[i].Trim() + " in table " + sourceLayerName;
                                                                            break;
                                                                        }
                                                                        sourceFieldNums[i] = fnum;
                                                                    }
                                                                    if (missingFieldMess == null)
                                                                    {
                                                                        for (int i = 0; i < destFieldNums.Length; i++)
                                                                        {
                                                                            int fnum = inFeature.Fields.FindField(destFieldNames[i].Trim());
                                                                            if (fnum < 0)
                                                                            {
                                                                                missingFieldMess = destFieldNames[i].Trim() + " in table " + tableName;
                                                                                break;
                                                                            }
                                                                            destFieldNums[i] = fnum;
                                                                        }
                                                                    }
                                                                    if (missingFieldMess == null)
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain81"));

                                                                        // found source and destination fields.

                                                                        if (searchDistance > 0)
                                                                        {
                                                                            sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false);

                                                                        }
                                                                        else
                                                                        {
                                                                            sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false);

                                                                        }

                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain82"));

                                                                        pFS = (IFeatureSelection)sourceLayer;
                                                                        if (boolLayerOrFC)
                                                                        {
                                                                            if (pFS.SelectionSet.Count > 0)
                                                                            {
                                                                                pFS.SelectionSet.Search(sFilter, false, out cCurs);
                                                                                fCursor = cCurs as IFeatureCursor;

                                                                            }
                                                                            else
                                                                            {
                                                                                fCursor = sourceLayer.Search(sFilter, false);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            fCursor = sourceLayer.FeatureClass.Search(sFilter, false);
                                                                        }

                                                                        sourceFeature = fCursor.NextFeature();
                                                                        nearestFeature = null;

                                                                        proxOp = (IProximityOperator)inFeature.Shape;
                                                                        lastDistance = searchDistance;
                                                                        if (sourceFeature != null)
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain83"));

                                                                            while (sourceFeature != null)
                                                                            {
                                                                                if (sourceFeature.Class != inFeature.Class)
                                                                                {

                                                                                    IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                    pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                    distance = proxOp.ReturnDistance(pTempGeo);
                                                                                    pTempGeo = null;
                                                                                    if (distance <= lastDistance)
                                                                                    {
                                                                                        nearestFeature = sourceFeature;
                                                                                        lastDistance = distance;
                                                                                    }
                                                                                }
                                                                                else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                                {

                                                                                    IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                    pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                    distance = proxOp.ReturnDistance(pTempGeo);
                                                                                    pTempGeo = null;
                                                                                    if (distance <= lastDistance)
                                                                                    {
                                                                                        nearestFeature = sourceFeature;
                                                                                        lastDistance = distance;
                                                                                    }
                                                                                }
                                                                                sourceFeature = fCursor.NextFeature();
                                                                            }
                                                                        }
                                                                        if (nearestFeature != null)
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain84") + lastDistance + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain85") + nearestFeature.OID);

                                                                            for (int i = 0; i < sourceFieldNums.Length; i++)
                                                                            {
                                                                                try
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain86") + sourceFieldNames[i] + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain87") + destFieldNames[i]);

                                                                                    inObject.set_Value(destFieldNums[i], nearestFeature.get_Value(sourceFieldNums[i]));
                                                                                }
                                                                                catch
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14n") + sourceFieldNames[i] + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain87") + destFieldNames[i]);

                                                                                }
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain88"));

                                                                            for (int i = 0; i < destFieldNums.Length; i++)
                                                                            {
                                                                                IField field = inObject.Fields.get_Field(destFieldNums[i]);
                                                                                object newval = field.DefaultValue;
                                                                                if (newval == null)
                                                                                {
                                                                                    if (field.IsNullable)
                                                                                    {
                                                                                        inObject.set_Value(destFieldNums[i], null);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    inObject.set_Value(destFieldNums[i], newval);
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14o") + missingFieldMess);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + sourceLayerName + " data source is not set");
                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14e") + valData);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14f"));
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "NEAREST_FEATURE_ATTRIBUTES" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "NEAREST_FEATURE_ATTRIBUTES");
                                                }
                                                break;
                                            }
                                        case "MINIMUM_LENGTH":
                                            {
                                                try
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "MINIMUM_LENGTH");

                                                    double minlength;
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain89"));

                                                    if (Double.TryParse(valData, out minlength))
                                                    {
                                                        if (inFeature != null)
                                                        {
                                                            ICurve curve = inFeature.Shape as ICurve;
                                                            if (curve != null)
                                                            {
                                                                if (curve.Length < minlength)
                                                                {
                                                                    String mess = "Line is shorter than " +
                                                                        String.Format("{0:0.00}", minlength) + " " + Globals.GetSpatRefUnitName(inFeature.Shape.SpatialReference, true) +
                                                                        ", aborting edit.";
                                                                    AAState.WriteLine("                  " + mess);

                                                                    MessageBox.Show(mess, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain90"));
                                                                    AAState._editor.AbortOperation();
                                                                    return false;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14p"));

                                                            }
                                                        }
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "MINIMUM_LENGTH \n" + ex.Message);
                                                }
                                                finally
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "MINIMUM_LENGTH");

                                                }

                                                break;
                                            }
                                        case "LINK_TABLE_ASSET":

                                            try
                                            {
                                                intersectLayerName = "";
                                                intersectTable = null;
                                                intersectLayer = null;
                                                List<string> intersectLayerFieldNameList = new List<string>();
                                                List<int> intersectFieldPosList = new List<int>();
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "LINK_TABLE_ASSET");
                                                args = valData.Split('|');
                                                switch (args.GetLength(0))
                                                {
                                                    case 1:  // Feature Layer only
                                                        intersectLayerName = args[0].ToString();
                                                        break;
                                                    case 2:  // Feature Layer| Field to copy
                                                        intersectLayerName = args[0].ToString();

                                                        intersectLayerFieldNameList = new List<string>(args[1].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));

                                                        break;
                                                    case 3:  // Feature Layer| Field to copy | for future
                                                        intersectLayerName = args[0].ToString();
                                                        intersectLayerFieldNameList = new List<string>(args[1].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));

                                                        break;
                                                    default:
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14q") + valData);
                                                        continue;

                                                }
                                                bool FCorLayerIntersect = true;
                                                intersectLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref FCorLayerIntersect);
                                                intersectTable = Globals.FindStandAloneTable(AAState._editor.Map, intersectLayerName);

                                                if (intersectLayer != null)
                                                {
                                                    //Find Area Field

                                                    foreach (string intersectLayerFieldName in intersectLayerFieldNameList)
                                                    {

                                                        intersectFieldPos = intersectLayer.FeatureClass.Fields.FindField(intersectLayerFieldName);
                                                        if (intersectFieldPos < 0)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14r") +"(" + intersectLayerFieldName + ") not found");
                                                            break;
                                                        }

                                                        else
                                                        {
                                                            intersectFieldPosList.Add(intersectFieldPos);
                                                        }
                                                    }
                                                    intersectLayerSelection = (IFeatureSelection)intersectLayer;
                                                    if (intersectLayerSelection.SelectionSet.Count == 0)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14s") + intersectLayerName);

                                                        break;
                                                    }
                                                    if (intersectLayerSelection.SelectionSet.Count > 1)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14t") + intersectLayerName);

                                                        break;
                                                    }

                                                    intersectLayerSelection.SelectionSet.Search(null, true, out cCurs);
                                                }
                                                else if (intersectTable != null)
                                                {
                                                    if (intersectTable.Table == null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14u") + "(" + intersectLayerName + ") not found");
                                                        break;
                                                    }

                                                    foreach (string intersectLayerFieldName in intersectLayerFieldNameList)
                                                    {

                                                        intersectFieldPos = intersectTable.Table.Fields.FindField(intersectLayerFieldName);
                                                        if (intersectFieldPos < 0)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14v") + "(" + intersectLayerFieldName + ") not found");
                                                            break;
                                                        }
                                                        else
                                                        {
                                                            intersectFieldPosList.Add(intersectFieldPos);
                                                        }
                                                    }

                                                    intersectTableSelection = (ITableSelection)intersectTable;
                                                    if (intersectTableSelection.SelectionSet.Count == 0)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14s") + intersectLayerName);

                                                        break;
                                                    }
                                                    if (intersectTableSelection.SelectionSet.Count > 1)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14t") + intersectLayerName);

                                                        break;
                                                    }

                                                    intersectTableSelection.SelectionSet.Search(null, true, out cCurs);
                                                }
                                                else
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14u") + "(" + intersectLayerName + ") not found");
                                                    break;
                                                }

                                                IRow row;

                                                while ((row = cCurs.NextRow()) != null)
                                                {
                                                    int idx = 0;
                                                    foreach (int fldIdxInt in intersectFieldPosList)
                                                    {
                                                        if (idx >= intFldIdxs.Count)
                                                            continue;

                                                        string val = row.get_Value(fldIdxInt).ToString();
                                                        if (inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeString)
                                                            inObject.set_Value(intFldIdxs[idx], val);
                                                        else if (inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeSmallInteger || inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeInteger)
                                                        {
                                                            if (Globals.IsNumeric(val))
                                                            {
                                                                inObject.set_Value(intFldIdxs[idx], Convert.ToInt32(val));

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14w") + val);

                                                            }
                                                        }
                                                        else if (inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeSingle || inObject.Fields.get_Field(intFldIdxs[idx]).Type == esriFieldType.esriFieldTypeDouble)
                                                        {
                                                            if (Globals.IsNumeric(val))
                                                            {
                                                                inObject.set_Value(intFldIdxs[idx], Convert.ToDouble(val));

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14x") + val);

                                                            }
                                                        }
                                                        else
                                                        {
                                                            inObject.set_Value(intFldIdxs[idx], val);
                                                        }
                                                        idx++;

                                                    }

                                                }
                                                if (row != null)
                                                    Marshal.ReleaseComObject(cCurs);

                                                row = null;

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "LINK_TABLE_ASSET" + Environment.NewLine + ex.Message);
                                            }

                                            finally
                                            {
                                                if (cCurs != null)
                                                {
                                                    Marshal.ReleaseComObject(cCurs);
                                                    GC.Collect(300);
                                                    GC.WaitForFullGCComplete();
                                                    cCurs = null;

                                                }
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "LINK_TABLE_ASSET");
                                            }
                                            break;

                                        case "GET_ADDRESS_FROM_CENTERLINE":

                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "GET_ADDRESS_FROM_CENTERLINE");
                                            List<IPoint> pPnts = null;
                                            try
                                            {
                                                if ((valData != null) && (inFeature != null))
                                                {
                                                    sourceLayerName = "";
                                                    string[] sourceFieldNames = null;

                                                    searchDistance = 0;

                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    if (args.Length == 2)
                                                    {
                                                        sourceLayerName = args[0].ToString().Trim();
                                                        sourceFieldNames = args[1].ToString().Split(',');
                                                        searchDistance = 2;
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain79"));

                                                    }
                                                    else if (args.Length == 3)
                                                    {
                                                        sourceLayerName = args[0].ToString().Trim();
                                                        sourceFieldNames = args[1].ToString().Split(',');
                                                        Double.TryParse(args[2], out searchDistance);

                                                    }

                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14d"));
                                                        continue;

                                                    }

                                                    if (sourceFieldNames.Length != 5)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14y"));
                                                        continue;

                                                    }

                                                    boolLayerOrFC = false;
                                                    if (sourceLayerName.Contains("("))
                                                    {
                                                        string[] tempSplt = sourceLayerName.Split('(');
                                                        sourceLayerName = tempSplt[0];
                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                    }
                                                    pPnts = Globals.GetGeomCenter(inObject as IFeature);
                                                    if (pPnts.Count != 0)
                                                    {

                                                        AddressInfo pRetValu = Globals.GetAddressInfo(ArcMap.Application, pPnts[0] as IPoint, sourceLayerName,
                                                            sourceFieldNames[0].Trim(), sourceFieldNames[1].Trim(), sourceFieldNames[2].Trim(), sourceFieldNames[3].Trim(), sourceFieldNames[4].Trim(), false, searchDistance);
                                                        if (pRetValu != null)
                                                        {
                                                            if (pRetValu.Messages == "")
                                                            {

                                                                bool rightSide = true;
                                                                IPoint pPnt = Globals.GetPointOnLine((inObject as IFeature).Shape as IPoint, pRetValu.StreetGeometry as IPolyline, 400, out rightSide);

                                                                try
                                                                {
                                                                    if (strFldNames.Count == 2)
                                                                    {
                                                                        if (intFldIdxs[0] != -1)
                                                                        {
                                                                            if (rightSide)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], pRetValu.RightAddress);
                                                                            }
                                                                            else
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], pRetValu.LeftAddress);
                                                                            }
                                                                        }
                                                                        if (intFldIdxs[1] != -1)
                                                                            inObject.set_Value(intFldIdxs[1], pRetValu.StreetName);

                                                                    }
                                                                    else
                                                                    {
                                                                        if (intFldIdxs[0] != -1)
                                                                        {
                                                                            if (rightSide)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], pRetValu.RightAddress + " " + pRetValu.StreetName);
                                                                            }
                                                                            else
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], pRetValu.LeftAddress + " " + pRetValu.StreetName);
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14z") + Environment.NewLine + ex.Message);
                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aa") + pRetValu.Messages);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ab"));
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ac"));
                                                    }

                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GET_ADDRESS_FROM_CENTERLINE" + Environment.NewLine + ex.Message);
                                            }

                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "GET_ADDRESS_FROM_CENTERLINE");
                                                pPnts = null;

                                            }

                                            break;

                                        case "GET_ADDRESS_USING_GEOCODER":
                                            {
                                                IReverseGeocoding reverseGeocoding = null;
                                                IAddressGeocoding addressGeocoding = null;
                                                IPoint revGCLoc = null;
                                                IFields matchFields = null;
                                                IField shapeField = null;

                                                IReverseGeocodingProperties reverseGeocodingProperties = null;
                                                IPropertySet addressProperties = null;

                                                IAddressInputs addressInputs = null;
                                                IFields addressFields = null;
                                                object key = null;
                                                object value = null;
                                                try
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "GET_ADDRESS_USING_GEOCODER");

                                                    if (!String.IsNullOrEmpty(valData))
                                                    {
                                                        args = valData.Split('|');
                                                        if (args.Length != 2)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad"));
                                                            break;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad"));
                                                        break;
                                                    }
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain91"));
                                                    reverseGeocoding = Globals.OpenLocator(args[0], args[1]);

                                                    if (reverseGeocoding == null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ae"));
                                                        break;
                                                    }
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain92"));
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain93"));
                                                    revGCLoc = Globals.GetGeomCenter(inFeature)[0];
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain94"));
                                                    // Create a Point at which to find the address.
                                                    addressGeocoding = (IAddressGeocoding)reverseGeocoding;

                                                    matchFields = addressGeocoding.MatchFields;
                                                    int shpFld = matchFields.FindField("Shape");

                                                    shapeField = matchFields.get_Field(shpFld);
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain95"));
                                                    // Set the search tolerance for reverse geocoding.
                                                    reverseGeocodingProperties = (IReverseGeocodingProperties)reverseGeocoding;
                                                    reverseGeocodingProperties.SearchDistance = 100;
                                                    reverseGeocodingProperties.SearchDistanceUnits = esriUnits.esriFeet;
                                                    reverseGeocoding.InitDefaults();

                                                    // Find the address nearest the Point.
                                                    addressProperties = reverseGeocoding.ReverseGeocode(revGCLoc, false);

                                                    // Print the address properties.
                                                    addressInputs = (IAddressInputs)reverseGeocoding;
                                                    addressFields = addressInputs.AddressFields;

                                                    addressProperties.GetAllProperties(out key, out value);

                                                    string tempVal = "";
                                                    for (int i = 0; i < addressFields.FieldCount; i++)
                                                    {
                                                        IField addressField = addressFields.get_Field(i);
                                                        if (tempVal == "")
                                                        {
                                                            tempVal = addressProperties.GetProperty(addressField.Name).ToString();
                                                        }
                                                        else
                                                        {
                                                            tempVal = tempVal + ", " + addressProperties.GetProperty(addressField.Name).ToString();
                                                        }

                                                    }
                                                    inFeature.set_Value(intFldIdxs[0], tempVal);

                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GET_ADDRESS_USING_GEOCODER" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "GET_ADDRESS_USING_GEOCODER");
                                                    reverseGeocoding = null;
                                                    addressGeocoding = null;
                                                    revGCLoc = null;
                                                    matchFields = null;
                                                    shapeField = null;

                                                    reverseGeocodingProperties = null;
                                                    addressProperties = null;

                                                    addressInputs = null;
                                                    addressFields = null;
                                                    key = null;
                                                    value = null;
                                                }
                                                break;

                                            }

                                        case "GET_ADDRESS_USING_ARCGIS_SERVICE":  //ARGS: url

                                            try
                                            {
                                                IPoint revGCLoc = null;
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "GET_ADDRESS_USING_ARCGIS_SERVICE");
                                                if (fieldObj.Type == esriFieldType.esriFieldTypeString)
                                                {
                                                    if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty))
                                                    {
                                                        args = valData.Split('|');
                                                        revGCLoc = Globals.GetGeomCenter(inFeature)[0];
                                                        int wkid = inFeature.Shape.SpatialReference.FactoryCode;
                                                        if (revGCLoc != null)
                                                        {
                                                            //Test for user specified URL
                                                            if (valData.Trim() != "")
                                                            {
                                                                if (args.Length == 2)
                                                                {
                                                                    wkid = Convert.ToInt32(args[1]);
                                                                }
                                                                if (Globals.IsUrl(args[0]))
                                                                {
                                                                    locatorURL = args[0];

                                                                    if (!(locatorURL.EndsWith(reverseGeocodeStr)))
                                                                    {
                                                                        if (!(locatorURL.EndsWith(GeocodeStr)))
                                                                        {
                                                                            if (!(locatorURL.EndsWith("/")))
                                                                            {
                                                                                locatorURL += "/" + GeocodeStr + "/" + reverseGeocodeStr;
                                                                            }
                                                                            else
                                                                            {
                                                                                locatorURL += GeocodeStr + "/" + reverseGeocodeStr;
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            if (!(locatorURL.EndsWith("/")))
                                                                            {
                                                                                locatorURL += "/" + reverseGeocodeStr;
                                                                            }
                                                                            else
                                                                            {
                                                                                locatorURL += reverseGeocodeStr;
                                                                            }
                                                                        }
                                                                    }
                                                                }

                                                                //else if (args[0] == "TA_Streets_US_10")
                                                                //{
                                                                //    locatorURL = _agsOnlineLocators + args[0] + GeocodeStr + "/" + reverseGeocodeStr;
                                                                //    //       wkid = 102100;
                                                                //}
                                                                //else if (args[0] == "TA_Address_NA_10" || args[0] == "TA_Address_EU")
                                                                //{
                                                                //    locatorURL = _agsOnlineLocators + args[0] + GeocodeStr + "/" + reverseGeocodeStr;
                                                                //    //    wkid = 4326;
                                                                //}
                                                                ////Default to AGS Online USA geocode service
                                                                //else if (_agsOnlineLocators.Substring(_agsOnlineLocators.LastIndexOf('/', _agsOnlineLocators.Length - 2)).Contains("Locator"))
                                                                //{
                                                                //    locatorURL = _agsOnlineLocators + "TA_Address_NA_10" + GeocodeStr + "/" + reverseGeocodeStr;
                                                                //    //        wkid = 4326;
                                                                //}
                                                                else
                                                                {
                                                                    locatorURL = _agsOnlineLocators + GeocodeStr + "/" + reverseGeocodeStr; ;
                                                                    //     wkid = 4326;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                if (_agsOnlineLocators.Substring(_agsOnlineLocators.LastIndexOf('/', _agsOnlineLocators.Length - 2)).Contains(GeocodeStr))
                                                                {
                                                                    locatorURL = _agsOnlineLocators + "/" + reverseGeocodeStr;
                                                                    //      wkid = 4326;
                                                                }
                                                                else
                                                                {
                                                                    _agsOnlineLocators = _agsOnlineLocators + "/" + GeocodeStr;
                                                                    locatorURL = _agsOnlineLocators + "/" + reverseGeocodeStr;
                                                                    // wkid = 4326;
                                                                }
                                                            }

                                                            if (!locatorURL.ToUpper().Contains("/REST/"))
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14af"));
                                                            }
                                                            else
                                                            {
                                                                //Copy point from this current feature
                                                                _copyPoint = revGCLoc;//inFeature.ShapeCopy as IPoint;

                                                                StreamReader reader = null;
                                                                HttpWebRequest request = null;
                                                                try
                                                                {
                                                                    // Create the web request
                                                                    request = WebRequest.Create(_agsOnlineLocators) as HttpWebRequest;

                                                                    // Get response

                                                                    using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                                                                    {
                                                                        // Get the response stream
                                                                        reader = new StreamReader(response.GetResponseStream());
                                                                        string resp = reader.ReadToEnd();
                                                                        resp = resp.Substring(resp.IndexOf("Spatial Reference:"));
                                                                        resp = resp.Substring(0, resp.IndexOf("<br/>"));
                                                                        resp = resp.Substring(resp.IndexOf("</b>") + 4);
                                                                        wkid = Convert.ToInt32(resp.Split(' ')[0]);

                                                                    }
                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain96"));
                                                                    wkid = 4326;
                                                                }
                                                                finally
                                                                {

                                                                    reader = null;
                                                                    request = null;
                                                                }

                                                                _copyPoint.Project(Globals.CreateSpatRef(wkid));
                                                                //Include location parameters in URL
                                                                string results = Globals.FormatLocationRequest(locatorURL, _copyPoint.X, _copyPoint.Y, 100);
                                                                //Send and receieve the request
                                                                WebRequest req = null;
                                                                WebResponse res = null;

                                                                XmlDictionaryReader xr = null;
                                                                XmlDocument doc = null;
                                                                try
                                                                {
                                                                    req = WebRequest.Create(results);
                                                                    res = req.GetResponse();

                                                                    //Convert response from JSON to XML
                                                                    doc = new XmlDocument();
                                                                    using (Stream s = res.GetResponseStream())
                                                                    {
                                                                        xr = JsonReaderWriterFactory.CreateJsonReader(s, XmlDictionaryReaderQuotas.Max);
                                                                        doc.Load(xr);
                                                                        xr.Close();
                                                                        s.Close();
                                                                        string val = "";

                                                                        for (int h = 0; h < doc.DocumentElement.FirstChild.ChildNodes.Count - 1; h++)
                                                                        {
                                                                            if (doc.DocumentElement.FirstChild.ChildNodes[h].Name.Contains("Match") == false)
                                                                            {
                                                                                if (val == "")
                                                                                {
                                                                                    val = doc.DocumentElement.FirstChild.ChildNodes[h].InnerText;
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (val.EndsWith(","))
                                                                                        val = val + " " + doc.DocumentElement.FirstChild.ChildNodes[h].InnerText;
                                                                                    else
                                                                                        val = val + ", " + doc.DocumentElement.FirstChild.ChildNodes[h].InnerText;

                                                                                }
                                                                            }

                                                                            val = val.Trim();
                                                                        }

                                                                        inFeature.set_Value(intFldIdxs[0], val);

                                                                    }
                                                                }
                                                                catch
                                                                {
                                                                }
                                                                finally
                                                                {
                                                                    req = null;
                                                                    res = null;

                                                                    xr = null;
                                                                    doc = null;
                                                                }

                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain97"));
                                                        }
                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GET_ADDRESS_USING_ARCGIS_SERVICE: " + ex.Message);
                                            }

                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "GET_ADDRESS_USING_ARCGIS_SERVICE");
                                            }
                                            break;
                                        case "TIMESTAMP":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TIMESTAMP");

                                                if (!String.IsNullOrEmpty(valData))
                                                {
                                                    args = valData.Split('|');
                                                    if (args.Length > 0)
                                                    {

                                                        try
                                                        {

                                                            if (fieldObj.Type == esriFieldType.esriFieldTypeDate)
                                                            {
                                                                if (args[0].ToString().ToUpper() == "DATE")
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], DateTime.Now.Date);
                                                                }
                                                                else if (args[0].ToString().Trim() != "")
                                                                {
                                                                    try
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString(args[0]));
                                                                    }
                                                                    catch
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString());
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], DateTime.Now);
                                                                }
                                                            }
                                                            else if (fieldObj.Type == esriFieldType.esriFieldTypeString)
                                                            {
                                                                if (args[0].ToString().ToUpper() == "DATE")
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], DateTime.Now.Date);
                                                                }
                                                                else if (args[0].ToString().ToUpper() == "TIME")
                                                                {

                                                                    inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString("hh:mm:ss tt"));
                                                                }
                                                                else if (args[0].ToString().ToUpper() == "TIME24")
                                                                {
                                                                    //  ReadOnlyCollection<System.TimeZoneInfo> timeZones = System.TimeZoneInfo.GetSystemTimeZones();
                                                                    //  string s = System.TimeZoneInfo.ConvertTime(DateTime.Now, timeZones[0]).ToString("HH:mm:ss");

                                                                    inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString("HH:mm:ss"));
                                                                }
                                                                else if (args[0].ToString().ToUpper() == "YEAR")
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], DateTime.Now.Year.ToString());
                                                                }
                                                                else if (args[0].ToString().ToUpper() == "MONTH")
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], DateTime.Now.Month.ToString());
                                                                }
                                                                else if (args[0].ToString().ToUpper() == "DAY")
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], DateTime.Now.DayOfWeek.ToString());
                                                                }
                                                                else if (args[0].ToString().Trim() != "")
                                                                {
                                                                    try
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString(args[0]));
                                                                    }
                                                                    catch
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString());
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString());
                                                                }
                                                            }

                                                        }
                                                        catch
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ag"));
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain98"));
                                                        if (fieldObj.Type == esriFieldType.esriFieldTypeDate)
                                                            inObject.set_Value(intFldIdxs[0], DateTime.Now);
                                                        else if (fieldObj.Type == esriFieldType.esriFieldTypeString)
                                                            inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString());

                                                    }
                                                }
                                                else
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain98"));
                                                    if (fieldObj.Type == esriFieldType.esriFieldTypeDate)
                                                        inObject.set_Value(intFldIdxs[0], DateTime.Now);
                                                    else if (fieldObj.Type == esriFieldType.esriFieldTypeString)
                                                        inObject.set_Value(intFldIdxs[0], DateTime.Now.ToString());

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TIMESTAMP: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TIMESTAMP");
                                            }
                                            break;

                                        case "LAST_VALUE":
                                            try
                                            {

                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "LAST_VALUE");
                                                bool CheckForValue = false;
                                                if (!String.IsNullOrEmpty(valData))
                                                {
                                                    args = valData.Split('|');
                                                    if (args.Length > 0)
                                                    {
                                                        if (args[0].ToString().ToUpper() == "TRUE")
                                                        {
                                                            CheckForValue = true;
                                                        }
                                                    }

                                                }
                                                else
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain98"));
                                                }
                                                if (CheckForValue && (inObject.get_Value(intFldIdxs[0]) != null && inObject.get_Value(intFldIdxs[0]) != DBNull.Value))
                                                {

                                                }
                                                else
                                                {
                                                    if (mode == "ON_CREATE")
                                                    {

                                                        lastValue = AAState.lastValueProperties.GetProperty(strFldNames[0]) as LastValueEntry;
                                                        if (lastValue == null)
                                                        {
                                                            if (inObject.get_Value(intFldIdxs[0]) != null)
                                                            {
                                                                if (inObject.get_Value(intFldIdxs[0]) != DBNull.Value)
                                                                {
                                                                    AAState.lastValueProperties.SetProperty(strFldNames[0], inObject.get_Value(intFldIdxs[0]));
                                                                }
                                                            }
                                                        }
                                                        else if (lastValue.Value != null)
                                                        {
                                                            if (lastValue.Value != DBNull.Value)
                                                            {
                                                                inObject.set_Value(intFldIdxs[0], lastValue.Value);

                                                                AAState.WriteLine("                  " + strFldNames[0] + ": " + lastValue.Value);
                                                            }
                                                        }
                                                        else
                                                        {
                                                            if (inObject.get_Value(intFldIdxs[0]) != null)
                                                            {
                                                                if (inObject.get_Value(intFldIdxs[0]) != DBNull.Value)
                                                                {
                                                                    AAState.lastValueProperties.SetProperty(strFldNames[0], inObject.get_Value(intFldIdxs[0]));
                                                                }
                                                            }
                                                        }
                                                    }
                                                    else if (mode == "ON_CHANGE")
                                                    {
                                                        IRowChanges pRowCh = inObject as IRowChanges;
                                                        changed = pRowCh.get_ValueChanged(intFldIdxs[0]);
                                                        if (!changed)
                                                        {
                                                            lastValue = AAState.lastValueProperties.GetProperty(strFldNames[0]) as LastValueEntry;
                                                            if (lastValue != null)
                                                            {
                                                                if (lastValue.Value != null)
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], lastValue.Value);
                                                                    AAState.WriteLine("                  " + strFldNames[0] + ": " + lastValue.Value);
                                                                }

                                                            }
                                                        }
                                                    }

                                                }
                                            }
                                            catch (Exception ex)
                                            {

                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "LAST_VALUE: " + ex.Message);

                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "LAST_VALUE");
                                            }
                                            break;

                                        case "X_COORDINATE":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "X_COORDINATE");
                                                if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty))
                                                {
                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
                                                    {
                                                        _copyPoint = inFeature.Shape as IPoint;
                                                        inFeature.set_Value(intFldIdxs[0], _copyPoint.X);
                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                    {
                                                        _copyPolyline = inFeature.Shape as IPolyline;
                                                        if (valData.Trim() == "")
                                                        {
                                                            inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].X);
                                                        }
                                                        else
                                                        {
                                                            args = valData.Split('|');
                                                            if (args[0].ToUpper() == "S")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolyline.FromPoint.X);
                                                            }
                                                            else if (args[0].ToUpper() == "E")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolyline.ToPoint.X);
                                                            }
                                                            else
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].X);
                                                            }

                                                        }

                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                                                    {

                                                        _copyPolygon = inFeature.ShapeCopy as IPolygon;
                                                        if (valData.Trim() == "")
                                                        {
                                                            inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolygon)[0].X);
                                                        }
                                                        else
                                                        {
                                                            args = valData.Split('|');
                                                            if (args[0].ToUpper() == "S")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolygon.FromPoint.X);
                                                            }
                                                            else if (args[0].ToUpper() == "E")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolygon.ToPoint.X);
                                                            }
                                                            else
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolygon)[0].X);
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ah"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "X_COORDINATE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "X_COORDINATE");
                                            }
                                            break;

                                        case "Y_COORDINATE":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "Y_COORDINATE");
                                                if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty))
                                                {
                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
                                                    {
                                                        _copyPoint = inFeature.Shape as IPoint;
                                                        inFeature.set_Value(intFldIdxs[0], _copyPoint.Y);
                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                    {
                                                        _copyPolyline = inFeature.Shape as IPolyline;
                                                        if (valData == "")
                                                        {
                                                            inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].Y);
                                                        }
                                                        else
                                                        {
                                                            args = valData.Split('|');
                                                            if (args[0].ToUpper() == "S")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolyline.FromPoint.Y);
                                                            }
                                                            else if (args[0].ToUpper() == "E")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolyline.ToPoint.Y);
                                                            }
                                                            else
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolyline)[0].Y);
                                                            }

                                                        }

                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                                                    {
                                                        _copyPolygon = inFeature.ShapeCopy as IPolygon;

                                                        if (valData.Trim() == "")
                                                        {
                                                            inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolygon)[0].Y);
                                                        }
                                                        else
                                                        {
                                                            args = valData.Split('|');
                                                            if (args[0].ToUpper() == "S")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolygon.FromPoint.Y);
                                                            }
                                                            else if (args[0].ToUpper() == "E")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], _copyPolygon.ToPoint.Y);
                                                            }
                                                            else
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.GetGeomCenter(_copyPolygon)[0].Y);
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ah"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "Y_COORDINATE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "Y_COORDINATE");
                                            }
                                            break;

                                        case "LATITUDE":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "LATITUDE");
                                                if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty))
                                                {

                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
                                                    {
                                                        _copyPoint = inFeature.ShapeCopy as IPoint;
                                                        _copyPoint.Project(AAState._sr1);
                                                        inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPoint.Y.ToString()));

                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                    {
                                                        _copyPolyline = inFeature.ShapeCopy as IPolyline;
                                                        _copyPolyline.Project(AAState._sr1);

                                                        if (valData == "")
                                                        {
                                                            inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolyline)[0].Y.ToString()));

                                                        }
                                                        else
                                                        {
                                                            args = valData.Split('|');
                                                            if (args[0].ToUpper() == "S")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolyline.FromPoint.Y.ToString()));

                                                            }
                                                            else if (args[0].ToUpper() == "E")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolyline.ToPoint.Y.ToString()));

                                                            }
                                                            else
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolyline)[0].Y.ToString()));

                                                            }

                                                        }

                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                                                    {
                                                        _copyPolygon = inFeature.ShapeCopy as IPolygon;
                                                        _copyPolygon.Project(AAState._sr1);

                                                        if (valData.Trim() == "")
                                                        {
                                                            inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolygon)[0].Y.ToString()));

                                                        }
                                                        else
                                                        {
                                                            args = valData.Split('|');
                                                            if (args[0].ToUpper() == "S")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolygon.FromPoint.Y.ToString()));

                                                            }
                                                            else if (args[0].ToUpper() == "E")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolygon.ToPoint.Y.ToString()));

                                                            }
                                                            else
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolygon)[0].Y.ToString()));

                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ah"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "LATITUDE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "LATITUDE");
                                            }
                                            break;

                                        case "LONGITUDE":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "LONGITUDE");
                                                if ((inFeature != null) && (inFeature.Shape != null) && !(inFeature.Shape.IsEmpty))
                                                {

                                                    if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
                                                    {
                                                        _copyPoint = inFeature.ShapeCopy as IPoint;
                                                        _copyPoint.Project(AAState._sr1);

                                                        inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPoint.X.ToString()));

                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                    {
                                                        _copyPolyline = inFeature.Shape as IPolyline;
                                                        _copyPolyline.Project(AAState._sr1);

                                                        if (valData == "")
                                                        {

                                                            inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolyline)[0].X.ToString()));

                                                        }
                                                        else
                                                        {
                                                            args = valData.Split('|');
                                                            if (args[0].ToUpper() == "S")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolyline.FromPoint.X.ToString()));

                                                            }
                                                            else if (args[0].ToUpper() == "E")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolyline.ToPoint.X.ToString()));

                                                            }
                                                            else
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolyline)[0].X.ToString()));

                                                            }

                                                        }

                                                    }
                                                    else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
                                                    {
                                                        _copyPolygon = inFeature.ShapeCopy as IPolygon;
                                                        _copyPolygon.Project(AAState._sr1);

                                                        if (valData.Trim() == "")
                                                        {
                                                            inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolygon)[0].X.ToString()));

                                                        }
                                                        else
                                                        {
                                                            args = valData.Split('|');
                                                            if (args[0].ToUpper() == "S")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolygon.FromPoint.X.ToString()));

                                                            }
                                                            else if (args[0].ToUpper() == "E")
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), _copyPolygon.ToPoint.X.ToString()));

                                                            }
                                                            else
                                                            {
                                                                inFeature.set_Value(intFldIdxs[0], Globals.FormatValueToFieldLength(inFeature.Fields.get_Field(intFldIdxs[0]), Globals.GetGeomCenter(_copyPolygon)[0].X.ToString()));

                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ah"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "LONGITUDE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "LONGITUDE");
                                            }
                                            break;

                                        case "FIELD":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "Field");
                                                // verify that field to copy exists

                                                if (!String.IsNullOrEmpty(valData))
                                                {
                                                    args = valData.Split('|');
                                                    fieldCopy = inObject.Fields.FindField(args[0] as string);

                                                    if (fieldCopy > -1)
                                                    {
                                                        bool useDisplayValue = true;
                                                        if (args.Length == 2)
                                                        {
                                                            if (args[1].ToUpper() == "CODE")
                                                                useDisplayValue = false;
                                                        }

                                                        try
                                                        {
                                                            if (useDisplayValue)
                                                            {

                                                                inObject.set_Value(intFldIdxs[0], Globals.GetDomainDisplay(inObject.get_Value(fieldCopy), inObject as IFeature, inObject.Fields.get_Field(fieldCopy)));
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az"));
                                                            }

                                                            else
                                                            {
                                                                inObject.set_Value(intFldIdxs[0], inObject.get_Value(fieldCopy));
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az"));
                                                            }
                                                        }
                                                        catch (Exception ex)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + ex.Message);
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + valData + " is not found");
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "Field: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "Field");
                                            }
                                            break;

                                        //CURRENT_USER
                                        //Value Data options:
                                        //U - windows username only
                                        //W or (blank) - full username including domain i.e. domain\username
                                        //D - database user if available and not dbo
                                        case "CURRENT_USER":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "CURRENT_USER");

                                                lastEditorName = AAState._currentUserInfo.GetCurrentUser(valData, fieldObj.Length);
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain99") + lastEditorName);

                                                if (!String.IsNullOrEmpty(lastEditorName))
                                                {
                                                    inObject.set_Value(intFldIdxs[0], lastEditorName);
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CURRENT_USER: "******"AttributeAssistantEditorMess_14as") + "CURRENT_USER");
                                            }
                                            break;

                                        case "JUNCTION_ROTATION":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "JUNCTION_ROTATION");
                                                if ((inFeature != null))
                                                {
                                                    AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolGeographic;
                                                    args = null;
                                                    AAState.rCalc.UseDiameter = false;
                                                    AAState.rCalc.DiameterFieldName = "";
                                                    AAState.rCalc.SpinAngle = 0;

                                                    if (!String.IsNullOrEmpty(valData))
                                                    {
                                                        args = valData.Split('|');
                                                        if (args.Length == 0)
                                                        {

                                                            AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolGeographic;
                                                        }
                                                        else if (args.Length == 1)
                                                        {
                                                            if (args[0].Substring(0, 1).ToLower() == "a")
                                                                AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolArithmetic;

                                                        }
                                                        else if (args.Length == 2)
                                                        {
                                                            if (args[0].Substring(0, 1).ToLower() == "a")
                                                                AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolArithmetic;
                                                            if (Globals.IsNumeric(args[1].ToString()))
                                                                AAState.rCalc.SpinAngle = Convert.ToDouble(args[1]);

                                                        }
                                                        else if (args.Length == 3)
                                                        {
                                                            if (args[0].Substring(0, 1).ToLower() == "a")
                                                                AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolArithmetic;
                                                            if (Globals.IsNumeric(args[1].ToString()))
                                                                AAState.rCalc.SpinAngle = Convert.ToDouble(args[1]);
                                                            AAState.rCalc.UseDiameter = true;
                                                            AAState.rCalc.DiameterFieldName = args[2].ToString();

                                                        }
                                                        else
                                                        {
                                                            AAState.rCalc.RotationType = esriSymbolRotationType.esriRotateSymbolGeographic;
                                                        }

                                                    }
                                                    AAState.WriteLine("                  " + AAState.rCalc.RotationType.ToString() + " is being used");
                                                    rotationAngle = AAState.rCalc.GetRotationUsingConnectedEdges(inFeature);
                                                    if (rotationAngle == null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain100"));
                                                        continue;
                                                    }

                                                    //Accept optional second argument to provide extra rotation

                                                    if (rotationAngle != -1)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain101") + rotationAngle.ToString());

                                                        inObject.set_Value(intFldIdxs[0], rotationAngle);
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain102"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "JUNCTION_ROTATION \r\n" + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "JUNCTION_ROTATION");
                                            }
                                            break;

                                        //For Release: 1.2
                                        //New Dynamic Value Method: Length - stores calculated length of line feature
                                        case "LENGTH":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "LENGTH");
                                                if (inFeature != null)
                                                {
                                                    curve = (ICurve)inFeature.Shape;
                                                    if (curve != null)
                                                    {
                                                        inObject.set_Value(intFldIdxs[0], curve.Length);
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "LENGTH: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "LENGTH");
                                            }
                                            break;

                                        //Release: 1.2
                                        //New Dynamic Value Method: SET_MEASURES - stores calculated M values (from 0 to length of line) for line feature
                                        //Value Data options:
                                        //P = Percent - Ms will be zero to 100
                                        //default - Ms will be zero to length of line
                                        case "SET_MEASURES":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "SET_MEASURES");
                                                if (inFeature != null)
                                                {
                                                    curve = inFeature.Shape as ICurve;
                                                    mseg = inFeature.Shape as IMSegmentation;
                                                    if (curve != null && mseg != null)
                                                        if (valData != null && valData != "" && valData.Substring(0, 1).ToUpper() == "P")
                                                            mseg.SetAndInterpolateMsBetween(0, 100);
                                                        else
                                                            mseg.SetAndInterpolateMsBetween(0, curve.Length);
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "SET_MEASURES: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "SET_MEASURES");
                                            }
                                            break;
                                        //case "EDGE_INTERSECT_SECOND":
                                        //    try
                                        //    {
                                        //        if (inFeature != null)
                                        //        {
                                        //            netFeat = inFeature as INetworkFeature;
                                        //            if (netFeat != null)
                                        //            {
                                        //                if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                        //                {

                                        //                    iJuncFeat = (IJunctionFeature)netFeat;
                                        //                    // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                        //                    ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                        //                    if (iSJunc == null)
                                        //                        break;
                                        //                    if (iSJunc.EdgeFeatureCount <= 1)
                                        //                        break;
                                        //                    iEdgeFeat = iSJunc.get_EdgeFeature(1);

                                        //                    // verify that field (in junction) to copy exists

                                        //                    IRow pRow = iEdgeFeat as IRow;

                                        //                    juncField = pRow.Fields.FindField(valData as string);
                                        //                    if (juncField > -1)
                                        //                    {
                                        //                        inObject.set_Value(intFldIdxs[0], pRow.get_Value(juncField));
                                        //                    }
                                        //                }
                                        //            }
                                        //        }
                                        //    }
                                        //    catch
                                        //    {
                                        //    }
                                        //    break;
                                        //case "EDGE_INTERSECT_FIRST":
                                        //    try
                                        //    {
                                        //        if (inFeature != null)
                                        //        {
                                        //            netFeat = inFeature as INetworkFeature;
                                        //            if (netFeat != null)
                                        //            {
                                        //                if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                        //                {

                                        //                    iJuncFeat = (IJunctionFeature)netFeat;
                                        //                    // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                        //                    ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                        //                    if (iSJunc == null)
                                        //                        break;
                                        //                    if (iSJunc.EdgeFeatureCount <= 0)
                                        //                        break;
                                        //                    iEdgeFeat = iSJunc.get_EdgeFeature(0);

                                        //                    IRow pRow = iEdgeFeat as IRow;

                                        //                    juncField = pRow.Fields.FindField(valData as string);
                                        //                    if (juncField > -1)
                                        //                    {
                                        //                        inObject.set_Value(intFldIdxs[0], pRow.get_Value(juncField));
                                        //                    }
                                        //                }
                                        //            }
                                        //        }
                                        //    }
                                        //    catch
                                        //    {
                                        //    }
                                        //    break;

                                        //Release: 2.0
                                        //New Dynamic Value Method: TO_EDGE_FIELD transfers a field value from a connected egde feature to a junction feature
                                        //Takes value from the frist edge whose "TO" point connects with this junction
                                        case "TO_EDGE_FIELD":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TO_EDGE_FIELD");
                                                if (inFeature != null)
                                                {
                                                    if (valData == null)
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba"));
                                                        break;
                                                    }
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                        {
                                                            string netField = "";
                                                            string netRestrictFC = "";
                                                            string netRestrictField = "";
                                                            string netRestrictValue = "";
                                                            args = valData.Split('|');
                                                            switch (args.GetLength(0))
                                                            {
                                                                case 1:  // sequenceColumnName only
                                                                    netField = args[0].ToString().Trim();
                                                                    break;
                                                                case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    break;
                                                                case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    break;
                                                                case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    netRestrictValue = args[3].ToString().Trim();
                                                                    break;
                                                                default: break;
                                                            }

                                                            iJuncFeat = (IJunctionFeature)netFeat;
                                                            // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                            ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                            if (iSJunc == null)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount <= 0)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount > 0)
                                                            {
                                                                for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                {
                                                                    iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                    try
                                                                    {

                                                                        if (netRestrictFC != "")
                                                                        {
                                                                            string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class));

                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName);
                                                                            if (strClsName != netRestrictFC)
                                                                            {
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg"));
                                                                                continue;
                                                                            }
                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh"));
                                                                            if (netRestrictField != "" && netRestrictValue != "")
                                                                            {
                                                                                int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField);

                                                                                if (intTmpFld > -1)
                                                                                {
                                                                                    //IFeature pTest = ((IFeature)iEdgeFeat);

                                                                                    if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl"));
                                                                                        continue;

                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm"));
                                                                            }
                                                                        }

                                                                        iJuncFeat = (IJunctionFeature)iEdgeFeat.FromJunctionFeature;
                                                                        if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                        {
                                                                            IRow pRow = iEdgeFeat as IRow;

                                                                            // verify that field (in junction) to copy exists
                                                                            juncField = Globals.GetFieldIndex(pRow.Fields, netField);

                                                                            if (juncField > -1)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], pRow.get_Value(juncField));
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  " + netField + " field not found in edge");
                                                                            }
                                                                            pRow = null;
                                                                            break;

                                                                        }
                                                                    }
                                                                    catch
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14an"));
                                                                    }

                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi"));
                                                            }
                                                            iSJunc = null;
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj"));
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_EDGE_FIELD: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_FIELD");
                                            }
                                            break;

                                        //Release: 2.0
                                        //New Dynamic Value Method: FROM_EDGE_FIELD transfers a field value from a connected egde feature to a junction feature
                                        //Takes value from the frist edge whose "FROM" point connects with this junction
                                        case "FROM_EDGE_FIELD":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FROM_EDGE_FIELD");
                                                if (inFeature != null)
                                                {
                                                    if (valData == null)
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba"));
                                                        break;
                                                    }
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                        {
                                                            string netField = "";
                                                            string netRestrictFC = "";
                                                            string netRestrictField = "";
                                                            string netRestrictValue = "";
                                                            args = valData.Split('|');
                                                            switch (args.GetLength(0))
                                                            {
                                                                case 1:  // sequenceColumnName only
                                                                    netField = args[0].ToString().Trim();
                                                                    break;
                                                                case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    break;
                                                                case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    break;
                                                                case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    netRestrictValue = args[3].ToString().Trim();
                                                                    break;
                                                                default: break;
                                                            }

                                                            iJuncFeat = (IJunctionFeature)netFeat;
                                                            // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                            ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                            if (iSJunc == null)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount <= 0)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount > 0)
                                                            {
                                                                for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                {
                                                                    iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                    try
                                                                    {
                                                                        if (netRestrictFC != "")
                                                                        {
                                                                            string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class));

                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName);
                                                                            if (strClsName != netRestrictFC)
                                                                            {
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg"));
                                                                                continue;
                                                                            }
                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh"));
                                                                            if (netRestrictField != "" && netRestrictValue != "")
                                                                            {
                                                                                int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField);

                                                                                if (intTmpFld > -1)
                                                                                {
                                                                                    //IFeature pTest = ((IFeature)iEdgeFeat);

                                                                                    if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl"));
                                                                                        continue;

                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm"));
                                                                            }
                                                                        }

                                                                        iJuncFeat = iEdgeFeat.ToJunctionFeature;
                                                                        if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                        {
                                                                            IRow pRow = iEdgeFeat as IRow;

                                                                            // verify that field (in junction) to copy exists
                                                                            juncField = Globals.GetFieldIndex(pRow.Fields, netField);

                                                                            if (juncField > -1)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], pRow.get_Value(juncField));
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  " + iSJunc + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") );
                                                                            }
                                                                            pRow = null;

                                                                            break;

                                                                        }
                                                                    }
                                                                    catch
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14an"));
                                                                    }

                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi"));
                                                            }
                                                            iSJunc = null;
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj"));
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "FROM_EDGE_FIELD: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "FROM_EDGE_FIELD");
                                            }
                                            break;

                                        case "TO_EDGE_STATS":
                                            try
                                            {
                                                if (valData == null) break;
                                                args = valData.Split('|');
                                                string statType = "MAX";
                                                switch (args.GetLength(0))
                                                {
                                                    case 1:
                                                        sourceFieldName = args[0].ToString();
                                                        break;
                                                    case 2:
                                                        sourceFieldName = args[0].ToString();
                                                        statType = args[1].ToString();
                                                        break;

                                                    default: break;
                                                }

                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TO_EDGE_STATS");

                                                int AverageCount = 0;
                                                double result = -999999.1;
                                                string textRes = "";
                                                if (inFeature != null)
                                                {
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain103"));
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain104"));
                                                            iJuncFeat = (IJunctionFeature)netFeat;
                                                            // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                            ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                            if (iSJunc == null)
                                                                break;
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount);
                                                            if (iSJunc.EdgeFeatureCount <= 0)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount > 0)
                                                            {
                                                                for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount);

                                                                    iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                    try
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain106"));

                                                                        iJuncFeat = iEdgeFeat.FromJunctionFeature;

                                                                        if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain107"));

                                                                            IRow pRow = iEdgeFeat as IRow;

                                                                            // verify that field (in junction) to copy exists
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain108"));
                                                                            juncField = pRow.Fields.FindField(sourceFieldName);
                                                                            string test = pRow.get_Value(juncField).ToString();
                                                                            if (Globals.IsNumeric(test))
                                                                            {

                                                                                double valToTest = Convert.ToDouble(test);
                                                                                if (result == -999999.1)
                                                                                {
                                                                                    result = valToTest;

                                                                                }
                                                                                else
                                                                                {
                                                                                    switch (statType.ToUpper())
                                                                                    {
                                                                                        case "MAX":
                                                                                            if (result < valToTest)
                                                                                            {
                                                                                                result = valToTest;

                                                                                            }
                                                                                            break;
                                                                                        case "MIN":
                                                                                            if (result > valToTest)
                                                                                            {
                                                                                                result = valToTest;

                                                                                            }
                                                                                            break;
                                                                                        case "SUM":
                                                                                            result += valToTest;

                                                                                            break;
                                                                                        case "AVERAGE":
                                                                                            result += valToTest;
                                                                                            AverageCount++;
                                                                                            break;
                                                                                        case "MEAN":
                                                                                            result += valToTest;
                                                                                            AverageCount++;

                                                                                            break;
                                                                                        case "CONCAT":
                                                                                            if (textRes.Contains(valToTest.ToString() + ConcatDelim))
                                                                                            {
                                                                                            }
                                                                                            else if (textRes.Contains(ConcatDelim + valToTest.ToString()))
                                                                                            {
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                if (textRes == "")
                                                                                                {
                                                                                                    textRes += valToTest.ToString();
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    textRes += ConcatDelim + valToTest.ToString();
                                                                                                }
                                                                                            }

                                                                                            break;
                                                                                        default:
                                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test);
                                                                                            break;
                                                                                    }

                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                switch (statType.ToUpper())
                                                                                {

                                                                                    case "CONCAT":
                                                                                        if (textRes.Contains(test.ToString() + ConcatDelim))
                                                                                        {
                                                                                        }
                                                                                        else if (textRes.Contains(ConcatDelim + test.ToString()))
                                                                                        {
                                                                                        }
                                                                                        else
                                                                                        {

                                                                                            if (textRes == "")
                                                                                            {
                                                                                                textRes += test;
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                textRes += ConcatDelim + test;
                                                                                            }
                                                                                        }

                                                                                        break;
                                                                                    default:
                                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14d") + test);

                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test);
                                                                                        break;
                                                                                }

                                                                            }

                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain109"));

                                                                        }
                                                                    }
                                                                    catch
                                                                    {
                                                                    }
                                                                }//end loop
                                                                try
                                                                {
                                                                    if (textRes != "")
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], textRes);
                                                                    }
                                                                    else if (result != -999999.1)
                                                                    {
                                                                        if (AverageCount != 0)
                                                                        {
                                                                            result = result / AverageCount;
                                                                        }
                                                                        inObject.set_Value(intFldIdxs[0], result);

                                                                    }
                                                                    else
                                                                    {
                                                                        IField field = inObject.Fields.get_Field(intFldIdxs[0]);
                                                                        object newval = field.DefaultValue;
                                                                        if (newval == null)
                                                                        {
                                                                            if (field.IsNullable)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], null);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[0], newval);
                                                                        }
                                                                    }
                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.Message);

                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi"));
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj"));
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_EDGE_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_STATS");
                                            }
                                            break;

                                        case "FROM_EDGE_STATS":
                                            try
                                            {
                                                if (valData == null) break;
                                                args = valData.Split('|');
                                                string statType = "MAX";
                                                switch (args.GetLength(0))
                                                {
                                                    case 1:
                                                        sourceFieldName = args[0].ToString();
                                                        break;
                                                    case 2:
                                                        sourceFieldName = args[0].ToString();
                                                        statType = args[1].ToString();
                                                        break;

                                                    default: break;
                                                }

                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FROM_EDGE_STATS");

                                                int AverageCount = 0;
                                                double result = -999999.1;
                                                string textRes = "";
                                                if (inFeature != null)
                                                {
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain103"));
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain104"));
                                                            iJuncFeat = (IJunctionFeature)netFeat;
                                                            // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                            ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                            if (iSJunc == null)
                                                                break;
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount);
                                                            if (iSJunc.EdgeFeatureCount <= 0)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount > 0)
                                                            {
                                                                for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount);

                                                                    iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                    try
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain106"));

                                                                        iJuncFeat = iEdgeFeat.ToJunctionFeature;

                                                                        if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain110"));

                                                                            IRow pRow = iEdgeFeat as IRow;

                                                                            // verify that field (in junction) to copy exists
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain111"));
                                                                            juncField = pRow.Fields.FindField(sourceFieldName);
                                                                            string test = pRow.get_Value(juncField).ToString();
                                                                            if (Globals.IsNumeric(test))
                                                                            {

                                                                                double valToTest = Convert.ToDouble(test);
                                                                                if (result == -999999.1)
                                                                                {
                                                                                    result = valToTest;

                                                                                }
                                                                                else
                                                                                {
                                                                                    switch (statType.ToUpper())
                                                                                    {
                                                                                        case "MAX":
                                                                                            if (result < valToTest)
                                                                                            {
                                                                                                result = valToTest;

                                                                                            }
                                                                                            break;
                                                                                        case "MIN":
                                                                                            if (result > valToTest)
                                                                                            {
                                                                                                result = valToTest;

                                                                                            }
                                                                                            break;
                                                                                        case "SUM":
                                                                                            result += valToTest;

                                                                                            break;
                                                                                        case "AVERAGE":
                                                                                            result += valToTest;
                                                                                            AverageCount++;
                                                                                            break;
                                                                                        case "MEAN":
                                                                                            result += valToTest;
                                                                                            AverageCount++;

                                                                                            break;
                                                                                        case "CONCAT":
                                                                                            if (textRes.Contains(valToTest.ToString() + ConcatDelim))
                                                                                            {
                                                                                            }
                                                                                            else if (textRes.Contains(ConcatDelim + valToTest.ToString()))
                                                                                            {
                                                                                            }
                                                                                            else
                                                                                            {

                                                                                                if (textRes == "")
                                                                                                {
                                                                                                    textRes += valToTest.ToString();
                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    textRes += ConcatDelim + valToTest.ToString();
                                                                                                }

                                                                                            }

                                                                                            break;
                                                                                        default:
                                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test);
                                                                                            break;
                                                                                    }

                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                switch (statType.ToUpper())
                                                                                {

                                                                                    case "CONCAT":
                                                                                        if (textRes.Contains(test.ToString() + ConcatDelim))
                                                                                        {
                                                                                        }
                                                                                        else if (textRes.Contains(ConcatDelim + test.ToString()))
                                                                                        {
                                                                                        }
                                                                                        else
                                                                                        {

                                                                                            if (textRes == "")
                                                                                            {
                                                                                                textRes += test;
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                textRes += ConcatDelim + test;
                                                                                            }

                                                                                        }

                                                                                        break;
                                                                                    default:
                                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14d") + test);

                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test);
                                                                                        break;
                                                                                }

                                                                            }

                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain112"));

                                                                        }
                                                                    }
                                                                    catch
                                                                    {
                                                                    }
                                                                }//end loop
                                                                try
                                                                {
                                                                    if (textRes != "")
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], textRes);
                                                                    }
                                                                    else if (result != -999999.1)
                                                                    {
                                                                        if (AverageCount != 0)
                                                                        {
                                                                            result = result / AverageCount;
                                                                        }
                                                                        inObject.set_Value(intFldIdxs[0], result);

                                                                    }
                                                                    else
                                                                    {
                                                                        IField field = inObject.Fields.get_Field(intFldIdxs[0]);
                                                                        object newval = field.DefaultValue;
                                                                        if (newval == null)
                                                                        {
                                                                            if (field.IsNullable)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], null);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[0], newval);
                                                                        }
                                                                    }
                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.Message);

                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi"));
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj"));
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_EDGE_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_STATS");
                                            }
                                            break;

                                        case "EDGE_STATS":
                                            try
                                            {
                                                if (valData == null) break;
                                                args = valData.Split('|');
                                                string statType = "MAX";
                                                switch (args.GetLength(0))
                                                {
                                                    case 1:
                                                        sourceFieldName = args[0].ToString();
                                                        break;
                                                    case 2:
                                                        sourceFieldName = args[0].ToString();
                                                        statType = args[1].ToString();
                                                        break;

                                                    default: break;
                                                }

                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "EDGE_STATS");

                                                int AverageCount = 0;
                                                double result = -999999.1;
                                                string textRes = "";
                                                if (inFeature != null)
                                                {
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain103"));
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain104"));
                                                            iJuncFeat = (IJunctionFeature)netFeat;
                                                            // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                            ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                            if (iSJunc == null)
                                                                break;
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount);
                                                            if (iSJunc.EdgeFeatureCount <= 0)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount > 0)
                                                            {
                                                                for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount);

                                                                    iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                    try
                                                                    {

                                                                        IRow pRow = iEdgeFeat as IRow;

                                                                        // verify that field (in junction) to copy exists
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain113"));
                                                                        juncField = pRow.Fields.FindField(sourceFieldName);
                                                                        string test = pRow.get_Value(juncField).ToString();
                                                                        if (Globals.IsNumeric(test))
                                                                        {

                                                                            double valToTest = Convert.ToDouble(test);
                                                                            if (result == -999999.1)
                                                                            {
                                                                                result = valToTest;

                                                                            }
                                                                            else
                                                                            {
                                                                                switch (statType.ToUpper())
                                                                                {
                                                                                    case "MAX":
                                                                                        if (result < valToTest)
                                                                                        {
                                                                                            result = valToTest;

                                                                                        }
                                                                                        break;
                                                                                    case "MIN":
                                                                                        if (result > valToTest)
                                                                                        {
                                                                                            result = valToTest;

                                                                                        }
                                                                                        break;
                                                                                    case "SUM":
                                                                                        result += valToTest;

                                                                                        break;
                                                                                    case "AVERAGE":
                                                                                        result += valToTest;
                                                                                        AverageCount++;
                                                                                        break;
                                                                                    case "MEAN":
                                                                                        result += valToTest;
                                                                                        AverageCount++;

                                                                                        break;
                                                                                    case "CONCAT":
                                                                                        if (textRes.Contains(valToTest.ToString() + ConcatDelim))
                                                                                        {
                                                                                        }
                                                                                        else if (textRes.Contains(ConcatDelim + valToTest.ToString()))
                                                                                        {
                                                                                        }
                                                                                        else
                                                                                        {

                                                                                            if (textRes == "")
                                                                                            {
                                                                                                textRes += valToTest.ToString();
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                textRes += ConcatDelim + valToTest.ToString();
                                                                                            }

                                                                                        }

                                                                                        break;
                                                                                    default:
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test);
                                                                                        break;
                                                                                }

                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            switch (statType.ToUpper())
                                                                            {

                                                                                case "CONCAT":
                                                                                    if (textRes.Contains(test.ToString() + ConcatDelim))
                                                                                    {
                                                                                    }
                                                                                    else if (textRes.Contains(ConcatDelim + test.ToString()))
                                                                                    {
                                                                                    }
                                                                                    else
                                                                                    {

                                                                                        if (textRes == "")
                                                                                        {
                                                                                            textRes += test;
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            textRes += ConcatDelim + test;
                                                                                        }
                                                                                    }

                                                                                    break;
                                                                                default:
                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14d") + test);

                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test);
                                                                                    break;
                                                                            }

                                                                        }

                                                                    }
                                                                    catch
                                                                    {
                                                                    }
                                                                }//end loop
                                                                try
                                                                {
                                                                    if (textRes != "")
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], textRes);
                                                                    }
                                                                    else if (result != -999999.1)
                                                                    {
                                                                        if (AverageCount != 0)
                                                                        {
                                                                            result = result / AverageCount;
                                                                        }
                                                                        inObject.set_Value(intFldIdxs[0], result);

                                                                    }
                                                                    else
                                                                    {
                                                                        IField field = inObject.Fields.get_Field(intFldIdxs[0]);
                                                                        object newval = field.DefaultValue;
                                                                        if (newval == null)
                                                                        {
                                                                            if (field.IsNullable)
                                                                            {
                                                                                inObject.set_Value(intFldIdxs[0], null);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[0], newval);
                                                                        }
                                                                    }
                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.Message);

                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi"));
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj"));
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_EDGE_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_STATS");
                                            }
                                            break;
                                        case "TO_EDGE_MULTI_FIELD_INTERSECT":
                                            try
                                            {
                                                if (valData == null) break;

                                                sourceFieldName = "";
                                                sourceField = -1;
                                                found = false;
                                                //LayerToIntersect|Field To Elevate
                                                // Parse arguments
                                                args = valData.Split('|');
                                                int popFldIdx = 0;
                                                if (args.GetLength(0) >= 2)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain114"));

                                                    sourceFieldName = args[0].ToString();
                                                    string[] fieldsToPop = args[1].ToString().Split(',');

                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TO_EDGE_MULTI_FIELD_INTERSECT");

                                                    if (inFeature != null)
                                                    {
                                                        netFeat = inFeature as INetworkFeature;
                                                        if (netFeat != null)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain103"));
                                                            if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain104"));
                                                                iJuncFeat = (IJunctionFeature)netFeat;
                                                                // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                                ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                                if (iSJunc == null)
                                                                    break;
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount);
                                                                if (iSJunc.EdgeFeatureCount <= 0)
                                                                    break;
                                                                if (iSJunc.EdgeFeatureCount > 0)
                                                                {
                                                                    for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount);

                                                                        iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                        try
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain106"));

                                                                            iJuncFeat = iEdgeFeat.FromJunctionFeature;

                                                                            if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain107"));

                                                                                IRow pRow = iEdgeFeat as IRow;

                                                                                // verify that field (in junction) to copy exists
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain108"));
                                                                                juncField = pRow.Fields.FindField(sourceFieldName);
                                                                                string test = pRow.get_Value(juncField).ToString();
                                                                                if (fieldsToPop.Length == popFldIdx)
                                                                                    break;

                                                                                int tempFieldNum = inObject.Fields.FindField(fieldsToPop[popFldIdx]);

                                                                                if (tempFieldNum > -1)
                                                                                {
                                                                                    inObject.set_Value(tempFieldNum, test);
                                                                                    popFldIdx++;
                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain109"));

                                                                            }
                                                                        }
                                                                        catch
                                                                        {
                                                                        }
                                                                    }//end loop

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi"));
                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj"));
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk"));
                                                        }
                                                    }
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_EDGE_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_STATS");
                                            }
                                            break;
                                        case "FROM_EDGE_MULTI_FIELD_INTERSECT":
                                            try
                                            {
                                                if (valData == null) break;
                                                sourceFieldName = "";
                                                sourceField = -1;
                                                found = false;
                                                //LayerToIntersect|Field To Elevate
                                                // Parse arguments
                                                args = valData.Split('|');
                                                int popFldIdx = 0;
                                                if (args.GetLength(0) >= 2)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain114"));

                                                    sourceFieldName = args[0].ToString();
                                                    string[] fieldsToPop = args[1].ToString().Split(',');

                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FROM_EDGE_MULTI_FIELD_INTERSECT");

                                                    if (inFeature != null)
                                                    {
                                                        netFeat = inFeature as INetworkFeature;
                                                        if (netFeat != null)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain103"));
                                                            if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain104"));
                                                                iJuncFeat = (IJunctionFeature)netFeat;
                                                                // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                                ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                                if (iSJunc == null)
                                                                    break;
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount);
                                                                if (iSJunc.EdgeFeatureCount <= 0)
                                                                    break;
                                                                if (iSJunc.EdgeFeatureCount > 0)
                                                                {
                                                                    for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount);

                                                                        iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                        try
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain106"));

                                                                            iJuncFeat = iEdgeFeat.ToJunctionFeature;

                                                                            if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain110"));

                                                                                IRow pRow = iEdgeFeat as IRow;

                                                                                // verify that field (in junction) to copy exists
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain111"));
                                                                                juncField = pRow.Fields.FindField(sourceFieldName);
                                                                                string test = pRow.get_Value(juncField).ToString();
                                                                                if (fieldsToPop.Length == popFldIdx)
                                                                                    break;

                                                                                int tempFieldNum = inObject.Fields.FindField(fieldsToPop[popFldIdx]);

                                                                                if (tempFieldNum > -1)
                                                                                {
                                                                                    inObject.set_Value(tempFieldNum, test);
                                                                                    popFldIdx++;
                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain112"));

                                                                            }
                                                                        }
                                                                        catch
                                                                        {
                                                                        }
                                                                    }//end loop

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi"));
                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj"));
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk"));
                                                        }
                                                    }
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_EDGE_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_STATS");
                                            }
                                            break;

                                        case "FROM_JUNCTION_FIELD":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FROM_JUNCTION_FIELD");
                                                if (valData == null)
                                                {
                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba"));
                                                    break;
                                                }
                                                if (inFeature != null)
                                                {
                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge)
                                                        {
                                                            string netField = "";
                                                            string netRestrictFC = "";
                                                            string netRestrictField = "";
                                                            string netRestrictValue = "";
                                                            args = valData.Split('|');
                                                            switch (args.GetLength(0))
                                                            {
                                                                case 1:  // sequenceColumnName only
                                                                    netField = args[0].ToString().Trim();
                                                                    break;
                                                                case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    break;
                                                                case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    break;
                                                                case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    netRestrictValue = args[3].ToString().Trim();
                                                                    break;
                                                                default: break;
                                                            }

                                                            iEdgeFeat = (IEdgeFeature)netFeat;
                                                            iJuncFeat = iEdgeFeat.FromJunctionFeature;
                                                            if (netRestrictFC != "")
                                                            {
                                                                string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class));

                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName);
                                                                if (strClsName != netRestrictFC)
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg"));
                                                                    break;
                                                                }
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh"));
                                                                if (netRestrictField != "" && netRestrictValue != "")
                                                                {
                                                                    int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField);

                                                                    if (intTmpFld > -1)
                                                                    {
                                                                        if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl"));
                                                                            break;

                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm"));
                                                                }
                                                            }
                                                            // verify that field (in junction) to copy exists
                                                            juncField = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netField);
                                                            if (juncField > -1)
                                                            {
                                                                inObject.set_Value(intFldIdxs[0], ((IFeature)iJuncFeat).get_Value(juncField));
                                                            }
                                                            else
                                                                AAState.WriteLine("                  " + netField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") );
                                                        }
                                                        else
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bc"));
                                                    }
                                                    else
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain115"));
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "FROM_JUNCTION_FIELD: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "FROM_JUNCTION_FIELD");
                                            }
                                            break;

                                        //Release: 1.2
                                        //New Dynamic Value Method: TO_JUNCTION_FIELD transfers a field value from a junction connected at terminal end of a line feature
                                        case "TO_JUNCTION_FIELD":
                                            try
                                            {

                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TO_JUNCTION_FIELD");
                                                if (valData == null)
                                                {
                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba"));
                                                    break;
                                                }
                                                if (inFeature != null)
                                                {

                                                    netFeat = inFeature as INetworkFeature;
                                                    if (netFeat != null)
                                                    {
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge)
                                                        {

                                                            string netField = "";
                                                            string netRestrictFC = "";
                                                            string netRestrictField = "";
                                                            string netRestrictValue = "";
                                                            args = valData.Split('|');
                                                            switch (args.GetLength(0))
                                                            {
                                                                case 1:  // sequenceColumnName only
                                                                    netField = args[0].ToString().Trim();
                                                                    break;
                                                                case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    break;
                                                                case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    break;
                                                                case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                    netField = args[0].ToString().Trim();
                                                                    netRestrictFC = args[1].ToString().Trim();
                                                                    netRestrictField = args[2].ToString().Trim();
                                                                    netRestrictValue = args[3].ToString().Trim();
                                                                    break;
                                                                default: break;
                                                            }

                                                            iEdgeFeat = (IEdgeFeature)netFeat;
                                                            iJuncFeat = iEdgeFeat.ToJunctionFeature;

                                                            if (netRestrictFC != "")
                                                            {
                                                                string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class));

                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName);
                                                                if (strClsName != netRestrictFC)
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg"));
                                                                    break;
                                                                }
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh"));
                                                                if (netRestrictField != "" && netRestrictValue != "")
                                                                {
                                                                    int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField);

                                                                    if (intTmpFld > -1)
                                                                    {
                                                                        if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl"));
                                                                            break;

                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm"));
                                                                }
                                                            }
                                                            // verify that field (in junction) to copy exists
                                                            juncField = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netField);

                                                            //juncField = ((IFeature)iJuncFeat).Fields.FindField(valData as string);
                                                            if (juncField > -1)
                                                            {
                                                                inObject.set_Value(intFldIdxs[0], ((IFeature)iJuncFeat).get_Value(juncField));
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + netField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") );
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bc"));
                                                    }
                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bd"));
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TO_JUNCTION_FIELD: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_JUNCTION_FIELD");
                                            }
                                            break;
                                        case "UPDATE_TO_JUNCTION_FIELD":
                                            try
                                            {

                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "UPDATE_TO_JUNCTION_FIELD");
                                                IRowChanges pRowCh = null;

                                                pRowCh = inObject as IRowChanges;

                                                if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true)
                                                {

                                                    if (valData == null)
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba"));
                                                        break;
                                                    }
                                                    if (inFeature != null)
                                                    {

                                                        netFeat = inFeature as INetworkFeature;
                                                        if (netFeat != null)
                                                        {
                                                            if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge)
                                                            {

                                                                string netField = "";
                                                                string netRestrictFC = "";
                                                                string netRestrictField = "";
                                                                string netRestrictValue = "";
                                                                args = valData.Split('|');
                                                                switch (args.GetLength(0))
                                                                {
                                                                    case 1:  // sequenceColumnName only
                                                                        netField = args[0].ToString().Trim();
                                                                        break;
                                                                    case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        break;
                                                                    case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        break;
                                                                    case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        netRestrictValue = args[3].ToString().Trim();
                                                                        break;
                                                                    default: break;
                                                                }

                                                                iEdgeFeat = (IEdgeFeature)netFeat;
                                                                iJuncFeat = iEdgeFeat.ToJunctionFeature;

                                                                if (netRestrictFC != "")
                                                                {
                                                                    string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class));

                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName);
                                                                    if (strClsName != netRestrictFC)
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg"));
                                                                        break;
                                                                    }
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh"));
                                                                    if (netRestrictField != "" && netRestrictValue != "")
                                                                    {
                                                                        int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField);

                                                                        if (intTmpFld > -1)
                                                                        {
                                                                            if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl"));
                                                                                break;

                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm"));
                                                                    }
                                                                }
                                                                // verify that field (in junction) to copy exists
                                                                juncField = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netField);

                                                                //juncField = ((IFeature)iJuncFeat).Fields.FindField(valData as string);
                                                                if (juncField > -1)
                                                                {
                                                                    if (ChangeFeatureList == null)
                                                                    {
                                                                        ChangeFeatureList = new List<IObject>();
                                                                    }
                                                                    ((IFeature)iJuncFeat).set_Value(juncField, inObject.get_Value(intFldIdxs[0]));
                                                                    ChangeFeatureList.Add(((IFeature)iJuncFeat));

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + netField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") );
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bc"));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bd"));
                                                    }
                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be"));
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "UPDATE_TO_JUNCTION_FIELD: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_TO_JUNCTION_FIELD");
                                            }
                                            break;
                                        case "UPDATE_FROM_JUNCTION_FIELD":
                                            try
                                            {

                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "UPDATE_FROM_JUNCTION_FIELD");
                                                IRowChanges pRowCh = null;

                                                pRowCh = inObject as IRowChanges;

                                                if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true)
                                                {

                                                    if (valData == null)
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba"));
                                                        break;
                                                    }
                                                    if (inFeature != null)
                                                    {

                                                        netFeat = inFeature as INetworkFeature;
                                                        if (netFeat != null)
                                                        {
                                                            if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge)
                                                            {

                                                                string netField = "";
                                                                string netRestrictFC = "";
                                                                string netRestrictField = "";
                                                                string netRestrictValue = "";
                                                                args = valData.Split('|');
                                                                switch (args.GetLength(0))
                                                                {
                                                                    case 1:
                                                                        netField = args[0].ToString().Trim();
                                                                        break;
                                                                    case 2:
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        break;
                                                                    case 3:
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        break;
                                                                    case 4:
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        netRestrictValue = args[3].ToString().Trim();
                                                                        break;
                                                                    default: break;
                                                                }

                                                                iEdgeFeat = (IEdgeFeature)netFeat;
                                                                iJuncFeat = iEdgeFeat.FromJunctionFeature;

                                                                if (netRestrictFC != "")
                                                                {
                                                                    string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class));

                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName);
                                                                    if (strClsName != netRestrictFC)
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg"));
                                                                        break;
                                                                    }
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh"));
                                                                    if (netRestrictField != "" && netRestrictValue != "")
                                                                    {
                                                                        int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField);

                                                                        if (intTmpFld > -1)
                                                                        {
                                                                            if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl"));
                                                                                break;

                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm"));
                                                                    }
                                                                }
                                                                // verify that field (in junction) to copy exists
                                                                juncField = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netField);

                                                                //juncField = ((IFeature)iJuncFeat).Fields.FindField(valData as string);
                                                                if (juncField > -1)
                                                                {
                                                                    if (ChangeFeatureList == null)
                                                                    {
                                                                        ChangeFeatureList = new List<IObject>();
                                                                    }
                                                                    ((IFeature)iJuncFeat).set_Value(juncField, inObject.get_Value(intFldIdxs[0]));
                                                                    ChangeFeatureList.Add(((IFeature)iJuncFeat));

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + netField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") );
                                                                }
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bc"));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bd"));
                                                    }

                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be"));
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "UPDATE_FROM_JUNCTION_FIELD: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_FROM_JUNCTION_FIELD");
                                            }
                                            break;
                                        case "UPDATE_FROM_EDGE_FIELD":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "UPDATE_FROM_EDGE_FIELD");
                                                if (inFeature != null)
                                                {
                                                    IRowChanges pRowCh = null;

                                                    pRowCh = inObject as IRowChanges;

                                                    if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true)
                                                    {

                                                        if (valData == null)
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba"));
                                                            break;
                                                        }
                                                        netFeat = inFeature as INetworkFeature;
                                                        if (netFeat != null)
                                                        {
                                                            if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                            {
                                                                string netField = "";
                                                                string netRestrictFC = "";
                                                                string netRestrictField = "";
                                                                string netRestrictValue = "";
                                                                args = valData.Split('|');
                                                                switch (args.GetLength(0))
                                                                {
                                                                    case 1:  // sequenceColumnName only
                                                                        netField = args[0].ToString().Trim();
                                                                        break;
                                                                    case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        break;
                                                                    case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        break;
                                                                    case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        netRestrictValue = args[3].ToString().Trim();
                                                                        break;
                                                                    default: break;
                                                                }

                                                                iJuncFeat = (IJunctionFeature)netFeat;
                                                                // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                                ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                                if (iSJunc == null)
                                                                    break;
                                                                if (iSJunc.EdgeFeatureCount <= 0)
                                                                    break;
                                                                if (iSJunc.EdgeFeatureCount > 0)
                                                                {
                                                                    for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                    {
                                                                        iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                        try
                                                                        {
                                                                            if (netRestrictFC != "")
                                                                            {
                                                                                string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class));

                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName);
                                                                                if (strClsName != netRestrictFC)
                                                                                {
                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg"));
                                                                                    continue;
                                                                                }
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh"));
                                                                                if (netRestrictField != "" && netRestrictValue != "")
                                                                                {
                                                                                    int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField);

                                                                                    if (intTmpFld > -1)
                                                                                    {
                                                                                        //IFeature pTest = ((IFeature)iEdgeFeat);

                                                                                        if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                                        {
                                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl"));
                                                                                            continue;

                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine("                  " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm"));
                                                                                }
                                                                            }

                                                                            iJuncFeat = iEdgeFeat.ToJunctionFeature;
                                                                            if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                            {
                                                                                IFeature pRow = iEdgeFeat as IFeature;

                                                                                // verify that field (in junction) to copy exists
                                                                                juncField = Globals.GetFieldIndex(pRow.Fields, netField);

                                                                                if (juncField > -1)
                                                                                {
                                                                                    if (ChangeFeatureList == null)
                                                                                    {
                                                                                        ChangeFeatureList = new List<IObject>();
                                                                                    }
                                                                                    pRow.set_Value(juncField, inObject.get_Value(intFldIdxs[0]));
                                                                                    ChangeFeatureList.Add(((IFeature)pRow));

                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  " + iSJunc + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14am") );
                                                                                }
                                                                                pRow = null;

                                                                                break;

                                                                            }
                                                                        }
                                                                        catch
                                                                        {
                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14an"));
                                                                        }

                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi"));
                                                                }
                                                                iSJunc = null;
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj"));
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk"));
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be"));
                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "UPDATE_FROM_EDGE_FIELD: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_FROM_EDGE_FIELD");
                                            }
                                            break;
                                        case "UPDATE_TO_EDGE_FIELD":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "UPDATE_TO_EDGE_FIELD");
                                                if (inFeature != null)
                                                {
                                                    IRowChanges pRowCh = null;

                                                    pRowCh = inObject as IRowChanges;

                                                    if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true)
                                                    {

                                                        if (valData == null)
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba"));
                                                            break;
                                                        }
                                                        netFeat = inFeature as INetworkFeature;
                                                        if (netFeat != null)
                                                        {
                                                            if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                            {
                                                                string netField = "";
                                                                string netRestrictFC = "";
                                                                string netRestrictField = "";
                                                                string netRestrictValue = "";
                                                                args = valData.Split('|');
                                                                switch (args.GetLength(0))
                                                                {
                                                                    case 1:  // sequenceColumnName only
                                                                        netField = args[0].ToString().Trim();
                                                                        break;
                                                                    case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        break;
                                                                    case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        break;
                                                                    case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        netRestrictValue = args[3].ToString().Trim();
                                                                        break;
                                                                    default: break;
                                                                }

                                                                iJuncFeat = (IJunctionFeature)netFeat;
                                                                // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                                ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                                if (iSJunc == null)
                                                                    break;
                                                                if (iSJunc.EdgeFeatureCount <= 0)
                                                                    break;
                                                                if (iSJunc.EdgeFeatureCount > 0)
                                                                {
                                                                    for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                    {
                                                                        iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                        try
                                                                        {

                                                                            if (netRestrictFC != "")
                                                                            {
                                                                                string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class));

                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName);
                                                                                if (strClsName != netRestrictFC)
                                                                                {
                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg"));
                                                                                    continue;
                                                                                }
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh"));
                                                                                if (netRestrictField != "" && netRestrictValue != "")
                                                                                {
                                                                                    int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField);

                                                                                    if (intTmpFld > -1)
                                                                                    {
                                                                                        //IFeature pTest = ((IFeature)iEdgeFeat);

                                                                                        if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                                        {
                                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl"));
                                                                                            continue;

                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine("                  " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm"));
                                                                                }
                                                                            }

                                                                            iJuncFeat = (IJunctionFeature)iEdgeFeat.FromJunctionFeature;
                                                                            if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                            {
                                                                                IFeature pRow = iEdgeFeat as IFeature;

                                                                                // verify that field (in junction) to copy exists
                                                                                juncField = Globals.GetFieldIndex(pRow.Fields, netField);

                                                                                if (juncField > -1)
                                                                                {
                                                                                    if (ChangeFeatureList == null)
                                                                                    {
                                                                                        ChangeFeatureList = new List<IObject>();
                                                                                    }
                                                                                    pRow.set_Value(juncField, inObject.get_Value(intFldIdxs[0]));
                                                                                    ChangeFeatureList.Add(((IFeature)pRow));

                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  " + netField + " field not found in edge");
                                                                                }
                                                                                pRow = null;
                                                                                break;

                                                                            }
                                                                        }
                                                                        catch
                                                                        {
                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14an"));
                                                                        }

                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi"));
                                                                }
                                                                iSJunc = null;
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj"));
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk"));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "UPDATE_TO_EDGE_FIELD: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_TO_EDGE_FIELD");
                                            }
                                            break;
                                        //***************8

                                        case "TRIGGER_UPDATE_INTERSECTING_FEATURE"://Intersected Feature|FieldIntersectingFeatureToChange|FromFieldinModifiedFeature
                                            {
                                                try
                                                {
                                                    IFeatureCursor fLocalCursor = null;
                                                    IFeature sourceFeatureLocal = null;
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_UPDATE_INTERSECTING_FEATURE");
                                                    if (!String.IsNullOrEmpty(valData))
                                                    {
                                                        args = valData.Split('|');
                                                        if (args.Length != 3)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad"));
                                                            break;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad"));
                                                        break;
                                                    }
                                                    if (inFeature == null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ak"));
                                                        break;
                                                    }
                                                    bool cont = true;
                                                    if (intFldIdxs.Count > 1)
                                                    {
                                                        IRowChanges inChanges = inObject as IRowChanges;
                                                        if (inChanges.get_ValueChanged(intFldIdxs[0]))
                                                        {
                                                            cont = true;
                                                        }
                                                        else
                                                        {
                                                            cont = false;
                                                        }

                                                        inChanges = null;

                                                    }
                                                    if (cont)
                                                    {

                                                        sourceLayerName = "";
                                                        sourceFieldName = "";
                                                        sourceField = -1;
                                                        found = false;
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bs"));
                                                        sourceLayerNames = args[0].ToString().Split(',');
                                                        sourceFieldName = args[1].ToString().Trim();
                                                        string targetFieldName = args[2].ToString().Trim();
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bt"));
                                                        if (sourceFieldName != null)
                                                        {
                                                            for (int i = 0; i < sourceLayerNames.Length; i++)
                                                            {
                                                                sourceLayerName = sourceLayerNames[i].ToString().Trim();
                                                                if (sourceLayerName != "")
                                                                {

                                                                    boolLayerOrFC = true;
                                                                    if (sourceLayerName.Contains("("))
                                                                    {
                                                                        string[] tempSplt = sourceLayerName.Split('(');
                                                                        sourceLayerName = tempSplt[0].Trim();
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                    }
                                                                    if (sourceLayer != null)
                                                                    {

                                                                        if (Globals.IsEditable(ref sourceLayer, ref AAState._editor))
                                                                        {

                                                                            if (inObject.Class.ObjectClassID != sourceLayer.FeatureClass.ObjectClassID)
                                                                            {

                                                                                sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false);

                                                                                pFS = (IFeatureSelection)sourceLayer;
                                                                                if (boolLayerOrFC)
                                                                                {
                                                                                    if (pFS.SelectionSet.Count > 0)
                                                                                    {
                                                                                        pFS.SelectionSet.Search(sFilter, false, out cCurs);
                                                                                        fLocalCursor = cCurs as IFeatureCursor;

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        fLocalCursor = sourceLayer.Search(sFilter, false);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    fLocalCursor = sourceLayer.FeatureClass.Search(sFilter, false);
                                                                                }

                                                                                while ((sourceFeatureLocal = fLocalCursor.NextFeature()) != null)
                                                                                {
                                                                                    try
                                                                                    {
                                                                                        if (sourceFeatureLocal.Class.ObjectClassID != inFeature.Class.ObjectClassID)
                                                                                        {
                                                                                            if (sourceFieldName == "CREATE")
                                                                                            {
                                                                                                if (NewFeatureList == null)
                                                                                                {
                                                                                                    NewFeatureList = new List<IObject>();
                                                                                                }

                                                                                                NewFeatureList.Add(((IFeature)sourceFeatureLocal));
                                                                                            }
                                                                                            else if (sourceFieldName == "CHANGEGEO")
                                                                                            {
                                                                                                if (ChangeFeatureGeoList == null)
                                                                                                {
                                                                                                    ChangeFeatureGeoList = new List<IObject>();
                                                                                                }

                                                                                                ChangeFeatureGeoList.Add(((IFeature)sourceFeatureLocal));
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                if (ChangeFeatureList == null)
                                                                                                {
                                                                                                    ChangeFeatureList = new List<IObject>();
                                                                                                }

                                                                                                ChangeFeatureList.Add(((IFeature)sourceFeatureLocal));
                                                                                            }

                                                                                        }
                                                                                        else if (sourceFeatureLocal.Class == inFeature.Class && sourceFeatureLocal.OID != inFeature.OID)
                                                                                        {
                                                                                            if (sourceFieldName == "CREATE")
                                                                                            {
                                                                                                if (NewFeatureList == null)
                                                                                                {
                                                                                                    NewFeatureList = new List<IObject>();
                                                                                                }

                                                                                                NewFeatureList.Add(((IFeature)sourceFeatureLocal));
                                                                                            }
                                                                                            else if (sourceFieldName == "CHANGEGEO")
                                                                                            {
                                                                                                if (ChangeFeatureGeoList == null)
                                                                                                {
                                                                                                    ChangeFeatureGeoList = new List<IObject>();
                                                                                                }

                                                                                                ChangeFeatureGeoList.Add(((IFeature)sourceFeatureLocal));
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                if (ChangeFeatureList == null)
                                                                                                {
                                                                                                    ChangeFeatureList = new List<IObject>();
                                                                                                }

                                                                                                ChangeFeatureList.Add(((IFeature)sourceFeatureLocal));
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                    catch
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14al"));
                                                                                    }
                                                                                    finally
                                                                                    {

                                                                                    }

                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14b") + sourceLayerName);
                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName);
                                                                }
                                                            }
                                                        }
                                                        if (found)
                                                        {
                                                            break;

                                                        }

                                                    }
                                                    fLocalCursor = null;
                                                    sourceFeatureLocal = null;
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TRIGGER_UPDATE_INTERSECTING_FEATURE" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_UPDATE_INTERSECTING_FEATURE");

                                                }
                                                break;

                                            }

                                        case "TRIGGER_UPDATE_TO_JUNCTION":
                                            try
                                            {

                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_UPDATE_TO_JUNCTION");
                                                IRowChanges pRowCh = null;

                                                pRowCh = inObject as IRowChanges;

                                                if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true)
                                                {

                                                    if (valData == null)
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba"));
                                                        break;
                                                    }
                                                    if (inFeature != null)
                                                    {

                                                        netFeat = inFeature as INetworkFeature;
                                                        if (netFeat != null)
                                                        {
                                                            if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge)
                                                            {

                                                                string netField = "";
                                                                string netRestrictFC = "";
                                                                string netRestrictField = "";
                                                                string netRestrictValue = "";
                                                                args = valData.Split('|');
                                                                switch (args.GetLength(0))
                                                                {
                                                                    case 1:  // sequenceColumnName only
                                                                        netField = args[0].ToString().Trim();
                                                                        break;
                                                                    case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        break;
                                                                    case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        break;
                                                                    case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        netRestrictValue = args[3].ToString().Trim();
                                                                        break;
                                                                    default: break;
                                                                }

                                                                iEdgeFeat = (IEdgeFeature)netFeat;
                                                                iJuncFeat = iEdgeFeat.ToJunctionFeature;

                                                                if (netRestrictFC != "")
                                                                {
                                                                    string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class));

                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName);
                                                                    if (strClsName != netRestrictFC)
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg"));
                                                                        break;
                                                                    }
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh"));
                                                                    if (netRestrictField != "" && netRestrictValue != "")
                                                                    {
                                                                        int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField);

                                                                        if (intTmpFld > -1)
                                                                        {
                                                                            if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl"));
                                                                                break;

                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm"));
                                                                    }
                                                                }
                                                                // verify that field (in junction) to copy exists
                                                                if (netField == "CREATE")
                                                                {
                                                                    if (NewFeatureList == null)
                                                                    {
                                                                        NewFeatureList = new List<IObject>();
                                                                    }

                                                                    NewFeatureList.Add(((IFeature)iJuncFeat));
                                                                }
                                                                else if (netField == "CHANGEGEO")
                                                                {
                                                                    if (ChangeFeatureGeoList == null)
                                                                    {
                                                                        ChangeFeatureGeoList = new List<IObject>();
                                                                    }

                                                                    ChangeFeatureGeoList.Add(((IFeature)iJuncFeat));
                                                                }
                                                                else
                                                                {
                                                                    if (ChangeFeatureList == null)
                                                                    {
                                                                        ChangeFeatureList = new List<IObject>();
                                                                    }

                                                                    ChangeFeatureList.Add(((IFeature)iJuncFeat));
                                                                }

                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bc"));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bd"));
                                                    }
                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be"));
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TRIGGER_UPDATE_TO_JUNCTION: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_UPDATE_TO_JUNCTION");
                                            }
                                            break;
                                        case "TRIGGER_UPDATE_FROM_JUNCTION":
                                            try
                                            {

                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_UPDATE_FROM_JUNCTION");
                                                IRowChanges pRowCh = null;

                                                pRowCh = inObject as IRowChanges;

                                                if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true)
                                                {

                                                    if (valData == null)
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba"));
                                                        break;
                                                    }
                                                    if (inFeature != null)
                                                    {

                                                        netFeat = inFeature as INetworkFeature;
                                                        if (netFeat != null)
                                                        {
                                                            if (inFeature.FeatureType == esriFeatureType.esriFTComplexEdge || inFeature.FeatureType == esriFeatureType.esriFTSimpleEdge)
                                                            {

                                                                string netField = "";
                                                                string netRestrictFC = "";
                                                                string netRestrictField = "";
                                                                string netRestrictValue = "";
                                                                args = valData.Split('|');
                                                                switch (args.GetLength(0))
                                                                {
                                                                    case 1:
                                                                        netField = args[0].ToString().Trim();
                                                                        break;
                                                                    case 2:
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        break;
                                                                    case 3:
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        break;
                                                                    case 4:
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        netRestrictValue = args[3].ToString().Trim();
                                                                        break;
                                                                    default: break;
                                                                }

                                                                iEdgeFeat = (IEdgeFeature)netFeat;
                                                                iJuncFeat = iEdgeFeat.FromJunctionFeature;

                                                                if (netRestrictFC != "")
                                                                {
                                                                    string strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class));

                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName);
                                                                    if (strClsName != netRestrictFC)
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg"));
                                                                        break;
                                                                    }
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh"));
                                                                    if (netRestrictField != "" && netRestrictValue != "")
                                                                    {
                                                                        int intTmpFld = Globals.GetFieldIndex(((IFeature)iJuncFeat).Fields, netRestrictField);

                                                                        if (intTmpFld > -1)
                                                                        {
                                                                            if (((IFeature)iJuncFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl"));
                                                                                break;

                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm"));
                                                                    }
                                                                }
                                                                if (netField == "CREATE")
                                                                {
                                                                    if (NewFeatureList == null)
                                                                    {
                                                                        NewFeatureList = new List<IObject>();
                                                                    }

                                                                    NewFeatureList.Add(((IFeature)iJuncFeat));
                                                                }
                                                                else if (netField == "CHANGEGEO")
                                                                {
                                                                    if (ChangeFeatureGeoList == null)
                                                                    {
                                                                        ChangeFeatureGeoList = new List<IObject>();
                                                                    }

                                                                    ChangeFeatureGeoList.Add(((IFeature)iJuncFeat));
                                                                }
                                                                else
                                                                {
                                                                    if (ChangeFeatureList == null)
                                                                    {
                                                                        ChangeFeatureList = new List<IObject>();
                                                                    }

                                                                    ChangeFeatureList.Add(((IFeature)iJuncFeat));
                                                                }
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bc"));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bd"));
                                                    }

                                                }
                                                else
                                                {
                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be"));
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TRIGGER_UPDATE_FROM_JUNCTION: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_UPDATE_FROM_JUNCTION");
                                            }
                                            break;
                                        case "TRIGGER_UPDATE_FROM_EDGE":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_UPDATE_FROM_EDGE");
                                                if (inFeature != null)
                                                {
                                                    IRowChanges pRowCh = null;

                                                    pRowCh = inObject as IRowChanges;

                                                    if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true)
                                                    {

                                                        if (valData == null)
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba"));
                                                            break;
                                                        }
                                                        netFeat = inFeature as INetworkFeature;
                                                        if (netFeat != null)
                                                        {
                                                            if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                            {
                                                                string netField = "";
                                                                string netRestrictFC = "";
                                                                string netRestrictField = "";
                                                                string netRestrictValue = "";
                                                                args = valData.Split('|');
                                                                switch (args.GetLength(0))
                                                                {
                                                                    case 1:  // sequenceColumnName only
                                                                        netField = args[0].ToString().Trim();
                                                                        break;
                                                                    case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        break;
                                                                    case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        break;
                                                                    case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        netRestrictValue = args[3].ToString().Trim();
                                                                        break;
                                                                    default: break;
                                                                }

                                                                iJuncFeat = (IJunctionFeature)netFeat;
                                                                // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                                ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                                if (iSJunc == null)
                                                                    break;
                                                                if (iSJunc.EdgeFeatureCount <= 0)
                                                                    break;
                                                                if (iSJunc.EdgeFeatureCount > 0)
                                                                {
                                                                    for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                    {
                                                                        iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                        try
                                                                        {
                                                                            if (netRestrictFC != "")
                                                                            {
                                                                                string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class));

                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName);
                                                                                if (strClsName != netRestrictFC)
                                                                                {
                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg"));
                                                                                    continue;
                                                                                }
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh"));
                                                                                if (netRestrictField != "" && netRestrictValue != "")
                                                                                {
                                                                                    int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField);

                                                                                    if (intTmpFld > -1)
                                                                                    {
                                                                                        //IFeature pTest = ((IFeature)iEdgeFeat);

                                                                                        if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                                        {
                                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl"));
                                                                                            continue;

                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine("                  " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm"));
                                                                                }
                                                                            }

                                                                            iJuncFeat = iEdgeFeat.ToJunctionFeature;
                                                                            if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                            {

                                                                                if (netField == "CREATE")
                                                                                {
                                                                                    if (NewFeatureList == null)
                                                                                    {
                                                                                        NewFeatureList = new List<IObject>();
                                                                                    }

                                                                                    NewFeatureList.Add(((IFeature)iEdgeFeat));
                                                                                }
                                                                                else if (netField == "CHANGEGEO")
                                                                                {
                                                                                    if (ChangeFeatureGeoList == null)
                                                                                    {
                                                                                        ChangeFeatureGeoList = new List<IObject>();
                                                                                    }

                                                                                    ChangeFeatureGeoList.Add(((IFeature)iEdgeFeat));
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (ChangeFeatureList == null)
                                                                                    {
                                                                                        ChangeFeatureList = new List<IObject>();
                                                                                    }

                                                                                    ChangeFeatureList.Add(((IFeature)iEdgeFeat));
                                                                                }

                                                                                break;

                                                                            }
                                                                        }
                                                                        catch
                                                                        {
                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14an"));
                                                                        }

                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi"));
                                                                }
                                                                iSJunc = null;
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj"));
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk"));
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be"));
                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TRIGGER_UPDATE_FROM_EDGE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_UPDATE_FROM_EDGE");
                                            }
                                            break;
                                        case "TRIGGER_UPDATE_TO_EDGE":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_UPDATE_TO_EDGE");
                                                if (inFeature != null)
                                                {
                                                    IRowChanges pRowCh = null;

                                                    pRowCh = inObject as IRowChanges;

                                                    if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true)
                                                    {

                                                        if (valData == null)
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ba"));
                                                            break;
                                                        }
                                                        netFeat = inFeature as INetworkFeature;
                                                        if (netFeat != null)
                                                        {
                                                            if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                            {
                                                                string netField = "";
                                                                string netRestrictFC = "";
                                                                string netRestrictField = "";
                                                                string netRestrictValue = "";
                                                                args = valData.Split('|');
                                                                switch (args.GetLength(0))
                                                                {
                                                                    case 1:  // sequenceColumnName only
                                                                        netField = args[0].ToString().Trim();
                                                                        break;
                                                                    case 2:  // sequenceColumnName|sequenceFixedWidth
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        break;
                                                                    case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        break;
                                                                    case 4:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                                        netField = args[0].ToString().Trim();
                                                                        netRestrictFC = args[1].ToString().Trim();
                                                                        netRestrictField = args[2].ToString().Trim();
                                                                        netRestrictValue = args[3].ToString().Trim();
                                                                        break;
                                                                    default: break;
                                                                }

                                                                iJuncFeat = (IJunctionFeature)netFeat;
                                                                // IComplexJunctionFeature iCEd = iJuncFeat as IComplexJunctionFeature;
                                                                ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                                if (iSJunc == null)
                                                                    break;
                                                                if (iSJunc.EdgeFeatureCount <= 0)
                                                                    break;
                                                                if (iSJunc.EdgeFeatureCount > 0)
                                                                {
                                                                    for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                    {
                                                                        iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                        try
                                                                        {

                                                                            if (netRestrictFC != "")
                                                                            {
                                                                                string strClsName = Globals.getClassName(((IDataset)((IFeature)iEdgeFeat).Class));

                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bf") + strClsName);
                                                                                if (strClsName != netRestrictFC)
                                                                                {
                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bg"));
                                                                                    continue;
                                                                                }
                                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bh"));
                                                                                if (netRestrictField != "" && netRestrictValue != "")
                                                                                {
                                                                                    int intTmpFld = Globals.GetFieldIndex(((IFeature)iEdgeFeat).Fields, netRestrictField);

                                                                                    if (intTmpFld > -1)
                                                                                    {
                                                                                        //IFeature pTest = ((IFeature)iEdgeFeat);

                                                                                        if (((IFeature)iEdgeFeat).get_Value(intTmpFld).ToString() == netRestrictValue)
                                                                                        {
                                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bl"));
                                                                                            continue;

                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine("                  " + netRestrictField + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bm"));
                                                                                }
                                                                            }

                                                                            iJuncFeat = (IJunctionFeature)iEdgeFeat.FromJunctionFeature;
                                                                            if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape))
                                                                            {
                                                                                if (netField == "CREATE")
                                                                                {
                                                                                    if (NewFeatureList == null)
                                                                                    {
                                                                                        NewFeatureList = new List<IObject>();
                                                                                    }

                                                                                    NewFeatureList.Add(((IFeature)iEdgeFeat));
                                                                                }
                                                                                else if (netField == "CHANGEGEO")
                                                                                {
                                                                                    if (ChangeFeatureGeoList == null)
                                                                                    {
                                                                                        ChangeFeatureGeoList = new List<IObject>();
                                                                                    }

                                                                                    ChangeFeatureGeoList.Add(((IFeature)iEdgeFeat));
                                                                                }
                                                                                else
                                                                                {
                                                                                    if (ChangeFeatureList == null)
                                                                                    {
                                                                                        ChangeFeatureList = new List<IObject>();
                                                                                    }

                                                                                    ChangeFeatureList.Add(((IFeature)iEdgeFeat));
                                                                                }

                                                                                break;
                                                                                break;

                                                                            }
                                                                        }
                                                                        catch
                                                                        {
                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14an"));
                                                                        }

                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi"));
                                                                }
                                                                iSJunc = null;
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj"));
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk"));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14be"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "TRIGGER_UPDATE_TO_EDGE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_UPDATE_TO_EDGE");
                                            }
                                            break;
                                        //***********8
                                        //Release: 1.2
                                        //New Dynamic Value Method: GENERATE_ID - uses value in specificed table and increments it as specified
                                        case "GENERATE_ID":

                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "GENERATE_ID");
                                                if (AAState._gentab != null)
                                                {
                                                    sequenceColumnName = "";
                                                    sequenceColumnNum = -1;
                                                    sequenceValue = -1;
                                                    sequenceFixedWidth = "";
                                                    sequencePadding = 0;
                                                    formatString = "";

                                                    // Parse arguments
                                                    if (valData == null) break;
                                                    args = valData.Split('|');
                                                    switch (args.GetLength(0))
                                                    {
                                                        case 1:  // sequenceColumnName only
                                                            sequenceColumnName = args[0].ToString(); break;
                                                        case 2:  // sequenceColumnName|sequenceFixedWidth
                                                            sequenceColumnName = args[0].ToString();
                                                            sequenceFixedWidth = args[1].ToString();
                                                            break;
                                                        case 3:  // sequenceColumnName|sequenceFixedWidth|formatString
                                                            sequenceColumnName = args[0].ToString();
                                                            sequenceFixedWidth = args[1].ToString();
                                                            formatString = args[2].ToString();
                                                            break;
                                                        default: break;
                                                    }

                                                    //Check for requested zero padding of sequence number
                                                    if (sequenceFixedWidth != "")
                                                        int.TryParse(sequenceFixedWidth.ToString(), out sequencePadding);
                                                    if (sequencePadding > 25)
                                                    {

                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain116"));
                                                        AAState.WriteLine("                  WARNING: " + sequencePadding + " 0's is what you have");

                                                    }
                                                    else if (sequencePadding > 50)
                                                    {
                                                        MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain117"));
                                                    }
                                                    qFilter = new QueryFilterClass();
                                                    qFilter.WhereClause = "SEQNAME = '" + sequenceColumnName + "'";
                                                    cCurs = AAState._gentab.Update(qFilter, false);
                                                    sequenceColumnNum = AAState._gentab.Fields.FindField("SEQCOUNTER");
                                                    //get value of first row, increment it, and return incremented value
                                                    for (int j = 0; j < 51; j++)
                                                    {
                                                        row = cCurs.NextRow();
                                                        if (row == null)
                                                        {
                                                            break;
                                                        }
                                                        if (row.get_Value(sequenceColumnNum) == null)
                                                        {
                                                            sequenceValue = 0;
                                                        }
                                                        else if (row.get_Value(sequenceColumnNum).ToString() == "")
                                                        {
                                                            sequenceValue = 0;
                                                        }
                                                        else
                                                            sequenceValue = Convert.ToInt32(row.get_Value(sequenceColumnNum));

                                                        // _editEvents.OnChangeFeature -= OnChangeFeature;
                                                        // _editEvents.OnCreateFeature -= OnCreateFeature;
                                                        int sequenceInt = 1;

                                                        if (AAState._gentab.Fields.FindField("SEQINTERV") > 0)
                                                        {
                                                            if (row.get_Value(AAState._gentab.Fields.FindField("SEQINTERV")) != null)
                                                            {
                                                                if (row.get_Value(AAState._gentab.Fields.FindField("SEQINTERV")) != DBNull.Value)
                                                                    sequenceInt = Convert.ToInt32(row.get_Value(AAState._gentab.Fields.FindField("SEQINTERV")));
                                                            }
                                                        }
                                                        sequenceValue = sequenceValue + sequenceInt;

                                                        row.set_Value(sequenceColumnNum, sequenceValue);
                                                        AAState.WriteLine("                  " + row.Fields.get_Field(sequenceColumnNum).AliasName + " changed to " + sequenceValue);
                                                        //AAState.changeFeature -= OnChangeFeature;
                                                        //AAState.createFeature -= OnCreateFeature;

                                                        row.Store();
                                                        //AAState.changeFeature += OnChangeFeature;
                                                        //AAState.createFeature += OnCreateFeature;

                                                        //  _editEvents.OnChangeFeature += OnChangeFeature;
                                                        //  _editEvents.OnCreateFeature += OnCreateFeature;
                                                        if (Convert.ToInt32(row.get_Value(sequenceColumnNum)) == sequenceValue)
                                                            break;

                                                    }
                                                    if (sequenceValue == -1)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ao"));
                                                    }

                                                    else
                                                    {
                                                        if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeString)
                                                            if (formatString == null || formatString == "" || formatString.ToLower().IndexOf("[seq]") == -1)
                                                            {
                                                                string setVal = (sequenceValue.ToString("D" + sequencePadding) + sequencePostfix).ToString();

                                                                if (inObject.Fields.get_Field(intFldIdxs[0]).Length < setVal.Length && inObject.Fields.get_Field(intFldIdxs[0]).Length != 0)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + sequenceValue + " is to long for field " + row.Fields.get_Field(sequenceColumnNum).AliasName);
                                                                }
                                                                else
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], (sequenceValue.ToString("D" + sequencePadding) + sequencePostfix).Trim());
                                                                    AAState.WriteLine("                  " + inObject.Fields.get_Field(intFldIdxs[0]).AliasName + " set to " + sequenceValue.ToString("D" + sequencePadding) + sequencePostfix);

                                                                }

                                                            }
                                                            else
                                                            {

                                                                int locIdx = formatString.ToUpper().IndexOf("[SEQ]");
                                                                if (locIdx >= 0)
                                                                {
                                                                    formatString = formatString.Remove(locIdx, 5);
                                                                    formatString = formatString.Insert(locIdx, sequenceValue.ToString("D" + sequencePadding));
                                                                }
                                                                //formatString = formatString.Replace("[seq]", sequenceValue.ToString("D" + sequencePadding));

                                                                if (inObject.Fields.get_Field(intFldIdxs[0]).Length < formatString.Length && inObject.Fields.get_Field(intFldIdxs[0]).Length != 0)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + formatString + " is to long for field " + row.Fields.get_Field(sequenceColumnNum).AliasName);
                                                                }
                                                                else
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], formatString.Trim());
                                                                    AAState.WriteLine("                  " + inObject.Fields.get_Field(intFldIdxs[0]).AliasName + " set to " + formatString);
                                                                }

                                                            }
                                                        else
                                                        {

                                                            inObject.set_Value(intFldIdxs[0], sequenceValue);
                                                            AAState.WriteLine("                  " + sequenceColumnNum + " changed to " + sequenceValue);
                                                        }
                                                    }

                                                }
                                                else
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ap"));

                                                }

                                            }

                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID: " + ex.Message);
                                            }
                                            finally
                                            {
                                                if (cCurs != null)
                                                {
                                                    Marshal.ReleaseComObject(cCurs);
                                                    GC.Collect(300);
                                                    GC.WaitForFullGCComplete();
                                                    cCurs = null;

                                                }
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "GENERATE_ID");
                                            }
                                            break;

                                        case "GENERATE_ID_BY_INTERSECT":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "GENERATE_ID_BY_INTERSECT");
                                                if (AAState._gentab != null && inFeature != null && !(inFeature.Shape.IsEmpty))
                                                {
                                                    sequenceColumnName = "";
                                                    sequenceColumnNum = -1;
                                                    sequenceValue = -1;
                                                    sequenceFixedWidth = "";
                                                    sequencePadding = 0;
                                                    //genIdAreaFieldName = "";
                                                    intersectLayerName = "";
                                                    intersectLayerFieldName = "";
                                                    formatString = "";
                                                    intersectFieldPos = -1;

                                                    // Parse arguments
                                                    if (valData == null) break;

                                                    args = valData.Split('|');
                                                    if (args.GetLength(0) < 3)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ap"));
                                                        break;
                                                    }
                                                    switch (args.GetLength(0))
                                                    {
                                                        case 3:  //columnName
                                                            intersectLayerName = args[0].ToString();
                                                            intersectLayerFieldName = args[1].ToString();
                                                            // genIdAreaFieldName = args[2].ToString();
                                                            sequenceColumnName = args[2].ToString();
                                                            break;
                                                        case 4:  // columnName|sequenceFixedWidth
                                                            //sequenceFixedWidth formats the sequence with leading zeros to create specified width
                                                            intersectLayerName = args[0].ToString();
                                                            intersectLayerFieldName = args[1].ToString();
                                                            //genIdAreaFieldName = args[2].ToString();
                                                            sequenceColumnName = args[2].ToString();
                                                            sequenceFixedWidth = Convert.ToString(0);
                                                            formatString = args[3].ToString();

                                                            break;
                                                        case 5:  // columnName|sequenceFixedWidth|formatString
                                                            //formatString must contain [seq] and [id]  and may contain [area] plus any desired text
                                                            intersectLayerName = args[0].ToString();
                                                            intersectLayerFieldName = args[1].ToString();
                                                            //genIdAreaFieldName = args[2].ToString();
                                                            sequenceColumnName = args[2].ToString();
                                                            sequenceFixedWidth = args[3].ToString();
                                                            formatString = args[4].ToString();
                                                            break;
                                                        default: break;
                                                    }

                                                    //Find Area Layer
                                                    // FindLayerByName(areaLayerName, out areaLayer);

                                                    boolLayerOrFC = true;
                                                    if (intersectLayerName.Contains("("))
                                                    {
                                                        string[] tempSplt = intersectLayerName.Split('(');
                                                        intersectLayerName = tempSplt[0];
                                                        intersectLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC);
                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                        {
                                                            boolLayerOrFC = false;
                                                        }
                                                        else
                                                        {
                                                            boolLayerOrFC = true;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        intersectLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, intersectLayerName, ref boolLayerOrFC);

                                                    }
                                                    if (intersectLayer == null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aq") +"(" + intersectLayerName + ") not found");
                                                        break;
                                                    }
                                                    //Find Area Field
                                                    intersectFieldPos = intersectLayer.FeatureClass.FindField(intersectLayerFieldName);
                                                    if (intersectFieldPos < 0)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14as") +"(" + intersectLayerFieldName + ") not found");
                                                        break;
                                                    }

                                                    //Perform spatial search
                                                    IGeometry pSearchGeo = Globals.GetGeomCenter((IGeometry)inFeature.ShapeCopy)[0];
                                                    pSearchGeo.SpatialReference = (inFeature.Class as IGeoDataset).SpatialReference;
                                                    pSearchGeo.Project((intersectLayer as IGeoDataset).SpatialReference);

                                                    sFilter = Globals.createSpatialFilter(intersectLayer, inFeature, false);

                                                    pFS = (IFeatureSelection)intersectLayer;
                                                    if (boolLayerOrFC)
                                                    {
                                                        if (pFS.SelectionSet.Count > 0)
                                                        {
                                                            pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                            fCursor = cCurs as IFeatureCursor;

                                                        }
                                                        else
                                                        {
                                                            fCursor = intersectLayer.Search(sFilter, true);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        fCursor = intersectLayer.FeatureClass.Search(sFilter, true);
                                                    }

                                                    sourceFeature = fCursor.NextFeature();
                                                    intersectValue = "-9999.1";
                                                    if (sourceFeature == null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14at"));
                                                        break;
                                                    }
                                                    else
                                                    {
                                                        while (sourceFeature != null)
                                                        {
                                                            if (sourceFeature.Class != inFeature.Class)
                                                            {
                                                                intersectValue = sourceFeature.get_Value(intersectFieldPos).ToString();
                                                                break;
                                                            }
                                                            else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                            {
                                                                intersectValue = sourceFeature.get_Value(intersectFieldPos).ToString();
                                                                break;
                                                            }
                                                            sourceFeature = fCursor.NextFeature();
                                                        }
                                                    }
                                                    if (intersectValue == "-9999.1")
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14at"));
                                                        break;
                                                    }
                                                    //Check for requested zero padding of sequence number
                                                    if (sequenceFixedWidth != "")
                                                        int.TryParse(sequenceFixedWidth.ToString(), out sequencePadding);

                                                    if (sequencePadding > 25)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain116"));
                                                        AAState.WriteLine("                  WARNING: " + sequencePadding + " 0's is what you have");

                                                    }
                                                    sequenceColumnName = sequenceColumnName + intersectValue;
                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bn") + sequenceColumnName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bo"));

                                                    qFilter = new QueryFilterClass();
                                                    qFilter.WhereClause = "SEQNAME = '" + sequenceColumnName + "'";
                                                    cCurs = AAState._gentab.Update(qFilter, false);
                                                    sequenceColumnNum = AAState._gentab.Fields.FindField("SEQCOUNTER");

                                                    //get value of first row, increment it, and return incremented value
                                                    for (int j = 0; j < 51; j++)
                                                    {
                                                        row = cCurs.NextRow();
                                                        if (row == null)
                                                        {
                                                            break;
                                                        }
                                                        if (row.get_Value(sequenceColumnNum) == null)
                                                        {
                                                            sequenceValue = 0;
                                                        }
                                                        else if (row.get_Value(sequenceColumnNum).ToString() == "")
                                                        {
                                                            sequenceValue = 0;
                                                        }
                                                        else
                                                            sequenceValue = Convert.ToInt32(row.get_Value(sequenceColumnNum));

                                                        int sequenceInt = 1;

                                                        if (AAState._gentab.Fields.FindField("SEQINTERV") > 0)
                                                        {
                                                            if (row.get_Value(AAState._gentab.Fields.FindField("SEQINTERV")) != null)
                                                            {
                                                                if (row.get_Value(AAState._gentab.Fields.FindField("SEQINTERV")) != DBNull.Value)
                                                                    sequenceInt = Convert.ToInt32(row.get_Value(AAState._gentab.Fields.FindField("SEQINTERV")));
                                                            }
                                                        }
                                                        sequenceValue = sequenceValue + sequenceInt;

                                                        row.set_Value(sequenceColumnNum, sequenceValue);

                                                        row.Store();

                                                        if (Convert.ToInt32(row.get_Value(sequenceColumnNum)) == sequenceValue)
                                                            break;

                                                    }
                                                    if (sequenceValue == -1)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14au"));
                                                    }
                                                    else
                                                    {
                                                        if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeString)
                                                            if (formatString == null || formatString == "" || (formatString.ToUpper().IndexOf("[SEQ]") == -1 && formatString.ToUpper().IndexOf("[ID]") == -1))
                                                                inObject.set_Value(intFldIdxs[0], intersectValue + sequenceValue.ToString("D" + sequencePadding) + sequencePostfix);
                                                            else
                                                            {

                                                                int locIdx = formatString.ToUpper().IndexOf("[ID]");
                                                                if (locIdx >= 0)
                                                                {
                                                                    formatString = formatString.Remove(locIdx, 4);
                                                                    formatString = formatString.Insert(locIdx, intersectValue);
                                                                }

                                                                locIdx = formatString.ToUpper().IndexOf("[SEQ]");
                                                                if (locIdx >= 0)
                                                                {
                                                                    string sequenceValuePad = sequenceValue.ToString("D" + sequencePadding);
                                                                    formatString = formatString.Remove(locIdx, 5);
                                                                    formatString = formatString.Insert(locIdx, sequenceValuePad.ToString());
                                                                }
                                                                //
                                                                inObject.set_Value(intFldIdxs[0], formatString);
                                                            }
                                                        else
                                                            inObject.set_Value(intFldIdxs[0], sequenceValue);
                                                    }

                                                }
                                                else
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ap"));

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID_BY_INTERSECT: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "GENERATE_ID_BY_INTERSECT");
                                            }
                                            break;

                                        //Modified for Release 1.2  (No longer uses ICalculator)
                                        //Requires valid VBScript expression
                                        //Can include string, numeric, and date fields by name in square brackets []
                                        //Example: DateDiff("yyyy",[INSTALLDATE],Now())
                                        case "EXPRESSION":
                                            try
                                            {

                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "EXPRESSION");
                                                if (inObject != null & valData != null)
                                                {
                                                    int intTargetFld = -1;
                                                    if (intFldIdxs.Count == 0)
                                                    {

                                                    }
                                                    else
                                                    {
                                                        intTargetFld = intFldIdxs[0];
                                                    }

                                                    newValue = valData;
                                                    for (int i = 0; i <= inObject.Fields.FieldCount; i++)
                                                    {

                                                        string strTmpFldName;
                                                        int intTmpIdx;
                                                        if (i == inObject.Fields.FieldCount)
                                                        {
                                                            testField = inObject.Fields.get_Field(intFldIdxs[0]);
                                                            strTmpFldName = "#";
                                                            intTmpIdx = intFldIdxs[0];
                                                        }
                                                        else
                                                        {
                                                            testField = inObject.Fields.get_Field(i);
                                                            strTmpFldName = testField.Name;
                                                            intTmpIdx = i;
                                                        }

                                                        int indFld = newValue.ToUpper().IndexOf("[" + strTmpFldName.ToUpper() + "]");
                                                        while (indFld >= 0)
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bp") + testField.Name + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bq"));
                                                            int fldLen = strTmpFldName.Length;
                                                            string tmpStr1 = newValue.Substring(0, indFld + 1);
                                                            string tmpStr2 = newValue.Substring(indFld + fldLen + 1);
                                                            newValue = tmpStr1 + "_REPLACE_VAL_" + tmpStr2;

                                                            switch (testField.Type)
                                                            {
                                                                case esriFieldType.esriFieldTypeString:

                                                                    if (inObject.get_Value(intTmpIdx) == null || inObject.get_Value(intTmpIdx).ToString() == "")
                                                                    {
                                                                        if (newValue.Contains("IsNull"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("isNull"))
                                                                        {
                                                                            newValue = newValue.Replace("isNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("ISNULL"))
                                                                        {
                                                                            newValue = newValue.Replace("ISNULL([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == null)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == DBNull.Value)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx).ToString() == "")
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                        else
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        if (newValue.Contains("IsNull"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False");
                                                                        }

                                                                        else
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                    }

                                                                    break;
                                                                case esriFieldType.esriFieldTypeDate:

                                                                    if (inObject.get_Value(intTmpIdx) == null || inObject.get_Value(intTmpIdx).ToString() == "" || inObject.get_Value(intTmpIdx) == DBNull.Value)
                                                                    {
                                                                        if (newValue.Contains("IsNull([" + "_REPLACE_VAL_" + "])"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("isNull([" + "_REPLACE_VAL_" + "])"))
                                                                        {
                                                                            newValue = newValue.Replace("isNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("ISNULL([" + "_REPLACE_VAL_" + "])"))
                                                                        {
                                                                            newValue = newValue.Replace("ISNULL([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == null)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == DBNull.Value)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");//"\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx).ToString() == "")
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + inObject.get_Value(intTmpIdx).ToString() + "\"");
                                                                        }
                                                                        else
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "CDATE(\"" + inObject.get_Value(intTmpIdx).ToString() + "\")");
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        if (newValue.Contains("IsNull"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False");
                                                                        }

                                                                        else
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "CDATE(\"" + inObject.get_Value(intTmpIdx).ToString() + "\")");
                                                                        }
                                                                    }

                                                                    break;
                                                                case esriFieldType.esriFieldTypeDouble:

                                                                    if (inObject.get_Value(intTmpIdx) == null || inObject.get_Value(intTmpIdx).ToString() == "")
                                                                    {
                                                                        if (newValue.Contains("IsNull"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("isNull"))
                                                                        {
                                                                            newValue = newValue.Replace("isNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("ISNULL"))
                                                                        {
                                                                            newValue = newValue.Replace("ISNULL([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == null)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == DBNull.Value)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx).ToString() == "")
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");
                                                                        }
                                                                        else
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "" + inObject.get_Value(intTmpIdx).ToString() + "");
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        if (newValue.Contains("IsNull"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False");
                                                                        }

                                                                        else
                                                                        {

                                                                            double val;
                                                                            Double.TryParse(inObject.get_Value(intTmpIdx).ToString(), out val);

                                                                            // '  string test2 = test.ToString("N",nfi);
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", val.ToString("N", nfi));
                                                                        }
                                                                    }

                                                                    break;

                                                                default:
                                                                    if (inObject.get_Value(intTmpIdx) == null || inObject.get_Value(intTmpIdx).ToString() == "")
                                                                    {
                                                                        if (newValue.Contains("IsNull"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("isNull"))
                                                                        {
                                                                            newValue = newValue.Replace("isNull([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (newValue.Contains("ISNULL"))
                                                                        {
                                                                            newValue = newValue.Replace("ISNULL([" + "_REPLACE_VAL_" + "])", "True");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == null)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx) == DBNull.Value)
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");
                                                                        }
                                                                        else if (inObject.get_Value(intTmpIdx).ToString() == "")
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");
                                                                        }
                                                                        else
                                                                        {
                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "" + inObject.get_Value(intTmpIdx).ToString() + "");
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        if (newValue.Contains("IsNull"))
                                                                        {
                                                                            newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False");
                                                                        }

                                                                        else
                                                                        {

                                                                            newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", inObject.get_Value(intTmpIdx).ToString());
                                                                        }
                                                                    }

                                                                    break;
                                                            }
                                                            indFld = newValue.ToUpper().IndexOf("[" + testField.Name.ToUpper() + "]");
                                                        }
                                                    }

                                                    try
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain118"));
                                                        if (intTargetFld > -1)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14br") + newValue);

                                                            newValue = script.Eval(newValue).ToString();
                                                            if (newValue.ToUpper() == "<Null>".ToUpper())
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain119"));
                                                                inObject.set_Value(intTargetFld, DBNull.Value);
                                                            }
                                                            else if (inObject.get_Value(intTargetFld).ToString() != newValue)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain120") + newValue.Trim());
                                                                inObject.set_Value(intTargetFld, newValue.Trim());
                                                            }
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14av") + inObject.Class.AliasName + " with OID of " + inObject.OID);
                                                        AAState.WriteLine("                         " + ex.Message);
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "EXPRESSION: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "EXPRESSION");
                                            }
                                            break;

                                        // GUID values are calculated into text fields or into native GUID field types
                                        // When using text field you have an optional argument (valdata) to specify the format
                                        // N-none 32 chars, D-dash 36, B-braces 38, P-Parenthesis 38
                                        case "GUID":
                                            try
                                            {
                                                if (inObject != null)
                                                {
                                                    if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeGUID)
                                                        inObject.set_Value(intFldIdxs[0], System.Guid.NewGuid().ToString("B"));
                                                    else if (inObject.Fields.get_Field(intFldIdxs[0]).Type == esriFieldType.esriFieldTypeString &&
                                                             inObject.Fields.get_Field(intFldIdxs[0]).Length >= 32)
                                                    {

                                                        valData = valData.Trim();
                                                        if (valData != "N" && valData != "D" && valData != "B" && valData != "P")
                                                            if (inObject.Fields.get_Field(intFldIdxs[0]).Length >= 38)
                                                                valData = "B";  //Default to braces
                                                            else if (inObject.Fields.get_Field(intFldIdxs[0]).Length < 36)
                                                                valData = "N";
                                                            else
                                                                valData = "D";
                                                        inObject.set_Value(intFldIdxs[0], System.Guid.NewGuid().ToString(valData));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "EXPRESSION: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "EXPRESSION");
                                            }
                                            break;

                                        case "CREATE_LINKED_RECORD"://Feature Layer|Field To Copy|Field To Populate|Primary Key Field|Foreign Key Field
                                            {
                                                try
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "CREATE_LINKED_RECORD");
                                                    if (!String.IsNullOrEmpty(valData))
                                                    {
                                                        args = valData.Split('|');
                                                        if (args.Length < 5)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad"));
                                                            break;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad"));
                                                        break;
                                                    }
                                                    if (inObject == null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ak"));
                                                        break;
                                                    }
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    sourceField = -1;
                                                    found = false;
                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bs"));
                                                    sourceLayerNames = args[0].ToString().Split(',');
                                                    sourceFieldName = args[1].ToString().Trim();
                                                    string targetFieldName = args[2].ToString().Trim();
                                                    string sourceIDFieldName = args[3].ToString().Trim();
                                                    string targetIDFieldName = args[4].ToString().Trim();
                                                    int countFld = 1;
                                                    if (args.Length == 6)
                                                    {

                                                        if (!Globals.IsNumeric(args[5].ToString().Trim()))
                                                        {
                                                            int fldx = Globals.GetFieldIndex(inObject.Fields, args[5].ToString().Trim());

                                                            if (fldx > 0)
                                                            {
                                                                string tempVal = inObject.get_Value(fldx).ToString();
                                                                if (Globals.IsNumeric(tempVal))
                                                                    countFld = Convert.ToInt32(tempVal);

                                                            }

                                                        }
                                                        else
                                                        {
                                                            countFld = Convert.ToInt32(args[5].ToString().Trim());

                                                        }

                                                    }
                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bt"));
                                                    if (sourceFieldName != null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain121"));
                                                        int fldValToCopyIdx = Globals.GetFieldIndex(inObject.Fields, sourceFieldName);
                                                        int fldIDToCopyIdx = Globals.GetFieldIndex(inObject.Fields, sourceIDFieldName);
                                                        if (fldValToCopyIdx > -1 && fldIDToCopyIdx > -1)
                                                        {

                                                            for (int i = 0; i < sourceLayerNames.Length; i++)
                                                            {
                                                                sourceLayerName = sourceLayerNames[i].ToString().Trim();

                                                                if (sourceLayerName != "")
                                                                {

                                                                    // Get layer
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain122"));
                                                                    bool FCorLayerSource = true;
                                                                    sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref FCorLayerSource);

                                                                    if (sourceLayer != null)
                                                                    {
                                                                        AAState.WriteLine("                  " + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));

                                                                    }
                                                                    else
                                                                    {
                                                                        ITable pTable = Globals.FindTable(AAState._editor.Map, sourceLayerName);
                                                                        if (pTable != null)
                                                                        {
                                                                            int fldValToPopIdx = Globals.GetFieldIndex(pTable.Fields, targetFieldName);
                                                                            int fldIDToPopIdx = Globals.GetFieldIndex(pTable.Fields, targetIDFieldName);
                                                                            if (fldValToPopIdx > -1 && fldIDToPopIdx > -1)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain123"));
                                                                                IRow pNewRow;
                                                                                for (int j = 0; j < countFld; j++)
                                                                                {
                                                                                    pNewRow = pTable.CreateRow();
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain124"));
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain125"));
                                                                                    try
                                                                                    {
                                                                                        pNewRow.set_Value(fldIDToPopIdx, inObject.get_Value(fldIDToCopyIdx));

                                                                                    }
                                                                                    catch
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + inObject.get_Value(fldIDToCopyIdx) + " to field: " + targetIDFieldName);
                                                                                    }
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain126"));
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain127"));
                                                                                    try
                                                                                    {
                                                                                        pNewRow.set_Value(fldValToPopIdx, inObject.get_Value(fldValToCopyIdx));

                                                                                    }
                                                                                    catch
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + inObject.get_Value(fldValToCopyIdx) + " to field: " + targetFieldName);
                                                                                    }
                                                                                    if (NewFeatureList == null)
                                                                                    {
                                                                                        NewFeatureList = new List<IObject>();
                                                                                    }
                                                                                    IObject featobj = pNewRow as IObject;

                                                                                    if (featobj != null)
                                                                                    {
                                                                                        NewFeatureList.Add(featobj);
                                                                                    }

                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain128"));
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14k"));
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ax") + sourceLayerName);
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ay"));
                                                        }

                                                    }

                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CREATE_LINKED_RECORD" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "CREATE_LINKED_RECORD");

                                                }
                                                break;

                                            }

                                        case "UPDATE_INTERSECTING_FEATURE"://Intersected Feature|FieldIntersectingFeatureToChange|FromFieldinModifiedFeature
                                            {
                                                try
                                                {
                                                    IFeatureCursor fLocalCursor = null;
                                                    IFeature sourceFeatureLocal = null;
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "UPDATE_INTERSECTING_FEATURE");
                                                    if (!String.IsNullOrEmpty(valData))
                                                    {
                                                        args = valData.Split('|');
                                                        if (args.Length != 3)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad"));
                                                            break;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ad"));
                                                        break;
                                                    }
                                                    if (inFeature == null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ak"));
                                                        break;
                                                    }
                                                    bool cont = true;
                                                    if (intFldIdxs.Count > 1)
                                                    {
                                                        IRowChanges inChanges = inObject as IRowChanges;
                                                        if (inChanges.get_ValueChanged(intFldIdxs[0]))
                                                        {
                                                            cont = true;
                                                        }
                                                        else
                                                        {
                                                            cont = false;
                                                        }

                                                        inChanges = null;

                                                    }
                                                    if (cont)
                                                    {

                                                        sourceLayerName = "";
                                                        sourceFieldName = "";
                                                        sourceField = -1;
                                                        found = false;
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bs"));
                                                        sourceLayerNames = args[0].ToString().Split(',');
                                                        sourceFieldName = args[1].ToString().Trim();
                                                        string targetFieldName = args[2].ToString().Trim();
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bt"));
                                                        if (sourceFieldName != null)
                                                        {
                                                            for (int i = 0; i < sourceLayerNames.Length; i++)
                                                            {
                                                                sourceLayerName = sourceLayerNames[i].ToString().Trim();
                                                                if (sourceLayerName != "")
                                                                {

                                                                    boolLayerOrFC = true;
                                                                    if (sourceLayerName.Contains("("))
                                                                    {
                                                                        string[] tempSplt = sourceLayerName.Split('(');
                                                                        sourceLayerName = tempSplt[0].Trim();
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                    }
                                                                    if (sourceLayer != null)
                                                                    {

                                                                        if (Globals.IsEditable(ref sourceLayer, ref AAState._editor))
                                                                        {

                                                                            if (inObject.Class.ObjectClassID != sourceLayer.FeatureClass.ObjectClassID)
                                                                            {
                                                                                sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName);

                                                                                if (sourceField > -1)
                                                                                {
                                                                                    sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false);

                                                                                    int fldIdx = Globals.GetFieldIndex(inFeature.Fields, targetFieldName);
                                                                                    AAState.WriteLine("                  " + targetFieldName + " at index " + fldIdx);
                                                                                    string test = targetFieldName;
                                                                                    if (fldIdx > -1)
                                                                                    {
                                                                                        test = inFeature.get_Value(fldIdx).ToString().Trim();
                                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bu") + test);
                                                                                    }
                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bv") + test);

                                                                                    pFS = (IFeatureSelection)sourceLayer;
                                                                                    if (boolLayerOrFC)
                                                                                    {
                                                                                        if (pFS.SelectionSet.Count > 0)
                                                                                        {
                                                                                            pFS.SelectionSet.Search(sFilter, false, out cCurs);
                                                                                            fLocalCursor = cCurs as IFeatureCursor;

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            fLocalCursor = sourceLayer.Search(sFilter, false);
                                                                                        }
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        fLocalCursor = sourceLayer.FeatureClass.Search(sFilter, false);
                                                                                    }

                                                                                    while ((sourceFeatureLocal = fLocalCursor.NextFeature()) != null)
                                                                                    {
                                                                                        try
                                                                                        {
                                                                                            if (sourceFeatureLocal.Class.ObjectClassID != inFeature.Class.ObjectClassID)
                                                                                            {
                                                                                                if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeString)
                                                                                                {
                                                                                                    sourceFeatureLocal.set_Value(sourceField, test);

                                                                                                    if (ChangeFeatureList == null)
                                                                                                    {
                                                                                                        ChangeFeatureList = new List<IObject>();
                                                                                                    }
                                                                                                    ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                    found = true;

                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    if (Globals.IsNumeric(test))
                                                                                                    {
                                                                                                        if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeSmallInteger ||
                                                                                                            sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeInteger)
                                                                                                        {

                                                                                                            sourceFeatureLocal.set_Value(sourceField, Convert.ToInt32(test));

                                                                                                            if (ChangeFeatureList == null)
                                                                                                            {
                                                                                                                ChangeFeatureList = new List<IObject>();
                                                                                                            }
                                                                                                            ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                            found = true;
                                                                                                            //break;
                                                                                                        }
                                                                                                        else if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeDouble ||
                                                                                                            sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeSingle)
                                                                                                        {
                                                                                                            sourceFeatureLocal.set_Value(sourceField, Convert.ToDouble(test));

                                                                                                            if (ChangeFeatureList == null)
                                                                                                            {
                                                                                                                ChangeFeatureList = new List<IObject>();
                                                                                                            }
                                                                                                            ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                            found = true;

                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            sourceFeatureLocal.set_Value(sourceField, test as object);

                                                                                                            if (ChangeFeatureList == null)
                                                                                                            {
                                                                                                                ChangeFeatureList = new List<IObject>();
                                                                                                            }
                                                                                                            ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                            found = true;

                                                                                                        }
                                                                                                    }
                                                                                                    else
                                                                                                    {
                                                                                                        sourceFeatureLocal.set_Value(sourceField, test as object);

                                                                                                        if (ChangeFeatureList == null)
                                                                                                        {
                                                                                                            ChangeFeatureList = new List<IObject>();
                                                                                                        }
                                                                                                        ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                        found = true;

                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                            else if (sourceFeatureLocal.Class == inFeature.Class && sourceFeatureLocal.OID != inFeature.OID)
                                                                                            {
                                                                                                if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeString)
                                                                                                {
                                                                                                    sourceFeatureLocal.set_Value(sourceField, test);

                                                                                                    if (ChangeFeatureList == null)
                                                                                                    {
                                                                                                        ChangeFeatureList = new List<IObject>();
                                                                                                    }
                                                                                                    ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                    found = true;

                                                                                                }
                                                                                                else
                                                                                                {
                                                                                                    if (Globals.IsNumeric(test))
                                                                                                    {
                                                                                                        if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeSmallInteger ||
                                                                                                            sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeInteger)
                                                                                                        {

                                                                                                            sourceFeatureLocal.set_Value(sourceField, Convert.ToInt32(test));

                                                                                                            if (ChangeFeatureList == null)
                                                                                                            {
                                                                                                                ChangeFeatureList = new List<IObject>();
                                                                                                            }
                                                                                                            ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                            found = true;

                                                                                                        }
                                                                                                        else if (sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeDouble ||
                                                                                                            sourceFeatureLocal.Fields.get_Field(sourceField).Type == esriFieldType.esriFieldTypeSingle)
                                                                                                        {
                                                                                                            sourceFeatureLocal.set_Value(sourceField, Convert.ToDouble(test));

                                                                                                            if (ChangeFeatureList == null)
                                                                                                            {
                                                                                                                ChangeFeatureList = new List<IObject>();
                                                                                                            }
                                                                                                            ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                            found = true;

                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            sourceFeatureLocal.set_Value(sourceField, test as object);

                                                                                                            if (ChangeFeatureList == null)
                                                                                                            {
                                                                                                                ChangeFeatureList = new List<IObject>();
                                                                                                            }
                                                                                                            ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                            found = true;

                                                                                                        }
                                                                                                    }
                                                                                                    else
                                                                                                    {
                                                                                                        sourceFeatureLocal.set_Value(sourceField, test as object);

                                                                                                        if (ChangeFeatureList == null)
                                                                                                        {
                                                                                                            ChangeFeatureList = new List<IObject>();
                                                                                                        }
                                                                                                        ChangeFeatureList.Add(sourceFeatureLocal);
                                                                                                        found = true;

                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                        catch
                                                                                        {
                                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14al"));
                                                                                        }
                                                                                        finally
                                                                                        {

                                                                                        }

                                                                                    }

                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName);
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14b") + sourceLayerName);
                                                                        }

                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName);
                                                                    }
                                                                }
                                                            }
                                                            if (found)
                                                            {
                                                                break;

                                                            }

                                                        }

                                                    }
                                                    fLocalCursor = null;
                                                    sourceFeatureLocal = null;
                                                }
                                                catch (Exception ex)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "UPDATE_INTERSECTING_FEATURE" + Environment.NewLine + ex.Message);
                                                }

                                                finally
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_INTERSECTING_FEATURE");

                                                }
                                                break;

                                            }
                                        case "MULTI_FIELD_INTERSECT":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "MULTI_FIELD_INTERSECT");
                                                if (inFeature != null & valData != null)
                                                {
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    sourceField = -1;
                                                    found = false;
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    int popFldIdx = 0;
                                                    if (args.GetLength(0) > 2)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain114"));

                                                        sourceLayerNames = args[0].ToString().Split(',');
                                                        sourceFieldName = args[1].ToString().Trim();
                                                        string[] fieldsToPop = args[2].ToString().Split(',');
                                                        if (args.GetLength(0) == 4)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain129"));

                                                            if (Globals.IsDouble(args[3]))
                                                            {
                                                                searchDistance = Convert.ToDouble(args[3]);
                                                            }
                                                            else
                                                            {
                                                                searchDistance = 0.0;
                                                            }
                                                        }
                                                        else
                                                        {

                                                            searchDistance = 0.0;
                                                        }

                                                        if (sourceFieldName != null)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain130"));

                                                            for (int i = 0; i < sourceLayerNames.Length; i++)
                                                            {
                                                                if (fieldsToPop.Length == popFldIdx)
                                                                    break;

                                                                sourceLayerName = sourceLayerNames[i].ToString().Trim();
                                                                if (sourceLayerName != "")
                                                                {

                                                                    boolLayerOrFC = true;
                                                                    if (sourceLayerName.Contains("("))
                                                                    {
                                                                        string[] tempSplt = sourceLayerName.Split('(');
                                                                        sourceLayerName = tempSplt[0].Trim();
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                    }

                                                                    else
                                                                    {
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                    }
                                                                    if (sourceLayer != null)
                                                                    {
                                                                        if (sourceLayer.FeatureClass != null)
                                                                        {
                                                                            sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName);

                                                                            if (sourceField > -1)
                                                                            {

                                                                                sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false);

                                                                                pFS = (IFeatureSelection)sourceLayer;
                                                                                if (boolLayerOrFC)
                                                                                {
                                                                                    if (pFS.SelectionSet.Count > 0)
                                                                                    {
                                                                                        pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                                        fCursor = cCurs as IFeatureCursor;

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        fCursor = sourceLayer.Search(sFilter, true);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                                }

                                                                                while ((sourceFeature = fCursor.NextFeature()) != null)
                                                                                {
                                                                                    if (sourceFeature.Class != inFeature.Class)
                                                                                    {
                                                                                        if (fieldsToPop.Length == popFldIdx)
                                                                                            break;

                                                                                        string test = sourceFeature.get_Value(sourceField).ToString().Trim();

                                                                                        int tempFieldNum = Globals.GetFieldIndex(inObject.Fields, fieldsToPop[popFldIdx]);
                                                                                        popFldIdx++;
                                                                                        if (tempFieldNum > -1)
                                                                                        {
                                                                                            inObject.set_Value(tempFieldNum, sourceFeature.get_Value(sourceField));
                                                                                        }

                                                                                    }
                                                                                    else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                                    {
                                                                                        if (fieldsToPop.Length == popFldIdx)
                                                                                            break;

                                                                                        string test = sourceFeature.get_Value(sourceField).ToString().Trim();

                                                                                        int tempFieldNum = Globals.GetFieldIndex(inObject.Fields, fieldsToPop[popFldIdx]);
                                                                                        popFldIdx++;
                                                                                        if (tempFieldNum > -1)
                                                                                        {
                                                                                            inObject.set_Value(tempFieldNum, sourceFeature.get_Value(sourceField));
                                                                                        }

                                                                                    }
                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14f") + sourceLayerName);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14e"));

                                                                }
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14az"));

                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ba"));

                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "MULTI_FIELD_INTERSECT: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "MULTI_FIELD_INTERSECT");
                                            }
                                            break;
                                        case "INTERSECT_STATS":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECT_STATS");
                                                if (inFeature != null & valData != null)
                                                {
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    sourceField = -1;
                                                    found = false;
                                                    //LayerToIntersect|Field To Elevate
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    int AverageCount = 0;
                                                    if (args.GetLength(0) > 2)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain114"));

                                                        sourceLayerNames = args[0].ToString().Split(',');
                                                        sourceFieldName = args[1].ToString().Trim();
                                                        string statType = args[2].ToString().Trim();
                                                        if (args.GetLength(0) == 4)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain129"));

                                                            if (Globals.IsDouble(args[3]))
                                                                searchDistance = Convert.ToDouble(args[3]);
                                                            else
                                                                searchDistance = 0.0;
                                                        }
                                                        else
                                                        {

                                                            searchDistance = 0.0;
                                                        }
                                                        double result = -999999.1;
                                                        string textRes = "";
                                                        if (sourceFieldName != null)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain130"));

                                                            for (int i = 0; i < sourceLayerNames.Length; i++)
                                                            {

                                                                sourceLayerName = sourceLayerNames[i].ToString().Trim();
                                                                if (sourceLayerName != "")
                                                                {
                                                                    boolLayerOrFC = true;
                                                                    if (sourceLayerName.Contains("("))
                                                                    {
                                                                        string[] tempSplt = sourceLayerName.Split('(');
                                                                        sourceLayerName = tempSplt[0].Trim();
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                    }

                                                                    else
                                                                    {
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);
                                                                    }

                                                                    if (sourceLayer != null)
                                                                    {
                                                                        if (sourceLayer.FeatureClass != null)
                                                                        {
                                                                            sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName);

                                                                            if (sourceField > -1)
                                                                            {

                                                                                sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false);

                                                                                pFS = (IFeatureSelection)sourceLayer;
                                                                                if (boolLayerOrFC)
                                                                                {
                                                                                    if (pFS.SelectionSet.Count > 0)
                                                                                    {
                                                                                        pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                                        fCursor = cCurs as IFeatureCursor;

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        fCursor = sourceLayer.Search(sFilter, true);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                                }
                                                                                sourceFeature = fCursor.NextFeature();
                                                                                while (sourceFeature != null)
                                                                                {
                                                                                    if (sourceFeature.Class != inFeature.Class)
                                                                                    {
                                                                                        string test = sourceFeature.get_Value(sourceField).ToString().Trim();
                                                                                        if (Globals.IsNumeric(test))
                                                                                        {

                                                                                            double valToTest = Convert.ToDouble(test);
                                                                                            if (result == -999999.1)
                                                                                            {
                                                                                                result = valToTest;

                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                switch (statType.ToUpper())
                                                                                                {
                                                                                                    case "MAX":
                                                                                                        if (result < valToTest)
                                                                                                        {
                                                                                                            result = valToTest;

                                                                                                        }
                                                                                                        break;
                                                                                                    case "MIN":
                                                                                                        if (result > valToTest)
                                                                                                        {
                                                                                                            result = valToTest;

                                                                                                        }
                                                                                                        break;
                                                                                                    case "SUM":
                                                                                                        result += valToTest;

                                                                                                        break;
                                                                                                    case "AVERAGE":
                                                                                                        result += valToTest;
                                                                                                        AverageCount++;
                                                                                                        break;
                                                                                                    case "MEAN":
                                                                                                        result += valToTest;
                                                                                                        AverageCount++;

                                                                                                        break;
                                                                                                    case "CONCAT":
                                                                                                        if (textRes.Contains(valToTest.ToString() + ConcatDelim))
                                                                                                        {
                                                                                                        }
                                                                                                        else if (textRes.Contains(ConcatDelim + valToTest.ToString()))
                                                                                                        {
                                                                                                        }
                                                                                                        else
                                                                                                        {

                                                                                                            if (textRes == "")
                                                                                                            {
                                                                                                                textRes += valToTest.ToString();
                                                                                                            }
                                                                                                            else
                                                                                                            {
                                                                                                                textRes += ConcatDelim + valToTest.ToString();
                                                                                                            }

                                                                                                        }

                                                                                                        break;
                                                                                                    default:
                                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test);
                                                                                                        break;
                                                                                                }

                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            switch (statType.ToUpper())
                                                                                            {

                                                                                                case "CONCAT":
                                                                                                    if (textRes.Contains(test.ToString() + ConcatDelim))
                                                                                                    {
                                                                                                    }
                                                                                                    else if (textRes.Contains(ConcatDelim + test.ToString()))
                                                                                                    {
                                                                                                    }
                                                                                                    else
                                                                                                    {

                                                                                                        if (textRes == "")
                                                                                                        {
                                                                                                            textRes += test;
                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            textRes += ConcatDelim + test;
                                                                                                        }
                                                                                                    }

                                                                                                    break;
                                                                                                default:
                                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14d") + test);

                                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test);
                                                                                                    break;
                                                                                            }

                                                                                        }

                                                                                    }
                                                                                    else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                                    {
                                                                                        string test = sourceFeature.get_Value(sourceField).ToString();
                                                                                        if (Globals.IsNumeric(test))
                                                                                        {

                                                                                            double valToTest = Convert.ToDouble(test);
                                                                                            if (result == -999999.1)
                                                                                            {
                                                                                                result = valToTest;

                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                switch (statType.ToUpper())
                                                                                                {
                                                                                                    case "MAX":
                                                                                                        if (result < valToTest)
                                                                                                        {
                                                                                                            result = valToTest;

                                                                                                        }
                                                                                                        break;
                                                                                                    case "MIN":
                                                                                                        if (result > valToTest)
                                                                                                        {
                                                                                                            result = valToTest;

                                                                                                        }
                                                                                                        break;
                                                                                                    case "SUM":
                                                                                                        result += valToTest;

                                                                                                        break;
                                                                                                    case "AVERAGE":
                                                                                                        result += valToTest;
                                                                                                        AverageCount++;
                                                                                                        break;
                                                                                                    case "MEAN":
                                                                                                        result += valToTest;
                                                                                                        AverageCount++;

                                                                                                        break;
                                                                                                    case "CONCAT":
                                                                                                        if (textRes.Contains(valToTest.ToString() + ConcatDelim))
                                                                                                        {
                                                                                                        }
                                                                                                        else if (textRes.Contains(ConcatDelim + valToTest.ToString()))
                                                                                                        {
                                                                                                        }
                                                                                                        else
                                                                                                        {

                                                                                                            if (textRes == "")
                                                                                                            {
                                                                                                                textRes += valToTest.ToString();
                                                                                                            }
                                                                                                            else
                                                                                                            {
                                                                                                                textRes += ConcatDelim + valToTest.ToString();
                                                                                                            }

                                                                                                        }
                                                                                                        break;
                                                                                                    default:
                                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test);
                                                                                                        break;
                                                                                                }

                                                                                            }
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            switch (statType.ToUpper())
                                                                                            {

                                                                                                case "CONCAT":
                                                                                                    if (textRes.Contains(test.ToString() + ConcatDelim))
                                                                                                    {
                                                                                                    }
                                                                                                    else if (textRes.Contains(ConcatDelim + test.ToString()))
                                                                                                    {
                                                                                                    }
                                                                                                    else
                                                                                                    {

                                                                                                        if (textRes == "")
                                                                                                        {
                                                                                                            textRes += test;
                                                                                                        }
                                                                                                        else
                                                                                                        {
                                                                                                            textRes += ConcatDelim + test;
                                                                                                        }

                                                                                                    }
                                                                                                    break;
                                                                                                default:
                                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14d") + test);

                                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test);
                                                                                                    break;
                                                                                            }

                                                                                        }
                                                                                    }
                                                                                    sourceFeature = fCursor.NextFeature();

                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14f") + sourceLayerName);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName);
                                                                    }
                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14e"));

                                                                }
                                                            }
                                                            try
                                                            {
                                                                if (textRes != "")
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], textRes);
                                                                }
                                                                else if (result != -999999.1)
                                                                {
                                                                    if (AverageCount != 0)
                                                                    {
                                                                        result = result / AverageCount;
                                                                    }
                                                                    inObject.set_Value(intFldIdxs[0], result);

                                                                }
                                                                else
                                                                {
                                                                    IField field = inObject.Fields.get_Field(intFldIdxs[0]);
                                                                    object newval = field.DefaultValue;
                                                                    if (newval == null)
                                                                    {
                                                                        if (field.IsNullable)
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[0], null);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], newval);
                                                                    }
                                                                }
                                                            }
                                                            catch (Exception ex)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.Message);

                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14az"));

                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ba"));

                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECT_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECT_STATS");
                                            }
                                            break;
                                        case "FEATURE_STATS":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FEATURE_STATS");
                                                if (inFeature != null & valData != null)
                                                {

                                                    sourceFieldName = "";
                                                    sourceField = -1;
                                                    found = false;
                                                    //LayerToIntersect|Field To Elevate
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    int AverageCount = 0;
                                                    if (args.GetLength(0) > 1)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain114"));

                                                        string[] sourceFieldNames = args[0].ToString().Split(',');
                                                        string statType = args[1].ToString();

                                                        double result = -999999.1;
                                                        string textRes = "";
                                                        if (sourceFieldNames != null)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain131"));

                                                            for (int i = 0; i < sourceFieldNames.Length; i++)
                                                            {

                                                                sourceFieldName = sourceFieldNames[i].ToString();
                                                                if (sourceFieldName != "")
                                                                {

                                                                    sourceField = Globals.GetFieldIndex(inObject.Fields, sourceFieldName);

                                                                    if (sourceField > -1)
                                                                    {
                                                                        string test = inObject.get_Value(sourceField).ToString();
                                                                        if (Globals.IsNumeric(test))
                                                                        {

                                                                            double valToTest = Convert.ToDouble(test);
                                                                            if (result == -999999.1)
                                                                            {
                                                                                result = valToTest;

                                                                            }
                                                                            else
                                                                            {
                                                                                switch (statType.ToUpper())
                                                                                {
                                                                                    case "MAX":
                                                                                        if (result < valToTest)
                                                                                        {
                                                                                            result = valToTest;

                                                                                        }
                                                                                        break;
                                                                                    case "MIN":
                                                                                        if (result > valToTest)
                                                                                        {
                                                                                            result = valToTest;

                                                                                        }
                                                                                        break;
                                                                                    case "SUM":
                                                                                        result += valToTest;

                                                                                        break;
                                                                                    case "AVERAGE":
                                                                                        result += valToTest;
                                                                                        AverageCount++;
                                                                                        break;
                                                                                    case "MEAN":
                                                                                        result += valToTest;
                                                                                        AverageCount++;

                                                                                        break;
                                                                                    case "CONCAT":
                                                                                        if (textRes.Contains(valToTest.ToString() + ConcatDelim))
                                                                                        {
                                                                                        }
                                                                                        else if (textRes.Contains(ConcatDelim + valToTest.ToString()))
                                                                                        {
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            if (textRes == "")
                                                                                            {
                                                                                                textRes += valToTest.ToString();
                                                                                            }
                                                                                            else
                                                                                            {
                                                                                                textRes += ConcatDelim + valToTest.ToString();
                                                                                            }
                                                                                        }

                                                                                        break;
                                                                                    default:
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test);
                                                                                        break;
                                                                                }

                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            switch (statType.ToUpper())
                                                                            {

                                                                                case "CONCAT":
                                                                                    if (textRes.Contains(test.ToString() + ConcatDelim))
                                                                                    {
                                                                                    }
                                                                                    else if (textRes.Contains(ConcatDelim + test.ToString()))
                                                                                    {
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        if (textRes == "")
                                                                                        {
                                                                                            textRes += test;
                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            textRes += ConcatDelim + test;
                                                                                        }
                                                                                    }

                                                                                    break;
                                                                                default:
                                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14d") + test);

                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test);
                                                                                    break;
                                                                            }
                                                                        }
                                                                    }
                                                                }

                                                            }
                                                            try
                                                            {
                                                                if (textRes != "")
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], textRes);
                                                                }
                                                                else if (result != -999999.1)
                                                                {
                                                                    if (AverageCount != 0)
                                                                    {
                                                                        result = result / AverageCount;
                                                                    }
                                                                    inObject.set_Value(intFldIdxs[0], result);

                                                                }
                                                                else
                                                                {
                                                                    IField field = inObject.Fields.get_Field(intFldIdxs[0]);
                                                                    object newval = field.DefaultValue;
                                                                    if (newval == null)
                                                                    {
                                                                        if (field.IsNullable)
                                                                        {
                                                                            inObject.set_Value(intFldIdxs[0], null);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        inObject.set_Value(intFldIdxs[0], newval);
                                                                    }
                                                                }
                                                            }
                                                            catch (Exception ex)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.Message);

                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14az"));

                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ba"));

                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "FEATURE_STATS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "FEATURE_STATS");
                                            }
                                            break;
                                        case "INTERSECTING_EDGE":
                                            try
                                            {
                                                if (valData == null) break;
                                                args = valData.Split('|');
                                                switch (args.GetLength(0))
                                                {
                                                    case 1:
                                                        sourceFieldName = args[0].ToString();
                                                        break;
                                                    case 2:
                                                        sourceFieldName = args[1].ToString();
                                                        break;

                                                    default: break;
                                                }

                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECTING_EDGE");

                                                if (inFeature != null)
                                                {
                                                    netFeat = inFeature as INetworkFeature;
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain132"));
                                                    if (netFeat != null)
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain103"));
                                                        if (inFeature.FeatureType == esriFeatureType.esriFTComplexJunction || inFeature.FeatureType == esriFeatureType.esriFTSimpleJunction)
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain104"));
                                                            iJuncFeat = (IJunctionFeature)netFeat;

                                                            ISimpleJunctionFeature iSJunc = iJuncFeat as ISimpleJunctionFeature;
                                                            if (iSJunc == null)
                                                                break;
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain105") + iSJunc.EdgeFeatureCount);
                                                            if (iSJunc.EdgeFeatureCount <= 0)
                                                                break;
                                                            if (iSJunc.EdgeFeatureCount > 0)
                                                            {
                                                                for (int i = 0; i < iSJunc.EdgeFeatureCount; i++)
                                                                {

                                                                    iEdgeFeat = iSJunc.get_EdgeFeature(i);
                                                                    try
                                                                    {

                                                                        IRow pRow = iEdgeFeat as IRow;

                                                                        // verify that field (in junction) to copy exists
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain113"));
                                                                        juncField = Globals.GetFieldIndex(pRow.Fields, sourceFieldName);
                                                                        string test = pRow.get_Value(juncField).ToString();
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain133") + test);
                                                                        inObject.set_Value(intFldIdxs[0], test);
                                                                        continue;
                                                                    }
                                                                    catch
                                                                    {
                                                                    }
                                                                }//end loop
                                                                try
                                                                {

                                                                }
                                                                catch (Exception ex)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.Message);

                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bi"));
                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bj"));
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bk"));
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_EDGE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_EDGE");
                                            }
                                            break;
                                        case "INTERSECTING_FEATURE":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECTING_FEATURE");
                                                if (inFeature != null & valData != null)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain134"));
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    sourceField = -1;
                                                    found = false;
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain135") + valData);
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    //if (args.GetLength(0) >= 2)
                                                    if (args.Length >= 2)
                                                    {
                                                        AAState.intersectOptions strOpt = AAState.intersectOptions.First;
                                                        switch (args.Length)
                                                        {
                                                            case 2:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                sourceFieldName = args[1].ToString();
                                                                break;
                                                            case 3:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                sourceFieldName = args[1].ToString();
                                                                switch (args[2].ToString().ToUpper())
                                                                {
                                                                    case "PROMPT":
                                                                        strOpt = AAState.intersectOptions.PromptMulti;
                                                                        break;
                                                                    case "P":
                                                                        strOpt = AAState.intersectOptions.PromptMulti;
                                                                        break;
                                                                    case "CENTROID":
                                                                        strOpt = AAState.intersectOptions.Centroid;
                                                                        break;
                                                                    case "C":
                                                                        strOpt = AAState.intersectOptions.Centroid;
                                                                        break;
                                                                    case "F":
                                                                        strOpt = AAState.intersectOptions.First;
                                                                        break;
                                                                    case "L":
                                                                        strOpt = AAState.intersectOptions.Last;
                                                                        break;
                                                                    case "FIRST":
                                                                        strOpt = AAState.intersectOptions.First;
                                                                        break;
                                                                }
                                                                break;
                                                            default: break;
                                                        }

                                                        if (sourceFieldName != null)
                                                        {
                                                            List<Globals.OptionsToPresent> pFoundFeat = new List<Globals.OptionsToPresent>();

                                                            for (int i = 0; i < sourceLayerNames.Length; i++)
                                                            {
                                                                sourceLayerName = sourceLayerNames[i].ToString().Trim();
                                                                if (sourceLayerName != "")
                                                                {
                                                                    boolLayerOrFC = true;

                                                                    if (sourceLayerName.Contains("("))
                                                                    {
                                                                        string[] tempSplt = sourceLayerName.Split('(');
                                                                        sourceLayerName = tempSplt[0].Trim();
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                                        if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }

                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                        {
                                                                            boolLayerOrFC = true;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }
                                                                        else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                        {
                                                                            boolLayerOrFC = false;
                                                                        }

                                                                    }
                                                                    else
                                                                    {
                                                                        sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                                    }
                                                                    // Get layer

                                                                    if (sourceLayer != null)
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain136") + sourceLayer.Name);

                                                                        sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName);
                                                                        AAState.WriteLine("                  " + sourceFieldName + ": at " + sourceField);
                                                                        if (sourceField > -1)
                                                                        {

                                                                            sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, strOpt == AAState.intersectOptions.Centroid);
                                                                            if (sFilter == null)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain137"));
                                                                                continue;
                                                                            }

                                                                            pFS = (IFeatureSelection)sourceLayer;
                                                                            if (boolLayerOrFC)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain138"));
                                                                                if (pFS.SelectionSet.Count > 0)
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain139"));
                                                                                    pFS.SelectionSet.Search(sFilter, true, out cCurs);

                                                                                    fCursor = cCurs as IFeatureCursor;

                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140"));
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain141"));
                                                                                    fCursor = sourceLayer.Search(sFilter, true);
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140"));
                                                                                }
                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain142"));
                                                                                fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140"));
                                                                            }
                                                                            if (fCursor == null)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain143"));
                                                                                continue;
                                                                            }
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain144"));
                                                                            while ((sourceFeature = fCursor.NextFeature()) != null)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain145"));
                                                                                if (sourceFeature.Class != inFeature.Class)
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain146"));
                                                                                    if (strOpt == AAState.intersectOptions.PromptMulti)
                                                                                    {

                                                                                        Globals.OptionsToPresent pOp = new Globals.OptionsToPresent();
                                                                                        pOp.Display = sourceFeature.get_Value(Globals.GetFieldIndex(sourceFeature.Fields, sourceLayer.DisplayField)).ToString();
                                                                                        pOp.Value = sourceFeature.get_Value(sourceField);

                                                                                        if (pOp.Display.Trim() != "")
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString();

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString();

                                                                                        }

                                                                                        pOp.OID = sourceFeature.OID;
                                                                                        pOp.LayerName = sourceLayer.Name;

                                                                                        pFoundFeat.Add(pOp);
                                                                                    }
                                                                                    else if (strOpt == AAState.intersectOptions.Last)
                                                                                    {

                                                                                        Globals.OptionsToPresent pOp = new Globals.OptionsToPresent();
                                                                                        pOp.Display = sourceFeature.get_Value(Globals.GetFieldIndex(sourceFeature.Fields, sourceLayer.DisplayField)).ToString();
                                                                                        pOp.Value = sourceFeature.get_Value(sourceField);

                                                                                        if (pOp.Display.Trim() != "")
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString();

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString();

                                                                                        }
                                                                                        pOp.OID = sourceFeature.OID;
                                                                                        pOp.LayerName = sourceLayer.Name;

                                                                                        pFoundFeat.Add(pOp);
                                                                                    }

                                                                                    else
                                                                                    {
                                                                                        string test = sourceFeature.get_Value(sourceField).ToString();
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + test);
                                                                                        inObject.set_Value(intFldIdxs[0], sourceFeature.get_Value(sourceField));
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az"));
                                                                                        found = true;
                                                                                    }
                                                                                }
                                                                                else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain148"));
                                                                                    if (strOpt == AAState.intersectOptions.PromptMulti)
                                                                                    {
                                                                                        Globals.OptionsToPresent pOp = new Globals.OptionsToPresent();
                                                                                        pOp.Display = sourceFeature.get_Value(Globals.GetFieldIndex(sourceFeature.Fields, sourceLayer.DisplayField)).ToString();
                                                                                        pOp.Value = sourceFeature.get_Value(sourceField);

                                                                                        if (pOp.Display.Trim() != "")
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString();

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString();

                                                                                        }
                                                                                        pOp.OID = sourceFeature.OID;
                                                                                        pOp.LayerName = sourceLayer.Name;

                                                                                        pFoundFeat.Add(pOp);
                                                                                    }
                                                                                    else if (strOpt == AAState.intersectOptions.Last)
                                                                                    {
                                                                                        Globals.OptionsToPresent pOp = new Globals.OptionsToPresent();
                                                                                        pOp.Display = sourceFeature.get_Value(Globals.GetFieldIndex(sourceFeature.Fields, sourceLayer.DisplayField)).ToString();
                                                                                        pOp.Value = sourceFeature.get_Value(sourceField);

                                                                                        if (pOp.Display.Trim() != "")
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString();

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString();

                                                                                        }
                                                                                        pOp.OID = sourceFeature.OID;
                                                                                        pOp.LayerName = sourceLayer.Name;

                                                                                        pFoundFeat.Add(pOp);
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        string test = sourceFeature.get_Value(sourceField).ToString();
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + test);

                                                                                        inObject.set_Value(intFldIdxs[0], sourceFeature.get_Value(sourceField));
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az"));

                                                                                        found = true;
                                                                                    }
                                                                                }
                                                                                if (found == true)
                                                                                    break;

                                                                            }

                                                                            if (found == false && AAState._CheckEnvelope && pFoundFeat.Count == 0)
                                                                            {
                                                                                sFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects;

                                                                                pFS = (IFeatureSelection)sourceLayer;
                                                                                if (boolLayerOrFC)
                                                                                {
                                                                                    if (pFS.SelectionSet.Count > 0)
                                                                                    {
                                                                                        pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                                        fCursor = cCurs as IFeatureCursor;

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        fCursor = sourceLayer.Search(sFilter, true);
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                                }
                                                                                sourceFeature = fCursor.NextFeature();
                                                                                while (sourceFeature != null)
                                                                                {
                                                                                    if (strOpt == AAState.intersectOptions.PromptMulti)
                                                                                    {
                                                                                        Globals.OptionsToPresent pOp = new Globals.OptionsToPresent();
                                                                                        pOp.Display = sourceFeature.get_Value(Globals.GetFieldIndex(sourceFeature.Fields, sourceLayer.DisplayField)).ToString();
                                                                                        pOp.Value = sourceFeature.get_Value(sourceField);

                                                                                        if (pOp.Display.Trim() != "")
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString();

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString();

                                                                                        }
                                                                                        pOp.OID = sourceFeature.OID;
                                                                                        pOp.LayerName = sourceLayer.Name;

                                                                                        pFoundFeat.Add(pOp);

                                                                                    }
                                                                                    else if (strOpt == AAState.intersectOptions.Last)
                                                                                    {
                                                                                        Globals.OptionsToPresent pOp = new Globals.OptionsToPresent();
                                                                                        pOp.Display = sourceFeature.get_Value(Globals.GetFieldIndex(sourceFeature.Fields, sourceLayer.DisplayField)).ToString();
                                                                                        pOp.Value = sourceFeature.get_Value(sourceField);

                                                                                        if (pOp.Display.Trim() != "")
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString();

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString();

                                                                                        }
                                                                                        pOp.OID = sourceFeature.OID;
                                                                                        pOp.LayerName = sourceLayer.Name;

                                                                                        pFoundFeat.Add(pOp);

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        if (found)
                                                                                        {
                                                                                            break;
                                                                                        }
                                                                                        string test = sourceFeature.get_Value(sourceField).ToString();
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + test);

                                                                                        inObject.set_Value(intFldIdxs[0], sourceFeature.get_Value(sourceField));
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az"));

                                                                                        found = true;

                                                                                    }
                                                                                    sourceFeature = fCursor.NextFeature();
                                                                                }

                                                                            }

                                                                            if (found)
                                                                            {
                                                                                break;
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14am") + sourceFieldName);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName);
                                                                    }
                                                                }

                                                            }
                                                            if (pFoundFeat.Count > 0 && strOpt == AAState.intersectOptions.PromptMulti)
                                                            {
                                                                Globals.OptionsToPresent strRetVal = Globals.showOptionsForm(pFoundFeat, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain149") + sourceFieldName, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain149") + sourceFieldName, ComboBoxStyle.DropDownList);
                                                                if (strRetVal != null)
                                                                {
                                                                    //sourceFeature = sourceLayer.FeatureClass.GetFeature(strRetVal.OID);

                                                                    string test = strRetVal.Value.ToString();//sourceFeature.get_Value(sourceField).ToString();
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + test);

                                                                    inObject.set_Value(intFldIdxs[0], strRetVal.Value);
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az"));

                                                                    found = true;

                                                                }
                                                            }
                                                            else if (pFoundFeat.Count > 0 && strOpt == AAState.intersectOptions.Last)
                                                            {

                                                                //sourceFeature = sourceLayer.FeatureClass.GetFeature(pFoundFeat[pFoundFeat.Count - 1].OID);

                                                                string test = pFoundFeat[pFoundFeat.Count - 1].Value.ToString(); //sourceFeature.get_Value(sourceField).ToString();
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + test);

                                                                inObject.set_Value(intFldIdxs[0], pFoundFeat[pFoundFeat.Count - 1].Value);
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az"));

                                                                found = true;

                                                            }

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain150"));
                                                        }
                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain151"));
                                                    }
                                                }
                                                else
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain152"));
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_FEATURE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_FEATURE");
                                            }
                                            break;
                                        case "INTERSECTING_BOOLEAN":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECTING_BOOLEAN");
                                                if (inFeature != null & valData != null)
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain134"));
                                                    sourceLayerName = "";
                                                    string valTrue = "";
                                                    string valFalse = "";

                                                    found = false;
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain135") + valData);
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    //if (args.GetLength(0) >= 2)
                                                    if (args.Length == 3)
                                                    {
                                                        AAState.intersectOptions strOpt = AAState.intersectOptions.First;
                                                        switch (args.Length)
                                                        {

                                                            case 3:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                valTrue = args[1].ToString();
                                                                valFalse = args[2].ToString();

                                                                break;
                                                            default: break;
                                                        }

                                                        for (int i = 0; i < sourceLayerNames.Length; i++)
                                                        {
                                                            sourceLayerName = sourceLayerNames[i].ToString().Trim();
                                                            if (sourceLayerName != "")
                                                            {
                                                                boolLayerOrFC = true;

                                                                if (sourceLayerName.Contains("("))
                                                                {
                                                                    string[] tempSplt = sourceLayerName.Split('(');
                                                                    sourceLayerName = tempSplt[0].Trim();
                                                                    sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                                    if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                    {
                                                                        boolLayerOrFC = true;
                                                                    }

                                                                    else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                    {
                                                                        boolLayerOrFC = true;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                    {
                                                                        boolLayerOrFC = false;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                    {
                                                                        boolLayerOrFC = false;
                                                                    }
                                                                    else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                    {
                                                                        boolLayerOrFC = false;
                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                                }
                                                                // Get layer

                                                                if (sourceLayer != null)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain136") + sourceLayer.Name);

                                                                    sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, strOpt == AAState.intersectOptions.Centroid);
                                                                    if (sFilter == null)
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain137"));
                                                                        continue;
                                                                    }

                                                                    pFS = (IFeatureSelection)sourceLayer;
                                                                    if (boolLayerOrFC)
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain138"));
                                                                        if (pFS.SelectionSet.Count > 0)
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain139"));
                                                                            pFS.SelectionSet.Search(sFilter, true, out cCurs);

                                                                            fCursor = cCurs as IFeatureCursor;

                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140"));
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain141"));
                                                                            fCursor = sourceLayer.Search(sFilter, true);
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140"));
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain142"));
                                                                        fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140"));
                                                                    }
                                                                    if (fCursor == null)
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain143"));
                                                                        continue;
                                                                    }
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain144"));
                                                                    while ((sourceFeature = fCursor.NextFeature()) != null)
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain145"));
                                                                        if (sourceFeature.Class != inFeature.Class)
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain146"));

                                                                            found = true;

                                                                        }
                                                                        else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain148"));

                                                                            found = true;

                                                                        }
                                                                        if (found == true)
                                                                            break;

                                                                    }

                                                                    if (found == false && AAState._CheckEnvelope)
                                                                    {
                                                                        sFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects;

                                                                        pFS = (IFeatureSelection)sourceLayer;
                                                                        if (boolLayerOrFC)
                                                                        {
                                                                            if (pFS.SelectionSet.Count > 0)
                                                                            {
                                                                                pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                                fCursor = cCurs as IFeatureCursor;

                                                                            }
                                                                            else
                                                                            {
                                                                                fCursor = sourceLayer.Search(sFilter, true);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                        }
                                                                        sourceFeature = fCursor.NextFeature();
                                                                        while (sourceFeature != null)
                                                                        {

                                                                            found = true;
                                                                            break;

                                                                        }

                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName);
                                                                }

                                                                if (found)
                                                                {
                                                                    break;
                                                                }

                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine("                  " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14c") + sourceLayerName);
                                                            }

                                                        }

                                                        if (found)
                                                        {

                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + valTrue);

                                                            inObject.set_Value(intFldIdxs[0], valTrue);
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az"));

                                                        }
                                                        else
                                                        {
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + valFalse);

                                                            inObject.set_Value(intFldIdxs[0], valFalse);
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az"));

                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain153"));
                                                    }

                                                }
                                                else
                                                {
                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain154"));
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_BOOLEAN: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_BOOLEAN");
                                            }
                                            break;
                                        case "INTERSECTING_RASTER":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECTING_RASTER");
                                                if (inFeature != null & valData != null)
                                                {

                                                    sourceLayerName = "";
                                                    formatString = "";
                                                    found = false;

                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    if (args.Length < 1) break;
                                                    switch (args.Length)
                                                    {
                                                        case 1:
                                                            sourceLayerNames = args[0].ToString().Split(',');
                                                            break;
                                                        case 2:
                                                            sourceLayerNames = args[0].ToString().Split(',');
                                                            formatString = args[1].ToString();
                                                            break;
                                                        default: break;
                                                    }

                                                    // Get layer
                                                    for (int i = 0; i < sourceLayerNames.Length; i++)
                                                    {
                                                        sourceLayerName = sourceLayerNames[i].ToString().Trim();
                                                        IPoint pLoc = Globals.GetGeomCenter(inFeature)[0];

                                                        if (pLoc != null)
                                                        {
                                                            string cellVal = Globals.GetCellValue(sourceLayerName, pLoc, AAState._editor.Map);
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain155") + sourceLayerName);
                                                            if (cellVal != null && cellVal != "" && cellVal != "No Raster")
                                                            {

                                                                if (formatString == null || formatString == "" || (inObject.Fields.get_Field(intFldIdxs[0]).Type != esriFieldType.esriFieldTypeString))
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], cellVal);
                                                                    found = true;
                                                                    break;
                                                                }
                                                                else
                                                                {
                                                                    formatString = formatString + cellVal;
                                                                    inObject.set_Value(intFldIdxs[0], formatString);

                                                                    found = true;
                                                                    break;
                                                                }

                                                            }

                                                        }
                                                    }
                                                    if (!(found) && inObject.Fields.get_Field(intFldIdxs[0]).IsNullable)
                                                        inObject.set_Value(intFldIdxs[0], null);
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_RASTER: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_RASTER");
                                            }
                                            break;
                                        case "INTERSECTING_LAYER_DETAILS":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECTING_LAYER_DETAILS");
                                                if (inFeature != null & valData != null)
                                                {

                                                    sourceLayerName = "";
                                                    formatString = "";
                                                    found = false;
                                                    List<string> matchPattern = null;
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    if (args.Length >= 1)
                                                    {
                                                        AAState.intersectOptions strOpt = AAState.intersectOptions.First;

                                                        switch (args.Length)
                                                        {
                                                            case 1:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                formatString = "P";
                                                                break;
                                                            case 2:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                formatString = args[1].ToString();
                                                                break;
                                                            case 3:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                formatString = args[1].ToString();
                                                                switch (args[2].ToString().ToUpper())
                                                                {
                                                                    case "PROMPT":
                                                                        strOpt = AAState.intersectOptions.PromptMulti;
                                                                        break;
                                                                    case "P":
                                                                        strOpt = AAState.intersectOptions.PromptMulti;
                                                                        break;
                                                                    case "CENTROID":
                                                                        strOpt = AAState.intersectOptions.Centroid;
                                                                        break;
                                                                    case "C":
                                                                        strOpt = AAState.intersectOptions.Centroid;
                                                                        break;
                                                                    case "F":
                                                                        strOpt = AAState.intersectOptions.First;
                                                                        break;
                                                                    case "FIRST":
                                                                        strOpt = AAState.intersectOptions.First;
                                                                        break;
                                                                }
                                                                break;
                                                            case 4:
                                                                sourceLayerNames = args[0].ToString().Split(',');
                                                                formatString = args[1].ToString();
                                                                switch (args[2].ToString().ToUpper())
                                                                {
                                                                    case "PROMPT":
                                                                        strOpt = AAState.intersectOptions.PromptMulti;
                                                                        break;
                                                                    case "P":
                                                                        strOpt = AAState.intersectOptions.PromptMulti;
                                                                        break;
                                                                    case "CENTROID":
                                                                        strOpt = AAState.intersectOptions.Centroid;
                                                                        break;
                                                                    case "C":
                                                                        strOpt = AAState.intersectOptions.Centroid;
                                                                        break;
                                                                    case "F":
                                                                        strOpt = AAState.intersectOptions.First;
                                                                        break;
                                                                    case "FIRST":
                                                                        strOpt = AAState.intersectOptions.First;
                                                                        break;
                                                                }
                                                                matchPattern = new List<string>(args[3].ToString().Split(','));

                                                                break;
                                                            default: break;

                                                        }
                                                        List<Globals.OptionsToPresent> strFiles = new List<Globals.OptionsToPresent>();
                                                        // Get layer
                                                        for (int i = 0; i < sourceLayerNames.Length; i++)
                                                        {
                                                            sourceLayerName = sourceLayerNames[i].ToString().Trim();

                                                            IGeometry pGeo = inFeature.ShapeCopy;
                                                            List<IGeometry> pGeos = new List<IGeometry>();

                                                            if (pGeo != null)
                                                            {
                                                                if (strOpt == AAState.intersectOptions.Centroid)
                                                                {
                                                                    List<IPoint> pGeoPnts = Globals.GetGeomCenter(pGeo);
                                                                    pGeos = pGeoPnts.ConvertAll(new Converter<IPoint, IGeometry>(Globals.PointToGeometry));

                                                                }
                                                                else
                                                                {
                                                                    pGeos.Add(pGeo);
                                                                }
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain156") + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain157"));
                                                                IEnumLayer pEnum = Globals.GetLayers(AAState._editor.Map, sourceLayerName);

                                                                if (pEnum != null)
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain158") + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain157"));
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain159"));
                                                                    ILayer pLay = pEnum.Next();

                                                                    while (pLay != null)
                                                                    {

                                                                        intersectLayerDetailsFunctions(pLay, pGeos, strOpt, ref found, ref strFiles, ref inObject, intFldIdxs[0], matchPattern);

                                                                        if (found)
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain160"));
                                                                            break;
                                                                        }

                                                                        pLay = pEnum.Next();
                                                                    }
                                                                    pLay = null;
                                                                    pEnum = null;
                                                                }
                                                                else
                                                                {
                                                                    bool FCorLayerTemp = true;
                                                                    ILayer pLay = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref FCorLayerTemp);
                                                                    if (pLay != null)
                                                                    {

                                                                        intersectLayerDetailsFunctions(pLay, pGeos, strOpt, ref found, ref strFiles, ref inObject, intFldIdxs[0], matchPattern);

                                                                    }
                                                                    pLay = null;
                                                                }

                                                                if (pEnum != null)
                                                                    Marshal.ReleaseComObject(pEnum);
                                                                pEnum = null;
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain161"));
                                                            }
                                                            if (found)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain160"));
                                                                break;
                                                            }
                                                            pGeo = null;
                                                            pGeos = null;
                                                        }
                                                        if (strOpt == AAState.intersectOptions.PromptMulti && strFiles.Count > 0)
                                                        {
                                                            Globals.OptionsToPresent strRetVal = Globals.showOptionsForm(strFiles, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain162") + strFldNames[0], A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain163") + strFldNames[0], ComboBoxStyle.DropDownList);
                                                            if (strRetVal != null)
                                                            {
                                                                try
                                                                {
                                                                    inObject.set_Value(intFldIdxs[0], strRetVal.Display);
                                                                }
                                                                catch
                                                                {
                                                                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain164"));

                                                                }
                                                                found = true;
                                                            }
                                                        }

                                                    }
                                                    else
                                                    {
                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain165"));
                                                    }

                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_LAYER_DETAILS: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_LAYER_DETAILS");
                                            }
                                            break;
                                        case "INTERSECTING_FEATURE_DISTANCE":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECTING_FEATURE_DISTANCE");
                                                if (inFeature != null & valData != null)
                                                {
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    sourceField = -1;

                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    if (args.GetLength(0) >= 2)
                                                    {

                                                        sourceLayerNames = args[0].ToString().Split(',');
                                                        sourceFieldName = args[1].ToString().Trim();
                                                    }
                                                    // Get layer

                                                    if (sourceFieldName != null)
                                                    {
                                                        for (int i = 0; i < sourceLayerNames.Length; i++)
                                                        {
                                                            sourceLayerName = sourceLayerNames[i].ToString();
                                                            if (sourceLayerName != "")

                                                                sourceLayerName = args[i].ToString();
                                                            if (i == 0)
                                                                i++;
                                                            boolLayerOrFC = true;

                                                            if (sourceLayerName.Contains("("))
                                                            {
                                                                string[] tempSplt = sourceLayerName.Split('(');
                                                                sourceLayerName = tempSplt[0];
                                                                sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                                if (tempSplt[1].ToUpper().Contains("LAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURELAYER)"))
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURECLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("CLASS)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else if (tempSplt[1].ToUpper().Contains("FEATURE)"))
                                                                {
                                                                    boolLayerOrFC = false;
                                                                }
                                                                else
                                                                {
                                                                    boolLayerOrFC = true;
                                                                }
                                                            }
                                                            else
                                                            {
                                                                sourceLayer = (IFeatureLayer)Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC);

                                                            }
                                                            if (sourceLayer == null)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14b") + sourceLayerName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                continue;
                                                            }

                                                            IFeatureClass iFC = inFeature.Class as IFeatureClass;
                                                            if (sourceLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + sourceLayer + " is a polygon layer");

                                                                break;
                                                            }
                                                            if (sourceLayer != null)
                                                            {
                                                                sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName);

                                                                if (sourceField > -1)
                                                                {
                                                                    sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false);

                                                                    pFS = (IFeatureSelection)sourceLayer;
                                                                    if (boolLayerOrFC)
                                                                    {
                                                                        if (pFS.SelectionSet.Count > 0)
                                                                        {
                                                                            pFS.SelectionSet.Search(sFilter, true, out cCurs);
                                                                            fCursor = cCurs as IFeatureCursor;

                                                                        }
                                                                        else
                                                                        {
                                                                            fCursor = sourceLayer.Search(sFilter, true);
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        fCursor = sourceLayer.FeatureClass.Search(sFilter, true);
                                                                    }

                                                                    while ((sourceFeature = fCursor.NextFeature()) != null)
                                                                    {
                                                                        if (sourceFeature.Class != inFeature.Class)
                                                                        {
                                                                            IPoint pIntPnt;
                                                                            if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                                            {
                                                                                pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint;

                                                                            }
                                                                            else
                                                                                pIntPnt = inFeature.ShapeCopy as IPoint;
                                                                            IPoint snapPnt = null;

                                                                            double dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt);
                                                                            snapPnt = null;

                                                                            string strUnit = Globals.GetSpatRefUnitName(Globals.GetLayersCoordinateSystem(sourceLayer.FeatureClass), true);
                                                                            if (strUnit == "Foot" && dAlong != 1)
                                                                            {
                                                                                strUnit = "Feet";
                                                                            }
                                                                            else if (strUnit == "Meter" && dAlong != 1)
                                                                            {
                                                                                strUnit = "Meters";
                                                                            }
                                                                            string strDis = dAlong + " " + strUnit + " along " + sourceLayer.Name + " with " + sourceLayer.FeatureClass.Fields.get_Field(sourceField).AliasName + A4LGSharedFunctions.Localizer.GetString("Of") + sourceFeature.get_Value(sourceField);

                                                                            if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                            {

                                                                                strDis = dAlong + " " + strUnit + ": " + sourceFeature.get_Value(sourceField);
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain166") + strDis);

                                                                                if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                                {

                                                                                    if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                                    {
                                                                                        strDis = dAlong.ToString();
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    strDis = dAlong.ToString();
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain166") + strDis);
                                                                                    if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                                    {
                                                                                        strDis = dAlong.ToString();
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain167") + strDis);
                                                                                inObject.set_Value(intFldIdxs[0], strDis);
                                                                                break;
                                                                            }
                                                                        }

                                                                        else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                        {
                                                                            IPoint pIntPnt;
                                                                            if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
                                                                            {
                                                                                pIntPnt = Globals.GetIntersection(inFeature.ShapeCopy, sourceFeature.ShapeCopy as IPolyline) as IPoint;

                                                                            }
                                                                            else
                                                                                pIntPnt = inFeature.ShapeCopy as IPoint;
                                                                            IPoint snapPnt = null;

                                                                            double dAlong = Globals.PointDistanceOnLine(pIntPnt, sourceFeature.Shape as IPolyline, 2, out snapPnt);
                                                                            snapPnt = null;

                                                                            string strUnit = Globals.GetSpatRefUnitName(Globals.GetLayersCoordinateSystem(sourceLayer.FeatureClass), true);
                                                                            if (strUnit == "Foot" && dAlong != 1)
                                                                            {
                                                                                strUnit = "Feet";
                                                                            }
                                                                            else if (strUnit == "Meter" && dAlong != 1)
                                                                            {
                                                                                strUnit = "Meters";
                                                                            }
                                                                            string strDis = dAlong + " " + strUnit + " along " + sourceLayer.Name + " with " + sourceLayer.FeatureClass.Fields.get_Field(sourceField).AliasName + A4LGSharedFunctions.Localizer.GetString("Of") + sourceFeature.get_Value(sourceField);

                                                                            if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                            {

                                                                                strDis = dAlong + " " + strUnit + ": " + sourceFeature.get_Value(sourceField);
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain166") + strDis);

                                                                                if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                                {

                                                                                    if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                                    {
                                                                                        strDis = dAlong.ToString();
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    strDis = dAlong.ToString();
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain166") + strDis);
                                                                                    if (inObject.Fields.get_Field(intFldIdxs[0]).Length < strDis.Length - 1)
                                                                                    {
                                                                                        strDis = dAlong.ToString();
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        inObject.set_Value(intFldIdxs[0], strDis);
                                                                                        break;
                                                                                    }
                                                                                }

                                                                            }
                                                                            else
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain167") + strDis);
                                                                                inObject.set_Value(intFldIdxs[0], strDis);
                                                                                break;
                                                                            }
                                                                        }
                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + sourceLayer + ": field: " + sourceFieldName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                }
                                                            }
                                                            else { }
                                                        }
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_FEATURE_DISTANCE: " + ex.Message);
                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_FEATURE_DISTANCE");
                                            }
                                            break;

                                        //Release: 1.2
                                        //New Dynamic Value Method: NEARSET_FEATURE - similiar to INTERSECTING_FEATURE but requires a search distance.

                                        case "NEAREST_FEATURE":
                                            try
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "NEAREST_FEATURE");
                                                if (inFeature != null & valData != null)
                                                {
                                                    string sourceMatField = "";
                                                    string targetMatField = "";
                                                    sourceLayerName = "";
                                                    sourceFieldName = "";
                                                    searchDistance = 0;
                                                    found = false;
                                                    // Parse arguments
                                                    args = valData.Split('|');
                                                    switch (args.Length)
                                                    {
                                                        case 2:
                                                            sourceLayerNames = args[0].ToString().Split(',');
                                                            sourceFieldName = args[1].ToString();
                                                            break;
                                                        case 3:
                                                            sourceLayerNames = args[0].ToString().Split(',');
                                                            sourceFieldName = args[1].ToString();

                                                            Double.TryParse(args[2], out searchDistance);
                                                            break;
                                                        case 4:
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain168"));
                                                            break;

                                                        case 5:
                                                            sourceLayerNames = args[0].ToString().Split(',');
                                                            sourceFieldName = args[1].ToString();
                                                            Double.TryParse(args[2], out searchDistance);
                                                            sourceMatField = args[3].ToString();
                                                            targetMatField = args[4].ToString();
                                                            break;
                                                        default:
                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain168"));
                                                            break;

                                                    }

                                                    if (sourceLayerNames.Length > 0 & sourceFieldName != null)
                                                    {
                                                        for (int i = 0; i < sourceLayerNames.Length; i++)
                                                        {
                                                            sourceLayerName = sourceLayerNames[i].ToString();
                                                            if (sourceLayerName != "")
                                                            {
                                                                bool FCorLayerSource = true;
                                                                sourceLayer = Globals.FindLayer(AAState._editor.Map, sourceLayerName, ref FCorLayerSource) as IFeatureLayer;
                                                                if (sourceLayer != null)
                                                                {
                                                                    sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName);

                                                                    if (sourceField > -1)
                                                                    {

                                                                        sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false);
                                                                        pFS = (IFeatureSelection)sourceLayer;
                                                                        if (boolLayerOrFC)
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain169"));
                                                                            if (pFS.SelectionSet.Count > 0)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain170"));
                                                                                pFS.SelectionSet.Search(sFilter, false, out cCurs);
                                                                                fCursor = cCurs as IFeatureCursor;

                                                                            }
                                                                            else
                                                                            {

                                                                                fCursor = sourceLayer.Search(sFilter, false);
                                                                            }
                                                                        }
                                                                        else
                                                                        {
                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain171"));
                                                                            fCursor = sourceLayer.FeatureClass.Search(sFilter, false);
                                                                        }

                                                                        nearestFeature = null;

                                                                        proxOp = (IProximityOperator)inFeature.ShapeCopy;
                                                                        lastDistance = searchDistance;
                                                                        while ((sourceFeature = fCursor.NextFeature()) != null)
                                                                        {
                                                                            if (sourceFeature.Class != inFeature.Class)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain172"));
                                                                                if (targetMatField == "" && sourceMatField == "")
                                                                                {

                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain173"));
                                                                                    try
                                                                                    {
                                                                                        IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                        pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                        distance = proxOp.ReturnDistance(pTempGeo);
                                                                                        pTempGeo = null;

                                                                                        if (distance <= lastDistance)
                                                                                        {
                                                                                            nearestFeature = sourceFeature;
                                                                                            lastDistance = distance;
                                                                                        }
                                                                                        pTempGeo = null;
                                                                                    }
                                                                                    catch
                                                                                    {
                                                                                        MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain174"));
                                                                                        return false;

                                                                                    }
                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain175"));
                                                                                    int idxTargetFld = Globals.GetFieldIndex(sourceLayer, targetMatField);
                                                                                    int idxSourceFld = Globals.GetFieldIndex(inObject.Fields, sourceMatField);
                                                                                    if (idxSourceFld >= 0 && idxTargetFld >= 0)
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain176"));
                                                                                        if (inObject.get_Value(idxSourceFld).ToString() == sourceFeature.get_Value(idxTargetFld).ToString())
                                                                                        {
                                                                                            AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                                            IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                            pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                            distance = proxOp.ReturnDistance(pTempGeo);
                                                                                            pTempGeo = null;

                                                                                            if (distance <= lastDistance)
                                                                                            {
                                                                                                nearestFeature = sourceFeature;
                                                                                                lastDistance = distance;
                                                                                            }
                                                                                            pTempGeo = null;

                                                                                        }
                                                                                        else
                                                                                        {
                                                                                            AAState.WriteLine("                  Values does not Match: " + inObject.get_Value(idxSourceFld).ToString() + " - " + sourceFeature.get_Value(idxTargetFld).ToString());

                                                                                        }

                                                                                    }
                                                                                    else
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain177"));
                                                                                        IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                        pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                        distance = proxOp.ReturnDistance(pTempGeo);
                                                                                        pTempGeo = null;

                                                                                        if (distance <= lastDistance)
                                                                                        {
                                                                                            nearestFeature = sourceFeature;
                                                                                            lastDistance = distance;
                                                                                        }
                                                                                        pTempGeo = null;

                                                                                    }

                                                                                }
                                                                            }
                                                                            else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID)
                                                                            {
                                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain175"));
                                                                                int idxTargetFld = Globals.GetFieldIndex(sourceLayer, targetMatField);
                                                                                int idxSourceFld = Globals.GetFieldIndex(inObject.Fields, sourceMatField);
                                                                                if (idxSourceFld >= 0 && idxTargetFld >= 0)
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain176"));
                                                                                    if (inObject.get_Value(idxSourceFld).ToString() == sourceFeature.get_Value(idxTargetFld).ToString())
                                                                                    {
                                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ay"));
                                                                                        IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                        pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                        distance = proxOp.ReturnDistance(pTempGeo);
                                                                                        pTempGeo = null;

                                                                                        if (distance <= lastDistance)
                                                                                        {
                                                                                            nearestFeature = sourceFeature;
                                                                                            lastDistance = distance;
                                                                                        }
                                                                                        pTempGeo = null;

                                                                                    }

                                                                                }
                                                                                else
                                                                                {
                                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain177"));
                                                                                    IGeometry pTempGeo = sourceFeature.ShapeCopy;
                                                                                    pTempGeo.Project(inFeature.Shape.SpatialReference);

                                                                                    distance = proxOp.ReturnDistance(pTempGeo);
                                                                                    pTempGeo = null;

                                                                                    if (distance <= lastDistance)
                                                                                    {
                                                                                        nearestFeature = sourceFeature;
                                                                                        lastDistance = distance;
                                                                                    }
                                                                                    pTempGeo = null;
                                                                                }

                                                                            }

                                                                        }

                                                                        if (nearestFeature != null)
                                                                        {
                                                                            AAState.WriteLine("                  Feature found: " + nearestFeature.Class.AliasName + ":" + nearestFeature.OID);
                                                                            inObject.set_Value(intFldIdxs[0], nearestFeature.get_Value(sourceField));
                                                                            found = true;
                                                                            break;
                                                                        }
                                                                    }
                                                                    else
                                                                    {
                                                                        AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + sourceLayer + ": field: " + sourceFieldName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                    }

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a")  + sourceLayer + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bb"));
                                                                }
                                                            }
                                                            else
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain178"));
                                                            }

                                                        }
                                                        if (!found)
                                                        {

                                                        }
                                                    }
                                                }

                                            }
                                            catch (Exception ex)
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "NEAREST_FEATURE: " + ex.Message);

                                            }
                                            finally
                                            {
                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "NEAREST_FEATURE");
                                            }
                                            break;

                                        default:
                                            AAState.WriteLine("ERROR: " + valMethod + " for layer " + tableName + " is not a valid method, check the dynamic value table");

                                            break;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain179") + tableName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain180") + strFldNames[0] + System.Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain181") + valMethod + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain182") + valData + System.Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain183") + ex.Message, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain184"));
                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain185") + tableName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain180") + strFldNames[0] + System.Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain181") + valMethod + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain182") + valData + System.Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain183") + ex.Message);
                                }
                            }
                            else
                            {
                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain186"));

                            }

                            try
                            {
                                if (intFldIdxs.Count > 0 && strFldNames.Count > 0)
                                {
                                    for (int p = 0; p < strFldNames.Count; p++)
                                    {

                                        IRowChanges inChanges = inObject as IRowChanges;
                                        bool changed = inChanges.get_ValueChanged(intFldIdxs[p]);
                                        if (changed)
                                            try
                                            {
                                                if (AAState.lastValueProperties.GetProperty(strFldNames[p]) != null)
                                                {
                                                    LastValueEntry lstVal = AAState.lastValueProperties.GetProperty(strFldNames[p]) as LastValueEntry;
                                                    if (lstVal != null)
                                                    {
                                                        if (mode == "ON_CREATE" && lstVal.On_Create == false)
                                                        {
                                                            string test = "";
                                                        }
                                                        else if (mode == "ON_MANUAL" && lstVal.On_Manual == false)
                                                        {
                                                            string test = "";
                                                        }
                                                        else if (mode == "ON_CHANGE" && lstVal.On_ChangeAtt == false)
                                                        {
                                                            string test = "";
                                                        }
                                                        else if (mode == "ON_CHANGEGEO" && lstVal.On_ChangeGeo == false)
                                                        {
                                                            string test = "";
                                                        }
                                                        else
                                                        {
                                                            if (lstVal.Value != null)
                                                            {
                                                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14p") );
                                                                if (mode == "ON_CREATE" && (inObject.get_Value(intFldIdxs[p]) == null || inObject.get_Value(intFldIdxs[p]).ToString() == ""))
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain187"));

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine("                           " + strFldNames[p] + ": " + inObject.get_Value(intFldIdxs[p]).ToString());
                                                                    lstVal.Value = inObject.get_Value(intFldIdxs[p]);

                                                                    AAState.lastValueProperties.SetProperty(strFldNames[p], lstVal);
                                                                }
                                                            }

                                                            else
                                                            {
                                                                if (mode == "ON_CREATE" && (inObject.get_Value(intFldIdxs[p]) == null || inObject.get_Value(intFldIdxs[p]).ToString() == ""))
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain187"));

                                                                }
                                                                else
                                                                {
                                                                    AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14p") );
                                                                    AAState.WriteLine("                           " + strFldNames[p] + ": " + inObject.get_Value(intFldIdxs[p]).ToString());
                                                                    lstVal.Value = inObject.get_Value(intFldIdxs[p]);

                                                                    AAState.lastValueProperties.SetProperty(strFldNames[p], lstVal);
                                                                }
                                                            }
                                                        }
                                                    }
                                                }

                                            }
                                            catch
                                            {

                                            }

                                    }
                                }
                            }
                            catch
                            {
                                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain188"));

                            }

                            AAState.WriteLine("    ------------------------------------------------");

                        }

                    }

                }
                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain189") + System.Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain190") + ex.Message, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain184"));
                AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain189"));
                return false;

            }
            finally
            {
                if (AAState._tab == inObject.Class || AAState._gentab == inObject.Class)
                {
                    AAState.reInitExt();

                }
                //if (progressDialog != null)
                //{
                //    progressDialog.HideDialog();
                //}
                AAState.WriteLine("DONE");
                AAState.WriteLine("---------------------------------------");
                if (fCursor != null)
                {
                    Marshal.ReleaseComObject(fCursor);
                    GC.Collect(300);
                    GC.WaitForFullGCComplete();
                }
                inFeature = null;

                mseg = null;
                netFeat = null;
                iEdgeFeat = null;

                iJuncFeat = null;

                //progressDialogFactory = null;
                //stepProgressor = null;
                //progressDialog = null;
                //trackCancel = null;
                ArcMap.Application.StatusBar.set_Message(0, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain191"));
            }
        }
示例#30
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button == 1)
            {
                m_ActiveView = m_hookHelper.ActiveView;
                m_Map        = m_hookHelper.FocusMap;

                IFeatureLayer pFeatureLayer = (IFeatureLayer)m_Map.get_Layer(0);
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;

                IPoint pPoint = m_ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

                ITopologicalOperator pTopo = (ITopologicalOperator)pPoint;

                IGeometry pBuffer = pTopo.Buffer(0.1);

                IGeometry pGeo = pBuffer.Envelope;

                ISpatialFilter pSpatialFilter = new SpatialFilterClass();

                pSpatialFilter.Geometry = pGeo;

                switch (pFeatureClass.ShapeType)
                {
                case esriGeometryType.esriGeometryPoint:
                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
                    break;

                case esriGeometryType.esriGeometryPolyline:
                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelCrosses;
                    break;

                case esriGeometryType.esriGeometryPolygon:
                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    break;
                }
                IFeatureSelection pFeatureSelection = (IFeatureSelection)pFeatureLayer;

                pFeatureSelection.SelectFeatures(pSpatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false);

                ISelectionSet pFeatureSet = pFeatureSelection.SelectionSet;

                ICursor pCursor;

                pFeatureSet.Search(null, true, out pCursor);

                IFeatureCursor pFeatureCursor = (IFeatureCursor)pCursor;

                IFeature pFeature = pFeatureCursor.NextFeature();


                while (pFeature != null)
                {
                    m_Map.SelectFeature((ILayer)pFeatureLayer, pFeature);
                    pFeature = pFeatureCursor.NextFeature();
                }

                m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);


                // m_MapControl.MousePointer = esriControlsMousePointer.esriPointerCrosshair;

                // IPoint point = new PointClass();

                // point.PutCoords(X, Y);

                // //IScreenDisplay pScreenDisplay = m_MapControl.ActiveView.ScreenDisplay;
                // //pScreenDisplay.DisplayTransformation
                // //m_MapControl.Map.ClearSelection();

                // m_MapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);

                // IGraphicsContainer pGraphicsContainer = (IGraphicsContainer)m_MapControl.Map;
                // IEnumElement pEnumEle = pGraphicsContainer.LocateElements(point, 1);


                // m_MapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                // //m_MapControl.Map.SelectByShape((IGeometry)point, null, false);
                //// m_MapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
            }
        }
        /// <summary>
        /// 闪烁选中图斑
        /// </summary>
        /// <param name="featureCursor"></param>
        private void FlashPolygons(IFeatureCursor featureCursor)
        {
            IArray geoArray = new ArrayClass();
            IFeature feature = null;
            while ((feature = featureCursor.NextFeature()) != null)
            {
                //feature是循环外指针,所以必须用ShapeCopy
                geoArray.Add(feature.ShapeCopy);
            }

            //通过IHookActions闪烁要素集合
            HookHelperClass m_pHookHelper = new HookHelperClass();
            m_pHookHelper.Hook = m_MapControl.Object;
            IHookActions hookActions = (IHookActions)m_pHookHelper;

            hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsPan);

            System.Windows.Forms.Application.DoEvents();
            m_pHookHelper.ActiveView.ScreenDisplay.UpdateWindow();

            hookActions.DoActionOnMultiple(geoArray, esriHookActions.esriHookActionsFlash);
            System.Windows.Forms.Application.DoEvents();
            m_pHookHelper.ActiveView.ScreenDisplay.UpdateWindow();
        }
示例#32
0
        /// <summary>
        /// 注记高程值一致性检查
        /// </summary>
        /// <param name="hook"></param>
        /// <param name="feaClsLst"></param>
        /// <param name="codeName">分类代码字段名</param>
        /// <param name="oriFeaClsName">源要素类名称</param>
        /// <param name="oriCodeValue">源要素类分类代码值</param>
        /// <param name="oriElevFieldName">源高程值字段名</param>
        /// <param name="desFeaClsName">目标要素类名称</param>
        /// <param name="desCodeValue">目标要素类分类代码值</param>
        /// <param name="labelFieldName">目标要素类高程值</param>
        /// <param name="radius">搜索半径</param>
        /// <param name="precision">精度控制</param>
        /// <param name="outError"></param>
        public void ElevAccordanceCheck(IArcgisDataCheckHook hook, List <IDataset> feaClsLst, string codeName, string oriFeaClsName, string oriCodeValue, string oriElevFieldName, string desFeaClsName, string desCodeValue, string labelFieldName, double radius, long precision, out Exception outError)
        {
            outError = null;
            try
            {
                //源要素类
                IFeatureClass pOriFeaCls = null;// (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(oriFeaClsName);
                foreach (IDataset pDT in feaClsLst)
                {
                    string tempName = pDT.Name;
                    if (tempName.Contains("."))
                    {
                        tempName = tempName.Substring(tempName.IndexOf('.') + 1);
                    }
                    if (tempName == oriFeaClsName)
                    {
                        pOriFeaCls = pDT as IFeatureClass;
                        break;
                    }
                }
                if (pOriFeaCls == null)
                {
                    return;
                }
                //源要素类高程字段索引值
                int oriEleIndex = pOriFeaCls.Fields.FindField(oriElevFieldName);
                if (oriEleIndex == -1)
                {
                    outError = new Exception("要素类" + oriFeaClsName + "字段" + oriElevFieldName + "不存在!");
                    return;
                }

                //目标要素类
                IFeatureClass pDesFeaCls = null;// (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(desFeaClsName);
                foreach (IDataset pDT in feaClsLst)
                {
                    string tempName = pDT.Name;
                    if (tempName.Contains("."))
                    {
                        tempName = tempName.Substring(tempName.IndexOf('.') + 1);
                    }
                    if (tempName == desFeaClsName)
                    {
                        pDesFeaCls = pDT as IFeatureClass;
                        break;
                    }
                }
                if (pDesFeaCls == null)
                {
                    return;
                }
                //目标要素类高程字段索引值
                int desElevIndex = pDesFeaCls.Fields.FindField(labelFieldName);
                if (desElevIndex == -1)
                {
                    outError = new Exception("要素类" + desFeaClsName + "字段" + labelFieldName + "不存在!");
                    return;
                }

                //查找源要素类中符合分类代码限制条件的要素
                string whereStr = "";
                if (oriCodeValue != "")
                {
                    whereStr = codeName + " ='" + oriCodeValue + "'";
                }
                IQueryFilter pFilter = new QueryFilterClass();
                pFilter.WhereClause = whereStr;
                IFeatureCursor pCursor = pOriFeaCls.Search(pFilter, false);
                if (pCursor == null)
                {
                    return;
                }
                IFeature pOriFea = pCursor.NextFeature();

                //遍历源要素,进行比较
                while (pOriFea != null)
                {
                    #region 进行检查
                    string oriElevValue = pOriFea.get_Value(oriEleIndex).ToString();
                    //根据原高程值求出精度允许的高程值用于比较
                    if (oriElevValue.Contains("."))
                    {
                        //原高程值包含小数点
                        int oriDotIndex = oriElevValue.IndexOf('.');
                        if (precision == 0)
                        {
                            oriElevValue = oriElevValue.Substring(0, oriDotIndex);
                        }
                        else if (oriElevValue.Substring(oriDotIndex + 1).Length > precision && precision > 0)
                        {
                            //原高程值的小数点位数大于精度控制
                            int oriLen = oriDotIndex + 1 + Convert.ToInt32(precision);
                            oriElevValue = oriElevValue.Substring(0, oriLen);
                        }
                    }

                    IFeature desFeature = GetNearestFeature(pDesFeaCls, codeName, desCodeValue, pOriFea, radius, out outError);
                    if (outError != null)
                    {
                        return;
                    }
                    if (desFeature == null)
                    {
                        pOriFea = pCursor.NextFeature();
                        continue;
                    }
                    string desElevValue = desFeature.get_Value(desElevIndex).ToString();
                    if (desElevValue.Contains("."))
                    {
                        //目标高程值包含小数点
                        int desDotIndex = desElevValue.IndexOf('.');
                        if (precision == 0)
                        {
                            desElevValue = desElevValue.Substring(0, desDotIndex);
                        }
                        else if (desElevValue.Substring(desDotIndex + 1).Length > precision && precision > 0)
                        {
                            //目标高程值的小数点位数大于精度
                            int desLen = desDotIndex + 1 + Convert.ToInt32(precision);
                            desElevValue = desElevValue.Substring(0, desLen);
                        }
                    }

                    //根据精度进行比较,在容许的范围内不相同不算错误
                    if (Convert.ToDouble(oriElevValue) != Convert.ToDouble(desElevValue))
                    {
                        //说明点,或线与相应注记的高程值不一致。将错误结果显示出来
                        double pMapx  = 0.0;
                        double pMapy  = 0.0;
                        IPoint pPoint = new PointClass();
                        if (pOriFeaCls.ShapeType != esriGeometryType.esriGeometryPoint)
                        {
                            pPoint = TopologyCheckClass.GetPointofFeature(pOriFea);
                        }
                        else
                        {
                            //点要素类
                            pPoint = pOriFea.Shape as IPoint;
                        }
                        pMapx = pPoint.X;
                        pMapy = pPoint.Y;

                        List <object> ErrorLst = new List <object>();
                        ErrorLst.Add("要素属性检查");                                                //功能组名称
                        ErrorLst.Add("点线注记高程值一致性检查");                                          //功能名称
                        ErrorLst.Add("");                                                      //数据文件名
                        ErrorLst.Add(0);                                                       //错误id;
                        ErrorLst.Add("图层" + oriFeaClsName + "与图层" + desFeaClsName + "高程值不一致"); //错误描述
                        ErrorLst.Add(pMapx);                                                   //...
                        ErrorLst.Add(pMapy);                                                   //...
                        ErrorLst.Add(oriFeaClsName);
                        ErrorLst.Add(pOriFea.OID);
                        ErrorLst.Add(desFeaClsName);
                        ErrorLst.Add(desFeature.OID);
                        ErrorLst.Add(false);
                        ErrorLst.Add(System.DateTime.Now.ToString());

                        //传递错误日志
                        IDataErrInfo      dataErrInfo       = new DataErrInfo(ErrorLst);
                        DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo);
                        DataErrTreat(hook.DataCheckParaSet as object, dataErrTreatEvent);
                    }
                    pOriFea = pCursor.NextFeature();
                    #endregion
                }

                //释放cursor
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
            }
            catch (Exception ex)
            {
                outError = ex;
            }
        }
示例#33
0
 void IFeatureRenderer.Draw(IFeatureCursor cursor, esriDrawPhase DrawPhase, IDisplay Display, ITrackCancel trackCancel)
 {
     ((IFeatureRenderer)uvr).Draw(cursor, DrawPhase, Display, trackCancel);
 }
示例#34
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            try
            {
                frmProgress pfrmProgress = new frmProgress();
                pfrmProgress.lblStatus.Text    = "Processing:";
                pfrmProgress.pgbProgress.Style = ProgressBarStyle.Marquee;
                pfrmProgress.Show();

                if (cboFieldName.Text == "")
                {
                    MessageBox.Show("Please select the dependent input variables to be used in the regression model.",
                                    "Please choose at least one input variable");
                }
                if (lstIndeVar.Items.Count == 0)
                {
                    MessageBox.Show("Please select independents input variables to be used in the regression model.",
                                    "Please choose at least one input variable");
                }
                //Decimal places
                int intDeciPlaces = 5;

                //Get number of Independent variables
                int nIndevarlistCnt = lstIndeVar.Items.Count;
                //Indicate an intercept only model (2) or a non-intercept model (1) or not (0)
                int intInterceptModel = 1;
                for (int j = 0; j < nIndevarlistCnt; j++)
                {
                    if ((string)lstIndeVar.Items[j] == "Intercept")
                    {
                        intInterceptModel = 0;
                    }
                }
                if (nIndevarlistCnt == 1 && intInterceptModel == 0)
                {
                    intInterceptModel = 2;
                }

                int nIDepen = 0;
                if (intInterceptModel == 0)
                {
                    nIDepen = nIndevarlistCnt - 1;
                }
                else if (intInterceptModel == 1)
                {
                    nIDepen = nIndevarlistCnt;
                }

                // Gets the column of the dependent variable
                String dependentName = (string)cboFieldName.SelectedItem;
                //sourceTable.AcceptChanges();
                //DataTable dependent = sourceTable.DefaultView.ToTable(false, dependentName);

                // Gets the columns of the independent variables
                String[] independentNames   = new string[nIDepen];
                int      intIdices          = 0;
                string   strIndependentName = "";
                for (int j = 0; j < nIndevarlistCnt; j++)
                {
                    strIndependentName = (string)lstIndeVar.Items[j];
                    if (strIndependentName != "Intercept")
                    {
                        independentNames[intIdices] = strIndependentName;
                        intIdices++;
                    }
                }

                int nFeature = m_pFClass.FeatureCount(null);

                //Warning for method
                if (rbtEigen.Checked)
                {
                    if (nFeature > m_pForm.intWarningCount)
                    {
                        DialogResult dialogResult = MessageBox.Show("It might take a lot of time. Do you want to continue?", "Warning", MessageBoxButtons.YesNo);

                        if (dialogResult == DialogResult.No)
                        {
                            pfrmProgress.Close();
                            return;
                        }
                    }
                }

                IFeatureCursor pFCursor = m_pFLayer.Search(null, true);
                IFeature       pFeature = pFCursor.NextFeature();

                //Get index for independent and dependent variables
                int   intDepenIdx = m_pFLayer.FeatureClass.Fields.FindField(dependentName);
                int[] idxes       = new int[nIDepen];

                for (int j = 0; j < nIDepen; j++)
                {
                    idxes[j] = m_pFLayer.FeatureClass.Fields.FindField(independentNames[j]);
                }


                //Store independent values at Array
                double[]   arrDepen   = new double[nFeature];
                double[][] arrInDepen = new double[nIDepen][]; //Zigzaged Array needs to be define

                for (int j = 0; j < nIDepen; j++)
                {
                    arrInDepen[j] = new double[nFeature];
                }

                int i = 0;
                while (pFeature != null)
                {
                    arrDepen[i] = Convert.ToDouble(pFeature.get_Value(intDepenIdx));

                    for (int j = 0; j < nIDepen; j++)
                    {
                        arrInDepen[j][i] = Convert.ToDouble(pFeature.get_Value(idxes[j]));
                    }

                    i++;
                    pFeature = pFCursor.NextFeature();
                }
                //Plot command for R
                StringBuilder plotCommmand = new StringBuilder();

                if (!m_blnCreateSWM)
                {
                    //Get the file path and name to create spatial weight matrix
                    string strNameR = m_pSnippet.FilePathinRfromLayer(m_pFLayer);

                    if (strNameR == null)
                    {
                        return;
                    }

                    //Create spatial weight matrix in R
                    if (m_pFClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                    {
                        m_pEngine.Evaluate("sample.shp <- readShapePoly('" + strNameR + "')");
                    }
                    else if (m_pFClass.ShapeType == esriGeometryType.esriGeometryPoint)
                    {
                        m_pEngine.Evaluate("sample.shp <- readShapePoints('" + strNameR + "')");
                    }
                    else
                    {
                        MessageBox.Show("This geometry type is not supported");
                        pfrmProgress.Close();
                        this.Close();
                    }


                    int intSuccess = m_pSnippet.CreateSpatialWeightMatrix(m_pEngine, m_pFClass, txtSWM.Text, pfrmProgress);
                    if (intSuccess == 0)
                    {
                        return;
                    }
                }

                //Dependent variable to R vector
                NumericVector vecDepen = m_pEngine.CreateNumericVector(arrDepen);
                m_pEngine.SetSymbol(dependentName, vecDepen);
                if (rbtError.Checked)
                {
                    plotCommmand.Append("errorsarlm(" + dependentName + "~");
                }
                else if (rbtLag.Checked || rbtDurbin.Checked)
                {
                    plotCommmand.Append("lagsarlm(" + dependentName + "~");
                }
                else
                {
                    plotCommmand.Append("spautolm(" + dependentName + "~");
                }

                if (intInterceptModel == 2)
                {
                    plotCommmand.Append("1");
                }
                else
                {
                    for (int j = 0; j < nIDepen; j++)
                    {
                        //double[] arrVector = arrInDepen.GetColumn<double>(j);
                        NumericVector vecIndepen = m_pEngine.CreateNumericVector(arrInDepen[j]);
                        m_pEngine.SetSymbol(independentNames[j], vecIndepen);
                        plotCommmand.Append(independentNames[j] + "+");
                    }
                    plotCommmand.Remove(plotCommmand.Length - 1, 1);

                    if (intInterceptModel == 1)
                    {
                        plotCommmand.Append("-1");
                    }
                }

                //Select Method
                if (rbtEigen.Checked)
                {
                    plotCommmand.Append(", method='eigen'");
                }
                else if (rbtMatrix.Checked)
                {
                    plotCommmand.Append(", method='Matrix'");
                }
                else if (rbtMatrixJ.Checked)
                {
                    plotCommmand.Append(", method='Matrix_J'");
                }
                else if (rbtLU.Checked)
                {
                    plotCommmand.Append(", method='LU'");
                }
                else if (rbtChebyshev.Checked)
                {
                    plotCommmand.Append(", method='Chebyshev'");
                }
                else if (rbtMC.Checked)
                {
                    plotCommmand.Append(", method='MC'");
                }
                else
                {
                    plotCommmand.Append(", method='eigen'");
                }

                if (rbtError.Checked)
                {
                    plotCommmand.Append(", listw=sample.listw,  tol.solve=1.0e-20, zero.policy=TRUE)");
                }
                else if (rbtLag.Checked)
                {
                    plotCommmand.Append(", listw=sample.listw,  tol.solve=1.0e-20, zero.policy=TRUE)");
                }
                else if (rbtCAR.Checked)
                {
                    plotCommmand.Append(", listw=sample.listw, family='CAR', verbose=TRUE, zero.policy=TRUE)");
                }
                else if (rbtSMA.Checked)
                {
                    plotCommmand.Append(", listw=sample.listw, family='SMA', verbose=TRUE, zero.policy=TRUE)");
                }
                else if (rbtDurbin.Checked)
                {
                    plotCommmand.Append(", type='mixed', listw=sample.listw,  tol.solve=1.0e-20, zero.policy=TRUE)");
                }
                else
                {
                    return;
                }

                try
                {
                    m_pEngine.Evaluate("sum.lm <- summary(" + plotCommmand.ToString() + ", Nagelkerke=T)");
                }
                catch
                {
                    MessageBox.Show("Cannot solve the regression. Try again with different variables.");
                    pfrmProgress.Close();
                    return;
                }

                //Collect results from R
                NumericMatrix matCoe = m_pEngine.Evaluate("as.matrix(sum.lm$Coef)").AsNumericMatrix();

                double dblLRLambda = m_pEngine.Evaluate("as.numeric(sum.lm$LR1$statistic)").AsNumeric().First();
                double dblpLambda  = m_pEngine.Evaluate("as.numeric(sum.lm$LR1$p.value)").AsNumeric().First();

                double dblLRErrorModel = m_pEngine.Evaluate("as.numeric(sum.lm$LR1$estimate)").AsNumeric().First();

                double dblSigmasquared = 0;
                double dblAIC          = 0;
                double dblWald         = 0;
                double dblpWald        = 0;

                if (rbtLag.Checked || rbtError.Checked || rbtDurbin.Checked)
                {
                    dblSigmasquared = m_pEngine.Evaluate("as.numeric(sum.lm$s2)").AsNumeric().First();
                    //dblAIC = pEngine.Evaluate("as.numeric(sum.lm$AIC_lm.model)").AsNumeric().First();
                    dblWald  = m_pEngine.Evaluate("as.numeric(sum.lm$Wald1$statistic)").AsNumeric().First();
                    dblpWald = m_pEngine.Evaluate("as.numeric(sum.lm$Wald1$p.value)").AsNumeric().First();

                    double dblParaCnt = m_pEngine.Evaluate("as.numeric(sum.lm$parameters)").AsNumeric().First();
                    dblAIC = (2 * dblParaCnt) - (2 * dblLRErrorModel);
                }
                else
                {
                    dblSigmasquared = m_pEngine.Evaluate("as.numeric(sum.lm$fit$s2)").AsNumeric().First();
                    double dblParaCnt = m_pEngine.Evaluate("as.numeric(sum.lm$parameters)").AsNumeric().First();
                    dblAIC = (2 * dblParaCnt) - (2 * dblLRErrorModel);
                }

                double dblLambda    = 0;
                double dblSELambda  = 0;
                double dblResiAuto  = 0;
                double dblResiAutoP = 0;

                if (rbtLag.Checked || rbtDurbin.Checked)
                {
                    dblLambda    = m_pEngine.Evaluate("as.numeric(sum.lm$rho)").AsNumeric().First();
                    dblSELambda  = m_pEngine.Evaluate("as.numeric(sum.lm$rho.se)").AsNumeric().First();
                    dblResiAuto  = m_pEngine.Evaluate("as.numeric(sum.lm$LMtest)").AsNumeric().First();
                    dblResiAutoP = m_pEngine.Evaluate("as.numeric(sum.lm$rho.se)").AsNumeric().First();
                }
                else
                {
                    dblLambda   = m_pEngine.Evaluate("as.numeric(sum.lm$lambda)").AsNumeric().First();
                    dblSELambda = m_pEngine.Evaluate("as.numeric(sum.lm$lambda.se)").AsNumeric().First();
                }

                double dblRsquared = 0;
                //Previous method
                //if(intInterceptModel != 1)
                //    dblRsquared = m_pEngine.Evaluate("as.numeric(sum.lm$NK)").AsNumeric().First();

                //New pseduo R squared calculation
                if (rbtError.Checked || rbtLag.Checked || rbtDurbin.Checked)
                {
                    dblRsquared = m_pEngine.Evaluate("summary(lm(sum.lm$y~sum.lm$fitted.values))$r.squared").AsNumeric().First();
                }
                else
                {
                    dblRsquared = m_pEngine.Evaluate("summary(lm(sum.lm$Y~sum.lm$fit$fitted.values))$r.squared").AsNumeric().First();
                }


                //Open Ouput form
                frmRegResult pfrmRegResult = new frmRegResult();
                if (rbtError.Checked)
                {
                    pfrmRegResult.Text = "Spatial Autoregressive Model Summary (Error Model)";
                }
                else if (rbtLag.Checked)
                {
                    pfrmRegResult.Text = "Spatial Autoregressive Model Summary (Lag Model)";
                }
                else if (rbtCAR.Checked)
                {
                    pfrmRegResult.Text = "Spatial Autoregressive Model Summary (CAR Model)";
                }
                else if (rbtDurbin.Checked)
                {
                    pfrmRegResult.Text = "Spatial Autoregressive Model Summary (Spatial Durbin Model)";
                }
                else
                {
                    pfrmRegResult.Text = "Spatial Autoregressive Model Summary (SMA Model)";
                }

                //pfrmRegResult.panel2.Visible = true;
                //Create DataTable to store Result
                System.Data.DataTable tblRegResult = new DataTable("SRResult");

                //Assign DataTable
                DataColumn dColName = new DataColumn();
                dColName.DataType   = System.Type.GetType("System.String");
                dColName.ColumnName = "Name";
                tblRegResult.Columns.Add(dColName);

                DataColumn dColValue = new DataColumn();
                dColValue.DataType   = System.Type.GetType("System.Double");
                dColValue.ColumnName = "Estimate";
                tblRegResult.Columns.Add(dColValue);

                DataColumn dColSE = new DataColumn();
                dColSE.DataType   = System.Type.GetType("System.Double");
                dColSE.ColumnName = "Std. Error";
                tblRegResult.Columns.Add(dColSE);
                String.Format("{0:0.##}", tblRegResult.Columns["Std. Error"]);

                DataColumn dColTValue = new DataColumn();
                dColTValue.DataType   = System.Type.GetType("System.Double");
                dColTValue.ColumnName = "z value";
                tblRegResult.Columns.Add(dColTValue);

                DataColumn dColPvT = new DataColumn();
                dColPvT.DataType   = System.Type.GetType("System.Double");
                dColPvT.ColumnName = "Pr(>|z|)";
                tblRegResult.Columns.Add(dColPvT);

                //if (rbtDurbin.Checked)
                //    nIDepen = nIDepen * 2;

                int intNCoeff = matCoe.RowCount;

                //Store Data Table by R result
                for (int j = 0; j < intNCoeff; j++)
                {
                    DataRow pDataRow = tblRegResult.NewRow();
                    if (j == 0 && intInterceptModel != 1)
                    {
                        pDataRow["Name"] = "(Intercept)";
                    }
                    else if (intInterceptModel == 1)
                    {
                        if (rbtDurbin.Checked)
                        {
                            if (j <= intNCoeff / 2)
                            {
                                pDataRow["Name"] = independentNames[j];
                            }
                            else
                            {
                                pDataRow["Name"] = "lag." + independentNames[j - (intNCoeff / 2)];
                            }
                        }
                        else
                        {
                            pDataRow["Name"] = independentNames[j];
                        }
                    }
                    else
                    {
                        if (rbtDurbin.Checked)
                        {
                            if (j <= intNCoeff / 2)
                            {
                                pDataRow["Name"] = independentNames[j - 1];
                            }
                            else
                            {
                                pDataRow["Name"] = "lag." + independentNames[j - (intNCoeff / 2) - 1];
                            }
                        }
                        else
                        {
                            pDataRow["Name"] = independentNames[j - 1];
                        }
                    }
                    pDataRow["Estimate"]   = Math.Round(matCoe[j, 0], intDeciPlaces);
                    pDataRow["Std. Error"] = Math.Round(matCoe[j, 1], intDeciPlaces);
                    pDataRow["z value"]    = Math.Round(matCoe[j, 2], intDeciPlaces);
                    pDataRow["Pr(>|z|)"]   = Math.Round(matCoe[j, 3], intDeciPlaces);


                    tblRegResult.Rows.Add(pDataRow);
                }

                //Assign Datagridview to Data Table
                pfrmRegResult.dgvResults.DataSource = tblRegResult;

                //Assign values at Textbox
                string   strDecimalPlaces = "N" + intDeciPlaces.ToString();
                string[] strResults       = new string[5];
                if (rbtLag.Checked || rbtDurbin.Checked)
                {
                    if (dblpLambda < 0.001)
                    {
                        strResults[0] = "rho: " + dblLambda.ToString(strDecimalPlaces) +
                                        ", LR Test Value: " + dblLRLambda.ToString(strDecimalPlaces) + ", p-value < 0.001";
                    }
                    else if (dblpLambda > 0.999)
                    {
                        strResults[0] = "rho: " + dblLambda.ToString(strDecimalPlaces) +
                                        ", LR Test Value: " + dblLRLambda.ToString(strDecimalPlaces) + ", p-value > 0.999";
                    }
                    else
                    {
                        strResults[0] = "rho: " + dblLambda.ToString(strDecimalPlaces) +
                                        ", LR Test Value: " + dblLRLambda.ToString(strDecimalPlaces) + ", p-value: " + dblpLambda.ToString(strDecimalPlaces);
                    }

                    if (dblpWald < 0.001)
                    {
                        strResults[1] = "Asymptotic S.E: " + dblSELambda.ToString(strDecimalPlaces) +
                                        ", Wald: " + dblWald.ToString(strDecimalPlaces) + ", p-value < 0.001";
                    }
                    else if (dblpWald > 0.999)
                    {
                        strResults[1] = "Asymptotic S.E: " + dblSELambda.ToString(strDecimalPlaces) +
                                        ", Wald: " + dblWald.ToString(strDecimalPlaces) + ", p-value > 0.999";
                    }
                    else
                    {
                        strResults[1] = "Asymptotic S.E: " + dblSELambda.ToString(strDecimalPlaces) +
                                        ", Wald: " + dblWald.ToString(strDecimalPlaces) + ", p-value: " + dblpWald.ToString(strDecimalPlaces);
                    }


                    strResults[2] = "Log likelihood: " + dblLRErrorModel.ToString(strDecimalPlaces) +
                                    ", Sigma-squared: " + dblSigmasquared.ToString(strDecimalPlaces);
                    strResults[3] = "AIC: " + dblAIC.ToString(strDecimalPlaces) + ", LM test for residuals autocorrelation: " + dblResiAuto.ToString(strDecimalPlaces);
                }
                else if (rbtError.Checked)
                {
                    if (dblpLambda < 0.001)
                    {
                        strResults[0] = "Lambda: " + dblLambda.ToString(strDecimalPlaces) +
                                        ", LR Test Value: " + dblLRLambda.ToString(strDecimalPlaces) + ", p-value < 0.001";
                    }
                    else if (dblpLambda > 0.999)
                    {
                        strResults[0] = "Lambda: " + dblLambda.ToString(strDecimalPlaces) +
                                        ", LR Test Value: " + dblLRLambda.ToString(strDecimalPlaces) + ", p-value > 0.999";
                    }
                    else
                    {
                        strResults[0] = "Lambda: " + dblLambda.ToString(strDecimalPlaces) +
                                        ", LR Test Value: " + dblLRLambda.ToString(strDecimalPlaces) + ", p-value: " + dblpLambda.ToString(strDecimalPlaces);
                    }

                    if (dblpWald < 0.001)
                    {
                        strResults[1] = "Asymptotic S.E: " + dblSELambda.ToString(strDecimalPlaces) +
                                        ", Wald: " + dblWald.ToString(strDecimalPlaces) + ", p-value < 0.001";
                    }
                    else if (dblpWald > 0.999)
                    {
                        strResults[1] = "Asymptotic S.E: " + dblSELambda.ToString(strDecimalPlaces) +
                                        ", Wald: " + dblWald.ToString(strDecimalPlaces) + ", p-value > 0.999";
                    }
                    else
                    {
                        strResults[1] = "Asymptotic S.E: " + dblSELambda.ToString(strDecimalPlaces) +
                                        ", Wald: " + dblWald.ToString(strDecimalPlaces) + ", p-value: " + dblpWald.ToString(strDecimalPlaces);
                    }

                    //strResults[0] = "Lambda: " + dblLambda.ToString(strDecimalPlaces) +
                    //    ", LR Test Value: " + dblLRLambda.ToString(strDecimalPlaces) + ", p-value: " + dblpLambda.ToString(strDecimalPlaces);
                    //strResults[1] = "Asymptotic S.E: " + dblSELambda.ToString(strDecimalPlaces) +
                    //    ", Wald: " + dblWald.ToString(strDecimalPlaces) + ", p-value: " + dblpWald.ToString(strDecimalPlaces);
                    strResults[2] = "Log likelihood: " + dblLRErrorModel.ToString(strDecimalPlaces) +
                                    ", Sigma-squared: " + dblSigmasquared.ToString(strDecimalPlaces);
                    strResults[3] = "AIC: " + dblAIC.ToString(strDecimalPlaces);
                }
                else
                {
                    if (dblpLambda < 0.001)
                    {
                        strResults[0] = "Lambda: " + dblLambda.ToString(strDecimalPlaces) +
                                        ", LR Test Value: " + dblLRLambda.ToString(strDecimalPlaces) + ", p-value < 0.001";
                    }
                    else if (dblpLambda > 0.999)
                    {
                        strResults[0] = "Lambda: " + dblLambda.ToString(strDecimalPlaces) +
                                        ", LR Test Value: " + dblLRLambda.ToString(strDecimalPlaces) + ", p-value > 0.999";
                    }
                    else
                    {
                        strResults[0] = "Lambda: " + dblLambda.ToString(strDecimalPlaces) +
                                        ", LR Test Value: " + dblLRLambda.ToString(strDecimalPlaces) + ", p-value: " + dblpLambda.ToString(strDecimalPlaces);
                    }

                    strResults[1] = "Numerical Hessian S.E of lambda: " + dblSELambda.ToString(strDecimalPlaces);
                    strResults[2] = "Log likelihood: " + dblLRErrorModel.ToString(strDecimalPlaces) +
                                    ", Sigma-squared: " + dblSigmasquared.ToString(strDecimalPlaces);
                    strResults[3] = "AIC: " + dblAIC.ToString(strDecimalPlaces);
                }
                //if (intInterceptModel != 1)
                //    strResults[4] = "Pseudo-R-squared: " + dblRsquared.ToString(strDecimalPlaces);
                //else
                //    strResults[4] = "";

                strResults[4] = "Pseudo-R-squared: " + dblRsquared.ToString(strDecimalPlaces);

                pfrmRegResult.txtOutput.Lines = strResults;

                //Save Outputs in SHP
                if (chkSave.Checked)
                {
                    pfrmProgress.lblStatus.Text = "Saving residuals:";
                    //The field names are related with string[] DeterminedName in clsSnippet
                    string strResiFldName = lstSave.Items[0].SubItems[1].Text;

                    //Get EVs and residuals
                    NumericVector nvResiduals = m_pEngine.Evaluate("as.numeric(sum.lm$residuals)").AsNumeric();
                    if (rbtCAR.Checked || rbtSMA.Checked)
                    {
                        nvResiduals = m_pEngine.Evaluate("as.numeric(sum.lm$fit$residuals)").AsNumeric();
                    }

                    // Create field, if there isn't
                    if (m_pFClass.FindField(strResiFldName) == -1)
                    {
                        //Add fields
                        IField     newField  = new FieldClass();
                        IFieldEdit fieldEdit = (IFieldEdit)newField;
                        fieldEdit.Name_2 = strResiFldName;
                        fieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                        m_pFClass.AddField(newField);
                    }
                    else
                    {
                        DialogResult dialogResult = MessageBox.Show("Do you want to overwrite " + strResiFldName + " field?", "Overwrite", MessageBoxButtons.YesNo);

                        if (dialogResult == DialogResult.No)
                        {
                            return;
                        }
                    }


                    //Update Field
                    pFCursor.Flush();
                    pFCursor = m_pFClass.Update(null, false);
                    pFeature = pFCursor.NextFeature();

                    int featureIdx    = 0;
                    int intResiFldIdx = m_pFClass.FindField(strResiFldName);

                    while (pFeature != null)
                    {
                        //Update Residuals
                        pFeature.set_Value(intResiFldIdx, (object)nvResiduals[featureIdx]);

                        pFCursor.UpdateFeature(pFeature);

                        pFeature = pFCursor.NextFeature();
                        featureIdx++;
                    }
                }

                pfrmProgress.Close();
                pfrmRegResult.Show();
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
		private IFeatureCursor SortData(IFeatureCursor pCursor, ITrackCancel pTrackCancel)
		{
			// sort in descending by value
			ITable pTable = null;
			pTable = m_pFeatureClass as ITable;

			ITableSort pTableSort = null;
			pTableSort = new TableSort();
			pTableSort.Table = pTable;
			pTableSort.Cursor = pCursor as ICursor;

			//set up the query filter.
			IQueryFilter pQF = null;
			pQF = new QueryFilter();
			pQF.SubFields = "*";
			pQF.WhereClause = m_pQueryFilter.WhereClause;
			pTableSort.QueryFilter = pQF;

			IProportionalSymbolRenderer pPSRend = null;
      pPSRend = m_pSizeRend as IProportionalSymbolRenderer;
			string strValueField = null;
			strValueField = pPSRend.Field;
			pTableSort.Fields = strValueField;
			pTableSort.set_Ascending(strValueField, false);

			IDataNormalization pDataNorm = null;
            pDataNorm = pPSRend as IDataNormalization;
			if (pDataNorm.NormalizationType == esriDataNormalization.esriNormalizeByField)
			{
				// comparison is not simple comparison of field values, use callback to do custom compare

				// get normalization field and add to table sort
				string strFields = "";
				strFields = strFields + strValueField;
				string strNormField = null;
				strNormField = pDataNorm.NormalizationField;
				strFields = strFields + ",";
				strFields = strFields + strNormField;
				pTableSort.Fields = strFields;
				pTableSort.set_Ascending(strNormField, false);

				// create new custom table call sort object and connect to the TableSort object
				ITableSortCallBack pTableSortCallBack = null;
				pTableSortCallBack = new SortCallBack(pTable.Fields.FindField(strValueField), pTable.Fields.FindField(strNormField));
				pTableSort.Compare = pTableSortCallBack;
			}

			// call the sort
			pTableSort.Sort(pTrackCancel);

			// retrieve the sorted rows
			IFeatureCursor pSortedCursor = null;
			pSortedCursor = pTableSort.Rows as IFeatureCursor;

			return pSortedCursor;
		}
示例#36
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (pMap.SelectionCount > 1)
            {
                MessageBox.Show("Please select only one feature (starting point)", "Selection error...");
                return;
            }

            OperationLayer     = comboBox2.Text;
            OperationAttribute = comboBox3.Text;
            Tolerance          = Convert.ToDouble(textBox2.Text);
            NoOfSplit          = Convert.ToInt16(textBox1.Text);


            IEnumLayer pEnumLayer = pMap.Layers;

            ILayer pLayer;


            for (int i = 0; i < pMap.LayerCount; i++)
            {
                pLayer = pEnumLayer.Next();

                if (pLayer.Name.Equals(OperationLayer))
                {
                    IDataset pDataSet = (IDataset)(pLayer);

                    Geoprocessor GP = new Geoprocessor();
                    GP.OverwriteOutput = true;

                    AddField SplitGroup = new AddField();
                    SplitGroup.in_table = pDataSet.Workspace.PathName + System.IO.Path.DirectorySeparatorChar + pDataSet.Name + ".shp";
                    //........
                    workSpacePath = pDataSet.Workspace.PathName;

                    //........
                    SplitGroup.field_name = "SpltGropus";
                    SplitGroup.field_type = "SHORT";

                    GP.Execute(SplitGroup, null);

                    CalculateField CalculateField = new CalculateField();
                    CalculateField.in_table   = pDataSet.Workspace.PathName + System.IO.Path.DirectorySeparatorChar + pDataSet.Name + ".shp";
                    CalculateField.field      = "SpltGropus";
                    CalculateField.expression = "0";
                    GP.Execute(CalculateField, null);


                    AddField TempGroup = new AddField();
                    TempGroup.in_table   = pDataSet.Workspace.PathName + System.IO.Path.DirectorySeparatorChar + pDataSet.Name + ".shp";
                    TempGroup.field_name = "Distance";
                    TempGroup.field_type = "DOUBLE";
                    GP.Execute(TempGroup, null);

                    AggregatePolygons ConcaveHull = new AggregatePolygons();
                    ConcaveHull.aggregation_distance = Tolerance;
                    ConcaveHull.in_features          = pDataSet.Workspace.PathName + System.IO.Path.DirectorySeparatorChar + pDataSet.Name + ".shp";
                    ConcaveHull.out_feature_class    = System.IO.Path.GetTempPath() + System.IO.Path.DirectorySeparatorChar + "Temp_ConcaveHull.shp";

                    GP.AddOutputsToMap = false;

                    GP.Execute(ConcaveHull, null);

                    //IFeatureLayer2 pFeatureLayer21 = (IFeatureLayer2)pLayer;
                    //IFeatureClass pFeatureClass1 = pFeatureLayer21.FeatureClass;

                    //IField spltgrp = new FieldClass();
                    //IFieldEdit spltgrp1 = (IFieldEdit)spltgrp;
                    //spltgrp1.Name_2 = "SpltGropus";
                    //spltgrp1.Type_2 = esriFieldType.esriFieldTypeSmallInteger;
                    //spltgrp = spltgrp1;

                    //IField tmpgrp = new FieldClass();
                    //IFieldEdit tmpgrp1 = (IFieldEdit)tmpgrp;
                    //tmpgrp1.Name_2 = "TempGroups";
                    //tmpgrp1.Type_2 = esriFieldType.esriFieldTypeSmallInteger;
                    //tmpgrp = tmpgrp1;

                    //pFeatureClass1.AddField(spltgrp);
                    //pFeatureClass1.AddField(tmpgrp);

                    IFeatureLayer     pFeatureLayer     = (IFeatureLayer)pLayer;
                    IFeatureSelection pFeatureSelection = (IFeatureSelection)pFeatureLayer;
                    ISelectionSet     pSelectionSet     = pFeatureSelection.SelectionSet;

                    ICursor pCursor;
                    pSelectionSet.Search(null, false, out pCursor);
                    IFeatureCursor pFeatureCursor = (IFeatureCursor)pCursor;

                    IFeature pFeature = pFeatureCursor.NextFeature();

                    GroupIDTotal Group = new GroupIDTotal();
                    Group.setID(1);
                    Group.setCalculatedSplitValue(Convert.ToDouble(pFeature.get_Value(pFeature.Fields.FindField(OperationAttribute))));

                    pFeature.set_Value(pFeature.Fields.FindField("SpltGropus"), 1);
                    pFeature.Store();

                    GroupIDTotalList.Add(Group);

                    //Group = new GroupIDTotal (1,(double)pFeature.get_Value(pFeature.Fields.FindField(OperationAttribute)));


                    IFeatureLayer2 pFeatureLayer2 = (IFeatureLayer2)pLayer;
                    IFeatureClass  pFeatureClass  = pFeatureLayer2.FeatureClass;
                    IQueryFilter   pQueryFilter   = new QueryFilter();
                    pQueryFilter.WhereClause = null;

                    IFeatureCursor pFeatureCursor1 = pFeatureClass.Search(pQueryFilter, false);
                    IFeature       pFeature1;

                    for (int j = 0; j < pFeatureClass.FeatureCount(pQueryFilter); j++)
                    {
                        pFeature1  = pFeatureCursor1.NextFeature();
                        FieldTotal = FieldTotal + Convert.ToDouble(pFeature1.get_Value(pFeature1.Fields.FindField(OperationAttribute)));
                    }

                    EqualPartValue = FieldTotal / Convert.ToInt16(textBox1.Text);

                    F2FDistance.MakeDistanceArray(pFeature, GroupIDTotalList[0].getID());

                    int k = 2;
                    while ((NoOfSplit - 1) != RegionFormed)
                    {
                        IFeature NextStartingFeature = StaticMethodsClass.FindNextStartingFeature(RegionGeomtry);

                        //MessageBox.Show("..." + NextStartingFeature.OID, "hi");
                        GroupIDTotal NextGroup = new GroupIDTotal();
                        NextGroup.setID((short)k);
                        NextGroup.setCalculatedSplitValue(Convert.ToDouble(NextStartingFeature.get_Value(NextStartingFeature.Fields.FindField(OperationAttribute))));

                        NextStartingFeature.set_Value(NextStartingFeature.Fields.FindField("SpltGropus"), k);
                        NextStartingFeature.Store();

                        GroupIDTotalList.Add(NextGroup);

                        F2FDistance.MakeDistanceArray(NextStartingFeature, GroupIDTotalList[k - 1].getID());

                        k = k + 1;
                    }


                    //
                    //IGeometry pPol = CreateConvexHull.Create(pFeatureCursor1);
                    //IFeature dd = pFeatureClass.CreateFeature();
                    //dd.Shape = pPol;

                    //dd.Store();

                    //IActiveView activeView = pMap as IActiveView;
                    //activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);
                    //MessageBox.Show("...", "hi");

                    //
                }
            }


            MessageBox.Show("..." + FieldTotal + "..." + EqualPartValue, "hi");
            //MessageBox.Show("..." + pFeature1.OID, "hi");
        }
		private void DrawSymbols(IFeatureCursor Cursor, esriDrawPhase drawPhase, IDisplay Display, ITrackCancel trackCancel)
		{

			IFeature pFeat = null;
			IFeatureDraw pFeatDraw = null;
			bool bContinue = true;
			ISymbol pDrawSym = null;

			pFeat = Cursor.NextFeature();
			bContinue = true;
			// while there are still more features and drawing has not been cancelled
			while ((pFeat != null) & (bContinue == true))
			{
				// get symbol to draw
				pDrawSym = GetFeatureSymbol(pFeat);
				// draw the feature
				pFeatDraw = pFeat as IFeatureDraw;
				Display.SetSymbol(pDrawSym);

        //implementation of IExportSupport
        BeginFeature(pFeat, Display);
        
				pFeatDraw.Draw(drawPhase, Display, pDrawSym, true, null, esriDrawStyle.esriDSNormal);

        //implementation of IExportSupport
        GenerateExportInfo(pFeat, Display);
        EndFeature(Display);
        
				// get next feature
				pFeat = Cursor.NextFeature();
				if (trackCancel != null)
						bContinue = trackCancel.Continue();
			}

		}
示例#38
0
        public double RotatePoint(IMap pMap, IFeature pPointFeature, bool bArithmeticAngle, string strDiameterFld, string strLayerName)
        {
            IFeatureClass        pPointFC     = default(IFeatureClass);
            ISpatialFilter       pSFilter     = default(ISpatialFilter);
            IFeatureCursor       pLineCursor  = default(IFeatureCursor);
            IFeature             pLineFeature = default(IFeature);
            IPoint               pPoint       = default(IPoint);
            IEnumLayer           pEnumLayer   = default(IEnumLayer);
            ILayer               pLayer       = default(ILayer);
            IFeatureLayer        pFLayer      = default(IFeatureLayer);
            UID                  pId          = new UID();
            UID                  pUID         = new UID();
            ITopologicalOperator pTopo        = null;

            List <Double> cAngles    = new List <Double>();
            List <string> pLstInt    = new List <string>();
            List <double> cDiameters = new List <double>();


            double dblAngle              = 0;
            double dblDiameter           = 0;
            double ltest                 = 0;
            int    iLineDiameterFieldPos = 0;

            try
            {
                //This routine is used by both RotateDuringCreateFeature and RotateSelectedFeature.
                //It contains all of logic for determining the rotation angle.

                const int iAngleTol = 5;
                //Used for Tees> a straight line is 180 + or - iAngleTol



                pPointFC = (IFeatureClass)pPointFeature.Class;
                pPoint   = (IPoint)pPointFeature.Shape;

                //Create spatial filter to find intersecting features at this given point
                pTopo = (ITopologicalOperator)pPoint;

                pSFilter          = new SpatialFilter();
                pSFilter.Geometry = pTopo.Buffer(0.5);
                //pPoint
                pSFilter.GeometryField = pPointFC.ShapeFieldName;
                pSFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;

                //Step through each feature layer
                pUID.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}";
                //GeoFeatureLayer
                pEnumLayer = (IEnumLayer)pMap.get_Layers(pUID, true);
                pEnumLayer.Reset();
                pLayer = (ILayer)pEnumLayer.Next();


                while ((pLayer != null))
                {
                    //Verify that this is a line layer
                    pFLayer = (IFeatureLayer)pLayer;

                    if (pFLayer.FeatureClass != null)
                    {
                        if (pFLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline && pFLayer.Visible && (strLayerName == "" || strLayerName == Globals.getClassName((IDataset)pFLayer.FeatureClass)))
                        {
                            //Apply the filter this line layer
                            pLineCursor = pFLayer.FeatureClass.Search(pSFilter, true);

                            //Loop through the found lines for this layer
                            pLineFeature = pLineCursor.NextFeature();
                            while ((pLineFeature != null))
                            {
                                if (pLstInt.Count > 0)
                                {
                                    if (pLstInt.Contains(pLineFeature.Class.ObjectClassID + " " + pLineFeature.OID))
                                    {
                                        pLineFeature = pLineCursor.NextFeature();
                                        continue;
                                    }
                                }
                                pLstInt.Add(pLineFeature.Class.ObjectClassID.ToString() + " " + pLineFeature.OID.ToString());

                                dblAngle = Globals.GetAngleOfLineAtPoint((IPolyline)pLineFeature.ShapeCopy, (IPoint)pPointFeature.ShapeCopy, Globals.GetXYTolerance(pPointFeature));
                                dblAngle = Globals.ConvertRadsToDegrees(dblAngle);


                                //Convert to geographic degrees(zero north clockwise)
                                if (!(bArithmeticAngle))
                                {
                                    dblAngle = Globals.ConvertArithmeticToGeographic(dblAngle);
                                }
                                //Round angle
                                dblAngle = Math.Round(dblAngle, 4);

                                //Find diameter field, if it exists
                                iLineDiameterFieldPos = pFLayer.FeatureClass.FindField(strDiameterFld);

                                //Get diameter of line
                                if (iLineDiameterFieldPos < 0)
                                {
                                    dblDiameter = -9999;
                                }
                                else if (pLineFeature.get_Value(iLineDiameterFieldPos) == null)
                                {
                                    dblDiameter = -9999;
                                }
                                else if (object.ReferenceEquals(pLineFeature.get_Value(iLineDiameterFieldPos), DBNull.Value))
                                {
                                    dblDiameter = -9999;
                                }
                                else
                                {
                                    Double.TryParse(pLineFeature.get_Value(iLineDiameterFieldPos).ToString(), out dblDiameter);
                                }

                                //add this line (angle and diameter) to a collection of line info for this point
                                cAngles.Add(dblAngle);

                                if (dblDiameter != -9999)
                                {
                                    cDiameters.Add(dblDiameter);
                                }

                                //Get next line
                                pLineFeature = pLineCursor.NextFeature();
                            }
                        }
                    }
                    //Get next line layer
                    pLayer = pEnumLayer.Next();
                }

                //Read the collection of line segment angles and diameters
                //and use them to derive a symbol rotation angle for the point
                switch (cAngles.Count)
                {
                case 0:
                    //One line such as at valves

                    return(0.0);

                case 1:
                    //One line such as at valves
                    return(cAngles[0]);

                case 2:
                    //Two lines such as at reducers Or at tee fittings where line is not broken

                    if (cDiameters.Count == 2)
                    {
                        //If cDiameters(0) Is Nothing Or cDiameters(1) Is Nothing Then
                        //    Return cAngles.Item(0)
                        //Else
                        if (cDiameters[0] > cDiameters[1])
                        {
                            return(cAngles[1]);
                            //If cAngles.Item(0) = cAngles.Item(1) Then
                            //    Return cAngles.Item(1)
                            //Else
                            //    Return cAngles.Item(1) - 180
                            //End If
                        }
                        else
                        {
                            return(cAngles[0]);
                            //If cAngles.Item(0) = cAngles.Item(1) Then
                            //    Return cAngles.Item(0) - 180
                            //Else
                            //    Return cAngles.Item(1)
                            //End If
                        }
                    }
                    else
                    {
                        return(cAngles[0]);
                    }

                    break;

                case 3:
                    //Three lines such as at tee fittings where line is broken
                    ltest = Math.Abs(cAngles[0] - cAngles[1]);
                    if (ltest >= 180 - iAngleTol & ltest <= 180 + iAngleTol)
                    {
                        return(cAngles[2]);
                    }
                    else
                    {
                        ltest = Math.Abs(cAngles[0] - cAngles[2]);
                        if (ltest >= 180 - iAngleTol & ltest <= 180 + iAngleTol)
                        {
                            return(cAngles[1]);
                        }
                        else
                        {
                            ltest = Math.Abs(cAngles[1] - cAngles[2]);
                            if (ltest >= 180 - iAngleTol & ltest <= 180 + iAngleTol)
                            {
                                return(cAngles[0]);
                            }
                            else
                            {
                                return(-360);
                            }
                        }
                    }
                    break;

                case 4:
                    //Four lines such as at crosses
                    //the angle of any of the four lines should work since the symbol should be symetrically
                    return(cAngles[0]);

                default:
                    return(0);
                }

                //Clear collections
            }
            catch
            {
                return(0);
            }
            finally
            {
                pPointFC     = null;
                pSFilter     = null;
                pLineCursor  = null;
                pLineFeature = null;
                pPoint       = null;
                pEnumLayer   = null;
                pLayer       = null;
                pFLayer      = null;
                pId          = null;
                pUID         = null;
                pTopo        = null;

                cAngles.Clear();
                pLstInt.Clear();
                cDiameters.Clear();
            }
        }
        protected override void OnShutdown()
        {
            try
            {
                script = null;
                lastValue = null;

                areaLayer = null;
                intersectLayer = null;

                intersectTable = null;
                intersectLayerSelection = null;
                intersectTableSelection = null;
                qFilter = null;
                row = null;
                testField = null;

                curve = null;
                sourceLayer = null;
                pFS = null;

                _copyPoint = null;
                _copyPolyline = null;
                _copyPolygon = null;
                sFilter = null;
                try
                {
                    if (fCursor != null)
                        Marshal.ReleaseComObject(fCursor);
                    if (cCurs != null)
                        Marshal.ReleaseComObject(cCurs);
                    if (sourceFeature != null)
                        Marshal.ReleaseComObject(sourceFeature);

                }
                catch
                { }
                fCursor = null;
                cCurs = null;

                sourceFeature = null;
                nearestFeature = null;
                fieldObj = null;
                _currentDataset = null;
                proxOp = null;

            }
            catch { }
            try
            {
                if (AAState._sw != null)
                {
                    AAState._sw.Flush();
                    AAState._sw.Close();
                    AAState._sw = null;
                }

            }
            catch { }
            try
            {
                //ESRI.ArcGIS.ArcMap.IApplicationStatusEvents_Event appStatusEvents = ArcMap.Application as ESRI.ArcGIS.ArcMap.IApplicationStatusEvents_Event;
                //appStatusEvents.Initialized -= new ESRI.ArcGIS.ArcMap.IApplicationStatusEvents_InitializedEventHandler(appStatusEvents_Initialized);
                if (ArcMap.Events != null)
                {
                    ArcMap.Events.NewDocument -= ArcMap_NewOpenDocument;
                    ArcMap.Events.OpenDocument -= ArcMap_NewOpenDocument;
                }
                if (AAState._editor != null)
                {

                    if (AAState._editor != null)
                    {

                        //Wire editor events.
                        AAState._editEvents = (IEditEvents_Event)AAState._editor;
                        AAState._editEvents.OnStartEditing -= OnStartEditing;
                        AAState._editEvents.OnStopEditing -= OnStopEditing;

                        AAState._editor = null;
                        AAState._editEvents = null;

                    }
                }

                try
                {
                    AAState.bmpOff.Dispose();
                    AAState.bmpOn.Dispose();
                    AAState.commandItem = null;
                }
                catch { }
            }

            catch (Exception ex)
            {
                MessageBox.Show("OnShutdown: " + ex.Message);

            }
        }
示例#40
0
        public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY)
        {
            DF2DApplication app = DF2DApplication.Application;

            this._dict.Clear();
            bool ready = true;

            if (app == null || app.Current2DMapControl == null || app.Workbench == null)
            {
                return;
            }
            app.Workbench.SetMenuEnable(true);
            m_ActiveView = app.Current2DMapControl.ActiveView;
            IScreenDisplay m_Display = app.Current2DMapControl.ActiveView.ScreenDisplay;
            IGeometry      pGeo      = null;

            try
            {
                if (button == 1)
                {
                    ISimpleLineSymbol pLineSym = new SimpleLineSymbol();
                    IRgbColor         pColor   = new RgbColorClass();
                    pColor.Red     = 255;
                    pColor.Green   = 255;
                    pColor.Blue    = 0;
                    pLineSym.Color = pColor;
                    pLineSym.Style = esriSimpleLineStyle.esriSLSSolid;
                    pLineSym.Width = 2;

                    //pColor = Convert.ToUInt32(SystemInfo.Instance.LineColor, 16);
                    IRubberBand pRubberBand;
                    pRubberBand = new RubberLineClass();
                    IGeometry pLine;
                    pLine = pRubberBand.TrackNew(m_Display, null);
                    //IPolyline pLine = app.Current2DMapControl.TrackLine() as IPolyline;

                    object symbol = pLineSym as object;
                    app.Current2DMapControl.DrawShape(pLine, ref symbol);

                    WaitForm.Start("正在查询...", "请稍后");
                    //if (GlobalValue.System_Selection_Environment(m_ActiveView).CombinationMethod == 0)//new selection
                    //{
                    //    this.m_ActiveView.FocusMap.ClearSelection();
                    //}
                    pGeo = PublicFunction.DoBuffer(pLine,
                                                   PublicFunction.ConvertPixelsToMapUnits(m_ActiveView, GlobalValue.System_Selection_Option().Tolerate));
                    if (pGeo == null)
                    {
                        return;
                    }
                    //m_ActiveView.FocusMap.SelectByShape(pGeo, GlobalValue.System_Selection_Environment(m_ActiveView), false);

                    //if (m_ActiveView.FocusMap.SelectionCount > 0)
                    //{

                    //    ready = true;
                    //    m_ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null);
                    //}
                    //else
                    //{
                    //    m_ActiveView.Refresh();
                    //}


                    if (ready)
                    {
                        //foreach (LogicGroup lg in LogicDataStructureManage2D.Instance.RootLogicGroups)
                        //{
                        foreach (MajorClass mc in FrmMajorClass.Instance.MajorClasses)
                        {
                            foreach (SubClass sc in mc.SubClasses)
                            {
                                if (!sc.Visible2D)
                                {
                                    continue;
                                }
                                string[] arrFc2DId = mc.Fc2D.Split(';');
                                if (arrFc2DId == null)
                                {
                                    continue;
                                }
                                IFeatureCursor pFeatureCursor = null;
                                IFeature       pFeature       = null;
                                foreach (string fc2DId in arrFc2DId)
                                {
                                    DF2DFeatureClass dffc = DF2DFeatureClassManager.Instance.GetFeatureClassByID(fc2DId);
                                    if (dffc == null)
                                    {
                                        continue;
                                    }
                                    IFeatureClass fc   = dffc.GetFeatureClass();
                                    FacilityClass facc = dffc.GetFacilityClass();
                                    if (facc.Name != "PipeLine")
                                    {
                                        continue;
                                    }
                                    if (fc == null || pGeo == null)
                                    {
                                        continue;
                                    }
                                    ISpatialFilter pSpatialFilter = new SpatialFilter();
                                    pSpatialFilter.Geometry   = pGeo;
                                    pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                                    string whereClause = UpOrDown.DecorateWhereClasuse(fc) + mc.ClassifyField + " =  '" + sc.Name + "'";

                                    pSpatialFilter.WhereClause = whereClause;
                                    pFeatureCursor             = fc.Search(pSpatialFilter, false);
                                    if (pFeatureCursor == null)
                                    {
                                        continue;
                                    }
                                    DataTable dt = new DataTable();
                                    dt.TableName = facc.Name;
                                    DataColumn oidcol = new DataColumn();
                                    oidcol.ColumnName = "oid";
                                    oidcol.Caption    = "ID";
                                    dt.Columns.Add(oidcol);
                                    foreach (DFDataConfig.Class.FieldInfo fitemp in facc.FieldInfoCollection)
                                    {
                                        if (!fitemp.CanQuery)
                                        {
                                            continue;
                                        }
                                        DataColumn col = new DataColumn();
                                        col.ColumnName = fitemp.Name;
                                        col.Caption    = fitemp.Alias;
                                        dt.Columns.Add(col);
                                    }
                                    while ((pFeature = pFeatureCursor.NextFeature()) != null)
                                    {
                                        DataRow dtRow = dt.NewRow();
                                        dtRow["oid"] = pFeature.get_Value(pFeature.Fields.FindField("OBJECTID"));
                                        foreach (DataColumn col in dt.Columns)
                                        {
                                            int index1 = pFeature.Fields.FindField(col.ColumnName);
                                            if (index1 < 0)
                                            {
                                                continue;
                                            }
                                            object obj1 = pFeature.get_Value(index1);
                                            string str  = "";
                                            if (obj1 != null)
                                            {
                                                IField field = pFeature.Fields.get_Field(index1);
                                                switch (field.Type)
                                                {
                                                case esriFieldType.esriFieldTypeBlob:
                                                case esriFieldType.esriFieldTypeGeometry:
                                                case esriFieldType.esriFieldTypeRaster:
                                                    continue;

                                                case esriFieldType.esriFieldTypeDouble:
                                                    double d;
                                                    if (double.TryParse(obj1.ToString(), out d))
                                                    {
                                                        str = d.ToString("0.00");
                                                    }
                                                    break;

                                                default:
                                                    str = obj1.ToString();
                                                    break;
                                                }
                                            }
                                            dtRow[col.ColumnName] = str;
                                        }
                                        dt.Rows.Add(dtRow);
                                    }
                                    if (dt.Rows.Count > 0)
                                    {
                                        this._dict.Add(sc.Name, dt);
                                    }
                                }
                            }
                        }
                    }
                }
                WaitForm.Stop();
                try
                {
                    this._uPanel               = new UIDockPanel("查询结果", "查询结果", this.Location, this._width, this._height);
                    this._dockPanel            = FloatPanelManager.Instance.Add(ref this._uPanel, DockingStyle.Right);
                    this._dockPanel.Visibility = DockVisibility.Visible;
                    this._dockPanel.FloatSize  = new System.Drawing.Size(this._width, this._height);
                    this._dockPanel.Width      = this._width;
                    this._dockPanel.Height     = this._height;
                    if (this._ucPropInfo2D == null)
                    {
                        this._ucPropInfo2D = new UCPropertyInfo2D();
                    }
                    this._ucPropInfo2D.Dock = System.Windows.Forms.DockStyle.Fill;
                    this._uPanel.RegisterEvent(new PanelClose(this.Close));
                    this._dockPanel.Controls.Add(this._ucPropInfo2D);
                    this._ucPropInfo2D.Init();
                    this._ucPropInfo2D.SetPropertyInfo(this._dict);
                }
                catch
                {
                }

                //}
            }
            catch
            {
            }
        }
        private static void s_BtnRefreshClick(System.Object sender, System.EventArgs e)
        {
            IFeature pFeat = default(IFeature);

            try
            {

                if (LoadCursor() == false)
                {
                    v_ViewerRecordIndex = -1;
                    s_lblCount.Text = A4LGSharedFunctions.Localizer.GetString("FeatNotFound");//v_ViewerRecordIndex + 1 + A4LGSharedFunctions.Localizer.GetString("OutOf") + v_ViewerLayerCursorArray.Count;

                    v_ViewerLayerCursorArray.Clear();
                    v_ViewerLayerCursor = null;
                    setButtonState();
                    return;

                }
                if (v_ViewerLayerCursorArray == null) {
                    v_ViewerRecordIndex = -1;
                    s_lblCount.Text = A4LGSharedFunctions.Localizer.GetString("FeatNotFound");//v_ViewerRecordIndex + 1 + A4LGSharedFunctions.Localizer.GetString("OutOf") + v_ViewerLayerCursorArray.Count;

                    v_ViewerLayerCursor = null;
                    setButtonState();
                    return;
                }
                if (v_ViewerLayerCursorArray.Count == 0)
                {
                    v_ViewerRecordIndex = -1;
                    s_lblCount.Text = A4LGSharedFunctions.Localizer.GetString("FeatNotFound");//v_ViewerRecordIndex + 1 + A4LGSharedFunctions.Localizer.GetString("OutOf") + v_ViewerLayerCursorArray.Count;

                    v_ViewerLayerCursor = null;
                    setButtonState();
                    return;
                }

                v_ViewerRecordIndex = 0;
                s_lblCount.Text = v_ViewerRecordIndex + 1 + A4LGSharedFunctions.Localizer.GetString("OutOf") + v_ViewerLayerCursorArray.Count;

                pFeat = v_ViewerLayerCursorArray[v_ViewerRecordIndex] as IFeature;

                LoadFeatureToViewer(pFeat);
                if (s_chkZoomToOnAdvance.Checked)
                {
                    Globals.CenterMapOnFeatureWithScale(pFeat, ArcMap.Application, s_txtScale.Text);
                }

                setButtonState();

            }
            catch (Exception ex)
            {
                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("ErrorInThe") + A4LGSharedFunctions.Localizer.GetString("LW_5") + Environment.NewLine + ex.Message);

            }
            finally
            {
                pFeat = null;

            }
        }
示例#42
0
        public void ApplyBarChartValue(IGeoFeatureLayer geoLayer, string aFieldName)
        {
            //IChartRender is engaged with feature data
            IChartRenderer  chartRender  = new ChartRenderer();
            IRendererFields renderFields = chartRender as IRendererFields;

            renderFields.AddField(aFieldName);
            //Search Max
            IQueryFilter queryFilter = new QueryFilter();

            //Content in Cursor
            queryFilter.AddField(aFieldName);
            //Search all features without WhereClause
            IFeatureCursor fCursor = geoLayer.FeatureClass.Search(queryFilter, true);
            //the index of Field
            int           indexField = fCursor.FindField(aFieldName);
            List <double> valueList  = new List <double>();
            IFeature      aFeature   = fCursor.NextFeature();

            while (aFeature != null)
            {
                valueList.Add(Convert.ToDouble(aFeature.get_Value(indexField)));
                aFeature = fCursor.NextFeature();
            }
            //BarChartSymbol
            IBarChartSymbol barSymbol = new BarChartSymbol() as IBarChartSymbol;

            barSymbol.Width = 12;
            IChartSymbol chartSym = barSymbol as IChartSymbol;

            //
            chartSym.MaxValue = valueList.Max();
            IMarkerSymbol markerSymbol = (IMarkerSymbol)chartSym;

            markerSymbol.Size = 50;
            //Set Symbol
            ISymbolArray pSymbolArray = (ISymbolArray)barSymbol;
            IRgbColor    aColor       = new RgbColor();

            aColor.Red   = Convert.ToInt32(255);
            aColor.Green = Convert.ToInt32(255);
            aColor.Blue  = Convert.ToInt32(0);
            ISimpleFillSymbol pFillSymbol = new SimpleFillSymbol();

            pFillSymbol.Color = aColor;
            pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

            //Render Attribute
            chartRender.ChartSymbol   = (IChartSymbol)barSymbol;
            chartRender.Label         = "指标";
            chartRender.UseOverposter = false;
            chartRender.CreateLegend();

            //Back Ground
            ISimpleFillSymbol bgSym   = new SimpleFillSymbol();
            IRgbColor         bgColor = new RgbColor();

            bgColor.Red   = Convert.ToInt32(239);
            bgColor.Green = Convert.ToInt32(228);
            bgColor.Blue  = Convert.ToInt32(190);
            bgSym.Color   = bgColor;
            //bgSym.Color = Convert.ToInt32(System.Drawing.Color.FromArgb(239, 228, 190));
            chartRender.BaseSymbol = (ISymbol)bgSym;

            //Render Label
            geoLayer.ScaleSymbols = true;
            //Scale Symbol
            geoLayer.Renderer = chartRender as IFeatureRenderer;
            axMapControl1.ActiveView.Refresh();
            axTOCControl1.Update();
        }
        private static void s_BtnRefreshClick(System.Object sender, System.EventArgs e)
        {
            IFeature pFeat = default(IFeature);

            try
            {

                if (LoadCursor() == false)
                {
                    v_ViewerRecordIndex = -1;
                    s_lblCount.Text = "No Features Found";//v_ViewerRecordIndex + 1 + " out of " + v_ViewerLayerCursorArray.Count;

                    v_ViewerLayerCursorArray.Clear();
                    v_ViewerLayerCursor = null;
                    setButtonState();
                    return;

                }
                if (v_ViewerLayerCursorArray == null) {
                    v_ViewerRecordIndex = -1;
                    s_lblCount.Text = "No Features Found";//v_ViewerRecordIndex + 1 + " out of " + v_ViewerLayerCursorArray.Count;

                    v_ViewerLayerCursor = null;
                    setButtonState();
                    return;
                }
                if (v_ViewerLayerCursorArray.Count == 0)
                {
                    v_ViewerRecordIndex = -1;
                    s_lblCount.Text = "No Features Found";//v_ViewerRecordIndex + 1 + " out of " + v_ViewerLayerCursorArray.Count;

                    v_ViewerLayerCursor = null;
                    setButtonState();
                    return;
                }

                v_ViewerRecordIndex = 0;
                s_lblCount.Text = v_ViewerRecordIndex + 1 + " out of " + v_ViewerLayerCursorArray.Count;

                pFeat = v_ViewerLayerCursorArray[v_ViewerRecordIndex] as IFeature;

                LoadFeatureToViewer(pFeat);
                if (s_chkZoomToOnAdvance.Checked)
                {
                    Globals.CenterMapOnFeatureWithScale(pFeat, ArcMap.Application, s_txtScale.Text);
                }

                setButtonState();

            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in the Layer Window - s_BtnRefreshClick" + Environment.NewLine + ex.Message);

            }
            finally
            {
                pFeat = null;

            }
        }
示例#44
0
        private void VarioGramCloud()
        {
            try
            {
                string strValueFldNM  = cboValueFld.Text;
                int    intValueFldIdx = m_pFClass.FindField(strValueFldNM);

                int intNFeatureCount = 0;

                IFeatureCursor pFCursor1 = m_pFClass.Search(null, false);
                intNFeatureCount = m_pFClass.FeatureCount(null);

                if (intNFeatureCount == 0)
                {
                    return;
                }

                m_arrValue = new double[intNFeatureCount * (intNFeatureCount - 1)][];

                IFeature pFeature1 = pFCursor1.NextFeature();
                double[,] arrXYPts = new double[intNFeatureCount, 3];
                IPoint pPoint1;
                int    i = 0;
                while (pFeature1 != null)
                {
                    pPoint1 = pFeature1.Shape as IPoint;

                    arrXYPts[i, 0] = pPoint1.X;
                    arrXYPts[i, 1] = pPoint1.Y;
                    arrXYPts[i, 2] = Convert.ToDouble(pFeature1.get_Value(intValueFldIdx));
                    i++;
                    pFeature1 = pFCursor1.NextFeature();
                }

                pChart.Series.Clear();

                //Add Cloud point
                var pPtsCloud = new System.Windows.Forms.DataVisualization.Charting.Series
                {
                    Name              = "Cloud",
                    Color             = Color.Blue,
                    IsVisibleInLegend = false,
                    ChartType         = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point,
                    MarkerStyle       = MarkerStyle.Circle,
                };

                pChart.Series.Add(pPtsCloud);
                m_intTotalNSeries = pChart.Series.Count;

                i = 0;
                for (int j = 0; j < intNFeatureCount; j++)
                {
                    for (int k = 0; k < intNFeatureCount; k++)
                    {
                        if (j != k)
                        {
                            m_arrValue[i]    = new double[6];
                            m_arrValue[i][0] = arrXYPts[j, 0];
                            m_arrValue[i][1] = arrXYPts[j, 1];
                            m_arrValue[i][2] = arrXYPts[k, 0];
                            m_arrValue[i][3] = arrXYPts[k, 1];
                            m_arrValue[i][4] = Math.Sqrt(Math.Pow(arrXYPts[j, 0] - arrXYPts[k, 0], 2) + Math.Pow(arrXYPts[j, 1] - arrXYPts[k, 1], 2));
                            //m_arrValue[i][5] = Math.Abs(arrXYPts[k, 2] - arrXYPts[j, 2]);
                            m_arrValue[i][5] = Math.Pow(arrXYPts[k, 2] - arrXYPts[j, 2], 2);

                            //pPtsCloud.Points.AddXY(m_arrValue[i][4], m_arrValue[i][5]);
                            pPtsCloud.Points.AddXY(m_arrValue[i][4], m_arrValue[i][5] / 2);

                            //for (int l = 1; l <= m_intNDistBnd; l++)
                            //{
                            //    double dblUpperRefDist = l * m_dblDistInc + m_dblBeginDist;
                            //    double dblLowerRefDist = (l - 1) * m_dblDistInc + m_dblBeginDist;
                            //    if (m_arrValue[i][4] < dblUpperRefDist && m_arrValue[i][4] >= dblLowerRefDist)
                            //    {
                            //        m_arrResultIdxs[l - 1].Add(i);
                            //    }
                            //}
                            i++;
                        }
                    }
                }
                m_intTotalFlowCnt = i;
                if (m_intTotalFlowCnt != 0)
                {
                    grbVariogram.Enabled = true;
                }

                pChart.ChartAreas[0].AxisY.Title             = "Gamma";
                pChart.ChartAreas[0].AxisX.LabelStyle.Format = "{0:###0.###}";
                pChart.ChartAreas[0].AxisX.IsStartedFromZero = true;
                pChart.Update();
                m_dblOldXMax = pChart.ChartAreas[0].AxisX.Maximum;
                m_dblOldYMax = pChart.ChartAreas[0].AxisY.Maximum;
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
        private void 删除选中ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (((MessageBox.Show("确定要删除吗", "警告", MessageBoxButtons.YesNo)) == DialogResult.Yes))
            {
                ITable pTable = pFLayer as ITable;
                IRow pRow = pTable.GetRow(row_index);
                pRow.Delete();
                MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK);
                _MapControl.ActiveView.Refresh();

                pFCuror = pFClass.Search(null, false);
                RefreshDataGridViewDataSource(gdvAttribute, GetAttributeTable(pFClass, pFCuror));
            }
        }
示例#46
0
        private void guvbuttonX_Click(object sender, EventArgs e)
        {
            fieldvaluelistBox.Items.Clear();

            string strfieldName = fieldlistBox.SelectedItem.ToString();

            strfieldName = strfieldName.Substring(0, strfieldName.IndexOf('【'));

            bool blnStr = false;

            if (m_pFeaCls.Fields.get_Field(m_pFeaCls.Fields.FindField(strfieldName)).Type == esriFieldType.esriFieldTypeString)
            {
                blnStr = true;
            }

            if (m_pFeaCls == null || this.fieldlistBox.SelectedItems.Count == 0)
            {
                return;
            }

            string sFieldName = strfieldName;        //获取选中项的字符串

            IFeatureClass pFeatureClass = m_pFeaCls; //得到要素集合

            if (pFeatureClass == null)
            {
                return;
            }

            this.fieldvaluelistBox.Items.Clear();

            try
            {
                IFeatureCursor pCursor = null;
                if (m_Geometry == null)
                {
                    IQueryFilter pQueryFilter = new QueryFilterClass();
                    pQueryFilter.WhereClause = "";
                    pCursor = pFeatureClass.Search(pQueryFilter, false);
                }
                else
                {
                    ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                    //pSpatialFilter.GeometryField = "SHAPE";
                    pSpatialFilter.Geometry    = m_Geometry;
                    pSpatialFilter.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                    pSpatialFilter.WhereClause = "";
                    pCursor = pFeatureClass.Search(pSpatialFilter, false);
                }

                System.Collections.IEnumerator enumerator;
                IDataStatistics DS = new DataStatisticsClass();
                DS.Field   = sFieldName;         //设置唯一值字段
                DS.Cursor  = pCursor as ICursor; //数据来源
                enumerator = DS.UniqueValues;    //得到唯一值
                enumerator.Reset();              //从新指向第一个值
                while (enumerator.MoveNext())    //遍历唯一值
                {
                    string strTemp = enumerator.Current.ToString();
                    if (blnStr)
                    {
                        fieldvaluelistBox.Items.Add("'" + strTemp + "'");
                    }
                    else
                    {
                        fieldvaluelistBox.Items.Add(strTemp);
                    }
                }

                System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
                pCursor = null;

                //lstValue.Sorted=true;
                fieldvaluelistBox.Update();
            }
            catch (Exception ex)
            {
                MessageBox.Show("获取字段值发生错误,错误原因为" + ex.Message, "系统提示");
            }
        }
        /// <summary>
        /// 获取数据表
        /// </summary>
        /// <param name="dataGridView"></param>
        /// <param name="pFeatureLayer"></param>
        public static DataTable GetAttributeTable(IFeatureClass pFeatureClass, IFeatureCursor pFeatureCuror)
        {
            if (pFeatureClass == null) return null;

            DataTable dt = new DataTable();
            DataColumn dc = null;

            for (int i = 0; i < pFeatureClass.Fields.FieldCount; i++)
            {
                dc = new DataColumn(pFeatureClass.Fields.get_Field(i).Name);
                dt.Columns.Add(dc);
            }

            //IFeatureCursor pFeatureCuror = pFeatureClass.Search(null, false);
            IFeature pFeature = pFeatureCuror.NextFeature();

            DataRow dr = null;
            while (pFeature != null)
            {
                dr = dt.NewRow();
                for (int j = 0; j < pFeatureClass.Fields.FieldCount; j++)
                {
                    if (pFeatureClass.FindField(pFeatureClass.ShapeFieldName) == j)
                    {

                        dr[j] = pFeatureClass.ShapeType.ToString();
                    }
                    else
                    {
                        dr[j] = pFeature.get_Value(j).ToString();

                    }
                }

                dt.Rows.Add(dr);
                pFeature = pFeatureCuror.NextFeature();
            }
            //dataGridView.DataSource = dt;
            return dt;
        }
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (!(e.Argument is IFeatureCursor))
            {
                return;
            }

            _cursor = (IFeatureCursor)e.Argument;
            IFeature row;

            while ((row = _cursor.NextFeature) != null)
            {
                row.CaseSensitivFieldnameMatching = false;  // sollte auch pgSQL funktionieren

                string[] items = { row["PATH"].ToString(),
                                   row["MANAGED"].ToString() };

                ListViewItem item = new ListViewItem(items);
                try
                {
                    FileInfo fi = new FileInfo(items[0]);

                    if (fi.Exists)
                    {
                        DateTime t    = (DateTime)row["LAST_MODIFIED"];
                        int      span = (int)Math.Abs(((TimeSpan)(fi.LastWriteTimeUtc - t)).TotalSeconds);
                        try
                        {
                            FileInfo fi2 = new FileInfo(row["PATH2"].ToString());
                            if (fi2.Exists)
                            {
                                t    = (DateTime)row["LAST_MODIFIED2"];
                                span = Math.Max((int)Math.Abs(((TimeSpan)(fi2.LastWriteTimeUtc - t)).TotalSeconds), span);
                            }
                        }
                        catch { }
                        if (span < 1)
                        {
                            item.ImageIndex = 0;
                        }
                        else
                        {
                            item.ImageIndex = 1;
                        }
                    }
                    else
                    {
                        item.ImageIndex = 3;
                    }
                }
                catch
                {
                    item.ImageIndex = 3;
                }

                AddListItemCached(item);
                if (_cancelWorker)
                {
                    break;
                }
            }

            AddListItems(_itemCollection);
            _itemCollection.Clear();
            SetStatusLabel1Text(listView.Items.Count + " Items...");

            _cursor.Dispose();
            _cursor = null;
        }
        /// <summary>
        /// 数据排序
        /// </summary>
        /// <param name="pFeatureClass"></param>
        private void SortFeatures(IFeatureClass pFeatureClass)
        {
            ITableSort pTableSort = new TableSortClass();
            IFields pFields = pFeatureClass.Fields;
            IField pField = pFields.get_Field(col_index);

            pTableSort.Fields = pField.Name;
            pTableSort.set_Ascending(pField.Name, up); 
            pTableSort.set_CaseSensitive(pField.Name, true);
            pTableSort.Table = pFeatureClass as ITable;
            pTableSort.Sort(null);
            pFCuror = (IFeatureCursor)pTableSort.Rows;
            pTs = pTableSort;
            RefreshDataGridViewDataSource(gdvAttribute, GetAttributeTable(pFClass, pFCuror));
        }
        private void FrmPipeLineLengthStats_Load(object sender, EventArgs e)
        {
            this.Text = GetFrmText(_sysFieldName);
            WaitForm.Start("正在读取区域图层...", "请稍后");
            FacilityClass facDistrict = FacilityClassManager.Instance.GetFacilityClassByName("District");
            FacilityClass fac         = FacilityClassManager.Instance.GetFacilityClassByName(_sysFieldName);
            int           index       = 0;

            if (facDistrict != null && fac != null)
            {
                try
                {
                    IFeatureClass district = GetOnlyFcByFacilityClass(facDistrict);
                    IFeatureClass fc       = GetOnlyFcByFacilityClass(fac);
                    if (district == null || fc == null)
                    {
                        WaitForm.Stop(); return;
                    }
                    IFeatureCursor cursor = district.Search(null, true);
                    if (cursor == null)
                    {
                        return;
                    }
                    IFeature  feature;
                    FieldInfo disName = facDistrict.GetFieldInfoBySystemName("Name");
                    if (disName == null)
                    {
                        return;
                    }


                    index = district.Fields.FindField(disName.Name);
                    if (index == -1)
                    {
                        return;
                    }
                    while ((feature = cursor.NextFeature()) != null)
                    {
                        string name = feature.get_Value(index).ToString();
                        lbx_district.Items.Add(name);
                        this.cbProperty.Properties.Items.Add(name);
                    }
                    this.cbProperty.SelectedIndex = 0;


                    WaitForm.SetCaption("正在统计...", "请稍后");
                    EconomyStats econoyStats = EconomyStatsFactory.CreateEconomyStats(_sysFieldName);
                    econoyStats.SetFeatureClass(district, fc);
                    econoyStats.IndexOfDisName = index;
                    FieldInfo disArea = facDistrict.GetFieldInfoBySystemName("Area");
                    econoyStats.IndexOfDisArea = GetIndexByFieldInfo(district, disArea);
                    FieldInfo area = fac.GetFieldInfoBySystemName("Area2D");
                    econoyStats.IndexOfFcArea = GetIndexByFieldInfo(fc, area);
                    FieldInfo floorArea = fac.GetFieldInfoBySystemName("FloorArea");
                    econoyStats.IndexOfFloorArea = GetIndexByFieldInfo(fc, floorArea);
                    FieldInfo length = fac.GetFieldInfoBySystemName("ShapeLength2D");
                    econoyStats.IndexOfLength = GetIndexByFieldInfo(fc, length);
                    this._dict = econoyStats.GetStatsResult();
                    econoyStats.InitUserControl(ucStatsOutput1);
                    WaitForm.Stop();
                }
                catch (System.Exception ex)
                {
                    WaitForm.Stop();
                }
            }
        }
 private void 保存编辑ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ITable pTable;
     //pTable = pFeatureClass.CreateFeature().Table;//很重要的一种获取shp表格的一种方式           
     pTable = pFLayer as ITable;
     //将改变的记录值传给shp中的表  
     int i = 0;
     while (pRowAndCol[i].Column != 0 || pRowAndCol[i].Row != 0)
     {
         IRow pRow;
         pRow = pTable.GetRow(pRowAndCol[i].Row);
         pRow.set_Value(pRowAndCol[i].Column, pRowAndCol[i].Value);
         pRow.Store();
         i++;
     }
     count = 0;
     for (int j = 0; j < i; j++)
     {
         pRowAndCol[j].Row = 0;
         pRowAndCol[j].Column = 0;
         pRowAndCol[j].Value = null;
     }
     MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK);
     this.gdvAttribute.ReadOnly = true;
     pFCuror = pFClass.Search(null, false);
     RefreshDataGridViewDataSource(gdvAttribute, GetAttributeTable(pFClass, pFCuror));
 }
示例#52
0
        /// <summary>
        /// Generate the tower coverage
        /// </summary>
        public void GenerateReceptionArea()
        {
            IWorkspaceEdit pWorkspaceEdit;

            pWorkspaceEdit = (IWorkspaceEdit)this._workspace;
            try
            {
                //get all towers in this service territory
                Towers pTowers = GetTowers();

                IFeatureWorkspace pFWorkspace = (IFeatureWorkspace)pWorkspaceEdit;

                IFeatureClass pTowerRangeFC = pFWorkspace.OpenFeatureClass("sde.TowerRange");



                IMultiuserWorkspaceEdit pMUWorkspaceEdit = (IMultiuserWorkspaceEdit)pWorkspaceEdit;

                pMUWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
                // pWorkspaceEdit.StartEditing(true);
                pWorkspaceEdit.StartEditOperation();

                //delete all ranges , we should later change that to delete only dirty towers
                IFeatureCursor pcursor       = pTowerRangeFC.Update(null, false);
                IFeature       pfeaturerange = pcursor.NextFeature();
                while (pfeaturerange != null)
                {
                    //we need to change that later
                    pfeaturerange.Delete();

                    pfeaturerange = pcursor.NextFeature();
                }

                foreach (Tower pTower in pTowers.Items)
                {
                    ITopologicalOperator pTopo = (ITopologicalOperator)pTower.TowerLocation;

                    IPolygon range3Bars      = (IPolygon)pTopo.Buffer(pTower.TowerCoverage / 3);
                    IPolygon range2BarsWhole = (IPolygon)pTopo.Buffer((pTower.TowerCoverage * 2) / 3);
                    IPolygon range1BarsWhole = (IPolygon)pTopo.Buffer(pTower.TowerCoverage);

                    ITopologicalOperator pIntTopo = (ITopologicalOperator)range2BarsWhole;

                    ITopologicalOperator pIntTopo1 = (ITopologicalOperator)range1BarsWhole;


                    IPolygon range2BarsDonut = (IPolygon)pIntTopo.SymmetricDifference(range3Bars);       //,esriGeometryDimension.esriGeometry2Dimension);
                    IPolygon range1BarsDonut = (IPolygon)pIntTopo1.SymmetricDifference(range2BarsWhole); //,esriGeometryDimension.esriGeometry2Dimension);


                    IFeature pFeature = pTowerRangeFC.CreateFeature();

                    pFeature.set_Value(pFeature.Fields.FindField("TOWERID"), pTower.ID);
                    pFeature.set_Value(pFeature.Fields.FindField("RANGE"), 3);

                    pFeature.Shape = range3Bars;
                    pFeature.Store();


                    IFeature pFeature2Bar = pTowerRangeFC.CreateFeature();

                    pFeature2Bar.set_Value(pFeature.Fields.FindField("TOWERID"), pTower.ID);
                    pFeature2Bar.set_Value(pFeature.Fields.FindField("RANGE"), 2);

                    pFeature2Bar.Shape = range2BarsDonut;
                    pFeature2Bar.Store();


                    IFeature pFeature1Bar = pTowerRangeFC.CreateFeature();

                    pFeature1Bar.set_Value(pFeature1Bar.Fields.FindField("TOWERID"), pTower.ID);
                    pFeature1Bar.set_Value(pFeature1Bar.Fields.FindField("RANGE"), 1);

                    pFeature1Bar.Shape = range1BarsDonut;
                    pFeature1Bar.Store();
                }


                pWorkspaceEdit.StopEditOperation();
                pWorkspaceEdit.StopEditing(true);


                //generate dead areas
                GenerateDeadAreas();
            }
            catch (Exception ex)
            {
                //if anything went wrong, just roll back
                pWorkspaceEdit.AbortEditOperation();
                System.Windows.Forms.MessageBox.Show(ex.ToString());
            }
        }
示例#53
0
        private void CalculateIntersect(IFeatureCursor pFeatureCursor, IGeometry Geometry)
        {
            //要素游标
            IMultipoint pIntersectionPoints = null;
            //多点
            IPointCollection pPointColl = null;

            List<IFeature> pFeatureList = new List<IFeature>();
            //和直线相交的要素集合,未排序
            double[,] pIndex = null;
            //距离和初始索引

            if (pFeatureCursor == null)
            {
                return;
            }
            ITopologicalOperator pTopoOperator = Geometry as ITopologicalOperator;

            IPointCollection pSketchPointColl = Geometry as IPointCollection;
            //所画直线的起点
            IPoint P0 = pSketchPointColl.get_Point(0);
            IFeature pFeature = pFeatureCursor.NextFeature();
            double HValue = 0;
            int FldIndex = 0;
            pFeatureList.Clear();
            while ((pFeature != null))
            {
                //和直线相交的要素集合
                pFeatureList.Add(pFeature);
                //
                pFeature = pFeatureCursor.NextFeature();
            }
            //此时pFeatureL中的等值线并不是按顺序(空间)排列,需要排序
            //求出各交点到直线起点距离
            int pCount = pFeatureList.Count;
            pIndex = new double[2, pCount];
            for (int i = 0; i <= pCount - 1; i++)
            {
                try
                {
                    pFeature = pFeatureList[i];
                    //求交点:
                    pIntersectionPoints = pTopoOperator.Intersect(pFeature.Shape, esriGeometryDimension.esriGeometry0Dimension) as IMultipoint;

                    pPointColl = pIntersectionPoints as IPointCollection;
                    //QI
                    //原来序号
                    pIndex[0, i] = i;
                    //距离
                    pIndex[1, i] = GetDistace(P0, pPointColl.get_Point(0));
                    //下个要素
                    pFeature = pFeatureCursor.NextFeature();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }
            //排序:将和直线相交的等直线按与起点的距离排序,冒泡法
            for (int i = 0; i <= pCount - 1; i++)
            {
                for (int j = i + 1; j <= pCount - 1; j++)
                {
                    if (pIndex[1, j] < pIndex[1, i])
                    {
                        double pTempindex = pIndex[0, i];
                        pIndex[0, i] = pIndex[0, j];
                        pIndex[0, j] = pTempindex;
                        //交换索引
                        double pTemp = pIndex[1, i];

                        pIndex[1, i] = pIndex[1, j];

                        pIndex[1, j] = pTemp;
                        //交换距离
                    }
                }
            }
            //开始高程赋值
            HValue = pHeight;
            try
            {
                for (int i = 0; i <= pCount - 1; i++)
                {
                    pFeature = pFeatureList[i];
                    //获取高程字段的索引
                    FldIndex = pFeature.Fields.FindField(pHeightName);
                    //高程赋值
                    pFeature.set_Value(FldIndex, HValue as object);
                    //要素更新
                    pFeature.Store();
                    //Get the next feature and next H
                    HValue = HValue + pInterval;
                }

            }
            catch (Exception e)
            {

                MessageBox.Show(e.ToString());
            }
        }
        protected override void OnMouseDown(MouseEventArgs arg)
        {
            IFeatureLayer pPointLayer     = null;
            IFeatureLayer pLineLayer      = null;
            IArray        pParcelLayers   = null;
            IFeatureLayer pControlLayer   = null;
            IFeatureLayer pLinePointLayer = null;

            double         dXYTol      = 0.003;
            clsFabricUtils FabricUTILS = new clsFabricUtils();
            IEditor        pEd         = (IEditor)ArcMap.Application.FindExtensionByName("esri object editor");

            //first get the extension
            UID pUID = new UIDClass();

            pUID.Value = "{114D685F-99B7-4B63-B09F-6D1A41A4DDC1}";
            ICadastralExtensionManager2 pCadExtMan = (ICadastralExtensionManager2)ArcMap.Application.FindExtensionByCLSID(pUID);
            ICadastralEditor            pCadEd     = (ICadastralEditor)ArcMap.Application.FindExtensionByCLSID(pUID);

            //check if there is a Manual Mode "modify" job active ===========
            ICadastralPacketManager pCadPacMan = (ICadastralPacketManager)pCadExtMan;

            if (pCadPacMan.PacketOpen)
            {
                FabricUTILS.ExecuteCommand(m_CommUID);
                MessageBox.Show("This tool cannot be used when there is an open parcel, construction, or job.\r\nPlease complete or discard the open items, and try again.");
                return;
            }

            ICadastralFabric pCadFabric = null;

            //if we're in an edit session then grab the target fabric
            if (pEd.EditState == esriEditState.esriStateEditing)
            {
                pCadFabric = pCadEd.CadastralFabric;
            }
            else
            {
                FabricUTILS.ExecuteCommand(m_CommUID);
                MessageBox.Show("This tool works on a parcel fabric in an edit session.\r\nPlease start editing and try again.");
                return;
            }

            if (pCadFabric == null)
            {//find the first fabric in the map
                if (!FabricUTILS.GetFabricFromMap(ArcMap.Document.ActiveView.FocusMap, out pCadFabric))
                {
                    FabricUTILS.ExecuteCommand(m_CommUID);
                    MessageBox.Show("No Parcel Fabric found in the map.\r\nPlease add a single fabric to the map, and try again.");
                    return;
                }
            }

            IGeoDataset pGeoDS = (IGeoDataset)pCadFabric;
            ISpatialReferenceTolerance pSpatRefTol = (ISpatialReferenceTolerance)pGeoDS.SpatialReference;

            if (pSpatRefTol.XYToleranceValid == esriSRToleranceEnum.esriSRToleranceOK)
            {
                dXYTol = pSpatRefTol.XYTolerance;
            }

            IMouseCursor          pMouseCursor        = null;
            ISpatialFilter        pSpatFilt           = null; //spatial filter query hinging off the dragged rectangle selection
            IQueryFilter          pQuFilter           = null; //used for the non-spatial query for radial lines, as they have no geometry
            IRubberBand2          pRubberRect         = null;
            IGeometryBag          pGeomBag            = null;
            ITopologicalOperator5 pUnionedPolyine     = null;
            IPolygon      pBufferedToolSelectGeometry = null;         //geometry used to search for parents
            IFIDSet       pLineFIDs            = null;                //the FIDSet used to collect the lines that'll be deleted
            IFIDSet       pPointFIDs           = null;                // the FIDSet used to collect the points that'll be deleted
            IFIDSet       pLinePointFIDs       = null;                // the FIDSet used to collect the line-points that'll be deleted
            List <int>    pDeletedLinesPoints  = new List <int>();    //list used to stage the ids for points that are referenced by lines
            List <int>    pUsedPoints          = new List <int>();    //list used to collect pointids that are referenced by existing lines
            List <int>    CtrPointIDList       = new List <int>();    //list for collecting the ids of center points
            List <int>    pParcelsList         = new List <int>();    //used only to avoid adding duplicates to IN clause string for, based on ties to radial lines
            List <int>    pOrphanPointsList    = new List <int>();    //list of orphan points defined from radial ines
            List <int>    pPointsInsideBoxList = new List <int>();    //list of parcels that exist and that intersect the drag-box
            List <string> sFromToPair          = new List <string>(); //list of from/to pairs for manging line points
            List <int>    pLineToParcelIDRef   = new List <int>();    //list of parcel id refs stored on lines

            IInvalidArea3 pInvArea = null;

            IFeatureClass pLines      = null;
            IFeatureClass pPoints     = null;
            IFeatureClass pParcels    = null;
            IFeatureClass pLinePoints = null;
            IWorkspace    pWS         = null;

            try
            {
                #region define the rubber envelope geometry
                pRubberRect = new RubberEnvelopeClass();
                IGeometry ToolSelectEnvelope = pRubberRect.TrackNew(ArcMap.Document.ActiveView.ScreenDisplay, null);

                if (ToolSelectEnvelope == null)
                {
                    return;
                }

                ISegmentCollection pSegmentColl = new PolygonClass();
                pSegmentColl.SetRectangle(ToolSelectEnvelope.Envelope);
                IPolygon ToolSelectGeometry = (IPolygon)pSegmentColl;

                if (pCadFabric == null)
                {
                    return;
                }

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

                #endregion

                FabricUTILS.GetFabricSubLayersFromFabric(ArcMap.Document.ActiveView.FocusMap, pCadFabric,
                                                         out pPointLayer, out pLineLayer, out pParcelLayers, out pControlLayer,
                                                         out pLinePointLayer);

                #region get tables and field indexes
                pLines      = (IFeatureClass)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTLines);
                pPoints     = (IFeatureClass)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTPoints);
                pParcels    = (IFeatureClass)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTParcels);
                pLinePoints = (IFeatureClass)pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTLinePoints);
                string sPref = "";
                string sSuff = "";

                int iCtrPtFldIDX  = pLines.FindField("CENTERPOINTID");
                int iFromPtFldIDX = pLines.FindField("FROMPOINTID");
                int iToPtFldIDX   = pLines.FindField("TOPOINTID");
                int iCatFldIDX    = pLines.FindField("CATEGORY");
                int iParcelIDX    = pLines.FindField("PARCELID");
                int iDistanceIDX  = pLines.FindField("DISTANCE");


                pWS = pLines.FeatureDataset.Workspace;
                ISQLSyntax pSQLSyntax = (ISQLSyntax)pWS;
                sPref = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierPrefix);
                sSuff = pSQLSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_DelimitedIdentifierSuffix);

                pSpatFilt            = new SpatialFilterClass();
                pSpatFilt.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                pSpatFilt.Geometry   = ToolSelectGeometry;
                #endregion

                #region center point
                //need to make sure that center points are correctly handled for cases where the center point
                //is inside the select box, but the curve itself is not. The following is used to build an
                //IN CLAUSE for All the center points that are found within the tool's select geometry.
                int    iIsCtrPtIDX    = pPoints.FindField("CENTERPOINT");
                int    iCount         = 0;
                int    iCntCtrPoint   = 0;
                string sCtrPntIDList1 = "";

                IFeatureCursor pFeatCursPoints = pPoints.Search(pSpatFilt, false);
                IFeature       pFeat7          = pFeatCursPoints.NextFeature();
                while (pFeat7 != null)
                {
                    iCount++;
                    int    iVal     = -1;
                    object Attr_val = pFeat7.get_Value(iIsCtrPtIDX);

                    if (Attr_val != DBNull.Value)
                    {
                        iVal = Convert.ToInt32(pFeat7.get_Value(iIsCtrPtIDX));
                    }

                    if (iVal == 1)
                    {
                        if (sCtrPntIDList1.Trim() == "")
                        {
                            sCtrPntIDList1 += pFeat7.OID.ToString();
                        }
                        else
                        {
                            sCtrPntIDList1 += "," + pFeat7.OID.ToString();
                        }
                        iCntCtrPoint++;
                    }
                    pPointsInsideBoxList.Add(pFeat7.OID); //used to check for orphan linepoints
                    pOrphanPointsList.Add(pFeat7.OID);    //this gets whittled down till only "pure" orphan points remain
                    Marshal.ReleaseComObject(pFeat7);
                    pFeat7 = pFeatCursPoints.NextFeature();
                }
                Marshal.FinalReleaseComObject(pFeatCursPoints);
                #endregion

                #region create convex hull of lines
                //get the lines that intersect the search box and build a
                //polygon search geometry being the convex hull of those lines.
                IFeatureCursor pFeatCursLines = pLines.Search(pSpatFilt, false);
                pGeomBag = new GeometryBagClass();
                IGeometryCollection pGeomColl = (IGeometryCollection)pGeomBag;
                IFeature            pFeat1    = pFeatCursLines.NextFeature();
                m_sDebug = "Add lines to Geometry Collection.";
                string sParcelRefOnLines = "";
                object missing           = Type.Missing;
                while (pFeat1 != null)
                {
                    int    iVal    = (int)pFeat1.get_Value(iFromPtFldIDX);
                    string sFromTo = iVal.ToString() + ":";

                    if (pOrphanPointsList.Contains(iVal)) //Does this need to be done...will remove fail if it's not there?
                    {
                        pOrphanPointsList.Remove(iVal);   //does this need to be in the if block?
                    }
                    iVal     = (int)pFeat1.get_Value(iToPtFldIDX);
                    sFromTo += iVal.ToString();
                    if (pOrphanPointsList.Contains(iVal))
                    {
                        pOrphanPointsList.Remove(iVal);
                    }

                    sFromToPair.Add(sFromTo);
                    pGeomColl.AddGeometry(pFeat1.ShapeCopy, missing, missing);

                    if (sParcelRefOnLines.Trim() == "")
                    {
                        sParcelRefOnLines = pFeat1.get_Value(iParcelIDX).ToString();
                    }
                    else
                    {
                        sParcelRefOnLines += "," + pFeat1.get_Value(iParcelIDX).ToString();
                    }

                    Marshal.ReleaseComObject(pFeat1);
                    pFeat1 = pFeatCursLines.NextFeature();
                }
                Marshal.FinalReleaseComObject(pFeatCursLines);

                #endregion

                #region Add Center Points for curves outside map extent

                if (iCntCtrPoint > 999)
                {
                    throw new InvalidOperationException("The Delete Orphans tool works with smaller amounts of data." + Environment.NewLine +
                                                        "Please try again, by selecting fewer fabric lines and points. (More than 1000 center points returned.)");
                }

                //If there is no line geometry found, and there are also no points found, then nothing to do...
                if (pGeomColl.GeometryCount == 0 && iCount == 0)
                {
                    return;
                }

                //Radial lines have no geometry so there is a special treatment for those;
                //that special treatment takes two forms,
                //1. if a circular arc is selected and it turns out that it is an orphan line, then we
                //need to take down its radial lines, and its center point as well.
                //2. if a center point is selected, we need to check if it's an orphan, by searching for its parent.
                //The parent parcel can easily be well beyond the query rectangle, so the original
                //search rectangle is buffered by the largest found radius distance, to make sure that all
                //parent parcels are "find-able."

                //The radial lines themselves are also needed; Get the radial lines from the Center Points
                //CtrPt is always TO point, so find lines CATEGORY = 4 AND TOPOINT IN ()
                string sRadialLineListParcelID = "";
                string sRadialLinesID          = "";
                string sRadialLinePoints       = "";

                double dRadiusBuff = 0;
                pQuFilter = new QueryFilterClass();
                //Find all the radial lines based on the search query
                if (sCtrPntIDList1.Trim() != "")
                {
                    pQuFilter.WhereClause = "CATEGORY = 4 AND TOPOINTID IN (" + sCtrPntIDList1 + ")";

                    //add all the *references* to Parcel ids for the radial lines,
                    //and add the ID's of the lines
                    IFeatureCursor pFeatCursLines8 = pLines.Search(pQuFilter, false);
                    IFeature       pFeat8          = pFeatCursLines8.NextFeature();
                    while (pFeat8 != null)
                    {
                        object Attr_val = pFeat8.get_Value(iDistanceIDX);
                        double dVal     = 0;
                        if (Attr_val != DBNull.Value)
                        {
                            dVal = Convert.ToDouble(Attr_val);
                        }
                        dRadiusBuff = dRadiusBuff > dVal ? dRadiusBuff : dVal;
                        int iVal = Convert.ToInt32(pFeat8.get_Value(iParcelIDX));
                        if (!pParcelsList.Contains(iVal))
                        {
                            if (sRadialLineListParcelID.Trim() == "")
                            {
                                sRadialLineListParcelID += Convert.ToString(iVal);
                            }
                            else
                            {
                                sRadialLineListParcelID += "," + Convert.ToString(iVal);
                            }
                        }
                        pParcelsList.Add(iVal);

                        //pOrphanPointsList is used for "Pure Orphan point" detection
                        //meaning that these are points that do not have ANY line, not even an orphan line.
                        iVal = (int)pFeat8.get_Value(iFromPtFldIDX);
                        if (pOrphanPointsList.Contains(iVal))
                        {
                            pOrphanPointsList.Remove(iVal);
                        }

                        iVal = (int)pFeat8.get_Value(iToPtFldIDX);
                        if (pOrphanPointsList.Contains(iVal))
                        {
                            pOrphanPointsList.Remove(iVal);
                        }

                        if (sRadialLinesID.Trim() == "")
                        {
                            sRadialLinesID += Convert.ToString(iVal);
                        }
                        else
                        {
                            sRadialLinesID += "," + Convert.ToString(iVal);
                        }

                        //Add from point to list
                        if (sRadialLinePoints.Trim() == "")
                        {
                            sRadialLinePoints += Convert.ToString(pFeat8.get_Value(iFromPtFldIDX));
                        }
                        else
                        {
                            sRadialLinePoints += "," + Convert.ToString(pFeat8.get_Value(iFromPtFldIDX));
                        }
                        //Add To point to list
                        sRadialLinePoints += "," + Convert.ToString(pFeat8.get_Value(iToPtFldIDX));

                        Marshal.ReleaseComObject(pFeat8);
                        pFeat8 = pFeatCursLines8.NextFeature();
                    }
                    Marshal.FinalReleaseComObject(pFeatCursLines8);

                    //create a polygon goeometry that is a buffer of the selection rectangle expanded
                    //to the greatest radius of all the radial lines found.
                    ITopologicalOperator topologicalOperator = (ITopologicalOperator)ToolSelectGeometry;
                    pBufferedToolSelectGeometry = topologicalOperator.Buffer(dRadiusBuff) as IPolygon;
                }
                else
                {
                    pQuFilter.WhereClause = "";
                }
                #endregion

                #region OrphanLines

                if (pGeomColl.GeometryCount != 0)
                {
                    pUnionedPolyine = new PolylineClass();
                    pUnionedPolyine.ConstructUnion((IEnumGeometry)pGeomBag);
                    ITopologicalOperator pTopoOp     = (ITopologicalOperator)pUnionedPolyine;
                    IGeometry            pConvexHull = pTopoOp.ConvexHull();
                    //With this convex hull, do a small buffer,
                    //theis search geometry is used as a spatial query on the parcel polygons
                    //and also on the parcel lines, to build IN Clauses
                    pTopoOp = (ITopologicalOperator)pConvexHull;
                    IGeometry pBufferedConvexHull = pTopoOp.Buffer(10 * dXYTol);
                    if (pBufferedToolSelectGeometry != null)
                    {
                        pTopoOp = (ITopologicalOperator)pBufferedToolSelectGeometry;
                        IGeometry pUnionPolygon = pTopoOp.Union(pBufferedConvexHull);
                        pSpatFilt.Geometry = pUnionPolygon;
                    }
                    else
                    {
                        pSpatFilt.Geometry = pBufferedConvexHull;
                    }
                }
                else
                {
                    if (pQuFilter.WhereClause.Trim() == "" && pBufferedToolSelectGeometry == null)
                    {
                        pSpatFilt.Geometry = ToolSelectGeometry;
                    }
                    else
                    {
                        pSpatFilt.Geometry = pBufferedToolSelectGeometry;
                    }
                }

                IColor pColor = new RgbColorClass();
                pColor.RGB = System.Drawing.Color.Blue.ToArgb();
                IScreenDisplay pScreenDisplay = ArcMap.Document.ActiveView.ScreenDisplay;
                FabricUTILS.FlashGeometry(pSpatFilt.Geometry, pScreenDisplay, pColor, 5, 100);

                pSpatFilt.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;

                m_sDebug = "Searching Parcels table.";
                pInvArea = new InvalidAreaClass();
                IFeatureCursor pFeatCursParcels = pParcels.Search(pSpatFilt, false);
                IFeature       pFeat2           = pFeatCursParcels.NextFeature();
                string         sParcelIDList    = "";
                iCount = 0;
                //create the "NOT IN" CLAUSE for parcels that exist in the DB and that are within the search area
                //Will be used as a search on lines to get the Orphan Lines

                while (pFeat2 != null)
                {
                    iCount++;
                    if (sParcelIDList.Trim() == "")
                    {
                        sParcelIDList += pFeat2.OID.ToString();
                    }
                    else
                    {
                        sParcelIDList += "," + pFeat2.OID.ToString();
                    }

                    Marshal.ReleaseComObject(pFeat2);
                    if (iCount > 999)
                    {
                        break;
                    }
                    pFeat2 = pFeatCursParcels.NextFeature();
                }
                Marshal.FinalReleaseComObject(pFeatCursParcels);

                //if we have more than 999 in clause tokens, there will be problems on Oracle.
                //Since this is an interactive tool, we expect it not to be used on a large amount of data.
                //for this reason, the following message is displayed if more than 999 parcels are returned in this query.
                //TODO: for the future this can be made to work on larger sets of data.
                if (iCount > 999)
                {
                    throw new InvalidOperationException("The Delete Orphans tool works with smaller amounts of data." + Environment.NewLine +
                                                        "Please try again, by selecting fewer fabric lines and points. (More than 1000 parcels returned.)");
                }

                m_sDebug = "Building the used points list.";
                //This first pass contains all references to points found within the parent parcel search buffer
                //Later, points are removed from this list
                IFeatureCursor pFeatCursLargerLineSet = pLines.Search(pSpatFilt, false);
                IFeature       pFeat3 = pFeatCursLargerLineSet.NextFeature();
                while (pFeat3 != null)
                {
                    iCount++;
                    object Attr_val = pFeat3.get_Value(iCtrPtFldIDX);
                    if (Attr_val != DBNull.Value)
                    {
                        pUsedPoints.Add(Convert.ToInt32(Attr_val)); //add center point
                    }
                    int iVal = (int)pFeat3.get_Value(iFromPtFldIDX);
                    pUsedPoints.Add(iVal);//add from point

                    iVal = (int)pFeat3.get_Value(iToPtFldIDX);
                    pUsedPoints.Add(iVal);//add to point

                    Marshal.ReleaseComObject(pFeat3);
                    pFeat3 = pFeatCursLargerLineSet.NextFeature();
                }
                Marshal.FinalReleaseComObject(pFeatCursLargerLineSet);

                //pUsedPoints list is at this stage, references to points for all lines found within the search area.
                //use the IN clause of the parcel ids to search for lines within
                //the original search box, and that are also orphans that do not have a parent parcel.
                pSpatFilt.WhereClause = "";
                pSpatFilt.Geometry    = ToolSelectGeometry;
                pSpatFilt.SpatialRel  = esriSpatialRelEnum.esriSpatialRelIntersects;
                pSpatFilt.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;

                IFeatureCursor pFeatCursor = null;
                if (pGeomColl.GeometryCount == 0)
                {
                    if (sParcelIDList.Trim().Length > 0 && sCtrPntIDList1.Trim().Length > 0)
                    {
                        pQuFilter.WhereClause = "(PARCELID NOT IN (" + sParcelIDList +
                                                ")) AND (CATEGORY = 4 AND TOPOINTID IN (" + sCtrPntIDList1 + "))";
                        pFeatCursor = pLines.Search(pQuFilter, false);
                    }
                    else if (sParcelIDList.Trim().Length == 0 && sCtrPntIDList1.Trim().Length > 0)
                    {
                        pQuFilter.WhereClause = "CATEGORY = 4 AND TOPOINTID IN (" + sCtrPntIDList1 + ")";
                        pFeatCursor           = pLines.Search(pQuFilter, false);
                    }
                }
                else
                {//do a spatial query
                    if (sParcelIDList.Trim().Length > 0)
                    {
                        pSpatFilt.WhereClause = "PARCELID NOT IN (" + sParcelIDList + ")";
                    }
                    else
                    {
                        pSpatFilt.WhereClause = "";
                    }
                    pFeatCursor = pLines.Search(pSpatFilt, false);
                }

                m_sDebug = "Collecting lines to be deleted.";

                //start collecting the lines that need to be deleted
                iCount = 0;
                int    iCtrPointCount         = 0;
                string sCtrPointIDList        = "";
                string sLineParcelIDReference = "";
                //Feature cursor is lines that are NOT IN the ParcelIDList

                if (pFeatCursor != null)
                {
                    pLineFIDs = new FIDSetClass();
                    IFeature pFeat4 = pFeatCursor.NextFeature();
                    while (pFeat4 != null)
                    {
                        iCount++;
                        pLineFIDs.Add(pFeat4.OID);
                        int iParcRef = Convert.ToInt32(pFeat4.get_Value(iParcelIDX));
                        if (sLineParcelIDReference.Trim() == "")
                        {
                            sLineParcelIDReference = iParcRef.ToString();
                        }
                        else
                        {
                            if (!pLineToParcelIDRef.Contains(iParcRef))
                            {
                                sLineParcelIDReference += "," + iParcRef.ToString();
                            }
                        }
                        pLineToParcelIDRef.Add(iParcRef);
                        pInvArea.Add((IObject)pFeat4);
                        //now for this line, get it's points
                        //first add the center point reference if there is one
                        object Attr_val = pFeat4.get_Value(iCtrPtFldIDX);
                        if (Attr_val != DBNull.Value)
                        {
                            iCtrPointCount++;
                            int iCtrPointID = Convert.ToInt32(Attr_val);
                            pDeletedLinesPoints.Add(iCtrPointID); //add this line's center point
                            pUsedPoints.Remove(iCtrPointID);

                            if (sCtrPointIDList.Trim() == "")
                            {
                                sCtrPointIDList = iCtrPointID.ToString();
                            }
                            else
                            {
                                if (CtrPointIDList.Contains(iCtrPointID))
                                {
                                    iCtrPointCount--;
                                }
                                else
                                {
                                    sCtrPointIDList += "," + iCtrPointID.ToString();
                                }
                            }
                            CtrPointIDList.Add(iCtrPointID);//to keep track of repeats
                        }
                        //and also add the FROM and TO point references if they exist
                        int iVal = (int)pFeat4.get_Value(iFromPtFldIDX);
                        pDeletedLinesPoints.Add(iVal);//add FROM point
                        if (pGeomColl.GeometryCount > 0)
                        {
                            pUsedPoints.Remove(iVal);
                        }

                        iVal = (int)pFeat4.get_Value(iToPtFldIDX);
                        pDeletedLinesPoints.Add(iVal);//add TO point
                        if (pGeomColl.GeometryCount > 0)
                        {
                            pUsedPoints.Remove(iVal);
                        }

                        Marshal.ReleaseComObject(pFeat4);
                        if (iCtrPointCount > 999)
                        {
                            break;
                        }
                        pFeat4 = pFeatCursor.NextFeature();
                    }
                    Marshal.FinalReleaseComObject(pFeatCursor);
                }
                if (iCtrPointCount > 999)
                {
                    throw new InvalidOperationException("The Delete Orphans tool works with smaller amounts of data." + Environment.NewLine +
                                                        "Please try again, by selecting fewer fabric lines and points. (More than 1000 center points returned.)");
                }

                m_sDebug = "Adding orphan radial lines to list.";

                if (sCtrPointIDList.Trim().Length > 0)
                {
                    //add the Radial lines at each end of the curves using the collected CtrPtIDs
                    //CtrPt is always TO point, so find lines CATEGORY = 4 AND TOPOINT IN ()

                    pQuFilter.WhereClause = "CATEGORY = 4 AND TOPOINTID IN (" + sCtrPointIDList + ")";
                    pFeatCursor           = pLines.Search(pQuFilter, false);
                    IFeature pFeat5 = pFeatCursor.NextFeature();
                    while (pFeat5 != null)
                    {
                        pLineFIDs.Add(pFeat5.OID);
                        int iParcRef = Convert.ToInt32(pFeat5.get_Value(iParcelIDX));
                        pLineToParcelIDRef.Add(iParcRef);
                        if (sLineParcelIDReference.Trim() == "")
                        {
                            sLineParcelIDReference = iParcRef.ToString();
                        }
                        else
                        {
                            if (!pLineToParcelIDRef.Contains(iParcRef))
                            {
                                sLineParcelIDReference += "," + iParcRef.ToString();
                            }
                        }
                        Marshal.ReleaseComObject(pFeat5);
                        pFeat5 = pFeatCursor.NextFeature();
                    }
                    Marshal.FinalReleaseComObject(pFeatCursor);
                }
                else
                {
                    pQuFilter.WhereClause = "";
                }

                //refine the DeletedLinesPoints list
                foreach (int i in pUsedPoints)
                {
                    if (pDeletedLinesPoints.Contains(i))
                    {
                        do
                        {
                        } while (pDeletedLinesPoints.Remove(i));
                    }
                }

                //add the points to a new FIDSet
                pPointFIDs = new FIDSetClass();
                foreach (int i in pDeletedLinesPoints)
                {
                    pPointFIDs.Add(i);
                }

                #endregion

                #region OrphanPoints
                //We already know which points to delete based on taking down the orphan lines.
                //We need to still add to the points FIDSet those points that are "pure" ophan points
                //as defined for the pOrphanPointsList variable.
                //and add the orphan points to the points FIDSet
                foreach (int i in pOrphanPointsList)
                {
                    bool bFound = false;
                    pPointFIDs.Find(i, out bFound);
                    if (!bFound)
                    {
                        pPointFIDs.Add(i);
                    }
                }
                #endregion

                #region orphan Line points
                //next check for orphan line-points
                //the line-point is deleted if there is no underlying point
                //or if the from and to point references do not exist.
                pSpatFilt.WhereClause = "";
                pSpatFilt.Geometry    = ToolSelectGeometry;
                IFeatureCursor pFeatCursLinePoints = pLinePoints.Search(pSpatFilt, false);
                IFeature       pLPFeat             = pFeatCursLinePoints.NextFeature();
                int            iLinePtPointIdIdx   = pLinePoints.FindField("LINEPOINTID");
                int            iLinePtFromPtIdIdx  = pLinePoints.FindField("FROMPOINTID");
                int            iLinePtToPtIdIdx    = pLinePoints.FindField("TOPOINTID");

                pLinePointFIDs = new FIDSetClass();
                while (pLPFeat != null)
                {
                    bool bExistsA = true;

                    bool bExists1 = true;
                    bool bExists2 = true;
                    bool bExists3 = true;

                    int iVal = (int)pLPFeat.get_Value(iLinePtPointIdIdx);
                    pPointFIDs.Find(iVal, out bExists1);
                    if (!pPointsInsideBoxList.Contains(iVal))
                    {
                        bExistsA = false;
                    }

                    iVal = (int)pLPFeat.get_Value(iLinePtFromPtIdIdx);
                    string sFrom = iVal.ToString();
                    pPointFIDs.Find(iVal, out bExists2);

                    iVal = (int)pLPFeat.get_Value(iLinePtToPtIdIdx);
                    string sTo = iVal.ToString();
                    pPointFIDs.Find(iVal, out bExists3);

                    int iOID = pLPFeat.OID;

                    if (bExists1 || bExists2 || bExists3)
                    {
                        pLinePointFIDs.Add(iOID);
                    }

                    if (!sFromToPair.Contains(sFrom + ":" + sTo) && !sFromToPair.Contains(sTo + ":" + sFrom))
                    {
                        pLinePointFIDs.Find(iOID, out bExists1);
                        if (!bExists1)
                        {
                            pLinePointFIDs.Add(iOID);
                        }
                    }

                    //if (!bExistsA || !bExistsB || !bExistsC)
                    if (!bExistsA)
                    {
                        bool bFound = true;
                        pLinePointFIDs.Find(iOID, out bFound);
                        if (!bFound)
                        {
                            pLinePointFIDs.Add(iOID);
                        }
                    }
                    pPointsInsideBoxList.Contains(iVal);

                    Marshal.ReleaseComObject(pLPFeat);
                    pLPFeat = pFeatCursLinePoints.NextFeature();
                }

                Marshal.FinalReleaseComObject(pFeatCursLinePoints);
                #endregion

                #region Refine the lines that are on the delete list
                //next step is to refine and double-check to make sure that the lines that are on the delete list
                //do not have a parcel record somewhere else (not spatially connected to the line) (example unjoined, or bad geom)
                string sFreshlyFoundParcels = "";
                if (sLineParcelIDReference.Trim() != "")
                {
                    pQuFilter.WhereClause = sPref + pParcels.OIDFieldName + sSuff + " IN (" + sLineParcelIDReference + ")";
                    pFeatCursor           = pParcels.Search(pQuFilter, false);
                    IFeature pFeat6 = pFeatCursor.NextFeature();
                    while (pFeat6 != null)
                    {
                        int iOID = pFeat6.OID;
                        if (sFreshlyFoundParcels.Trim() == "")
                        {
                            sFreshlyFoundParcels = iOID.ToString();
                        }
                        else
                        {
                            sFreshlyFoundParcels += "," + iOID.ToString();
                        }
                        Marshal.ReleaseComObject(pFeat6);
                        pFeat6 = pFeatCursor.NextFeature();
                    }
                    Marshal.FinalReleaseComObject(pFeatCursor);

                    if (sFreshlyFoundParcels.Trim() != "")
                    {
                        pQuFilter.WhereClause = "PARCELID IN (" + sFreshlyFoundParcels + ")";
                        pFeatCursor           = pLines.Search(pQuFilter, false);
                        IFeature pFeat9 = pFeatCursor.NextFeature();
                        while (pFeat9 != null)
                        {
                            int  iOID    = pFeat9.OID;
                            bool bIsHere = false;
                            pLineFIDs.Delete(iOID);
                            int iVal = Convert.ToInt32(pFeat9.get_Value(iFromPtFldIDX));
                            pPointFIDs.Find(iVal, out bIsHere);
                            if (bIsHere)
                            {
                                pPointFIDs.Delete(iVal);
                            }

                            iVal = Convert.ToInt32(pFeat9.get_Value(iToPtFldIDX));
                            pPointFIDs.Find(iVal, out bIsHere);
                            if (bIsHere)
                            {
                                pPointFIDs.Delete(iVal);
                            }

                            Marshal.ReleaseComObject(pFeat9);
                            pFeat9 = pFeatCursor.NextFeature();
                        }
                        Marshal.FinalReleaseComObject(pFeatCursor);
                    }
                }
                #endregion

                #region Make sure the points on the delete list are not part of a construction
                //For post 10.0, Make sure the points on the delete list are not part of a construction if they are then null geometry
                //pQuFilter.WhereClause=pLines.LengthField.Name + " = 0 AND CATEGORY <> 4";
                //IFeatureCursor pFeatCursLines101 = pLines.Search(pQuFilter, false);
                //this would open a new cursor and do a query on the entire
                #endregion

                #region report results and do edits
                dlgReport Report = new dlgReport();
                //Display the dialog
                System.Drawing.Color BackColorNow = Report.textBox1.BackColor;
                if (iCount == 0 && pPointFIDs.Count() == 0 && pLinePointFIDs.Count() == 0)
                {
                    Report.textBox1.BackColor = System.Drawing.Color.LightGreen;
                    Report.textBox1.Text      = "Selected area has no orphan lines or points.";
                }
                else
                {
                    int iCount1 = 0;
                    int iCount2 = 0;
                    int iCount3 = 0;
                    if (pLineFIDs != null)
                    {
                        iCount1 = pLineFIDs.Count();
                    }

                    if (pPointFIDs != null)
                    {
                        iCount2 = pPointFIDs.Count();
                    }

                    if (pLinePointFIDs != null)
                    {
                        iCount3 = pLinePointFIDs.Count();
                    }

                    iCount = iCount1 + iCount2 + iCount3;
                    if (iCount > 0)
                    {
                        pEd.StartOperation();
                        FabricUTILS.DeleteRowsByFIDSet((ITable)pLines, pLineFIDs, null, null);
                        FabricUTILS.DeleteRowsByFIDSet((ITable)pPoints, pPointFIDs, null, null);
                        if (pPointFIDs.Count() > 0)
                        {
                            //now need to update the control points associated with any deleted points.
                            ICadastralFabricSchemaEdit2 pSchemaEd = (ICadastralFabricSchemaEdit2)pCadFabric;
                            ITable     pControlTable       = pCadFabric.get_CadastralTable(esriCadastralFabricTable.esriCFTControl);
                            int        idxNameFldOnControl = pControlTable.FindField("POINTID");
                            string     ControlNameFldName  = pControlTable.Fields.get_Field(idxNameFldOnControl).Name;
                            int        i;
                            List <int> pPointFIDList = new List <int>();
                            pPointFIDs.Reset();
                            pPointFIDs.Next(out i);
                            while (i > -1)
                            {
                                pPointFIDList.Add(i);
                                pPointFIDs.Next(out i);
                            }
                            List <string> InClausePointsNotConnectedToLines = FabricUTILS.InClauseFromOIDsList(pPointFIDList, 995);
                            pQuFilter.WhereClause = ControlNameFldName + " IN (" + InClausePointsNotConnectedToLines[0] + ")";
                            pSchemaEd.ReleaseReadOnlyFields(pControlTable, esriCadastralFabricTable.esriCFTControl); //release safety-catch
                            if (!FabricUTILS.ResetControlAssociations(pControlTable, pQuFilter, false))
                            {
                                pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTControl);//set safety back on
                                pEd.AbortOperation();
                                return;
                            }
                            pSchemaEd.ResetReadOnlyFields(esriCadastralFabricTable.esriCFTControl);//set safety back on
                        }
                        pQuFilter.WhereClause = "";
                        FabricUTILS.DeleteRowsByFIDSet((ITable)pLinePoints, pLinePointFIDs, null, null);
                        pEd.StopOperation("Delete " + iCount.ToString() + " orphans");
                        Report.textBox1.Text = "Deleted:";
                        if (iCount1 > 0)
                        {
                            Report.textBox1.Text += Environment.NewLine + iCount1.ToString() + " orphaned lines";
                        }
                        if (iCount2 > 0)
                        {
                            Report.textBox1.Text += Environment.NewLine + iCount2.ToString() + " orphaned points";
                        }
                        if (iCount3 > 0)
                        {
                            Report.textBox1.Text += Environment.NewLine + iCount3.ToString() + " orphaned line points";
                        }
                    }
                    if (sFreshlyFoundParcels.Trim() != "")
                    {
                        if (Report.textBox1.Text.Trim() != "")
                        {
                            Report.textBox1.Text += Environment.NewLine;
                        }
                        Report.textBox1.Text += "Info: Line(s) that you selected are not directly" +
                                                Environment.NewLine + "touching a parent parcel geometry. Check parcels with OIDs:" +
                                                sFreshlyFoundParcels;
                    }
                }
                IArea pArea = (IArea)ToolSelectGeometry;
                if (pArea.Area > 0)
                {
                    SetDialogLocationAtPoint(Report, pArea.Centroid);
                }

                DialogResult pDialogResult = Report.ShowDialog();
                Report.textBox1.BackColor = BackColorNow;
                pInvArea.Display          = ArcMap.Document.ActiveView.ScreenDisplay;
                pInvArea.Invalidate((short)esriScreenCache.esriAllScreenCaches);

                if (pPointLayer != null)
                {
                    ArcMap.Document.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography,
                                                              pPointLayer, ArcMap.Document.ActiveView.Extent);
                }
                #endregion
            }

            catch (Exception ex)
            {
                if (pEd != null)
                {
                    pEd.AbortOperation();
                }
                MessageBox.Show(ex.Message + Environment.NewLine + m_sDebug, "Delete Orphans Tool");
                this.OnDeactivate();
            }

            #region Final Cleanup
            finally
            {
                pDeletedLinesPoints.Clear();
                pDeletedLinesPoints = null;
                pUsedPoints.Clear();
                pUsedPoints = null;
                CtrPointIDList.Clear();
                CtrPointIDList = null;
                pParcelsList.Clear();
                pParcelsList = null;
                pOrphanPointsList.Clear();
                pOrphanPointsList = null;
                pPointsInsideBoxList.Clear();
                pPointsInsideBoxList = null;
                pLineToParcelIDRef.Clear();
                pLineToParcelIDRef = null;
                sFromToPair.Clear();
                sFromToPair = null;

                FabricUTILS = null;
            }
            #endregion
        }
 private void FlushCursor(bool noFlush, ref IFeatureCursor cursor)
 {
     try
     {
         if (!noFlush && !IsHluWorkspaceSDE && (cursor != null))
         {
             cursor.Flush();
         }
     }
     finally
     {
         Marshal.ReleaseComObject(cursor);
         cursor = null;
     }
 }
示例#56
0
        private void EditMouseDown(IPoint pPnt)
        {
            try
            {
                IPolygon  pGeompoly;
                IPolyline pGeomPolyline;
                IHitTest  pHtTest;
                IPoint    pPtHit;
                double    pDblHitDis   = 0;
                int       pLngPrtIdx   = 0;
                int       pLngSegIdx   = 0;
                Boolean   pBoolHitRt   = false;
                Boolean   pBoolHitTest = false;
                double    pDblSrchDis  = 0;
                pPnt.Z      = 0;
                pPtHit      = new PointClass();
                pDblSrchDis = m_activeView.Extent.Width / 200;
                //获取编辑目标图层
                IFeatureLayer pFeatLyr = m_EngineEditLayers.TargetLayer;
                if (pFeatLyr == null)
                {
                    return;
                }
                IFeatureCursor pFeatCur  = MapManager.GetSelectedFeatures(pFeatLyr);
                IFeature       pTFeature = pFeatCur.NextFeature();
                switch (pTFeature.Shape.GeometryType)
                {
                //当为单点、点集时直接返回
                case esriGeometryType.esriGeometryPoint:
                case esriGeometryType.esriGeometryMultipoint:
                    return;

                //线要素
                case esriGeometryType.esriGeometryLine:
                case esriGeometryType.esriGeometryPolyline:
                    m_pHitElem = new LineElementClass();
                    break;

                //面要素
                case esriGeometryType.esriGeometryPolygon:
                case esriGeometryType.esriGeometryEnvelope:
                    m_pHitElem = new PolygonElementClass();
                    break;
                }
                //获取选中要素的几何对象
                m_pHitElem.Geometry = pTFeature.Shape;
                if (m_pHitElem != null)
                {
                    switch (pTFeature.Shape.GeometryType)
                    {
                    case esriGeometryType.esriGeometryLine:
                    case esriGeometryType.esriGeometryPolyline:
                        pGeomPolyline = m_pHitElem.Geometry as IPolyline;
                        pHtTest       = pGeomPolyline as IHitTest;
                        pBoolHitTest  = pHtTest.HitTest(pPnt, pDblSrchDis,
                                                        esriGeometryHitPartType.esriGeometryPartVertex, pPtHit,
                                                        ref pDblHitDis, ref pLngPrtIdx, ref pLngSegIdx, ref pBoolHitRt);
                        if (pBoolHitTest)
                        {
                            EditVertexClass.pHitPnt = pPtHit;
                            m_editDispFeed          = new LineMovePointFeedbackClass();
                            m_editDispFeed.Display  = m_activeView.ScreenDisplay;
                            m_polylineMvPtFeed      = m_editDispFeed as ILineMovePointFeedback;
                            m_polylineMvPtFeed.Start(pGeomPolyline, pLngSegIdx, pPnt);
                        }

                        break;

                    case esriGeometryType.esriGeometryPolygon:
                    case esriGeometryType.esriGeometryEnvelope:
                        pGeompoly    = m_pHitElem.Geometry as IPolygon;
                        pHtTest      = pGeompoly as IHitTest;
                        pBoolHitTest = pHtTest.HitTest(pPnt, pDblSrchDis,
                                                       esriGeometryHitPartType.esriGeometryPartVertex,
                                                       pPtHit, ref pDblHitDis, ref pLngPrtIdx, ref pLngSegIdx, ref pBoolHitRt);
                        EditVertexClass.pHitPnt = pPtHit;
                        if (pBoolHitTest)
                        {
                            //定义获取到的与传入点的最近所选地物
                            IFeature pFeature;
                            //定义测量距离用于捕获离点最近的地物
                            double pTestDist = 0;
                            //用于求点与地物的距离
                            IProximityOperator pProximity;
                            IGeometry          pGeoM;
                            IFeature           pTestFeature;
                            //用于最短距离的比较
                            double               pTempDist = 0;
                            IFeatureCursor       pSelected;
                            ITopologicalOperator pTopoOpt;
                            //捕捉到的要移动的节点
                            IPoint pSnapVertex = default(IPoint);
                            //从所选地物中获得离点最近的那个地物
                            pFeature = null;
                            //用鼠标点进行运算
                            pTopoOpt = pPnt as ITopologicalOperator;
                            pTopoOpt.Simplify();
                            pProximity   = pPnt as IProximityOperator;
                            pSelected    = MapManager.GetSelectedFeatures(pFeatLyr);
                            pTestFeature = pSelected.NextFeature();
                            pGeoM        = pTestFeature.Shape;
                            pTestDist    = pProximity.ReturnDistance(pGeoM);
                            pFeature     = pTestFeature;
                            //从所选地物中获得离点最近的那个地物
                            while (pTestFeature != null)
                            {
                                pTestFeature = pSelected.NextFeature();
                                if (pTestFeature != null)
                                {
                                    pGeoM     = pTestFeature.Shape;
                                    pTempDist = pProximity.ReturnDistance(pGeoM);
                                    if (pTempDist < pTestDist)
                                    {
                                        pTestDist = pTempDist;
                                        pFeature  = pTestFeature;
                                    }
                                }
                            }

                            //检查pSnapPoint是否是所选地物中的某个图斑的一个节点
                            double pDblHDis      = 0;
                            int    pLngVertexIdx = 0;
                            int    pLngSIdx      = 0;
                            bool   pBoolHRt      = false;
                            bool   pBlnGet       = false;
                            double pDblDistMin   = 0;
                            pDblDistMin = pTempDist;
                            if (pDblDistMin == 0)
                            {
                                pDblDistMin = 3;
                            }
                            //两倍可以保证一般一次找的到
                            double   pDblSearchRadius = pDblDistMin * 2;
                            IHitTest pHT = default(IHitTest);
                            pHT = pFeature.Shape as IHitTest;
                            //如果pSnapPoint不是pTempParcel的节点
                            if (EditVertexClass.GetVertexIndex(pPnt, pFeature.Shape) == -2)
                            {
                                pSnapVertex = new Point();
                                while (!pBlnGet)
                                {
                                    pBlnGet = pHT.HitTest(pPnt, pDblSearchRadius,
                                                          esriGeometryHitPartType.esriGeometryPartVertex,
                                                          pSnapVertex, ref pDblHDis, ref pLngVertexIdx, ref pLngSIdx, ref pBoolHRt);
                                    pDblSearchRadius = pDblSearchRadius + pDblDistMin;
                                }
                                EditVertexClass.pHitPnt = pSnapVertex;
                                //如果pSnapVertex仍然不是pTempParcel的节点
                                if (EditVertexClass.GetVertexIndex(pSnapVertex, pFeature.Shape) == -2)
                                {
                                    MessageBox.Show("所想移动的起点不是所选面的节点", "提示",
                                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    return;
                                }
                                m_fromPoint = pSnapVertex;
                            }
                            else
                            {
                                pSnapVertex = pPnt;
                                m_fromPoint = pSnapVertex;
                            }
                            //找到包含所要移动的节点的图形,在该过程里面对m_FeatArray进行了赋值
                            EditVertexClass.SelectByShapeTop(pFeatLyr, pSnapVertex, esriSpatialRelEnum.esriSpatialRelTouches,
                                                             false, esriSelectionResultEnum.esriSelectionResultNew);
                            m_editDispFeed         = new PolygonMovePointFeedbackClass();
                            m_editDispFeed.Display = m_activeView.ScreenDisplay;
                            m_polyMvPtFeed         = m_editDispFeed as IPolygonMovePointFeedback;
                            m_polyMvPtFeed.Start(pGeompoly, pLngSegIdx, pPnt);
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
        protected override void OnShutdown()
        {
            try
            {
                script = null;
                lastValue = null;

                intersectLayer = null;

                intersectTable = null;
                intersectLayerSelection = null;
                intersectTableSelection = null;
                qFilter = null;
                row = null;
                testField = null;

                curve = null;
                sourceLayer = null;
                pFS = null;

                _copyPoint = null;
                _copyPolyline = null;
                _copyPolygon = null;
                sFilter = null;
                try
                {
                    if (fCursor != null)
                        Marshal.ReleaseComObject(fCursor);
                    if (cCurs != null)
                        Marshal.ReleaseComObject(cCurs);
                    if (sourceFeature != null)
                        Marshal.ReleaseComObject(sourceFeature);

                }
                catch
                { }
                fCursor = null;
                cCurs = null;

                sourceFeature = null;
                nearestFeature = null;
                fieldObj = null;
                _currentDataset = null;
                proxOp = null;

            }
            catch { }
            try
            {
                if (AAState._sw != null)
                {
                    AAState._sw.Flush();
                    AAState._sw.Close();
                    AAState._sw = null;
                }

            }
            catch { }
            try
            {
                if (ArcMap.Events != null)
                {
                    ArcMap.Events.NewDocument -= ArcMap_NewOpenDocument;
                    ArcMap.Events.OpenDocument -= ArcMap_NewOpenDocument;
                }
                if (AAState._editor != null)
                {

                    if (AAState._editor != null)
                    {

                        //Wire editor events.
                        AAState._editEvents = (IEditEvents_Event)AAState._editor;
                        AAState._editEvents.OnStartEditing -= OnStartEditing;
                        AAState._editEvents.OnStopEditing -= OnStopEditing;
                        AAState._editEvents2 = (IEditEvents2_Event)AAState._editor;// SG Jan 2003

                        AAState._editor = null;
                        AAState._editEvents = null;
                        AAState._editEvents2 = null;  // SG Jan 2003

                    }
                }

                try
                {
                    AAState.bmpOff.Dispose();
                    AAState.bmpOn.Dispose();
                    AAState.commandItem = null;
                }
                catch { }
            }

            catch (Exception ex)
            {
                MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain5") + ex.Message);

            }
        }
        public frmAttributeTable(IFeatureLayer layer, AxMapControl pMapControl)
        {
            this.pLayer   = layer;
            pAxMapControl = pMapControl;
            InitializeComponent();

            if (layer is IRasterLayer)
            {
                return;
            }

            IFeatureClass pFeatureClass = pLayer.FeatureClass;

            for (int i = 0; i < pFeatureClass.Fields.FieldCount; i++)
            {
                string pFieldName = pFeatureClass.Fields.get_Field(i).Name.ToString();
                //if (pFeatureClass.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeGeometry)
                //{
                //    //pTable.Columns.Add(pFeatureClass.ShapeType.ToString());
                //    pTable.Columns.Add("几何类型");
                //}
                //else
                //{
                pTable.Columns.Add(pFieldName);
                //}
            }
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
            IFeature       pFeature       = pFeatureCursor.NextFeature();
            string         sGometry       = "";

            if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
            {
                sGometry = "Polygon";
            }
            else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
            {
                sGometry = "Polyline";
            }
            else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
            {
                sGometry = "point";
            }

            while (pFeature != null)
            {
                DataRow pRow = pTable.NewRow();
                for (int j = 0; j < pFeatureClass.Fields.FieldCount; j++)
                {
                    string svalue = pFeature.get_Value(j).ToString();
                    if (svalue == "System.__ComObject")
                    {
                        svalue = sGometry;
                    }
                    pRow[j] = svalue;
                }
                pTable.Rows.Add(pRow);
                pFeature = pFeatureCursor.NextFeature();
            }

            BindingSource bs = new BindingSource();

            dataGridViewTOC.DataSource = bs;
            bs.DataSource = pTable;
            bindingNavigator1.BindingSource = bs;
        }
        public void LoadTempImportFC(int SurveyID, int BatchID, int NextTransectID, IFeatureCursor ImportFCursor,
            IFeatureClass TempImportFC, IGeoDataset ThisDEM, double TargetLength, ref List<int> NewOIDs,
            ref int TotalInExcluded, ref int TotalOutsideBndy, ref int TotalPassed,string ThisDEMUnits, ref string ErrorMessage)
        {
            IFeature ImportFeature;
            IFeatureCursor ImportToCursor = null;
            IFeatureBuffer ImportToBuffer = null;
            esriGeometryType FType;
            bool IsInExcludedAreas, IsInBndPoly;
            ESRI.ArcGIS.GeoAnalyst.ISurfaceOp2 npsSurfaceOp = null;
            int ThisFieldIndex;
            IPoint TempPoint;
            IPolyline NewTrnPolyline;
            double Elev;
            IPolyline CPolyline;
            IPoint centerPoint;
            IFeatureClass ExclPolyFC, BndPolyFC;

            ThisDEMUnits = ThisDEMUnits.ToLower();
            NewOIDs = new List<int>();
            TotalInExcluded = 0;
            TotalOutsideBndy = 0;
            TotalPassed = 0;

            ExclPolyFC = Util.GetFeatureClass(m_NPS.LYR_EXCLUDED_AREAS, ref ErrorMessage);
            if (string.IsNullOrEmpty(ErrorMessage) == false) return;

            BndPolyFC = Util.GetFeatureClass(m_NPS.LYR_SURVEY_BOUNDARY, ref ErrorMessage);
            if (string.IsNullOrEmpty(ErrorMessage) == false) return;

            FType = TempImportFC.ShapeType;

            //get insert cursor in the nps feature class we are going to insert into
            ImportToCursor = TempImportFC.Insert(true);
            ImportToBuffer = TempImportFC.CreateFeatureBuffer();

            if (FType == esriGeometryType.esriGeometryPolyline)
                npsSurfaceOp = new ESRI.ArcGIS.GeoAnalyst.RasterSurfaceOpClass();

            //loop through each import feature and import it to it's appropriate featureclass
            while ((ImportFeature = ImportFCursor.NextFeature()) != null)
            {
                //make sure the shape is valid
                if (ImportFeature.ShapeCopy == null)
                {
                    TotalOutsideBndy++;
                    continue;
                }

                if (FType == esriGeometryType.esriGeometryPoint)
                {

                    //check if rand point  falls in excluded areas
                    IsInExcludedAreas = Util.HasRelationshipWithFC(ImportFeature.ShapeCopy, esriSpatialRelEnum.esriSpatialRelWithin,
                        ExclPolyFC, "SurveyID=" + SurveyID);

                    //if point is in excluded areas, don't add
                    if (IsInExcludedAreas)
                    {
                        TotalInExcluded++;
                        continue;
                    }

                    //check if  rand point is within boundary
                    IsInBndPoly = Util.HasRelationshipWithFC(ImportFeature.ShapeCopy, esriSpatialRelEnum.esriSpatialRelWithin,
                        BndPolyFC, "SurveyID=" + SurveyID);

                    //if random point is not in boundary, dont add it
                    if (IsInBndPoly == false)
                    {
                        TotalOutsideBndy++;
                        continue;
                    }

                }

                if (FType == esriGeometryType.esriGeometryPolyline)
                {

                    //check if new line falls in excluded areas
                    IsInExcludedAreas = Util.HasRelationshipWithFC(ImportFeature.ShapeCopy, esriSpatialRelEnum.esriSpatialRelCrosses,
                         ExclPolyFC, "SurveyID=" + SurveyID);

                    //if point is in excluded areas, don't add
                    if (IsInExcludedAreas)
                    {
                        TotalInExcluded++;
                        continue;
                    }

                    //check if new line is within in boundary
                    IsInBndPoly = Util.HasRelationshipWithFC(ImportFeature.ShapeCopy, esriSpatialRelEnum.esriSpatialRelWithin,
                         BndPolyFC, "SurveyID=" + SurveyID);

                    //if random point is not in boundary, dont add it
                    if (IsInBndPoly == false)
                    {
                        TotalOutsideBndy++;
                        continue;
                    }

                }

                TotalPassed++;

                //add feature to temp feature class
                ImportToBuffer.Shape = ImportFeature.ShapeCopy;
                ImportToBuffer.set_Value(ImportToBuffer.Fields.FindField("SurveyID"), SurveyID);
                ImportToBuffer.set_Value(ImportToBuffer.Fields.FindField("BATCH_ID"), BatchID);

                if (FType == esriGeometryType.esriGeometryPolyline)
                {

                    ThisFieldIndex = ImportToBuffer.Fields.FindField("Flown");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ImportToBuffer.Fields.FindField("Flown"), "N");

                    ThisFieldIndex = ImportToBuffer.Fields.FindField("TransectID");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ImportToBuffer.Fields.FindField("TransectID"), NextTransectID);

                    NextTransectID++;

                    NewTrnPolyline = ImportToBuffer.Shape as IPolyline;

                    ThisFieldIndex = ImportToBuffer.Fields.FindField("LENGTH_MTR");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ThisFieldIndex, NewTrnPolyline.Length);

                    //add the name of the default projection
                    ThisFieldIndex = ImportToBuffer.Fields.FindField("PROJECTION");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ThisFieldIndex, NewTrnPolyline.SpatialReference.Name);

                    ThisFieldIndex = ImportToBuffer.Fields.FindField("TARGETLEN");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ThisFieldIndex, TargetLength);

                    //clone from point
                    TempPoint = ((ESRI.ArcGIS.esriSystem.IClone)NewTrnPolyline.FromPoint).Clone() as IPoint;

                    //add from point projected coords
                    ThisFieldIndex = ImportToBuffer.Fields.FindField("PROJTD_X1");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ThisFieldIndex, TempPoint.X);
                    ThisFieldIndex = ImportToBuffer.Fields.FindField("PROJTD_Y1");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ThisFieldIndex, TempPoint.Y);

                    //add from point geo coords
                    ((IGeometry2)TempPoint).ProjectEx(Util.GetWGSSpatRef(), esriTransformDirection.esriTransformForward, null, false, 0, 0);
                    ThisFieldIndex = ImportToBuffer.Fields.FindField("DD_LONG1");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ThisFieldIndex, TempPoint.X);
                    ThisFieldIndex = ImportToBuffer.Fields.FindField("DD_LAT1");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ThisFieldIndex, TempPoint.Y);

                    //clone to point
                    TempPoint = ((ESRI.ArcGIS.esriSystem.IClone)NewTrnPolyline.ToPoint).Clone() as IPoint;

                    //add to point projected coords
                    ThisFieldIndex = ImportToBuffer.Fields.FindField("PROJTD_X2");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ThisFieldIndex, TempPoint.X);
                    ThisFieldIndex = ImportToBuffer.Fields.FindField("PROJTD_Y2");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ThisFieldIndex, TempPoint.Y);

                    //add to point geo coords
                    ((IGeometry2)TempPoint).ProjectEx(Util.GetWGSSpatRef(), esriTransformDirection.esriTransformForward, null, false, 0, 0);
                    ThisFieldIndex = ImportToBuffer.Fields.FindField("DD_LONG2");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ThisFieldIndex, TempPoint.X);
                    ThisFieldIndex = ImportToBuffer.Fields.FindField("DD_LAT2");
                    if (ThisFieldIndex > -1) ImportToBuffer.set_Value(ThisFieldIndex, TempPoint.Y);

                    //get center point
                    centerPoint = new PointClass();
                    ((ICurve)NewTrnPolyline).QueryPoint(esriSegmentExtension.esriNoExtension, 0.5, true, centerPoint);

                    //get elevation for transect center
                    CPolyline = new PolylineClass();
                    npsSurfaceOp.ContourAsPolyline(ThisDEM, centerPoint, out CPolyline, out Elev);

                    //set elevation in meters
                    ThisFieldIndex = ImportToBuffer.Fields.FindField("ELEV_M");
                    if (ThisFieldIndex > -1)
                    {
                        if (ThisDEMUnits == "feet") ImportToBuffer.set_Value(ThisFieldIndex, 0.3048 * Elev);
                        if (ThisDEMUnits == "meters") ImportToBuffer.set_Value(ThisFieldIndex, Elev);

                    }

                    //get elevation in feet
                    ThisFieldIndex = ImportToBuffer.Fields.FindField("ELEVFT");
                    if (ThisFieldIndex > -1)
                    {
                        if (ThisDEMUnits == "feet") ImportToBuffer.set_Value(ThisFieldIndex, Elev);
                        if (ThisDEMUnits == "meters") ImportToBuffer.set_Value(ThisFieldIndex, Elev * 3.2808399);
                    }

                }

                NewOIDs.Add((int)Util.SafeConvert(ImportToCursor.InsertFeature(ImportToBuffer), typeof(int)));

            }

            ImportFCursor = null;
            ImportToCursor = null;
            ImportToBuffer = null;
        }
        public static void ShowAllVertex(IFeatureLayer pFeatLyr)
        {
            m_vertexGeoBag = null;
            if (pFeatLyr == null)
            {
                return;
            }
            IFeatureCursor pFeatureCursor = MapManager.GetSelectedFeatures(pFeatLyr);

            if (pFeatureCursor == null)
            {
                return;
            }
            IFeature pTFeature = null;

            //得到要显示节点的地物
            pTFeature = pFeatureCursor.NextFeature();
            if (pTFeature == null)
            {
                return;
            }
            //只选中一个地物进行节点移动
            m_Map.ClearSelection();
            m_Map.SelectFeature(pFeatLyr as ILayer, pTFeature);
            m_activeView.Refresh();
            //如果为点状地物,不显示节点
            if (pTFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                return;
            }
            IArray pFeatureArray = null;

            pFeatureArray = new ESRI.ArcGIS.esriSystem.Array();
            pFeatureArray.Add(pTFeature);
            //绘图符号初始化
            SymbolInit();
            IFeature         pFeature = default(IFeature);
            IPointCollection pPointCol = default(IPointCollection);
            IPoint           pPoint = default(IPoint);
            int i = 0; int j = 0;

            m_vertexGeoBag = new GeometryBagClass();
            for (i = 0; i <= pFeatureArray.Count - 1; i++)
            {
                pFeature = pFeatureArray.get_Element(i) as IFeature;
                //获取图形边界的点集
                pPointCol = pFeature.ShapeCopy as IPointCollection;
                for (j = 0; j <= pPointCol.PointCount - 1; j++)
                {
                    pPoint = pPointCol.get_Point(j);
                    if (j == 0 | j == pPointCol.PointCount - 1)
                    {
                        //两个端点的ID设为10
                        pPoint.ID = 10;
                    }
                    else
                    {
                        //中间点的ID设为100
                        pPoint.ID = 100;
                    }
                    IColor pColor = null;
                    object obj    = Type.Missing;
                    //显示节点
                    if (pPoint == pHitPnt)
                    {
                        DisplayGraphic(pPoint, pColor, m_selPointSym as ISymbol);
                    }
                    if (j == 0 || j == pPointCol.PointCount - 1)
                    {
                        DisplayGraphic(pPoint, pColor, m_endPointSym as ISymbol);
                    }
                    else
                    {
                        DisplayGraphic(pPoint, pColor, m_vertexSym as ISymbol);
                    }

                    m_vertexGeoBag.AddGeometry(pPoint, ref obj, ref obj);
                }
            }
            Marshal.ReleaseComObject(pFeatureCursor);
        }