/* | Version 1.17.2018 | Copyright 2018 ESRI | | Licensed under the Apache License, Version 2.0 (the "License"); | you may not use this file except in compliance with the License. | You may obtain a copy of the License at | | http://www.apache.org/licenses/LICENSE-2.0 | | Unless required by applicable law or agreed to in writing, software | distributed under the License is distributed on an "AS IS" BASIS, | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | See the License for the specific language governing permissions and | limitations under the License. */ using System.Diagnostics; using System.Globalization; using System; using System.Collections.ObjectModel; using System.Collections.Generic; using System.Text; using System.IO; using System.Runtime.InteropServices; using System.Data; using System.Windows.Forms; using System.Net; using System.Web; using System.Xml; //using System.Runtime.Serialization.JSON; using System.Runtime.Serialization.Json; using System.Text.RegularExpressions; using ESRI.ArcGIS.ADF; using ESRI.ArcGIS.CartoUI; using ESRI.ArcGIS.ArcMapUI; using ESRI.ArcGIS.ArcMap; using ESRI.ArcGIS.Carto; using ESRI.ArcGIS.Editor; using ESRI.ArcGIS.Display; using ESRI.ArcGIS.Framework; using ESRI.ArcGIS.Geodatabase; using ESRI.ArcGIS.GeoDatabaseExtensions; using ESRI.ArcGIS.GeoDatabaseUI; using ESRI.ArcGIS.Geometry; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.ADF; using ESRI.ArcGIS.DataSourcesRaster; using ESRI.ArcGIS.Location; using System.Drawing; using System.Reflection; using A4LGSharedFunctions; namespace ArcGIS4LocalGovernment { public class LastValueEntry { public LastValueEntry(object value, bool on_Create, bool on_changeAtt, bool on_ChangeGeo, bool on_Manual) { Value = value; On_Create = on_Create; On_ChangeAtt = on_changeAtt; On_ChangeGeo = on_ChangeGeo; On_Manual = on_Manual; } public LastValueEntry() { Value = null; On_Create = false; On_ChangeAtt = false; On_ChangeGeo = false; On_Manual = false; } public object Value { get; set; } public bool On_Create { get; set; } public bool On_ChangeAtt { get; set; } public bool On_ChangeGeo { get; set; } public bool On_Manual { get; set; } } public static class AAState { public enum intersectOptions { Centroid, PromptMulti, First, Last, Feature, Start, End, Highest } public static ESRI.ArcGIS.esriSystem.IPropertySet2 lastValueProperties; public static string _filePath = ""; public enum TriggerByToolsOptions { Edit, Create, Change, Geo, Manual } public static TriggerByToolsOptions triggerByTools = TriggerByToolsOptions.Edit; public static ISpatialReference _sr1; public static RotationCalculator rCalc; public static int _processCount = 0; public static IEditEvents_Event _editEvents; public static IEditEvents2_Event _editEvents2; // SG Jan 2013 public static bool _onStopOperationEvent = true;// SG Jan 2013 public static List _objectClassEventList; //private static Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment"); //private static System.Object obj = Activator.CreateInstance(factoryType); //public static ISpatialReferenceFactory spatRefFact = obj as ISpatialReferenceFactory; ////public static ISpatialReferenceFactory spatRefFact = new SpatialReferenceEnvironmentClass(); //public static IGeographicCoordinateSystem srWGS84 = spatRefFact.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); public static CurrentUserInfo _currentUserInfo; private static string _Debug = "false"; public static string Debug() { return ConfigUtil.GetConfigValue("AttributeAssistant_Debug", AAState._Debug); } private static bool _PerformUpdates = true; public static bool PerformUpdates { get { return _PerformUpdates; } set { _PerformUpdates = value; try { AAState.setIcon(); } catch { } } } public static bool _Suspend = false; public static Bitmap bmpOff; public static Bitmap bmpOn; public static ICommandItem commandItem; public static ITable _gentab; public static IWorkspaceEdit2 _gentabWorkspace; public static ITable _tab; public static DataTable _dt; public static DataView _dv; public static IEditor _editor; public static StreamWriter _sw; public static string indent = ""; public static IArray _fabricLayers; public static IArray _fabricObjectClasses; public static List _fabricObjectClassIds; public static Dictionary _fabricInMemTablesLookUp; public static bool _CheckEnvelope = false; public static bool _bypassEditOperationCheck = false; public static bool _onCreateWhenSplit = false; // Declare configuration variables public static string _defaultsTableName = "DynamicValue"; public static string _sequenceTableName = "GenerateId"; public static bool setOff = true; public static string _seqNameField = "SEQNAME"; public static string _seqCounterField = "SEQCOUNTER"; public static string _seqIntervalField = "SEQINTERV"; public static void setIcon() { try { if (bmpOn == null) { LoadBitmaps(); } LoadCommand(); if (AAState.commandItem == null) return; if (setOff) { if (AAState.PerformUpdates) { AAState.commandItem.FaceID = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromBitmap(bmpOn); AAState.commandItem.Caption = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCapt_1a"); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_1a")); } else { AAState.commandItem.FaceID = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromBitmap(bmpOff); AAState.commandItem.Caption = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCapt_1b"); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_1b")); } setOff = false; } if (AAState.PerformUpdates && !commandItem.Caption.ToString().Contains(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCheck_1"))) //on { AAState.commandItem.FaceID = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromBitmap(bmpOn); AAState.commandItem.Caption = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCapt_1a"); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_1a")); } else if (AAState.PerformUpdates == false && !commandItem.Caption.ToString().Contains(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCheck_2")) && !commandItem.Caption.ToString().Contains(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCheck_3"))) //off { AAState.commandItem.FaceID = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromBitmap(bmpOff); AAState.commandItem.Caption = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCapt_1b"); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_1b")); } else if (AAState.commandItem.Caption.ToString().Contains(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCheck_4"))) //startup { if (AAState.PerformUpdates) { AAState.commandItem.FaceID = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromBitmap(bmpOn); AAState.commandItem.Caption = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCapt_1a"); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_1a")); } else if (AAState.PerformUpdates == false) { AAState.commandItem.FaceID = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromBitmap(bmpOff); AAState.commandItem.Caption = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCapt_1b"); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_1b")); } } else if (AAState.PerformUpdates == false && commandItem.Caption.ToString().Contains(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCheck_2")) && !commandItem.Caption.ToString().Contains(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCapt_1b"))) //off { AAState.commandItem.FaceID = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIPictureDispFromBitmap(bmpOff); AAState.commandItem.Caption = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCapt_1b"); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_1b")); } } catch (Exception ex) { // MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_1a") + ex.ToString()); } } public static void LoadCommand() { try { AAState.commandItem = ArcMap.Application.Document.CommandBars.Find("ArcGIS4LocalGovernment_AttributeAssistantToggleCommand", true, false); } catch { } } public static void LoadBitmaps() { Assembly myAssembly = Assembly.GetExecutingAssembly(); Stream myStream = myAssembly.GetManifestResourceStream("ArcGIS4LocalGovernment.Images.AttributeAssistantToggleOnSolidOff.png"); AAState.bmpOff = new Bitmap(myStream); AAState.bmpOff.MakeTransparent(AAState.bmpOff.GetPixel(0, 0)); Stream myStream2 = myAssembly.GetManifestResourceStream("ArcGIS4LocalGovernment.Images.AttributeAssistantToggleOnSolidOn.png"); AAState.bmpOn = new Bitmap(myStream2); AAState.bmpOn.MakeTransparent(AAState.bmpOn.GetPixel(0, 0)); } public static bool initTable() { if (_editor == null) { _editor = ArcMap.Application.FindExtensionByName("esriEditor.Editor") as IEditor; } if (_editor == null) { return false; } // Disable editor extension if editing shapefiles, coverages, etc. initDynTable(); if (_dt == null) { return false; } _dv = new DataView(_dt); _gentab = Globals.FindTable(ArcMap.Document.FocusMap, _sequenceTableName); if (AAState._gentab != null) { IDataset pDS = (IDataset)AAState._gentab; AAState._gentabWorkspace = (IWorkspaceEdit2)pDS.Workspace; pDS = null; } return true; } public static void initDynTable() { DataTable temp_dt; temp_dt = getConfigDataTable(); if (temp_dt != null) { _dt = temp_dt; } temp_dt = null; } private static DataTable getConfigDataTable() { try { DataTable dt = new DataTable(); _tab = Globals.FindTable(ArcMap.Document.FocusMap, _defaultsTableName); if (_tab == null) return null; for (int i = 0; i < _tab.Fields.FieldCount; i++) { if (_tab.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeString) dt.Columns.Add(_tab.Fields.get_Field(i).Name, typeof(string)); else if (_tab.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeGlobalID) dt.Columns.Add(_tab.Fields.get_Field(i).Name, typeof(string)); else if (_tab.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeGUID) dt.Columns.Add(_tab.Fields.get_Field(i).Name, typeof(string)); else if (_tab.Fields.get_Field(i).Type == esriFieldType.esriFieldTypeDate) dt.Columns.Add(_tab.Fields.get_Field(i).Name, typeof(string)); else dt.Columns.Add(_tab.Fields.get_Field(i).Name, typeof(int)); } ICursor cur = _tab.Search(null, true); IRow row; System.Collections.ArrayList ar = new System.Collections.ArrayList(); while ((row = cur.NextRow()) != null) { for (int i = 0; i < _tab.Fields.FieldCount; i++) { ar.Add(row.get_Value(i)); } dt.Rows.Add(ar.ToArray()); ar.Clear(); } if (row != null) { Marshal.ReleaseComObject(row); GC.WaitForFullGCComplete(); row = null; } if (cur != null) { Marshal.ReleaseComObject(cur); GC.Collect(300); GC.WaitForFullGCComplete(); cur = null; } return dt; } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain0") + ex.ToString()); //MessageBox.Show(); return null; } } public static void WriteLine(string valToWrite) { try { if (AAState._sw == null) return; else AAState._sw.WriteLine(AAState.indent + valToWrite); } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_1b") + ex.ToString()); } } public static void createLastValuePropertySet(bool clear = false) { try { if (AAState._dt == null) return; object nullObject = null; if (AAState.lastValueProperties == null || _clearLastValue == true || clear) { AAState.lastValueProperties = new PropertySetClass(); } if (AAState._dt.Columns["ON_CHANGEGEO"] == null) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_1c")); } if (AAState._dt.Columns["ON_CHANGE"] == null) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_1d")); } if (AAState._dt.Columns["ON_CREATE"] == null) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_1e")); } if (AAState._dt.Columns["ON_MANUAL"] == null) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_1f")); } DataView dv = new DataView(AAState._dt); dv.RowFilter = "ValueMethod = 'LAST_VALUE'"; string[] args; foreach (DataRowView drv in dv) { if (drv["FIELDNAME"].ToString() == "SHAPE") { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_1g")); } else { if (_clearLastValue || clear) { LastValueEntry lstV = new LastValueEntry(); lstV.Value = nullObject; lstV.On_ChangeAtt = Globals.toBoolean(drv["ON_CHANGE"].ToString()); if (drv.DataView.Table.Columns["ON_CHANGEGEO"] != null) { lstV.On_ChangeGeo = Globals.toBoolean(drv["ON_CHANGEGEO"].ToString()); } lstV.On_Create = Globals.toBoolean(drv["ON_CREATE"].ToString()); lstV.On_Manual = Globals.toBoolean(drv["ON_MANUAL"].ToString()); AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstV); lstV = null; } else { string valData = drv["VALUEINFO"].ToString().Trim(); if (valData.Contains(Environment.NewLine)) { valData = valData.Substring(0, valData.IndexOf(Environment.NewLine)); } if (valData.Trim() == "") { nullObject = null; } else { args = valData.Split('|'); if (args.Length >= 2) { nullObject = args[1] as System.Object; } } try { object temp = AAState.lastValueProperties.GetProperty(drv["FIELDNAME"].ToString()); if (nullObject != null && temp == null) { LastValueEntry lstV = new LastValueEntry(); lstV.Value = nullObject; lstV.On_ChangeAtt = Globals.toBoolean(drv["ON_CHANGE"].ToString()); if (drv.DataView.Table.Columns["ON_CHANGEGEO"] != null) { lstV.On_ChangeGeo = Globals.toBoolean(drv["ON_CHANGEGEO"].ToString()); } lstV.On_Create = Globals.toBoolean(drv["ON_CREATE"].ToString()); lstV.On_Manual = Globals.toBoolean(drv["ON_MANUAL"].ToString()); AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstV); lstV = null; } } catch { LastValueEntry lstV = new LastValueEntry(); lstV.Value = nullObject; lstV.On_ChangeAtt = Globals.toBoolean(drv["ON_CHANGE"].ToString()); if (drv.DataView.Table.Columns["ON_CHANGEGEO"] != null) { lstV.On_ChangeGeo = Globals.toBoolean(drv["ON_CHANGEGEO"].ToString()); } lstV.On_Create = Globals.toBoolean(drv["ON_CREATE"].ToString()); lstV.On_Manual = Globals.toBoolean(drv["ON_MANUAL"].ToString()); AAState.lastValueProperties.SetProperty(drv["FIELDNAME"].ToString(), lstV); lstV = null; } } } } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain1") + ex.ToString()); } } public static void promptLastValueProperrtySetOneForm() { try { object nullObject = null; if (AAState.lastValueProperties == null) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_2a")); return; } object lstNames; object lstValues; AAState.lastValueProperties.GetAllProperties(out lstNames, out lstValues); LastValueEntry lstVal; DataTable pDt = new DataTable("LastValues"); DataColumn pDC = pDt.Columns.Add("Field", typeof(String)); pDC.ReadOnly = true; pDC.Caption = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCapt_2a"); pDC = pDt.Columns.Add("Value", typeof(String)); pDC.ReadOnly = false; pDC.Caption = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCapt_2b"); pDC = pDt.Columns.Add("Changed", typeof(String)); pDC.ReadOnly = false; pDC.Caption = A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorCapt_2c"); DataRow pDR; for (int i = 0; i < AAState.lastValueProperties.Count; i++) { pDR = pDt.NewRow(); string strVal = ((object[])lstNames)[i].ToString().Trim(); pDR["Field"] = strVal; pDR["Changed"] = "F"; lstVal = AAState.lastValueProperties.GetProperty(strVal) as LastValueEntry; if (lstVal != null) { if (lstVal.Value == null || lstVal.Value == DBNull.Value) { nullObject = ""; } else { nullObject = lstVal.Value.ToString(); } pDR["Value"] = nullObject.ToString(); } pDt.Rows.Add(pDR); } LastValueForm lstValF = new LastValueForm(); lstValF.setDataTable(pDt); DialogResult dres = lstValF.ShowDialog(); if (dres == DialogResult.OK) { foreach (DataRow dr in lstValF.getDataTable().Rows) { if (dr[2].ToString() == "T") { lstVal = AAState.lastValueProperties.GetProperty(dr[0].ToString()) as LastValueEntry; if (lstVal != null) { lstVal.Value = dr[1].ToString().Trim(); AAState.lastValueProperties.SetProperty(dr[0].ToString(), lstVal); } } } } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain2") + ex.ToString()); } } public static void promptLastValueProperrtySet() { try { object nullObject = null; if (AAState.lastValueProperties == null) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_2a")); return; } object lstNames; object lstValues; AAState.lastValueProperties.GetAllProperties(out lstNames, out lstValues); LastValueEntry lstVal; for (int i = 0; i < AAState.lastValueProperties.Count; i++) { string strVal = ((object[])lstNames)[i].ToString().Trim(); lstVal = AAState.lastValueProperties.GetProperty(strVal) as LastValueEntry; if (lstVal != null) { if (lstVal.Value == null || lstVal.Value == DBNull.Value) { nullObject = ""; } else { nullObject = lstVal.Value.ToString(); } string strRet = Microsoft.VisualBasic.Interaction.InputBox(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_2b") + strVal + "\r\n" + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_2c") + nullObject.ToString() + "\r\n" + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_2d"), A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_2b") + strVal, nullObject.ToString()); if (strRet != "") { if (strRet.ToString().ToUpper() == "".ToUpper()) { lstVal.Value = null; AAState.lastValueProperties.SetProperty(strVal, lstVal); } else { lstVal.Value = strRet; AAState.lastValueProperties.SetProperty(strVal, lstVal); } } } } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain2") + ex.ToString()); } } public static void initEditing() { if (AAState.PerformUpdates == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_3a")); return; } // wire events if (reInitExt() == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_3b")); AAState.PerformUpdates = false; } if (AAState._editor.EditWorkspace != null) { if (AAState._editor.EditWorkspace.Type == esriWorkspaceType.esriFileSystemWorkspace) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_3c")); AAState.PerformUpdates = false; } } if (AAState.PerformUpdates) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_3d")); if (Debug().ToUpper() == "TRUE") { AAState._filePath = Globals.getDebugPath(); if (AAState._filePath != "") { AAState._sw = Globals.createTextFile(AAState._filePath, FileMode.Create); } Globals.LogLocations = AAState._filePath; } else { AAState._sw = null; Globals.LogLocations = ""; } // Get user Info reInitExt(); //obtain rotation calculator AAState.rCalc = new RotationCalculator(ArcMap.Application); //Create WGS_84 SR ISpatialReferenceFactory srFactory = new SpatialReferenceEnvironmentClass(); IGeographicCoordinateSystem gcs = srFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); _sr1 = gcs; _editEvents.OnChangeFeature += FeatureChange; _editEvents.OnCreateFeature += FeatureCreate; _editEvents2.BeforeStopOperation += StopOperation; // SG Jan 2013 } else { AAState.PerformUpdates = false; _editEvents.OnChangeFeature -= FeatureChange; _editEvents.OnCreateFeature -= FeatureCreate; _editEvents2.BeforeStopOperation -= StopOperation; // SG Jan 2013 MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("dynamicValueTableMissing")); } ArcMap.Application.StatusBar.set_Message(0, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorDone_3a")); } public static void StopChangeMonitor() { _editEvents.OnChangeFeature -= FeatureChange; _editEvents2.BeforeStopOperation -= StopOperation; // SG Jan 2013 } public static void StartChangeMonitor() { _editEvents.OnChangeFeature += FeatureChange; _editEvents2.BeforeStopOperation += StopOperation; // SG Jan 2013 } public static bool reInitExt() { AAState.indent = ""; bool blState = AAState.initTable(); AAState.createLastValuePropertySet(); _currentUserInfo = new CurrentUserInfo(AAState._editor); return blState; } public static void unInitEditing() { try { if (AAState._sw != null) { AAState.WriteLine("**************************************"); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_4a") + DateTime.Now.ToString()); AAState._sw.Flush(); AAState._sw.Close(); AAState._sw = null; } AAState._filePath = ""; // Globals.LogLocations = AAState._filePath; } catch { } try { _editEvents.OnChangeFeature -= FeatureChange; _editEvents.OnCreateFeature -= FeatureCreate; _editEvents2.BeforeStopOperation -= StopOperation; // SG Jan 2013 _currentUserInfo = null; } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_4a") + ex.ToString()); } } public static event BeforeStopOperation stopOperation; // SG Jan 2013 public delegate void BeforeStopOperation(ESRI.ArcGIS.Geodatabase.IObject obj); // SG Jan 2013 public static event OnChangeFeature changeFeature; public delegate void OnChangeFeature(ESRI.ArcGIS.Geodatabase.IObject obj); public static event OnChangeGeoFeature changeGeoFeature; public delegate void OnChangeGeoFeature(ESRI.ArcGIS.Geodatabase.IObject obj); public static event OnCreateFeature createFeature; public delegate void OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj); public static event OnManualFeature manualFeature; public delegate void OnManualFeature(ESRI.ArcGIS.Geodatabase.IObject obj); public static void StopOperation() // SG Jan 2013 { try { if (AAState._onStopOperationEvent == true && AAState._bypassEditOperationCheck == false) { IWorkspaceEdit2 wsEdit = (IWorkspaceEdit2)AAState._editor.EditWorkspace; if (wsEdit.IsInEditOperation == true) { try { IDataChangesEx changes = wsEdit.get_EditDataChanges(esriEditDataChangesType.esriEditDataChangesWithinOperation); // for edit operation IEnumBSTR modClass = changes.ModifiedClasses; string modItem = modClass.Next(); string classList = ""; while (modItem != null) { classList = classList + modItem; modItem = modClass.Next(); if (modItem != null) classList = classList + ", "; } string classItem = classList.Split(',')[0]; // might be a better way, but if this is "add selected" it should only be 1 class... classItem = classItem.Substring(classItem.LastIndexOf('.') + 1).ToUpper(); //IFIDSet ids = changes.get_ChangedIDs(classItem,(esriDifferenceType)2); // get updates, there must be only 1... //int fID; //ids.Next(out fID); //int oid = 0; //while(fID != -1) //{ // oid = fID; // ids.Next(out fID); //} // loop through selected features and find the selected on that matches this edit operation // if (AAState._editor.SelectionCount > 0) { IEnumFeature selection = AAState._editor.EditSelection; IObject obj = selection.Next(); while (obj != null) { if (classItem == obj.Class.AliasName.ToUpper()) { changeFeature((IObject)obj); } obj = selection.Next(); } } } catch { } } } AAState._onStopOperationEvent = true; // indicate this was a stop operation event so onchange doesn't fire 2x } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain3") + ex.ToString() + " \n"); } } private static bool InMemTableExistsForRow(ESRI.ArcGIS.Geodatabase.IObject obj) { if (AAState._fabricInMemTablesLookUp == null) return false; int iObjClassID = obj.Class.ObjectClassID; if (AAState._fabricInMemTablesLookUp[iObjClassID] != null) return true; else return false; } public static void FabricGeometryRowChange(ESRI.ArcGIS.Geodatabase.IObject obj) { if (obj is IFeature) { IFeatureChanges pFeatChanges = obj as IFeatureChanges; if (!pFeatChanges.ShapeChanged) return; if (pFeatChanges.OriginalShape.IsEmpty) //means new fabric parcel return; } if (InMemTableExistsForRow(obj)) FeatureGeoChange(obj); } public static void FabricRowChange(ESRI.ArcGIS.Geodatabase.IObject obj) { if (InMemTableExistsForRow(obj)) FeatureChange(obj); } public static void FabricRowCreate(ESRI.ArcGIS.Geodatabase.IObject obj) { if (InMemTableExistsForRow(obj)) FeatureCreate(obj); } public static void FeatureChange(ESRI.ArcGIS.Geodatabase.IObject obj) { try { if (changeFeature != null) changeFeature(obj); } catch (Exception ex) { MessageBox.Show("FeatureChange:" + ex.ToString() + " \n" + obj.Class.AliasName + ": " + obj.OID); } } public static void FeatureGeoChange(ESRI.ArcGIS.Geodatabase.IObject obj) { try { if (changeGeoFeature != null) changeGeoFeature(obj); } catch (Exception ex) { MessageBox.Show("FeatureGeoChange:" + ex.ToString() + " \n" + obj.Class.AliasName + ": " + obj.OID); } } public static void FeatureCreate(ESRI.ArcGIS.Geodatabase.IObject obj) { try { if (createFeature != null) createFeature(obj); } catch (Exception ex) { MessageBox.Show("OnCreateFeature:" + ex.ToString() + " \n" + obj.Class.AliasName + ": " + obj.OID); } } public static void FeatureManual(ESRI.ArcGIS.Geodatabase.IObject obj) { try { if (manualFeature != null) manualFeature(obj); } catch (Exception ex) { MessageBox.Show("OnFeatureManual:" + ex.ToString() + " \n" + obj.Class.AliasName + ": " + obj.OID); } } public static bool _clearLastValue = false; public static bool _clearLastValueStopEdit = false; public static string _generateIDStoreProceName = null; } public class AttributeAssistantEditorExtension : ESRI.ArcGIS.Desktop.AddIns.Extension { IFeature inFeature; static int _LastOID = -1; static string _LastMode = ""; static string _LastFC = ""; //The schema of the dynamic values table is fixed. Please copy the AttributeAssistant table provided in the sample data. //If it is modiifed these field positions may be incorrect. private string lastEditorName; private bool changed; private string tableName, valMethod, valData, valFC; private MSScriptControl.ScriptControlClass script; private LastValueEntry lastValue; private int fieldCopy, juncField; private Nullable rotationAngle; private string[] args; private string[] sourceLayerNames; private string sequenceColumnName, sequenceFixedWidth, sequencePostfix = ""; private string formatString; private string intersectLayerName, intersectLayerFieldName; private int sequenceColumnNum; private int sequenceIntColumnNum; private int sequencePadding; private bool found; private string newValue; private string sourceLayerName; private string sourceFieldName; private double searchDistance, distance, lastDistance; private int sourceField; private string[] _currentDatasetNameItems; private bool _enabledOnStart = true; private bool _enabledOnStartEditing = false; private IFeatureLayer intersectLayer; private bool boolLayerOrFC = false; private IStandaloneTable intersectTable; private IFeatureSelection intersectLayerSelection; private ITableSelection intersectTableSelection; private IQueryFilter qFilter; private IRow row; private IField testField; private ICurve curve; private IFeatureLayer sourceLayer; private IFeatureSelection pFS; private IPoint _copyPoint; private IPolyline _copyPolyline; private IPolygon _copyPolygon; private ISpatialFilter sFilter; private IFeatureCursor fCursor; private ICursor cCurs = null; private IFeature sourceFeature; private IFeature nearestFeature; private IField fieldObj; private IDataset _currentDataset; private IProximityOperator proxOp; private int intersectFieldPos; private string intersectValue; string locatorURL; string GeocodeStr = "GeocodeServer"; string reverseGeocodeStr = "ReverseGeocode"; private string _agsOnlineLocators = "http://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/"; public AttributeAssistantEditorExtension() { ConfigUtil.type = "aa"; } //Retrieve configuration from XML config file (overrides defaults set above) private void GetConfigSettings() { AAState._defaultsTableName = ConfigUtil.GetConfigValue("AttributeAssistant_TableName", AAState._defaultsTableName); AAState._sequenceTableName = ConfigUtil.GetConfigValue("AttributeAssistant_GenerateId_TableName", AAState._sequenceTableName); AAState._CheckEnvelope = ConfigUtil.GetConfigValue("AttributeAssistant_CheckEnvelope ", AAState._CheckEnvelope); _enabledOnStart = ConfigUtil.GetConfigValue("AttributeAssistant_EnabledOnStartUp", _enabledOnStart); _enabledOnStartEditing = ConfigUtil.GetConfigValue("AttributeAssistant_EnabledOnStartEditing", _enabledOnStartEditing); _agsOnlineLocators = ConfigUtil.GetConfigValue("Geocoder", _agsOnlineLocators); if (_agsOnlineLocators[_agsOnlineLocators.Length - 1] == '/') { _agsOnlineLocators = _agsOnlineLocators.Substring(0, _agsOnlineLocators.Length - 1); } if (ConfigUtil.GetConfigValue("AttributeAssistant_ClearLastValue", "FALSE").ToUpper() == "TRUE") AAState._clearLastValue = true; else AAState._clearLastValue = false; if (ConfigUtil.GetConfigValue("AttributeAssistant_ClearLastValueStopEdit", "FALSE").ToUpper() == "TRUE") AAState._clearLastValueStopEdit = true; else AAState._clearLastValueStopEdit = false; if (ConfigUtil.GetConfigValue("BypassEditOperationCheck", "FALSE").ToUpper() == "TRUE") AAState._bypassEditOperationCheck = true; else AAState._bypassEditOperationCheck = false; if (ConfigUtil.GetConfigValue("OnCreateWhenSplit", "FALSE").ToUpper() == "TRUE") AAState._onCreateWhenSplit = true; else AAState._onCreateWhenSplit = false; AAState._generateIDStoreProceName = (ConfigUtil.GetConfigValue("GenerateIDStoreProceName", null)); AAState._seqNameField = ConfigUtil.GetConfigValue("SequenceName", AAState._seqNameField); AAState._seqCounterField = ConfigUtil.GetConfigValue("SequenceCounter", AAState._seqCounterField); AAState._seqIntervalField = ConfigUtil.GetConfigValue("SequenceInterval", AAState._seqIntervalField); } void appStatusEvents_Initialized() { if (localEventAdded == false) { init(); } } private bool localEventAdded = false; void init() { AAState.initDynTable(); if (!_enabledOnStart || AAState._dt == null) { AAState.PerformUpdates = false; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_5a")); } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_5b")); AAState.PerformUpdates = true; } AAState.initEditing(); if (localEventAdded == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_5c")); AAState.changeFeature += OnChangeFeature; AAState.changeGeoFeature += OnChangeGeoFeature; AAState.createFeature += OnCreateFeature; AAState.manualFeature += OnManualFeature; AAState.stopOperation += OnBeforeStopOperation; // SG Jan 2013 localEventAdded = true; } } void ArcMap_NewOpenDocument() { try { AAState.setOff = true; AAState.setIcon(); } catch { } try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_6a")); AAState.unInitEditing(); } catch { } try { if (AAState._sw != null) { AAState._sw.Flush(); AAState._sw.Close(); AAState._sw = null; } } catch { } bool curVal = AAState._clearLastValue; AAState._clearLastValue = true; init(); AAState._clearLastValue = curVal; } void ArcMap_CloseDocument() { AAState.PerformUpdates = false; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_7a")); AAState.unInitEditing(); } private void reloadOccured(object sender, EventArgs e) { GetConfigSettings(); if (!_enabledOnStart | AAState._dt == null) { AAState.PerformUpdates = false; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_8a")); } } protected override void OnStartup() { ESRI.ArcGIS.ArcMap.IApplicationStatusEvents_Event appStatusEvents = ArcMap.Application as ESRI.ArcGIS.ArcMap.IApplicationStatusEvents_Event; appStatusEvents.Initialized += new ESRI.ArcGIS.ArcMap.IApplicationStatusEvents_InitializedEventHandler(appStatusEvents_Initialized); ArcMap.Events.NewDocument += ArcMap_NewOpenDocument; ArcMap.Events.OpenDocument += ArcMap_NewOpenDocument; ArcMap.Events.CloseDocument += ArcMap_CloseDocument; ReloadMonitor.reloadConfig += new ReloadEventHandler(reloadOccured); GetConfigSettings(); if (!_enabledOnStart | AAState._dt == null) { AAState.PerformUpdates = false; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_9a")); } IEditor _editor = Globals.getEditor(ArcMap.Application); //Wire editor events. AAState._editEvents = (IEditEvents_Event)_editor; AAState._editEvents2 = (IEditEvents2_Event)_editor;// SG Jan 2003- AAState._editEvents.OnStartEditing += OnStartEditing; AAState._editEvents.OnStopEditing += OnStopEditing; AAState._editEvents2.OnSaveEdits += OnSaveEditing; try { script = new MSScriptControl.ScriptControlClass(); script.AllowUI = false; script.Language = "VBScript"; script.UseSafeSubset = true; string strScript = "function iif(psdStr, trueStr, falseStr)" + System.Environment.NewLine + "On Error Resume Next" + System.Environment.NewLine + "if psdStr then" + System.Environment.NewLine + "iif = trueStr" + System.Environment.NewLine + "else " + System.Environment.NewLine + "iif = falseStr" + System.Environment.NewLine + "end if" + System.Environment.NewLine + "end function" + System.Environment.NewLine; string strScript2 = "function TCase(strTextString)" + System.Environment.NewLine + "Dim arrTextItem, strTextNew" + System.Environment.NewLine + "strSplitText = \" '-\"" + System.Environment.NewLine + "For y = 1 to len(strSplitText)" + System.Environment.NewLine + "strSplitItem = Mid(strSplitText,y,1)" + System.Environment.NewLine + "arrTextItem = Split(strTextString, strSplitItem)" + System.Environment.NewLine + "For x = 0 to Ubound(arrTextItem)" + System.Environment.NewLine + "If strSplitItem = \"'\" Then" + System.Environment.NewLine + "If Mid(arrTextItem(x),2,1) = \" \" Then" + System.Environment.NewLine + "strTextNew = strTextNew & strSplitItem & LCase(Left(arrTextItem(x),1)) & Right(arrTextItem(x),Len(arrTextItem(x))-1)" + System.Environment.NewLine + "Else" + System.Environment.NewLine + "strTextNew = strTextNew & strSplitItem & UCase(Left(arrTextItem(x),1)) & Right(arrTextItem(x),Len(arrTextItem(x))-1)" + System.Environment.NewLine + "End If" + System.Environment.NewLine + "Else" + System.Environment.NewLine + "If strSplitItem = \"-\" Then" + System.Environment.NewLine + "strTextNew = strTextNew & strSplitItem & UCase(Left(arrTextItem(x),1)) & Right(arrTextItem(x),Len(arrTextItem(x))-1)" + System.Environment.NewLine + "Else" + System.Environment.NewLine + "strTextNew = strTextNew & strSplitItem & UCase(Left(arrTextItem(x),1)) & LCase(Right(arrTextItem(x),Len(arrTextItem(x))-1))" + System.Environment.NewLine + "End If" + System.Environment.NewLine + "End If" + System.Environment.NewLine + "Next" + System.Environment.NewLine + "strTextString = Right(strTextNew,Len(strTextNew)-1)" + System.Environment.NewLine + "strTextNew = \"\"" + System.Environment.NewLine + "Next" + System.Environment.NewLine + "TCase = strTextString" + System.Environment.NewLine + "end function" + System.Environment.NewLine; string strScript3 = "function Ceil(number)" + System.Environment.NewLine + "Ceil = Int(number)" + System.Environment.NewLine + "if Ceil <> number then" + System.Environment.NewLine + "Ceil = Ceil + 1" + System.Environment.NewLine + "end if" + System.Environment.NewLine + "end function" + System.Environment.NewLine; string strScript4 = "function Floor(number)" + System.Environment.NewLine + "Floor = Int(number)" + System.Environment.NewLine + "end function" + System.Environment.NewLine; script.AddCode(strScript); script.AddCode(strScript2); script.AddCode(strScript3); script.AddCode(strScript4); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_9b") + newValue); } 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._editEvents2 = (IEditEvents2_Event)AAState._editor;// SG Jan 2003 AAState._editEvents.OnStartEditing -= OnStartEditing; AAState._editEvents.OnStopEditing -= OnStopEditing; AAState._editEvents2.OnSaveEdits -= OnSaveEditing; //AAState._editor = null; //AAState._editEvents = null; //AAState._editEvents2 = null; // SG Jan 2003 } } try { AAState.bmpOff.Dispose(); AAState.bmpOn.Dispose(); AAState.commandItem = null; } catch { } } catch { } } protected override bool OnSetState(ESRI.ArcGIS.Desktop.AddIns.ExtensionState state) { //Users can optionally check license here. this.State = state; try { AAState.setIcon(); } catch { } return true; } protected override ESRI.ArcGIS.Desktop.AddIns.ExtensionState OnGetState() { return this.State; } internal bool IsExtensionEnabled { get { return this.State == ESRI.ArcGIS.Desktop.AddIns.ExtensionState.Enabled; } } #region Editor Events #region Shortcut properties to the various editor event interfaces private IEditEvents_Event Events { get { return Globals.getEditor(ArcMap.Application) as IEditEvents_Event; } } private IEditEvents2_Event Events2 { get { return Globals.getEditor(ArcMap.Application) as IEditEvents2_Event; } } private IEditEvents3_Event Events3 { get { return Globals.getEditor(ArcMap.Application) as IEditEvents3_Event; } } private IEditEvents4_Event Events4 { get { return Globals.getEditor(ArcMap.Application) as IEditEvents4_Event; } } #endregion void WireEditorEvents() { try { Events.OnCurrentTaskChanged += delegate { if (Globals.getEditor(ArcMap.Application).CurrentTask != null) System.Diagnostics.Debug.WriteLine(Globals.getEditor(ArcMap.Application).CurrentTask.Name); }; Events2.BeforeStopEditing += delegate(bool save) { OnBeforeStopEditing(save); }; } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_10a") + ex.ToString()); } } void OnBeforeStopEditing(bool save) { } private void OnStartEditing() { try { //Start editing is a result of a save, as a save stops editing and saves if (SaveClicked == true) { SaveClicked = false; return; } AAState.initDynTable(); if (AAState.PerformUpdates == false && this._enabledOnStartEditing) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantMess_1b")); AAState.PerformUpdates = true; AAState.initEditing(); } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_11a")); if (AAState.PerformUpdates && AAState.Debug().ToUpper() == "TRUE") { if (AAState._sw == null && AAState._filePath != "") { AAState._sw = Globals.createTextFile(AAState._filePath, FileMode.Append); AAState.WriteLine("#######################################################"); Globals.LogLocations = AAState._filePath; } } if (AAState._editor != null) { if (AAState._editor.EditWorkspace != null) { IWorkspaceEditControl pWorkspaceEditControl = AAState._editor.EditWorkspace as IWorkspaceEditControl; if (pWorkspaceEditControl != null) { pWorkspaceEditControl.SetStoreEventsRequired(); } pWorkspaceEditControl = null; InitFabricState(); } } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_11a") + ex.ToString()); } } private void OnStopEditing(Boolean save) { if (SaveClicked == true) { return; } UnInitFabricState(); if (AAState._clearLastValueStopEdit == true) { AAState.createLastValuePropertySet(true); } } private bool SaveClicked = false; private void OnSaveEditing() { SaveClicked = true; } private void OnChangeGeoFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { try { if (obj != null) { inFeature = obj as IFeature; if (inFeature != null) { sendEvent(obj, "ON_CHANGEGEO"); } } } catch (Exception ex) { MessageBox.Show("OnChangeGeoFeature:" + ex.ToString() + " \n" + obj.Class.AliasName + ": " + obj.OID); } finally { } } private void OnChangeFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { IFeatureChanges pFeatChange = null; try { inFeature = obj as IFeature; bool bIsFabricRecord = false; if (inFeature != null) { if (AAState._fabricObjectClassIds != null) bIsFabricRecord = AAState._fabricObjectClassIds.Contains(obj.Class.ObjectClassID); if ((inFeature as INetworkFeature) != null && NetworkConnectivityChanged(obj)) //check to see if a feature is connected or disconnected { if (AAState.triggerByTools == AAState.TriggerByToolsOptions.Change) { sendEvent(obj, "ON_CHANGE"); } else { sendEvent(obj, "ON_CHANGEGEO"); } } else { pFeatChange = (IFeatureChanges)inFeature; if (pFeatChange.ShapeChanged) { if (bIsFabricRecord) { if (pFeatChange.OriginalShape.IsEmpty) sendEvent(obj, "ON_CREATE"); //original shape empty, but shape change means new parcel else sendEvent(obj, "ON_CHANGE");//treat geometry changes as standard change for fabric } else sendEvent(obj, "ON_CHANGEGEO"); } else { sendEvent(obj, "ON_CHANGE"); } } } else { sendEvent(obj, "ON_CHANGE"); } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain7") + ex.ToString() + " \n" + obj.Class.AliasName + ": " + obj.OID); } finally { inFeature = null; } } private bool NetworkConnectivityChanged(ESRI.ArcGIS.Geodatabase.IObject obj) { return (!ValuesChanged(obj) && !ShapeChanged(obj)); } private bool ValuesChanged(ESRI.ArcGIS.Geodatabase.IObject obj) { IRowChanges rowChanges; rowChanges = obj as IRowChanges; for (int i = 0; i <= obj.Fields.FieldCount - 1; i++) { if (rowChanges.get_ValueChanged(i)) { return true; } } return false; } private bool ShapeChanged(ESRI.ArcGIS.Geodatabase.IObject obj) { IFeatureChanges featureChanges; featureChanges = obj as IFeatureChanges; return featureChanges.ShapeChanged; } private void OnBeforeStopOperation(ESRI.ArcGIS.Geodatabase.IObject obj) { IFeatureChanges pFeatChange = null; MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain6")); try { inFeature = obj as IFeature; if (inFeature != null) { pFeatChange = (IFeatureChanges)inFeature; if (pFeatChange.ShapeChanged) { //sendEvent(obj, "ON_STOPOPERATION"); } else { //sendEvent(obj, "ON_STOPOPERATION"); } } else { //sendEvent(obj, "ON_STOPOPERATION"); } } catch (Exception ex) { MessageBox.Show("BeforeStopOperation:" + ex.ToString());// + " \n" + obj.Class.AliasName + ": " + obj.OID); } finally { inFeature = null; } } private void OnCreateRelationship(ESRI.ArcGIS.Geodatabase.IRelationship obj) { IFeatureChanges pFeatChange = null; try { inFeature = obj as IFeature; if (inFeature != null) { pFeatChange = (IFeatureChanges)inFeature; if (pFeatChange.ShapeChanged) { //sendEvent(obj, "ON_CHANGEGEO"); } else { //sendEvent(obj, "ON_CHANGE"); } } else { //sendEvent(obj, "ON_CHANGE"); } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain7") + ex.ToString() + " \n"); } finally { inFeature = null; } } private void OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { try { inFeature = obj as IFeature; bool bIsFabricRecord = false; if (inFeature != null) { if (AAState._fabricObjectClassIds != null) bIsFabricRecord = AAState._fabricObjectClassIds.Contains(obj.Class.ObjectClassID); if (bIsFabricRecord) { if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) return;// for parcels in fabrics, postpone the OnCreate event and let the OnChange test check if it's a new parcel } } sendEvent(obj, "ON_CREATE"); } catch (Exception ex) { MessageBox.Show("OnCreateFeature:" + ex.ToString() + " \n" + obj.Class.AliasName + ": " + obj.OID); } } private void OnManualFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { try { inFeature = obj as IFeature; sendEvent(obj, "ON_MANUAL"); } catch (Exception ex) { MessageBox.Show("OnManualFeature:" + ex.ToString() + " \n" + obj.Class.AliasName + ": " + obj.OID); } } private void sendEvent(IObject inObject, string mode) { if (AAState._Suspend == true) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantMess_1e")); return; } try { if (AAState.PerformUpdates == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_12a")); return; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_12b") + AAState._processCount); if (_LastOID == inObject.OID && _LastMode == mode && _LastFC == inObject.Class.AliasName && AAState._processCount > 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_12c")); _LastOID = -1; _LastMode = ""; _LastFC = ""; return; } if (AAState._onCreateWhenSplit == true) { // SG Jun 2017 - add a check that will trigger on_create when splitting/cutting features IApplication _myApp = ArcMap.Application; string name = _myApp.CurrentTool.Name; // The even more solid logic here would be the 2nd last OID == inObject.OID // but checking the current tool does a good job indicating the source of the onChangeGeo event if (_LastOID != inObject.OID && mode == "ON_CHANGEGEO" && _LastFC == inObject.Class.AliasName && (name == "Editor_SplitTool" || name == "Editor_CutPolygonsTool")) { string changes = ""; changes = "This: " + inObject.OID.ToString() + " Last: " + _LastOID.ToString() + " - " + mode; AAState.WriteLine("Change mode from ON_CHANGEGEO to ON_CREATE for " + name + ": " + changes); mode = "ON_CREATE"; //sendEvent(inObject, "ON_CREATE"); } } _LastOID = inObject.OID; _LastMode = mode; _LastFC = inObject.Class.AliasName; try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14at")); AAState.changeFeature -= OnChangeFeature; AAState.changeGeoFeature -= OnChangeGeoFeature; AAState.createFeature -= OnCreateFeature; AAState.stopOperation -= OnBeforeStopOperation; // SG Jan 2013 if (AAState.Debug().ToUpper() == "TRUE") { if (AAState._sw == null && AAState._filePath != "") { AAState._sw = Globals.createTextFile(AAState._filePath, FileMode.Append); Globals.LogLocations = AAState._filePath; } AAState.WriteLine("#######################################################"); AAState.WriteLine(inObject.Class.AliasName + " - " + mode.ToString()); } List newFeatureList = null; List changedFeatureList = null; List changedFeatureGeoList = null; try { AAState._onStopOperationEvent = false; // SG Jan 2013 - on a real onchange event flag that it was not a stopoperation event from a source like A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain8") AAState._processCount++; //Set attributes based on the dynamic defaults configuration table bool success = SetDynamicValues(inObject, mode, out changedFeatureList, out newFeatureList, out changedFeatureGeoList); if (!success) { // MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain9")); return; } else { if (changedFeatureList != null) { processFeatures(changedFeatureList, "ON_CHANGE"); } if (changedFeatureGeoList != null) { processFeatures(changedFeatureGeoList, "ON_CHANGEGEO"); } if (newFeatureList != null) { processFeatures(newFeatureList, "ON_CREATE"); } } } catch { } finally { AAState._processCount--; try { if (changedFeatureList != null) { changedFeatureList.Clear(); } } catch { } changedFeatureList = null; try { if (newFeatureList != null) { newFeatureList.Clear(); } } catch { } newFeatureList = null; try { if (changedFeatureGeoList != null) { changedFeatureGeoList.Clear(); } } catch { } changedFeatureGeoList = null; if (AAState._sw != null) { if (AAState._processCount == 0) { AAState.WriteLine("#######################################################"); AAState._sw.Flush(); } } } } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14au")); AAState.changeFeature += OnChangeFeature; AAState.changeGeoFeature += OnChangeGeoFeature; AAState.createFeature += OnCreateFeature; AAState.stopOperation += OnBeforeStopOperation; // SG Jan 2013 } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_12a") + ex.ToString()); } } private void processFeatures(List ObjectList, string eventType) { if (ObjectList != null) { List newFeatureList = null; List changedFeatureList = null; List changedFeatureGeoList = null; try { AAState._onStopOperationEvent = false; // SG Jan 2013 foreach (IObject inObject in ObjectList) { AAState.WriteLine("#######################################################"); AAState.WriteLine(inObject.Class.AliasName + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_13a") + eventType); try { AAState._processCount++; //Set attributes based on the dynamic defaults configuration table inFeature = inObject as IFeature; bool success = SetDynamicValues(inObject, eventType, out changedFeatureList, out newFeatureList, out changedFeatureGeoList); try { inObject.Store(); } catch { } if (!success) { // MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain9")); return; } else { if (changedFeatureList != null) { processFeatures(changedFeatureList, "ON_CHANGE"); } if (changedFeatureGeoList != null) { processFeatures(changedFeatureGeoList, "ON_CHANGEGEO"); } if (newFeatureList != null) { processFeatures(newFeatureList, "ON_CREATE"); } } } catch { } finally { AAState._processCount--; try { if (changedFeatureList != null) { changedFeatureList.Clear(); } } catch { } changedFeatureList = null; try { if (newFeatureList != null) { newFeatureList.Clear(); } } catch { } newFeatureList = null; try { if (changedFeatureGeoList != null) { changedFeatureGeoList.Clear(); } } catch { } changedFeatureGeoList = null; if (AAState._sw != null) { if (AAState._processCount == 0) { AAState.WriteLine("#######################################################"); AAState._sw.Flush(); } } } } } catch { } finally { try { if (changedFeatureList != null) { changedFeatureList.Clear(); } } catch { } changedFeatureList = null; try { if (newFeatureList != null) { newFeatureList.Clear(); } } catch { } newFeatureList = null; try { if (changedFeatureGeoList != null) { changedFeatureGeoList.Clear(); } } catch { } changedFeatureGeoList = null; } } } #endregion #region Helper Methods public void WireFabricEvents() { if (AAState._objectClassEventList == null) AAState._objectClassEventList = new List(); //create event handler for each fabric class in the edit workspace try { AAState._objectClassEventList.Clear(); for (int i = 0; i < AAState._fabricObjectClassIds.Count; i++) { IObjectClass pObjClass = (IObjectClass)AAState._fabricObjectClasses.get_Element(i); //Create event handler. ESRI.ArcGIS.Geodatabase.IObjectClassEvents_Event ev = (ESRI.ArcGIS.Geodatabase.IObjectClassEvents_Event)pObjClass; ev.OnChange += new ESRI.ArcGIS.Geodatabase.IObjectClassEvents_OnChangeEventHandler(AAState.FabricRowChange); ev.OnChange += new ESRI.ArcGIS.Geodatabase.IObjectClassEvents_OnChangeEventHandler(AAState.FabricGeometryRowChange); ev.OnCreate += new ESRI.ArcGIS.Geodatabase.IObjectClassEvents_OnCreateEventHandler(AAState.FabricRowCreate); AAState._objectClassEventList.Add(ev); } } catch (Exception ex) { MessageBox.Show(ex.ToString() + " in Wire Fabric Events"); } } public void UnWireFabricEvents() { if (AAState._objectClassEventList == null) return; try { for (int i = AAState._objectClassEventList.Count - 1; i >= 0; i--) { AAState._objectClassEventList[i].OnChange -= AAState.FabricRowChange; AAState._objectClassEventList[i].OnChange -= AAState.FabricGeometryRowChange; AAState._objectClassEventList[i].OnCreate -= AAState.FabricRowCreate; } AAState._objectClassEventList.Clear(); } catch (Exception ex) { MessageBox.Show(ex.ToString() + " in UnWire Fabric Events"); } } public void InitFabricState() { //get the fabric layers from the map IArray pFabricSubLayerArray; bool bHasFabricLayers = GetAllFabricSubLayers(out pFabricSubLayerArray); //bool bHasFabricLayers = GetFabricSubLayersByClass(esriCadastralFabricTable.esriCFTParcels, out pFabricSubLayerArray); //return the parcels fabric class as a feature class if (bHasFabricLayers) { AAState._fabricLayers = pFabricSubLayerArray; for (int i = 0; i < pFabricSubLayerArray.Count; i++) { IFeatureLayer pFLyr = (IFeatureLayer)pFabricSubLayerArray.get_Element(i); IFeatureClass featureClass = (IFeatureClass)pFLyr.FeatureClass; int iObjClassID = featureClass.ObjectClassID; if (AAState._fabricInMemTablesLookUp == null) AAState._fabricInMemTablesLookUp = new Dictionary(); if (AAState._fabricObjectClasses == null) AAState._fabricObjectClasses = new ArrayClass(); if (!AAState._fabricInMemTablesLookUp.ContainsKey(iObjClassID)) { AAState._fabricObjectClasses.Add(featureClass); IWorkspace pWS = Globals.CreateInMemoryWorkspace(); try { IFields NewFields = Globals.createFieldsFromSourceFields(featureClass.Fields); IDataset pDS = featureClass as IDataset; ITable InMemTable = Globals.createTableInMemory(pDS.Name, NewFields, pWS); if (InMemTable != null) AAState._fabricInMemTablesLookUp.Add(iObjClassID, InMemTable); } catch (Exception ex) { MessageBox.Show("Error Creating In Memory Fabric Table" + Environment.NewLine + ex.ToString()); } } if (AAState._fabricObjectClassIds == null) AAState._fabricObjectClassIds = new List(); if (!AAState._fabricObjectClassIds.Contains(iObjClassID)) AAState._fabricObjectClassIds.Add(iObjClassID); } WireFabricEvents(); } } public void UnInitFabricState() { if (AAState._fabricInMemTablesLookUp == null || AAState._objectClassEventList == null) return; try { UnWireFabricEvents(); AAState._objectClassEventList = null; AAState._fabricObjectClasses = null; AAState._fabricObjectClassIds = null; AAState._fabricInMemTablesLookUp = null; AAState._fabricLayers = null; } catch { } } public bool GetAllFabricSubLayers(out IArray CFSubLayers) { ICadastralFabricSubLayer pCFSubLyr = null; IArray CFParcelFabricSubLayers2 = new ArrayClass(); IFeatureLayer pParcelFabricSubLayer = null; UID pId = new UIDClass(); pId.Value = "{BA381F2B-F621-4F45-8F78-101F65B5BBE6}"; //ICadastralFabricSubLayer IMap pMap = AAState._editor.Map; IEnumLayer pEnumLayer = pMap.get_Layers(pId, true); pEnumLayer.Reset(); ILayer pLayer = pEnumLayer.Next(); while (pLayer != null) { pCFSubLyr = (ICadastralFabricSubLayer)pLayer; pParcelFabricSubLayer = (IFeatureLayer)pCFSubLyr; IDataset pDS = (IDataset)pParcelFabricSubLayer.FeatureClass; if (pDS.Workspace.Equals(AAState._editor.EditWorkspace)) CFParcelFabricSubLayers2.Add(pParcelFabricSubLayer); pLayer = pEnumLayer.Next(); } CFSubLayers = CFParcelFabricSubLayers2; if (CFParcelFabricSubLayers2.Count > 0) return true; else return false; } public bool GetFabricSubLayersByClass(esriCadastralFabricTable FabricSubClass, out IArray CFParcelFabSubLayers) { ICadastralFabricSubLayer pCFSubLyr = null; IArray CFParcelFabricSubLayers2 = new ArrayClass(); IFeatureLayer pParcelFabricSubLayer = null; UID pId = new UIDClass(); //pId.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}";//IGeoFeatureLayer pId.Value = "{BA381F2B-F621-4F45-8F78-101F65B5BBE6}"; //ICadastralFabricSubLayer IMap pMap = AAState._editor.Map; IEnumLayer pEnumLayer = pMap.get_Layers(pId, true); pEnumLayer.Reset(); ILayer pLayer = pEnumLayer.Next(); while (pLayer != null) { pCFSubLyr = (ICadastralFabricSubLayer)pLayer; if (pCFSubLyr.CadastralTableType == FabricSubClass) { pParcelFabricSubLayer = (IFeatureLayer)pCFSubLyr; IDataset pDS = (IDataset)pParcelFabricSubLayer.FeatureClass; if (pDS.Workspace.Equals(AAState._editor.EditWorkspace)) CFParcelFabricSubLayers2.Add(pParcelFabricSubLayer); } pLayer = pEnumLayer.Next(); } CFParcelFabSubLayers = CFParcelFabricSubLayers2; if (CFParcelFabricSubLayers2.Count > 0) return true; else return false; } public bool SetDynamicValues(IObject inObject, string mode, out List ChangeFeatureList, out List NewFeatureList, out List ChangeFeatureGeoList) { bool storeObject = false; NumberFormatInfo nfi = new CultureInfo(A4LGSharedFunctions.Localizer.GetString("AA_CultureInfo"), false).NumberFormat; nfi.NumberGroupSeparator = ""; nfi.NumberDecimalSeparator = "."; nfi.CurrencyDecimalSeparator = "."; 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()); bool UpdateValueOnCreate = true; if (AAState._dv.Count > 0) { IRowChanges pRowChLast = inObject as IRowChanges; for (int retRows = 0; retRows < AAState._dv.Count; retRows++) { UpdateValueOnCreate = true; DataRowView drv = AAState._dv[retRows]; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14m") + drv["FIELDNAME"].ToString()); //Check the value info to determine if the last value array entry should be changed on create. This will bypass values in an edit template and values add from a split operation string valDataTemp = drv["VALUEINFO"].ToString().Trim(); if (valDataTemp.Contains(Environment.NewLine)) { valDataTemp = valDataTemp.Substring(0, valDataTemp.IndexOf(Environment.NewLine)); } if (!String.IsNullOrEmpty(valDataTemp)) { args = valDataTemp.Split('|'); if (args.Length == 3) { if (args[2].ToString().ToUpper() == "FALSE" && mode == "ON_CREATE") { UpdateValueOnCreate = false; } } } if (UpdateValueOnCreate == true) { 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(); bool bHasFabricFeatureTarget = false; bool bHasFabricSubType = false; int iObjClassID = inObject.Class.ObjectClassID; bool bIsFabricClass = false; if (AAState._fabricInMemTablesLookUp != null) bIsFabricClass = AAState._fabricInMemTablesLookUp.ContainsKey(iObjClassID); if (valFC.Contains("|")) { if (bIsFabricClass) { string[] spliVal0 = valFC.Split('|'); string[] s = spliVal0[1].ToUpper().Trim().Split(','); for (int j = 0; j < s.Length; j++) s[j] = s[j].Trim(); List validFabricLayers = new List(s); IFeatureLayer pFLyr = null; string sCombinedOrSQL = ""; for (int i = 0; i < AAState._fabricLayers.Count; i++) { pFLyr = (IFeatureLayer)AAState._fabricLayers.get_Element(i); if (validFabricLayers.Contains(pFLyr.Name.ToUpper().Trim())) { IFeatureLayerDefinition2 pFeatLyrDef = (IFeatureLayerDefinition2)pFLyr; if (sCombinedOrSQL.Trim() == "") sCombinedOrSQL = "(" + pFeatLyrDef.DefinitionExpression + ")"; else sCombinedOrSQL += " OR (" + pFeatLyrDef.DefinitionExpression + ")"; } } if (pFLyr != null) //make sure there's at least one valid fabric feature layer { ITable InMemTable = AAState._fabricInMemTablesLookUp[iObjClassID]; IRowBuffer pRowBuff = InMemTable.CreateRowBuffer(); IFields pIncomingFlds = inObject.Fields; for (int i = 0; i < pIncomingFlds.FieldCount; i++) { IField pFld = pIncomingFlds.get_Field(i); if (pFld.Type == esriFieldType.esriFieldTypeOID || pFld.Type == esriFieldType.esriFieldTypeGeometry || pFld.Type == esriFieldType.esriFieldTypeGlobalID) continue; object val = inObject.get_Value(i); pRowBuff.set_Value(i, val); } ICursor pInsCurs = InMemTable.Insert(false); pInsCurs.InsertRow(pRowBuff); pInsCurs.Flush(); IQueryFilter pQueryF = new QueryFilterClass(); pQueryF.WhereClause = sCombinedOrSQL; if (sCombinedOrSQL.Trim() != "") { ICursor pCur = InMemTable.Search(pQueryF, false); IRow pRow = pCur.NextRow(); while (pRow != null) { bHasFabricFeatureTarget = true; Marshal.ReleaseComObject(pRow); pRow = pCur.NextRow(); } Marshal.ReleaseComObject(pCur); } //now drop all records from the table InMemTable.DeleteSearchedRows(null); ISubtypes pFabSubTyp = (ISubtypes)inObject.Class; if (pFabSubTyp != null) bHasFabricSubType = pFabSubTyp.HasSubtype; } if (!bHasFabricFeatureTarget && !bHasFabricSubType) { proc = false; continue; } } if (!bHasFabricFeatureTarget) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14af")); string[] spliVal = valFC.Split('|'); string[] s = spliVal[1].ToUpper().Trim().Split(','); for (int j = 0; j < s.Length; j++) s[j] = s[j].Trim(); List validSubtypes = new List(s); List inValidSubtypes; if (spliVal.GetLength(0) == 3) { inValidSubtypes = new List(spliVal[2].Split(',')); } else { inValidSubtypes = new List(); } 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 strFldNames = new List(); List strFldAlias = new List(); List intFldIdxs = new List(); fieldObj = null; if (drv["FIELDNAME"] != null && drv["FIELDNAME"].ToString().Trim() != "" && drv["FIELDNAME"].ToString().Trim() != "*" && drv["FIELDNAME"].ToString().Trim() != "#") { strFldNames = new List(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 "VALIDATE_DOMAIN": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "VALIDATE_DOMAIN"); IRowChanges pRowCh = null; if (valData != null) { if (intFldIdxs.Count == 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorErrr_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14aw")); continue; } pRowCh = inObject as IRowChanges; if (mode != "ON_MANUAL") { bool valueChanged = false; for (int i = 0; i < intFldIdxs.Count; i++) { if (pRowCh.get_ValueChanged(intFldIdxs[i]) == true) { valueChanged = true; break; } } if (valueChanged == true) { for (int i = 0; i < intFldIdxs.Count; i++) { if (pRowCh.get_ValueChanged(intFldIdxs[i]) == true) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ax")); if (inObject.get_Value(intFldIdxs[i]) == null || inObject.get_Value(intFldIdxs[i]) == "" || inObject.get_Value(intFldIdxs[i]) == DBNull.Value) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttrTrasftLoadRError_1")); } else { IDomain pD = null; ISubtypes pSubType = (ISubtypes)inObject.Class; if (pSubType.HasSubtype) { AAState.WriteLine("Layer has subtypes"); if (pSubType.SubtypeFieldIndex == intFldIdxs[i]) { AAState.WriteLine("Subtype field changed"); IList subList = Globals.SubtypeToList(pSubType); bool fldValid = false; foreach (Globals.DomSubList sub in subList) { if (sub.Value == inObject.get_Value(pSubType.SubtypeFieldIndex).ToString()) { fldValid = true; } } if (fldValid == false) { AAState.WriteLine("subtype not valid, aborting"); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19")); AAState._editor.AbortOperation(); return false; } else { AAState.WriteLine("Valid subtype"); } } else { pD = pSubType.get_Domain((int)inObject.get_Value(pSubType.SubtypeFieldIndex), inObject.Fields.get_Field(intFldIdxs[i]).Name); } } else { if (inObject.Fields.get_Field(intFldIdxs[i]).Domain != null) { pD = inObject.Fields.get_Field(intFldIdxs[i]).Domain; } } if (pD != null) { bool fldValid = false; if (pD is ICodedValueDomain) { AAState.WriteLine("Field has a coded value domain, checking value: " + inObject.get_Value(intFldIdxs[i]).ToString()); ICodedValueDomain2 pCD = (ICodedValueDomain2)pD; for (int j = 0; j < pCD.CodeCount; j++) { if (pCD.get_Value(j).ToString() == inObject.get_Value(intFldIdxs[i]).ToString()) { fldValid = true; break; } } pCD = null; } else { try { AAState.WriteLine("Field has a range domain, checking value: " + inObject.get_Value(intFldIdxs[i]).ToString()); IRangeDomain pRD = (IRangeDomain)pD; double fldVal; double minValue; double maxValue; double.TryParse(inObject.get_Value(intFldIdxs[i]).ToString(), out fldVal); double.TryParse(pRD.MinValue.ToString(), out minValue); double.TryParse(pRD.MaxValue.ToString(), out maxValue); if (fldVal >= minValue && fldVal <= maxValue) { fldValid = true; } else { AAState.WriteLine("Value is outside ther range: " + minValue.ToString() + " - " + maxValue.ToString()); } pRD = null; } catch { } } pD = null; if (fldValid == false) { AAState.WriteLine("Value not valid, aborting"); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19")); AAState._editor.AbortOperation(); return false; } else { AAState.WriteLine(inObject.Fields.get_Field(intFldIdxs[i]).Name + " is valid"); } } else { //do nothing } } } } } else { AAState.WriteLine("Listed Fields did not change"); } } else { AAState.WriteLine("Unsupported mode:" + mode); } } pRowCh = null; } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "VALIDATE_DOMAIN: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "VALIDATE_DOMAIN"); } break; case "MAP_INFO"://Value|FieldToChange|Value try { IRowChanges pRowCh = null; if (valData != null) { args = valData.Split('|'); if (args.Length < 1 || args.Length > 2) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "MAP_INFO: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bh")); continue; } string valType = ""; string limitField = ""; int limitFieldIdx = -1; int fieldToStoreResults = intFldIdxs[0]; switch (args.Length) { case 1: valType = args[0]; break; case 2: valType = args[0]; limitField = args[1]; limitFieldIdx = Globals.GetFieldIndex(inObject.Fields, limitField); break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "MAP_INFO: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bh")); continue; } IDocumentInfo2 pDocInfo = (IDocumentInfo2)(ArcMap.Document as IMapDocument); string resultValue = null; switch (valType.ToUpper()) { case "AUTHOR": resultValue = pDocInfo.Author; break; case "TITLE": resultValue = pDocInfo.DocumentTitle; break; case "NAME": resultValue = pDocInfo.Name; break; case "PATH": resultValue = pDocInfo.Path; break; case "VERSION": IDataset pDs = (IDataset)inObject.Class; IWorkspace pWork = pDs.Workspace; if (pWork is IVersionedWorkspace) { IVersion pVersion = (IVersion)(pWork as IVersionedWorkspace); resultValue = pVersion.VersionName; pDs = null; pVersion = null; } else { resultValue = "FGDB"; } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain48")); continue; } pRowCh = inObject as IRowChanges; if (limitFieldIdx >= 0) { if (pRowCh.get_ValueChanged(limitFieldIdx) == false && (mode != "ON_CREATE" && mode != "ON_MANUAL") && AAState.triggerByTools == AAState.TriggerByToolsOptions.Edit) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain64")); continue; } } if (resultValue != null) { if (fieldToStoreResults >= 0) { IField pTarField = inObject.Fields.get_Field(fieldToStoreResults); if (pTarField.Type != esriFieldType.esriFieldTypeString) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("FieldWrongType")); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14co") + resultValue); try { if (pTarField.Length < resultValue.Length) { resultValue = resultValue.Substring(0, pTarField.Length); } inObject.set_Value(fieldToStoreResults, resultValue); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az") + resultValue); } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14c") + resultValue); } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain25")); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain48")); } } pRowCh = null; } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "MAP_INFO: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "MAP_INFO"); } break; case "FIELD_TRIGGER"://Value|FieldToChange|Value try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FIELD_TRIGGER"); if (inObject != 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("AttributeAssistantEditorErrr_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])) if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true || mode == "ON_MANUAL" || AAState.triggerByTools == AAState.TriggerByToolsOptions.Manual || AAState.triggerByTools == AAState.TriggerByToolsOptions.Geo || AAState.triggerByTools == AAState.TriggerByToolsOptions.Change || AAState.triggerByTools == AAState.TriggerByToolsOptions.Create) { 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 { if (valToSet == "") { inObject.set_Value(chngFldIdx, DBNull.Value); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14az")); } else { 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.ToString()); } 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; IDisplayTable displayTable = 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 && mode != "ON_CREATE") { 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 { if (sourceLayerName.Contains("(")) { string[] tempSplt = sourceLayerName.Split('('); sourceLayerName = tempSplt[0]; pTbl = Globals.FindTableLayerOrFC(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) as IStandaloneTable; 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 { pTbl = Globals.FindTableLayerOrFC(AAState._editor.Map, sourceLayerName, ref boolLayerOrFC) 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"; } bool valueIsNull = false; 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 (inObject.get_Value(intFldIdxs[i]) == null || inObject.get_Value(intFldIdxs[i]) == "" || inObject.get_Value(intFldIdxs[i]) == DBNull.Value) { if (valueIsNull == false) { valueIsNull = true; } } if (pFlds.get_Field(sourceFieldNums[i]).Type == esriFieldType.esriFieldTypeString) { if (sqlString == "") { sqlString = pFlds.get_Field(sourceFieldNums[i]).Name + "" + " = '" + inObject.get_Value(intFldIdxs[i]).ToString().Replace("'", "''") + "'"; sqlStringUpper = sqlUpp + "(" + pFlds.get_Field(sourceFieldNums[i]).Name + ")" + " LIKE '" + specChar + inObject.get_Value(intFldIdxs[i]).ToString().ToUpper().Replace(" ", specChar).Replace("'", "''") + specChar + "'"; } else { sqlString = sqlString + " AND " + pFlds.get_Field(sourceFieldNums[i]).Name + "" + " = '" + inObject.get_Value(intFldIdxs[i]).ToString().Replace("'", "''") + "'"; sqlStringUpper = sqlStringUpper + " AND " + sqlUpp + "(" + pFlds.get_Field(sourceFieldNums[i]).Name + ")" + " LIKE '" + specChar + inObject.get_Value(intFldIdxs[i]).ToString().ToUpper().Replace(" ", specChar).Replace("'", "''") + 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) { if (boolLayerOrFC) { intRecFound = pTbl.Table.RowCount(pQFilt); } else { intRecFound = pTbl.Table.RowCount(pQFilt); } } else { if (boolLayerOrFC) { intRecFound = sourceLayer.FeatureClass.FeatureCount(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 on the feature class"); 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) { if (boolLayerOrFC) { displayTable = (IDisplayTable)pTbl; //ITableDefinition tblDef = (ITableDefinition)pTbl; pCurs = displayTable.SearchDisplayTable(pQFilt, true); //pCurs = pTbl.Table.Search(pQFilt, true); } else { pCurs = pTbl.Table.Search(pQFilt, true); } } else { if (boolLayerOrFC) { pCurs = sourceLayer.Search(pQFilt, true) as ICursor; } else { pCurs = sourceLayer.FeatureClass.Search(pQFilt, true) as ICursor; } } pQFilt = null; List pLst = Globals.CursorToList(ref pCurs, sourceFieldNums); if (pCurs != null) Marshal.ReleaseComObject(pCurs); pCurs = null; if (pLst.Count == 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19")); AAState._editor.AbortOperation(); return false; } string disFld = ""; for (int j = 0; j < sourceFieldNames.Length; j++) { disFld = disFld == "" ? sourceFieldNames[j] : disFld + "|" + sourceFieldNames[j]; } string selectVal = Globals.showOptionsForm(pLst, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain21") + disFld, ComboBoxStyle.DropDownList); if (selectVal == "||Cancelled||" && valueIsNull == true) { } else if (selectVal == "||Cancelled||" && valueIsNull == false) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain19")); AAState._editor.AbortOperation(); return false; } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain22") + selectVal); if (sourceFieldNums.Length == 1) { inObject.set_Value(intFldIdxs[0], selectVal); } else { string[] strVals = selectVal.Split((char)150); 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.ToString()); } 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(); //Changing store to be called at the end of the rules to ensure change events are properly handled storeObject = true; } } 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.ToString()); } 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.ToString()); } 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().Trim(); if (sourceLayerName != "") sourceLayerName = args[i].ToString().Trim(); 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(); IFeature sourceFeature = null; pTempLine = Globals.CreateAngledLineFromLocationOnLine((IPoint)inFeature.Shape, sourceLayer, boolLayerOrFC, Globals.ConvertDegToRads(90), offsetVal, "true", true, false, out sourceFeature, searchDistance); if (pTempLine != null) { if (pTempLine.IsEmpty == 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(); } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain34")); NewFeatureList.Add(pFeat); } else { AAState.WriteLine("A line was not found in the search distance: " + "CREATE_PERP_LINE"); } } else { AAState.WriteLine("A line was not found in the search distance: " + "CREATE_PERP_LINE"); } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CREATE_PERP_LINE: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "CREATE_PERP_LINE"); } break; case "CREATE_PERP_LINE_TO_LINE"://Layer to Search For|Search distance to look for a line|TargetLayer|TargetLayerTemplate try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "CREATE_PERP_LINE"); if (inFeature != null & valData != null) { sourceLayerName = ""; string targetLayerName = ""; IFeatureLayer targetLayer = null; string targetLayerTemp = ""; // Parse arguments args = valData.Split('|'); if (args.GetLength(0) == 4) { sourceLayerNames = args[0].ToString().Split(','); Double.TryParse(args[1], out searchDistance); targetLayerName = args[2]; targetLayerTemp = args[3]; } else if (args.GetLength(0) == 3) { sourceLayerNames = args[0].ToString().Split(','); Double.TryParse(args[1], out searchDistance); targetLayerName = args[2]; } 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().Trim(); if (sourceLayerName != "") sourceLayerName = args[i].ToString().Trim(); 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; } IPolyline pTempLine = new PolylineClass(); pTempLine = Globals.CreateAngledLineFromLocationToLine((IPoint)inFeature.Shape, sourceLayer, boolLayerOrFC, true, false, searchDistance); if (pTempLine != null) { if (pTempLine.IsEmpty == 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(); } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain34")); NewFeatureList.Add(pFeat); } else { AAState.WriteLine("A line was not found in the search distance: " + "CREATE_PERP_LINE"); } } else { AAState.WriteLine("A line was not found in the search distance: " + "CREATE_PERP_LINE"); } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CREATE_PERP_LINE: " + ex.ToString()); } 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, 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.ToString().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.ToString().ToString()); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14j") + ex.ToString().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.ToString().ToString()); } } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "AUTONUMBER: " + ex.ToString()); } 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 { IField pFldTemp = null; 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().Trim(); string targetLayerName = ""; string sourceIDFieldName = args[2].ToString().Trim(); string targetIDFieldName = args[3].ToString().Trim(); 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() != "") { List pFoundFeat = new List(); 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); AAState.WriteLine(" Search complete"); if (sourceLayer != null) { AAState.WriteLine(" layer " + targetLayerName + " " + sourceLayer.Name.ToString()); 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 || sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeGUID || sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeGlobalID) { pQFilt.WhereClause = "" + sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString().Replace("'", "''") + "'"; } else { pQFilt.WhereClause = sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx); } AAState.WriteLine(" whereclause: " + pQFilt.WhereClause); IFeatureCursor pCurs; IFeatureSelection pFeatSel; pFeatSel = (IFeatureSelection)sourceLayer; if (pFeatSel.SelectionSet.Count > 0) { AAState.WriteLine(" pFeatSel.SelectionSet: " + pFeatSel.SelectionSet.Count); ICursor pCurstemp; pFeatSel.SelectionSet.Search(pQFilt, true, out pCurstemp); pCurs = (IFeatureCursor)pCurstemp; } else { AAState.WriteLine(" No selection set"); pCurs = sourceLayer.FeatureClass.Search(pQFilt, true); } IFeature pRow; while ((pRow = pCurs.NextFeature()) != null) { Globals.OptionsToPresent pOp = new Globals.OptionsToPresent(); object val = pRow.get_Value(fldValToCopyIdx); AAState.WriteLine(" Field index: " + fldValToCopyIdx + " Field value: " + val.ToString()); pFldTemp = sourceLayer.FeatureClass.Fields.get_Field(fldValToCopyIdx); AAState.WriteLine(" Field index: " + fldValToCopyIdx + " Field name: " + pFldTemp.Name); string displayVal = Globals.GetDomainDisplay(val, pRow as IObject, pFldTemp); AAState.WriteLine(" Field display value: " + displayVal); pOp.Display = displayVal; pOp.Value = pRow.get_Value(fldValToCopyIdx); AAState.WriteLine(" Display: " + pOp.Display + " value: " + pOp.Value); pOp.OID = pRow.OID; pOp.LayerName = targetLayerName; pFoundFeat.Add(pOp); 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 { AAState.WriteLine(" No layer found"); IStandaloneTable pSTable = Globals.FindStandAloneTable(AAState._editor.Map, targetLayerName); AAState.WriteLine(" Search complete"); if (pSTable != null) { AAState.WriteLine(" table " + targetLayerName + " " + pSTable.Name.ToString()); if (pSTable.Table != null) { AAState.WriteLine(" " + targetLayerName + " " + pSTable.Table.OIDFieldName.ToString()); int fldValToCopyIdx = Globals.GetFieldIndex(pSTable.Table.Fields, targetFieldName); AAState.WriteLine(" fldValToCopyIdx = " + fldValToCopyIdx); int fldIDTargetIdx = Globals.GetFieldIndex(pSTable.Table.Fields, targetIDFieldName); AAState.WriteLine(" fldIDTargetIdx = " + fldIDTargetIdx); if (fldIDTargetIdx > -1 && fldValToCopyIdx > -1) { IQueryFilter pQFilt = Globals.createQueryFilter(); if (pSTable.Table.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeString) { pQFilt.WhereClause = "" + pSTable.Table.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString().Replace("'", "''") + "'"; } else { pQFilt.WhereClause = pSTable.Table.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx); } AAState.WriteLine(" where clause = " + pQFilt.WhereClause); ICursor pCurs; ITableSelection pTabSel = null; pTabSel = (ITableSelection)pSTable; if (pTabSel.SelectionSet.Count > 0) { AAState.WriteLine(" table selection count" + pTabSel.SelectionSet.Count); pTabSel.SelectionSet.Search(pQFilt, true, out pCurs); } else { AAState.WriteLine(" no selection count"); pCurs = pSTable.Table.Search(pQFilt, true); } IRow pRow; pRow = pCurs.NextRow(); if (pRow == null) { AAState.WriteLine(" Row not found"); } else { AAState.WriteLine(" Row found"); } while (pRow != null) { Globals.OptionsToPresent pOp = new Globals.OptionsToPresent(); try { object val = pRow.get_Value(fldValToCopyIdx); AAState.WriteLine(" Field index: " + fldValToCopyIdx + " Field value: " + val.ToString()); pFldTemp = pSTable.Table.Fields.get_Field(fldValToCopyIdx); AAState.WriteLine(" Field index: " + fldValToCopyIdx + " Field name: " + pFldTemp.Name); string displayVal = Globals.GetDomainDisplay(val, pRow as IObject, pFldTemp); AAState.WriteLine(" Field display value: " + displayVal); pOp.Display = displayVal; pOp.Value = pRow.get_Value(fldValToCopyIdx); AAState.WriteLine(" Display: " + pOp.Display + " value: " + pOp.Value); pOp.OID = pRow.OID; pOp.LayerName = targetLayerName; pFoundFeat.Add(pOp); } catch (Exception ex) { AAState.WriteLine(" Error trying to get the domain code, values: " + ex.ToString()); } pRow = pCurs.NextRow(); } pRow = null; 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") + targetLayerName); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ax") + targetLayerName); } pSTable = null; } } } if (pFoundFeat.Count == 0) { } else if (pFoundFeat.Count == 1) { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cf") + " " + pFoundFeat[0].Value); try { AAState.WriteLine(" trying to set value " + pFoundFeat[0].Value); inObject.set_Value(intFldIdxs[0], pFoundFeat[0].Value); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + pFoundFeat[0].Value); } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + pFoundFeat[0].Value + " to field: " + strFldNames[0]); } } else { Globals.OptionsToPresent strRetVal = Globals.showOptionsForm(pFoundFeat, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain149") + sourceFieldName, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain149") + sourceFieldName, ComboBoxStyle.DropDownList); if (strRetVal == null) { AAState.WriteLine(" selected value from prompt was null "); } else if (strRetVal.OID == -1) { AAState.WriteLine(" Error in prompt form: " + strRetVal.Display); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cf")); try { AAState.WriteLine(" trying to set value " + strRetVal.Value.ToString()); inObject.set_Value(intFldIdxs[0], strRetVal.Value); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + strRetVal.Value.ToString()); } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + strRetVal.Value + " to field: " + strFldNames[0]); } } } } } } 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.ToString()); } 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().Trim(); string targetLayerName = ""; string sourceIDFieldName = args[2].ToString().Trim(); string targetIDFieldName = args[3].ToString().Trim(); 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().Replace("'", "''") + "'"; } else { pQFilt.WhereClause = sourceLayer.FeatureClass.Fields.get_Field(fldIDTargetIdx).Name + " = " + inObject.get_Value(fldIDSourecIdx); } IFeatureCursor pCurs; pCurs = sourceLayer.FeatureClass.Search(pQFilt, false); 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(); //ISQLSyntax sqlSyntax = (ISQLSyntax)(pTable); //string specChar = sqlSyntax.GetSpecialCharacter(esriSQLSpecialCharacters.esriSQL_WildcardManyMatch); if (pTable.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeString || pTable.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeGUID || pTable.Fields.get_Field(fldIDTargetIdx).Type == esriFieldType.esriFieldTypeGlobalID) { pQFilt.WhereClause = "" + pTable.Fields.get_Field(fldIDTargetIdx).Name + "" + " = '" + inObject.get_Value(fldIDSourecIdx).ToString().Replace("'", "''") + "'"; } 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.ToString()); } 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 if (args.GetLength(0) >= 1) { sourceLayerNames = args[0].ToString().Split(','); offsetVal = 0; searchDistance = 1; } 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().Trim(); if (sourceLayerName != "") sourceLayerName = args[i].ToString().Trim(); 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, AAState._editor.Map.SpatialReference); 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.ToString()); } 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().Trim(); inputFieldName = args[2].ToString().Trim(); 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().Trim(); 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().Replace("'", "''") + "'"; } 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.ToString()); } 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 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 pVals = new List(); 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 pVals = new List(); 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 pVals = new List(); 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 pVals = new List(); 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 pVals = new List(); 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 pVals = new List(); 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.ToString()); } 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]).ToString().Replace("'", "''") + "'"; } 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(); } 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.ToString()); } 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; IField pTarField = 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" && mode != "ON_MANUAL")) { 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(), String.Format(A4LGSharedFunctions.Localizer.GetString("templatePrompt"), pTargetFL.Name)); } else { pEditTemp = null; } break; case 4: if (args[2].Trim() != "") { pEditTemp = Globals.PromptAndGetEditTemplateGraphic(pTargetFL, args[2].Trim(), String.Format(A4LGSharedFunctions.Localizer.GetString("templatePrompt"), pTargetFL.Name)); } else { pEditTemp = null; } sourceAction = args[3].ToUpper().Trim(); break; case 5: if (args[2].Trim() != "") { pEditTemp = Globals.PromptAndGetEditTemplateGraphic(pTargetFL, args[2].Trim(), String.Format(A4LGSharedFunctions.Localizer.GetString("templatePrompt"), pTargetFL.Name)); } 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 targFilds = new List(); 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 (intTarFldIdx == -1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bc")); } else { //Add target field to field list so it is not overwritten by matching source field targFilds.Add(strTarFldName.ToUpper()); //If the source field was found, use the value from that field, else use the valve as is if (intSrcFldIdx != -1) { 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); } } else { try { pTarField = pTargetFL.FeatureClass.Fields.get_Field(intTarFldIdx); if (pTarField.Type == esriFieldType.esriFieldTypeDouble || pTarField.Type == esriFieldType.esriFieldTypeSingle) { double dblToSet; Double.TryParse(strSrcFldName, out dblToSet); pNewFeat.set_Value(intTarFldIdx, dblToSet); } else if (pTarField.Type == esriFieldType.esriFieldTypeInteger || pTarField.Type == esriFieldType.esriFieldTypeSmallInteger) { int intToSet; Int32.TryParse(strSrcFldName, out intToSet); pNewFeat.set_Value(intTarFldIdx, intToSet); } else { pNewFeat.set_Value(intTarFldIdx, strSrcFldName); } } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "COPY_FEATURE: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14bb") + strFlpPair); } } } } } IFields pTarFields = pTargetFL.FeatureClass.Fields; 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(); } 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.ToString()); } 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].ToString().Trim())) { if (connectionCnt == Convert.ToInt32(fldCon[0].ToString().Trim())) { 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].ToString().Trim())) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52")); validFeat = true; break; } } if (fldCon.Length > 2) { if (connectionCnt >= Convert.ToInt32(fldCon[1].ToString().Trim()) && connectionCnt <= Convert.ToInt32(fldCon[2].ToString().Trim())) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52")); validFeat = true; break; } } } else if (inFeature.get_Value(intFldIdxs[0]).ToString() == fldCon[0].ToString().Trim()) { if (fldCon.Length == 2) { if (connectionCnt == Convert.ToInt32(fldCon[1].ToString().Trim())) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain52")); validFeat = true; break; } } if (fldCon.Length > 2) { if (connectionCnt >= Convert.ToInt32(fldCon[1].ToString().Trim()) && connectionCnt <= Convert.ToInt32(fldCon[2].ToString().Trim())) { 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.ToString()); } 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 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.ToString()); } 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._editor.Map.SpatialReference); 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, false, out cCurs); fCursor = cCurs as IFeatureCursor; } else { fCursor = intersectLayer.Search(sFilter, false); } } else { fCursor = intersectLayer.FeatureClass.Search(sFilter, false); } 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, true); if (featset != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain73")); if (featset.Count > 0) { if (NewFeatureList == null) { NewFeatureList = new List(); } 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, true); 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(); } 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.ToString()); } 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 { bool resetToDefault = false; 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 if (args.Length == 5) { sourceLayerName = args[0].ToString().Trim(); sourceFieldNames = args[1].ToString().Split(','); destFieldNames = args[2].ToString().Split(','); Double.TryParse(args[3], out searchDistance); resetToDefault = args[4].ToString().ToUpper() == "TRUE" ? true : false; } 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, (ISpatialReference)AAState._editor.Map.SpatialReference); } else { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false, AAState._editor.Map.SpatialReference); } 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 if (resetToDefault) { 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.ToString()); } 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.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "MINIMUM_LENGTH"); } break; } case "LINK_TABLE_ASSET": try { intersectLayerName = ""; intersectTable = null; intersectLayer = null; List intersectLayerFieldNameList = new List(); List intersectFieldPosList = new List(); 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().Trim(); break; case 2: // Feature Layer| Field to copy intersectLayerName = args[0].ToString().Trim(); intersectLayerFieldNameList = new List(args[1].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); break; case 3: // Feature Layer| Field to copy | for future intersectLayerName = args[0].ToString().Trim(); intersectLayerFieldNameList = new List(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.ToString()); } 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 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(), null, 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.ToString()); } } 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.ToString()); } 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 = 1; reverseGeocodingProperties.SearchDistanceUnits = esriUnits.esriMiles; 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.ToString()); } 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 { int wkid = 4326; string locatorURLOrg = _agsOnlineLocators; 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]; //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]; locatorURLOrg = locatorURL; 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 { locatorURLOrg = locatorURL.Replace("/" + 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 { // locatorURLOrg = _agsOnlineLocators; 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(locatorURLOrg) 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("
")); resp = resp.Substring(resp.IndexOf("") + 4); try { wkid = Convert.ToInt32(resp.Split(' ')[0]); } catch { } try { resp = Regex.Replace(resp, @"\t|\n|\r", ""); resp = resp.Replace(" ", "|"); string[] respArr = resp.Split('|'); wkid = Convert.ToInt32(respArr[0]); } catch { } } } catch (Exception ex) { AAState.WriteLine(ex.ToString()); 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.ToLower() == "Match_Addr".ToLower()) { val = doc.DocumentElement.FirstChild.ChildNodes[h].InnerText.Trim(); break; } } if (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 (Exception ex) { AAState.WriteLine(ex.ToString()); } 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.ToString()); } 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 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.ToString()); } 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" || mode == "ON_MANUAL") { 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.ToString()); } 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.ToString()); } 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.ToString()); } 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.ToString()); } 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.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].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.ToString()); } 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, 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.ToString()); } } else { AAState.WriteLine(" " + valData + " is not found"); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "Field: " + ex.ToString()); } 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: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("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().Trim(); } else if (args.Length == 4) { 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().Trim(); AAState.rCalc.OnlyLayerName = args[3].ToString().Trim(); } 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.ToString()); } 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"); bool geoDesic = false; if (inFeature != null) { if (!String.IsNullOrEmpty(valData)) { args = valData.Split('|'); if (args.Length >= 1) { if (args[0].ToUpper() == "TRUE") geoDesic = true; if (args[0].ToUpper() == "GEODESIC") geoDesic = true; } } if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryLine || inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { if (geoDesic && (inFeature.Class as IGeoDataset).SpatialReference is IProjectedCoordinateSystem) { IPolycurveGeodetic pCurDes = (IPolycurveGeodetic)inFeature.Shape; if (pCurDes != null) { IProjectedCoordinateSystem pProjSys = (IProjectedCoordinateSystem)(inFeature.Class as IGeoDataset).SpatialReference; inObject.set_Value(intFldIdxs[0], pCurDes.get_LengthGeodetic(esriGeodeticType.esriGeodeticTypeGeodesic, pProjSys.CoordinateUnit)); pProjSys = null; } } else { curve = (ICurve)inFeature.Shape; if (curve != null) { inObject.set_Value(intFldIdxs[0], curve.Length); } } } else if (inFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { if (geoDesic && (inFeature.Class as IGeoDataset).SpatialReference is IProjectedCoordinateSystem) { IAreaGeodetic pArDes = (IAreaGeodetic)inFeature.Shape; if (pArDes != null) { IProjectedCoordinateSystem pProjSys = (IProjectedCoordinateSystem)(inFeature.Class as IGeoDataset).SpatialReference; inObject.set_Value(intFldIdxs[0], pArDes.get_AreaGeodetic(esriGeodeticType.esriGeodeticTypeGeodesic, pProjSys.CoordinateUnit)); pProjSys = null; } pArDes = null; } else { IArea pAr = (IArea)inFeature.Shape; if (pAr != null) { inObject.set_Value(intFldIdxs[0], pAr.Area); } pAr = null; } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "LENGTH: " + ex.ToString()); } 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.ToString()); } 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.ToString()); } 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.ToString()); } 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"; string delim = ","; string sortOrder = "none"; switch (args.GetLength(0)) { case 1: sourceFieldName = args[0].ToString().Trim(); break; case 2: sourceFieldName = args[0].ToString().Trim(); statType = args[1].ToString().Trim(); break; case 3: sourceFieldName = args[0].ToString().Trim(); statType = args[1].ToString().Trim(); delim = args[2].ToString().Trim(); break; case 4: sourceFieldName = args[0].ToString().Trim(); statType = args[1].ToString().Trim(); delim = args[2].ToString().Trim(); sortOrder = args[3].ToString().Trim(); break; default: break; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TO_EDGE_STATS"); int AverageCount = 0; double result = -999999.1; string textRes = ""; List concatList = new List(); 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) { if (statType.ToUpper() == "CONCAT") { if (concatList.Contains(valToTest.ToString()) == false) { concatList.Add(valToTest.ToString()); } } else { 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": //concatFunc(valToTest.ToString(), ref textRes); if (concatList.Contains(valToTest.ToString()) == false) { concatList.Add(valToTest.ToString()); } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { switch (statType.ToUpper()) { case "CONCAT": //concatFunc(test.ToString(), ref textRes); if (concatList.Contains(test.ToString()) == false) { concatList.Add(test.ToString()); } 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 (statType.ToUpper() == "CONCAT") { if (sortOrder.ToUpper() == "ASC") { concatList.Sort((a, b) => a.CompareTo(b)); } else if (sortOrder.ToUpper() == "DESC") { concatList.Sort((a, b) => -1 * a.CompareTo(b)); } textRes = string.Join(delim, concatList.ToArray()); } 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.ToString()); } } 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.ToString()); } 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"; string delim = ","; string sortOrder = "none"; switch (args.GetLength(0)) { case 1: sourceFieldName = args[0].ToString().Trim(); break; case 2: sourceFieldName = args[0].ToString().Trim(); statType = args[1].ToString().Trim(); break; case 3: sourceFieldName = args[0].ToString().Trim(); statType = args[1].ToString().Trim(); delim = args[2].ToString().Trim(); break; case 4: sourceFieldName = args[0].ToString().Trim(); statType = args[1].ToString().Trim(); delim = args[2].ToString().Trim(); sortOrder = args[3].ToString().Trim(); break; default: break; } AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FROM_EDGE_STATS"); List concatList = new List(); 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) { if (statType.ToUpper() == "CONCAT") { if (concatList.Contains(valToTest.ToString()) == false) { concatList.Add(valToTest.ToString()); } } else { 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": //concatFunc(valToTest.ToString(), ref textRes); if (concatList.Contains(valToTest.ToString()) == false) { concatList.Add(valToTest.ToString()); } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { switch (statType.ToUpper()) { case "CONCAT": //concatFunc(test.ToString(), ref textRes); if (concatList.Contains(test.ToString()) == false) { concatList.Add(test.ToString()); } 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 (statType.ToUpper() == "CONCAT") { if (sortOrder.ToUpper() == "ASC") { concatList.Sort((a, b) => a.CompareTo(b)); } else if (sortOrder.ToUpper() == "DESC") { concatList.Sort((a, b) => -1 * a.CompareTo(b)); } textRes = string.Join(delim, concatList.ToArray()); } 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.ToString()); } } 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") + "FROM_EDGE_STATS: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "FROM_EDGE_STATS"); } break; case "EDGE_STATS": try { if (valData == null) break; args = valData.Split('|'); string statType = "MAX"; string delim = ","; string sortOrder = "none"; switch (args.GetLength(0)) { case 1: sourceFieldName = args[0].ToString().Trim(); break; case 2: sourceFieldName = args[0].ToString().Trim(); statType = args[1].ToString().Trim(); break; case 3: sourceFieldName = args[0].ToString().Trim(); statType = args[1].ToString().Trim(); delim = args[2].ToString().Trim(); break; case 4: sourceFieldName = args[0].ToString().Trim(); statType = args[1].ToString().Trim(); delim = args[2].ToString().Trim(); sortOrder = args[3].ToString().Trim(); break; default: break; } List concatList = new List(); 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) { if (statType.ToUpper() == "CONCAT") { if (concatList.Contains(valToTest.ToString()) == false) { concatList.Add(valToTest.ToString()); } } else { 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": //concatFunc(valToTest.ToString(), ref textRes); if (concatList.Contains(valToTest.ToString()) == false) { concatList.Add(valToTest.ToString()); } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { switch (statType.ToUpper()) { case "CONCAT": //concatFunc(test.ToString(), ref textRes); if (concatList.Contains(test.ToString()) == false) { concatList.Add(test.ToString()); } 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 (statType.ToUpper() == "CONCAT") { if (sortOrder.ToUpper() == "ASC") { concatList.Sort((a, b) => a.CompareTo(b)); } else if (sortOrder.ToUpper() == "DESC") { concatList.Sort((a, b) => -1 * a.CompareTo(b)); } textRes = string.Join(delim, concatList.ToArray()); } 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.ToString()); } } 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") + "EDGE_STATS: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "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().Trim(); 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_MULTI_FIELD_INTERSECT: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TO_EDGE_MULTI_FIELD_INTERSECT"); } 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().Trim(); 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") + "FROM_EDGE_MULTI_FIELD_INTERSECT: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "FROM_EDGE_MULTI_FIELD_INTERSECT"); } break; case "FROM_JUNCTION_FIELD": try { bool includeFCName = false; 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; case 5: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); includeFCName = args[4].ToString().ToUpper() == "TRUE" ? true : false; break; default: break; } iEdgeFeat = (IEdgeFeature)netFeat; iJuncFeat = iEdgeFeat.FromJunctionFeature; string strClsName; if (netRestrictFC != "") { 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.ToUpper() == "(NAME)") { strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class)); inObject.set_Value(intFldIdxs[0], strClsName); } else { 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.ToString()); } 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 { bool includeFCName = false; 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; case 5: // sequenceColumnName|sequenceFixedWidth|formatString netField = args[0].ToString().Trim(); netRestrictFC = args[1].ToString().Trim(); netRestrictField = args[2].ToString().Trim(); netRestrictValue = args[3].ToString().Trim(); includeFCName = args[4].ToString().ToUpper() == "TRUE" ? true : false; break; default: break; } iEdgeFeat = (IEdgeFeature)netFeat; iJuncFeat = iEdgeFeat.ToJunctionFeature; string strClsName; if (netRestrictFC != "") { 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.ToUpper() == "(NAME)") { strClsName = Globals.getClassName(((IDataset)((IFeature)iJuncFeat).Class)); inObject.set_Value(intFldIdxs[0], strClsName); } else { 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.ToString()); } 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(); } ((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.ToString()); } 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(); } ((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.ToString()); } 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(); } 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.ToString()); } 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(); } 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.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "UPDATE_TO_EDGE_FIELD"); } break; case "TRIGGER_AAEVENT_INTERSECTING_FEATURE"://Intersected Feature|FieldIntersectingFeatureToChange|FromFieldinModifiedFeature { try { IFeatureCursor fLocalCursor = null; IFeature sourceFeatureLocal = null; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_AAEVENT_INTERSECTING_FEATURE"); if (!String.IsNullOrEmpty(valData)) { args = valData.Split('|'); if (args.Length < 0) { 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]) && (mode != "ON_CREATE" || mode != "ON_MANUAL")) { cont = true; } else { cont = false; } inChanges = null; } if (cont) { sourceLayerName = ""; sourceFieldName = ""; sourceField = -1; found = false; AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14bs")); switch (args.GetLength(0)) { case 1: sourceLayerNames = args[0].ToString().Split(','); break; case 2: sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString().Trim(); break; default: break; } 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, AAState._editor.Map.SpatialReference); 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(); } NewFeatureList.Add(((IFeature)sourceFeatureLocal)); } else if (sourceFieldName == "CHANGEGEO") { if (ChangeFeatureGeoList == null) { ChangeFeatureGeoList = new List(); } ChangeFeatureGeoList.Add(((IFeature)sourceFeatureLocal)); } else { if (ChangeFeatureList == null) { ChangeFeatureList = new List(); } ChangeFeatureList.Add(((IFeature)sourceFeatureLocal)); } } else if (sourceFeatureLocal.Class == inFeature.Class && sourceFeatureLocal.OID != inFeature.OID) { if (sourceFieldName == "CREATE") { if (NewFeatureList == null) { NewFeatureList = new List(); } NewFeatureList.Add(((IFeature)sourceFeatureLocal)); } else if (sourceFieldName == "CHANGEGEO") { if (ChangeFeatureGeoList == null) { ChangeFeatureGeoList = new List(); } ChangeFeatureGeoList.Add(((IFeature)sourceFeatureLocal)); } else { if (ChangeFeatureList == null) { ChangeFeatureList = new List(); } 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_AAEVENT_INTERSECTING_FEATURE" + Environment.NewLine + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_AAEVENT_INTERSECTING_FEATURE"); } break; } case "TRIGGER_AAEVENT_TO_JUNCTION": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_AAEVENT_TO_JUNCTION"); IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true && (mode != "ON_CREATE" || mode != "ON_MANUAL")) { 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 = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].ToString().Trim(); break; default: break; } iEdgeFeat = (IEdgeFeature)netFeat; iJuncFeat = iEdgeFeat.ToJunctionFeature; // verify that field (in junction) to copy exists if (netField == "CREATE") { if (NewFeatureList == null) { NewFeatureList = new List(); } NewFeatureList.Add(((IFeature)iJuncFeat)); } else if (netField == "CHANGEGEO") { if (ChangeFeatureGeoList == null) { ChangeFeatureGeoList = new List(); } ChangeFeatureGeoList.Add(((IFeature)iJuncFeat)); } else { if (ChangeFeatureList == null) { ChangeFeatureList = new List(); } 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_AAEVENT_TO_JUNCTION: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_AAEVENT_TO_JUNCTION"); } break; case "TRIGGER_AAEVENT_FROM_JUNCTION": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_AAEVENT_FROM_JUNCTION"); IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true && (mode != "ON_CREATE" || mode != "ON_MANUAL")) { 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 = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].ToString().Trim(); break; default: break; } iEdgeFeat = (IEdgeFeature)netFeat; iJuncFeat = iEdgeFeat.FromJunctionFeature; if (netField == "CREATE") { if (NewFeatureList == null) { NewFeatureList = new List(); } NewFeatureList.Add(((IFeature)iJuncFeat)); } else if (netField == "CHANGEGEO") { if (ChangeFeatureGeoList == null) { ChangeFeatureGeoList = new List(); } ChangeFeatureGeoList.Add(((IFeature)iJuncFeat)); } else { if (ChangeFeatureList == null) { ChangeFeatureList = new List(); } 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_AAEVENT_FROM_JUNCTION: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_AAEVENT_FROM_JUNCTION"); } break; case "TRIGGER_AAEVENT_FROM_EDGE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_AAEVENT_FROM_EDGE"); if (inFeature != null) { IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true && (mode != "ON_CREATE" || mode != "ON_MANUAL")) { 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 = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].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 { iJuncFeat = iEdgeFeat.ToJunctionFeature; if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape)) { if (netField == "CREATE") { if (NewFeatureList == null) { NewFeatureList = new List(); } NewFeatureList.Add(((IFeature)iEdgeFeat)); } else if (netField == "CHANGEGEO") { if (ChangeFeatureGeoList == null) { ChangeFeatureGeoList = new List(); } ChangeFeatureGeoList.Add(((IFeature)iEdgeFeat)); } else { if (ChangeFeatureList == null) { ChangeFeatureList = new List(); } 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_AAEVENT_FROM_EDGE: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_AAEVENT_FROM_EDGE"); } break; case "TRIGGER_AAEVENT_TO_EDGE": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "TRIGGER_AAEVENT_TO_EDGE"); if (inFeature != null) { IRowChanges pRowCh = null; pRowCh = inObject as IRowChanges; if (pRowCh.get_ValueChanged(intFldIdxs[0]) == true && (mode != "ON_CREATE" || mode != "ON_MANUAL")) { 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 = ""; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only netField = args[0].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 { iJuncFeat = (IJunctionFeature)iEdgeFeat.FromJunctionFeature; if (((IFeature)iJuncFeat).Shape.Equals(inFeature.Shape)) { if (netField == "CREATE") { if (NewFeatureList == null) { NewFeatureList = new List(); } NewFeatureList.Add(((IFeature)iEdgeFeat)); } else if (netField == "CHANGEGEO") { if (ChangeFeatureGeoList == null) { ChangeFeatureGeoList = new List(); } ChangeFeatureGeoList.Add(((IFeature)iEdgeFeat)); } else { if (ChangeFeatureList == null) { ChangeFeatureList = new List(); } 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_AAEVENT_TO_EDGE: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "TRIGGER_AAEVENT_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; sequenceFixedWidth = ""; sequencePadding = 0; formatString = ""; bool onlyWhenNull = false; // Parse arguments if (valData == null) break; args = valData.Split('|'); switch (args.GetLength(0)) { case 1: // sequenceColumnName only sequenceColumnName = args[0].ToString().Trim(); break; case 2: // sequenceColumnName|sequenceFixedWidth sequenceColumnName = args[0].ToString().Trim(); sequenceFixedWidth = args[1].ToString().Trim(); break; case 3: // sequenceColumnName|sequenceFixedWidth|formatString sequenceColumnName = args[0].ToString().Trim(); sequenceFixedWidth = args[1].ToString().Trim(); formatString = args[2].ToString().Trim(); break; case 4: // sequenceColumnName|sequenceFixedWidth|formatString sequenceColumnName = args[0].ToString().Trim(); sequenceFixedWidth = args[1].ToString().Trim(); formatString = args[2].ToString().Trim(); onlyWhenNull = args[3].ToString().ToUpper() == "TRUE" ? true : false; break; default: break; } object val = inObject.get_Value(intFldIdxs[0]); bool proceed = true; if (onlyWhenNull && (inObject.get_Value(intFldIdxs[0]) != null && inObject.get_Value(intFldIdxs[0]) != DBNull.Value && inObject.get_Value(intFldIdxs[0]).ToString().Trim() != "") ) { proceed = false; } if (proceed) { //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 = AAState._seqNameField + " = '" + sequenceColumnName + "'"; sequenceColumnNum = Globals.GetFieldIndex(AAState._gentab.Fields, AAState._seqCounterField); sequenceIntColumnNum = Globals.GetFieldIndex(AAState._gentab.Fields, AAState._seqIntervalField); long sequenceValue = unversionedEdit(qFilter, sequenceColumnNum, sequenceIntColumnNum, sequenceColumnName); Debug.WriteLine(sequenceValue.ToString()); if (sequenceValue == -1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "GENERATE_ID: " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ao")); MessageBox.Show("Unable to retreive a valid sequences from the generate ID table, review the log for more information."); } 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.ToString()); } 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; sequenceFixedWidth = ""; sequencePadding = 0; //genIdAreaFieldName = ""; intersectLayerName = ""; intersectLayerFieldName = ""; formatString = ""; intersectFieldPos = -1; bool onlyWhenNull = false; // 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().Trim(); intersectLayerFieldName = args[1].ToString().Trim(); // genIdAreaFieldName = args[2].ToString().Trim(); sequenceColumnName = args[2].ToString().Trim(); break; case 4: // columnName|sequenceFixedWidth //sequenceFixedWidth formats the sequence with leading zeros to create specified width intersectLayerName = args[0].ToString().Trim(); intersectLayerFieldName = args[1].ToString().Trim(); //genIdAreaFieldName = args[2].ToString().Trim(); sequenceColumnName = args[2].ToString().Trim(); sequenceFixedWidth = Convert.ToString(0); formatString = args[3].ToString().Trim(); break; case 5: // columnName|sequenceFixedWidth|formatString //formatString must contain [seq] and [id] and may contain [area] plus any desired text intersectLayerName = args[0].ToString().Trim(); intersectLayerFieldName = args[1].ToString().Trim(); //genIdAreaFieldName = args[2].ToString().Trim(); sequenceColumnName = args[2].ToString().Trim(); sequenceFixedWidth = args[3].ToString().Trim(); formatString = args[4].ToString().Trim(); break; case 6: // columnName|sequenceFixedWidth|formatString|onlyWhenNull //formatString must contain [seq] and [id] and may contain [area] plus any desired text intersectLayerName = args[0].ToString().Trim(); intersectLayerFieldName = args[1].ToString().Trim(); //genIdAreaFieldName = args[2].ToString().Trim(); sequenceColumnName = args[2].ToString().Trim(); sequenceFixedWidth = args[3].ToString().Trim(); formatString = args[4].ToString().Trim(); onlyWhenNull = args[5].ToString().ToUpper() == "TRUE" ? true : false; break; default: break; } object val = inObject.get_Value(intFldIdxs[0]); bool proceed = true; if (onlyWhenNull && (inObject.get_Value(intFldIdxs[0]) != null && inObject.get_Value(intFldIdxs[0]) != DBNull.Value && inObject.get_Value(intFldIdxs[0]).ToString().Trim() != "") ) { proceed = false; } if (proceed) { 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, AAState._editor.Map.SpatialReference); 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 = AAState._seqNameField + " = '" + sequenceColumnName + "'"; //cCurs = AAState._gentab.Update(qFilter, false); sequenceColumnNum = Globals.GetFieldIndex(AAState._gentab.Fields, AAState._seqCounterField); sequenceIntColumnNum = Globals.GetFieldIndex(AAState._gentab.Fields, AAState._seqIntervalField); long sequenceValue = unversionedEdit(qFilter, sequenceColumnNum, sequenceIntColumnNum, sequenceColumnName); if (sequenceValue == -1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14au")); MessageBox.Show("Unable to retreive a valid sequences from the generate ID table, review the log for more information."); } 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.ToString()); } 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) { IRowChanges inChanges = inObject as IRowChanges; int intTargetFld = -1; if (intFldIdxs.Count == 0) { } else { intTargetFld = intFldIdxs[0]; } newValue = valData; for (int i = 0; i <= inObject.Fields.FieldCount * 2 + 1; i++) { string strTmpFldName; int intTmpIdx; if (i < inObject.Fields.FieldCount) { testField = inObject.Fields.get_Field(i); strTmpFldName = testField.Name; intTmpIdx = i; } else if (i < inObject.Fields.FieldCount * 2) { intTmpIdx = i - inObject.Fields.FieldCount; testField = inObject.Fields.get_Field(intTmpIdx); strTmpFldName = "~" + testField.Name; } else { testField = inObject.Fields.get_Field(intFldIdxs[0]); strTmpFldName = "#"; intTmpIdx = intFldIdxs[0]; } //if (i == inObject.Fields.FieldCount) //{ // testField = inObject.Fields.get_Field(intFldIdxs[0]); // strTmpFldName = "#"; // intTmpIdx = intFldIdxs[0]; //} //else if (i == inObject.Fields.FieldCount +1) //{ // 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; //newValue = newValue.Replace("[" + strTmpFldName + "]", "[_REPLACE_VAL_]"); string tmpStr1 = newValue.Substring(0, indFld + 1); string tmpStr2 = newValue.Substring(indFld + fldLen + 1); newValue = tmpStr1 + "_REPLACE_VAL_" + tmpStr2; object field_value = inObject.get_Value(intTmpIdx); if (strTmpFldName.IndexOf("~") >= 0 && mode != "ON_CREATE") { if (inChanges.get_ValueChanged(intTmpIdx)) { field_value = inChanges.get_OriginalValue(intTmpIdx); if (field_value == null || field_value == DBNull.Value) { field_value = "\"\""; } } } switch (testField.Type) { case esriFieldType.esriFieldTypeString: if (field_value == null || field_value.ToString() == "" || field_value == DBNull.Value) { 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 (field_value == null) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else if (field_value == DBNull.Value) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else if (field_value.ToString() == "") { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + field_value.ToString() + "\""); } else { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + field_value.ToString() + "\""); } } else { if (newValue.Contains("IsNull")) { newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False"); } else if (newValue.Contains("isNull")) { newValue = newValue.Replace("isNull([" + "_REPLACE_VAL_" + "])", "False"); } else if (newValue.Contains("ISNULL")) { newValue = newValue.Replace("ISNULL([" + "_REPLACE_VAL_" + "])", "False"); } } newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + field_value.ToString() + "\""); break; case esriFieldType.esriFieldTypeDate: if (field_value == null || field_value.ToString() == "" || field_value == 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 (field_value == null) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + field_value.ToString() + "\""); } else if (field_value == DBNull.Value) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\"");//"\"" + field_value.ToString() + "\""); } else if (field_value.ToString() == "") { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + field_value.ToString() + "\""); } else { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "CDATE(\"" + field_value.ToString() + "\")"); } } else { if (newValue.Contains("IsNull")) { newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False"); } } newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "CDATE(\"" + field_value.ToString() + "\")"); break; case esriFieldType.esriFieldTypeSingle: case esriFieldType.esriFieldTypeDouble: if (field_value == null || field_value.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 (field_value == null) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else if (field_value == DBNull.Value) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else if (field_value.ToString() == "") { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "" + field_value.ToString() + ""); } } else { if (newValue.Contains("IsNull")) { newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False"); } } double val; Double.TryParse(field_value.ToString(), out val); int intDigits = 2; if (val.ToString().IndexOf(".") >= 0) { intDigits = val.ToString().Split('.')[1].Length; } else if (val.ToString().IndexOf(",") >= 0) { intDigits = val.ToString().Split(',')[1].Length; } else if (val.ToString().IndexOf("'") >= 0) { intDigits = val.ToString().Split('\'')[1].Length; } else { intDigits = 2; } nfi.NumberDecimalDigits = intDigits; newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", val.ToString("N", nfi)); break; default: if (field_value == null || field_value.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 (field_value == null) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else if (field_value == DBNull.Value) { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else if (field_value.ToString() == "") { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "\"" + "\""); } else { newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", "" + field_value.ToString() + ""); } } else { if (newValue.Contains("IsNull")) { newValue = newValue.Replace("IsNull([" + "_REPLACE_VAL_" + "])", "False"); } } newValue = newValue.Replace("[" + "_REPLACE_VAL_" + "]", field_value.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() == "".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.ToString()); } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "EXPRESSION: " + ex.ToString()); } 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.ToString()); } 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(','); string[] sourceFieldNames = args[1].ToString().Trim().Split(','); string[] targetFieldNames = args[2].ToString().Trim().Split(','); string sourceIDFieldName = args[3].ToString().Trim(); string targetIDFieldName = args[4].ToString().Trim(); bool autoCommit = false; if (args.Length == 6) { autoCommit = args[5].ToString().Trim().ToLower() == "true" ? true : false; } else if (args.Length == 7) { autoCommit = args[6].ToString().Trim().ToLower() == "true" ? true : false; } int countFld = 1; if (args.Length >= 6) { if (args[5].ToString().Trim() != "") { 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")); bool cont = true; IRowChanges inChanges = inObject as IRowChanges; if (intFldIdxs.Count == 1) { if (inChanges.get_ValueChanged(intFldIdxs[0])) { cont = true; } else { cont = false; } } if (cont) { if (sourceFieldNames.Length > 0) { int fldIDToCopyIdx = Globals.GetFieldIndex(inObject.Fields, sourceIDFieldName); 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) { ISubtypes subtypes = (ISubtypes)pTable; IEnumSubtype enumSubtype; IRowSubtypes rowSubtypes = null; int subtypeCode = 0; string subtypeName; if (subtypes.HasSubtype) { enumSubtype = subtypes.Subtypes; subtypeName = enumSubtype.Next(out subtypeCode); } enumSubtype = null; int fldIDToPopIdx = Globals.GetFieldIndex(pTable.Fields, targetIDFieldName); if (fldIDToPopIdx > -1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain123")); IRow pNewRow; for (int j = 0; j < countFld; j++) { pNewRow = pTable.CreateRow(); rowSubtypes = (IRowSubtypes)pNewRow; if (subtypes.HasSubtype) { rowSubtypes.SubtypeCode = subtypeCode; } // Initialize any default values the feature has. rowSubtypes.InitDefaultValues(); 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")); if (sourceFieldNames.Length == targetFieldNames.Length) { for (int kl = 0; kl < sourceFieldNames.Length; kl++) { int fldToPopIdx = Globals.GetFieldIndex(pTable.Fields, sourceFieldNames[kl]); int fldValueIdx; object valueToSet = null; string[] targetFieldSplit = targetFieldNames[kl].Split('('); if (targetFieldNames[kl].Contains("~") == true) { string fieldName_without = targetFieldNames[kl].Replace("~", ""); fldValueIdx = Globals.GetFieldIndex(inObject.Fields, fieldName_without); if (fldValueIdx == -1) { valueToSet = targetFieldNames[kl]; } else { if (inChanges.get_ValueChanged(fldValueIdx)) { valueToSet = inChanges.get_OriginalValue(fldValueIdx); } else { valueToSet = inObject.get_Value(fldValueIdx); } } } else { fldValueIdx = Globals.GetFieldIndex(inObject.Fields, targetFieldNames[kl]); if (fldValueIdx == -1) { valueToSet = targetFieldNames[kl]; } else { valueToSet = inObject.get_Value(fldValueIdx); } } try { pNewRow.set_Value(fldToPopIdx, valueToSet); } catch { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aw") + sourceFieldNames[kl] + " to field: " + targetFieldNames[kl]); } } } if (autoCommit) { pNewRow.Store(); } if (NewFeatureList == null) { NewFeatureList = new List(); } 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("AttributeAssistantEditorChain64")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "CREATE_LINKED_RECORD" + Environment.NewLine + ex.ToString()); } 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, AAState._editor.Map.SpatialReference); 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(); } 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(); } 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(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } else { sourceFeatureLocal.set_Value(sourceField, test as object); if (ChangeFeatureList == null) { ChangeFeatureList = new List(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } } else { sourceFeatureLocal.set_Value(sourceField, test as object); if (ChangeFeatureList == null) { ChangeFeatureList = new List(); } 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(); } 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(); } 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(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } else { sourceFeatureLocal.set_Value(sourceField, test as object); if (ChangeFeatureList == null) { ChangeFeatureList = new List(); } ChangeFeatureList.Add(sourceFeatureLocal); found = true; } } else { sourceFeatureLocal.set_Value(sourceField, test as object); if (ChangeFeatureList == null) { ChangeFeatureList = new List(); } 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.ToString()); } 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, AAState._editor.Map.SpatialReference); 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.ToString()); } 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; string delim = ","; string sortOrder = "none"; //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; } if (args.GetLength(0) >= 5) { delim = args[4].ToString().Trim(); } else { delim = ","; } if (args.GetLength(0) >= 6) { sortOrder = args[5].ToString().Trim(); } else { sortOrder = "none"; } List concatList = new List(); 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) { if (searchDistance > 0.0) { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false, AAState._editor.Map.SpatialReference); } else { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false, AAState._editor.Map.SpatialReference); } 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) { if (statType.ToUpper() == "CONCAT") { if (concatList.Contains(valToTest.ToString()) == false) { concatList.Add(valToTest.ToString()); } } else { 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": //concatFunc(valToTest.ToString(), ref textRes); if (concatList.Contains(valToTest.ToString()) == false) { concatList.Add(valToTest.ToString()); } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { switch (statType.ToUpper()) { case "CONCAT": //concatFunc(test.ToString(), ref textRes); if (concatList.Contains(test.ToString()) == false) { concatList.Add(test.ToString()); } 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) { if (statType.ToUpper() == "CONCAT") { if (concatList.Contains(valToTest.ToString()) == false) { concatList.Add(valToTest.ToString()); } } else { 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": //concatFunc(valToTest.ToString(), ref textRes); if (concatList.Contains(valToTest.ToString()) == false) { concatList.Add(valToTest.ToString()); } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { switch (statType.ToUpper()) { case "CONCAT": //concatFunc(test.ToString(), ref textRes); if (concatList.Contains(test.ToString()) == false) { concatList.Add(test.ToString()); } 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 (statType.ToUpper() == "CONCAT") { if (sortOrder.ToUpper() == "ASC") { concatList.Sort((a, b) => a.CompareTo(b)); } else if (sortOrder.ToUpper() == "DESC") { concatList.Sort((a, b) => -1 * a.CompareTo(b)); } textRes = string.Join(delim, concatList.ToArray()); } 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.ToString()); } } 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.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECT_STATS"); } break; case "INTERSECT_COUNT": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "INTERSECT_COUNT"); if (inFeature != null & valData != null) { sourceLayerName = ""; found = false; //LayerToIntersect|Field To Elevate // Parse arguments args = valData.Split('|'); int count = 0; if (args.GetLength(0) >= 1) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain114")); sourceLayerNames = args[0].ToString().Split(','); if (args.GetLength(0) == 2) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain129")); if (Globals.IsDouble(args[1])) searchDistance = Convert.ToDouble(args[1]); else searchDistance = 0.0; } else { searchDistance = 0.0; } 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) { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, false, AAState._editor.Map.SpatialReference); if (boolLayerOrFC) { IFeatureLayerDefinition2 pfldef = (IFeatureLayerDefinition2)(sourceLayer); sFilter.WhereClause = pfldef.DefinitionExpression; count = count + sourceLayer.FeatureClass.FeatureCount(sFilter); pfldef = null; } else { count = count + sourceLayer.FeatureClass.FeatureCount(sFilter); } } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorWarn_14e")); } } } } try { IField field = inObject.Fields.get_Field(intFldIdxs[0]); inObject.set_Value(intFldIdxs[0], count); } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14aj") + ex.ToString()); } } } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECT_COUNT: " + ex.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECT_COUNT"); } break; case "FEATURE_STATS": try { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14ar") + "FEATURE_STATS"); if (inObject != null & valData != null) { sourceFieldName = ""; sourceField = -1; found = false; //LayerToIntersect|Field To Elevate // Parse arguments args = valData.Split('|'); int AverageCount = 0; if (args.Length > 1) { string delim = ","; string sortOrder = "none"; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain114")); string[] sourceFieldNames = args[0].ToString().Split(','); string statType = args[1].ToString().Trim(); if (args.Length > 2) { delim = args[2].ToString().Trim(); } if (args.Length > 3) { sortOrder = args[3].ToString().Trim(); } double result = -999999.1; string textRes = ""; List concatList = new List(); if (sourceFieldNames != null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain131")); for (int i = 0; i < sourceFieldNames.Length; i++) { sourceFieldName = sourceFieldNames[i].ToString().Trim(); 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) { if (statType.ToUpper() == "CONCAT") { if (concatList.Contains(valToTest.ToString()) == false) { concatList.Add(valToTest.ToString()); } } else { 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": //concatFunc(valToTest.ToString(), ref textRes); if (concatList.Contains(valToTest.ToString()) == false) { concatList.Add(valToTest.ToString()); } break; default: AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14ai") + test); break; } } } else { switch (statType.ToUpper()) { case "CONCAT": //concatFunc(test.ToString(), ref textRes); if (concatList.Contains(test.ToString()) == false) { concatList.Add(test.ToString()); } 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 (statType.ToUpper() == "CONCAT") { if (sortOrder.ToUpper() == "ASC") { concatList.Sort((a, b) => a.CompareTo(b)); } else if (sortOrder.ToUpper() == "DESC") { concatList.Sort((a, b) => -1 * a.CompareTo(b)); } textRes = string.Join(delim, concatList.ToArray()); } 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.ToString()); } } 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.ToString()); } 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().Trim(); break; case 2: sourceFieldName = args[1].ToString().Trim(); 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.ToString()); } } 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.ToString()); } finally { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14as") + "INTERSECTING_EDGE"); } break; case "INTERSECTING_FEATURE": try { bool switchToPrompt = false; bool valSet = false; 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 string nullOnNone = "False"; 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().Trim(); break; case 3: sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString().Trim(); switch (args[2].ToString().ToUpper()) { case "HIGHEST": strOpt = AAState.intersectOptions.Highest; break; case "H": strOpt = AAState.intersectOptions.Highest; break; 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 "CP": strOpt = AAState.intersectOptions.Centroid; switchToPrompt = true; break; case "F": strOpt = AAState.intersectOptions.First; break; case "L": strOpt = AAState.intersectOptions.Last; break; case "FIRST": strOpt = AAState.intersectOptions.First; break; case "S": strOpt = AAState.intersectOptions.Start; break; case "SP": strOpt = AAState.intersectOptions.Start; switchToPrompt = true; break; case "E": strOpt = AAState.intersectOptions.End; break; case "EP": strOpt = AAState.intersectOptions.End; switchToPrompt = true; break; } break; case 4: sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString().Trim(); switch (args[2].ToString().ToUpper()) { case "HIGHEST": strOpt = AAState.intersectOptions.Highest; break; case "H": strOpt = AAState.intersectOptions.Highest; break; 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 "CP": strOpt = AAState.intersectOptions.Centroid; switchToPrompt = true; break; case "F": strOpt = AAState.intersectOptions.First; break; case "L": strOpt = AAState.intersectOptions.Last; break; case "FIRST": strOpt = AAState.intersectOptions.First; break; case "S": strOpt = AAState.intersectOptions.Start; break; case "SP": strOpt = AAState.intersectOptions.Start; switchToPrompt = true; break; case "E": strOpt = AAState.intersectOptions.End; break; case "EP": strOpt = AAState.intersectOptions.End; switchToPrompt = true; break; } nullOnNone = args[3].ToString().Trim(); break; default: break; } if (sourceFieldName != null) { List pFoundFeat = new List(); 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) { double mapTol = ((IMxDocument)ArcMap.Application.Document).SearchTolerance; AAState.WriteLine(" map tolerance: " + mapTol.ToString()); try { ISpatialReferenceResolution pSRResolution2; pSRResolution2 = AAState._editor.Map.SpatialReference as ISpatialReferenceResolution; var spatialRef = AAState._editor.Map.SpatialReference; double calculatedToleranceMap = 0.0; if (spatialRef != null && spatialRef.HasXYPrecision()) { var spRefTolerance = spatialRef as ISpatialReferenceTolerance; if (spRefTolerance != null && spRefTolerance.XYToleranceValid == esriSRToleranceEnum.esriSRToleranceOK) { calculatedToleranceMap = spRefTolerance.XYTolerance; } else { calculatedToleranceMap = -1.0; } } double dblTol = Globals.GetXYTolerance(sourceLayer); //pSRResolution = ((sourceLayer.FeatureClass as IGeoDataset).SpatialReference) as ISpatialReferenceResolution; //dblTol = pSRResolution.get_XYResolution(false); dblTol = dblTol * 10; double dblTol2 = pSRResolution2.get_XYResolution(false); dblTol2 = dblTol2 * 10; if (dblTol2 > dblTol) { dblTol = dblTol2; } AAState.WriteLine(" spatial tolerance: " + dblTol.ToString()); //if (mapTol > dblTol) //{ // dblTol = mapTol; //} if (strOpt == AAState.intersectOptions.End && (inFeature.Class as IFeatureClass).ShapeType == esriGeometryType.esriGeometryPolyline) { IPolyline pLyLine = inFeature.Shape as IPolyline; ILine pLine = new LineClass(); sFilter = Globals.createSpatialFilter(sourceLayer, pLyLine.ToPoint, dblTol, strOpt == AAState.intersectOptions.Centroid, AAState._editor.Map.SpatialReference); pLyLine = null; pLine = null; } else if (strOpt == AAState.intersectOptions.Start && (inFeature.Class as IFeatureClass).ShapeType == esriGeometryType.esriGeometryPolyline) { IPolyline pLyLine = inFeature.Shape as IPolyline; ILine pLine = new LineClass(); sFilter = Globals.createSpatialFilter(sourceLayer, pLyLine.FromPoint, dblTol, strOpt == AAState.intersectOptions.Centroid, AAState._editor.Map.SpatialReference); pLyLine = null; pLine = null; } else { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, dblTol, strOpt == AAState.intersectOptions.Centroid, AAState._editor.Map.SpatialReference); } pSRResolution2 = null; try { string unitName = Globals.GetSpatRefUnitName(sFilter.Geometry.SpatialReference, false); double areaTest = (sFilter.Geometry as IArea).Area; AAState.WriteLine("Size of search polygon: " + areaTest + " in " + unitName + " ref " + sFilter.Geometry.SpatialReference.Name); } catch { } } catch { if (strOpt == AAState.intersectOptions.End && (inFeature.Class as IFeatureClass).ShapeType == esriGeometryType.esriGeometryPolyline) { IPolyline pLyLine = inFeature.Shape as IPolyline; ILine pLine = new LineClass(); sFilter = Globals.createSpatialFilter(sourceLayer, pLyLine.ToPoint, mapTol, strOpt == AAState.intersectOptions.Centroid, AAState._editor.Map.SpatialReference); pLyLine = null; pLine = null; } else if (strOpt == AAState.intersectOptions.Start && (inFeature.Class as IFeatureClass).ShapeType == esriGeometryType.esriGeometryPolyline) { IPolyline pLyLine = inFeature.Shape as IPolyline; ILine pLine = new LineClass(); sFilter = Globals.createSpatialFilter(sourceLayer, pLyLine.FromPoint, mapTol, strOpt == AAState.intersectOptions.Centroid, AAState._editor.Map.SpatialReference); pLyLine = null; pLine = null; } else { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, mapTol, strOpt == AAState.intersectOptions.Centroid, AAState._editor.Map.SpatialReference); } } if (switchToPrompt) { strOpt = AAState.intersectOptions.PromptMulti; } if (sFilter == null) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain137")); continue; } pFS = (IFeatureSelection)sourceLayer; if (boolLayerOrFC) { AAState.WriteLine("Using Layer: " + sourceLayer.Name); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain138")); if (pFS.SelectionSet.Count > 0) { AAState.WriteLine("Selected features count:" + pFS.SelectionSet.Count); 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("No Selected features"); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain141")); fCursor = sourceLayer.Search(sFilter, true); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain140")); } } else { AAState.WriteLine("Using Feature Class" + Globals.getClassName((IDataset)sourceLayer.FeatureClass).ToString()); AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain142")); AAState.WriteLine("Feature matching query: " + sourceLayer.FeatureClass.FeatureCount(sFilter)); 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 || strOpt == AAState.intersectOptions.Highest) { 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() != "") { if (boolLayerOrFC == true) { pOp.Display = sourceLayer.Name + ": " + pOp.Display + " value = " + pOp.Value.ToString(); } else { pOp.Display = sourceLayer.FeatureClass.AliasName + ": " + pOp.Display + " value = " + pOp.Value.ToString(); } } else { if (boolLayerOrFC == true) { pOp.Display = sourceLayer.Name + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString(); } else { pOp.Display = sourceLayer.FeatureClass.AliasName + ": " + sourceFeature.OID + " value = " + pOp.Value.ToString(); } } AAState.WriteLine(" " + "OID: " + sourceFeature.OID + " " + sourceLayer.Name + "/" + sourceLayer.FeatureClass.AliasName + ": " + pOp.Display + " 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")); valSet = true; 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); found = true; } } else if (sourceFeature.Class == inFeature.Class && sourceFeature.OID != inFeature.OID) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain148")); if (strOpt == AAState.intersectOptions.PromptMulti || strOpt == AAState.intersectOptions.Highest) { 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(); } AAState.WriteLine(" " + "OID: " + sourceFeature.OID + " " + sourceLayer.Name + "/" + sourceLayer.FeatureClass.AliasName + ": " + pOp.Display + " 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 || strOpt == AAState.intersectOptions.Highest) { 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(); } AAState.WriteLine(" " + "OID: " + sourceFeature.OID + " " + sourceLayer.Name + "/" + sourceLayer.FeatureClass.AliasName + ": " + pOp.Display + " 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); } } } AAState.WriteLine(" Feature count: " + pFoundFeat.Count); AAState.WriteLine(" Option: " + strOpt.ToString()); Globals.OptionsToPresent strRetVal = null; if (pFoundFeat.Count > 0 && strOpt == AAState.intersectOptions.Highest && valSet == false) { int highestOID = -1; foreach (var option in pFoundFeat) { if (option.OID > highestOID) { highestOID = option.OID; strRetVal = option; } } if (strRetVal == null) { AAState.WriteLine(" selected value from highest ID was null "); } else if (strRetVal.OID == -1) { AAState.WriteLine(" Error in highest ID: " + strRetVal.Display); } else { 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.PromptMulti && valSet == false) { strRetVal = Globals.showOptionsForm(pFoundFeat, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain149") + sourceFieldName, A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain149") + sourceFieldName, ComboBoxStyle.DropDownList); if (strRetVal == null) { AAState.WriteLine(" selected value from prompt was null "); } else if (strRetVal.OID == -1) { AAState.WriteLine(" Error in prompt form: " + strRetVal.Display); } else { //sourceFeature = sourceLayer.FeatureClass.GetFeature(strRetVal.OID); AAState.WriteLine(" selected value: " + strRetVal.Value.ToString()); 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 && valSet == false) { 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; } if (found == false && nullOnNone.ToUpper() == "TRUE" && inObject.Fields.get_Field(intFldIdxs[0]).IsNullable) { try { inObject.set_Value(intFldIdxs[0], DBNull.Value); } catch { } } } 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.ToString()); } 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 && valData != "") { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain134")); sourceLayerName = ""; string valTrue = "1"; string valFalse = "0"; found = false; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain135") + valData); // Parse arguments args = valData.Split('|'); //if (args.GetLength(0) >= 2) AAState.intersectOptions strOpt = AAState.intersectOptions.First; switch (args.Length) { case 1: sourceLayerNames = args[0].ToString().Split(','); break; case 2: sourceLayerNames = args[0].ToString().Split(','); valTrue = args[1].ToString().Trim(); break; case 3: sourceLayerNames = args[0].ToString().Split(','); valTrue = args[1].ToString().Trim(); valFalse = args[2].ToString().Trim(); 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, AAState._editor.Map.SpatialReference); 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")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + "INTERSECTING_BOOLEAN: " + ex.ToString()); } 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().Trim(); 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.ToString()); } 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 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().Trim(); break; case 3: sourceLayerNames = args[0].ToString().Split(','); formatString = args[1].ToString().Trim(); 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().Trim(); 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(args[3].ToString().Split(',')); break; default: break; } List strFiles = new List(); // Get layer for (int i = 0; i < sourceLayerNames.Length; i++) { sourceLayerName = sourceLayerNames[i].ToString().Trim(); IGeometry pGeo = inFeature.ShapeCopy; List pGeos = new List(); if (pGeo != null) { if (strOpt == AAState.intersectOptions.Centroid) { List pGeoPnts = Globals.GetGeomCenter(pGeo); pGeos = pGeoPnts.ConvertAll(new Converter(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) { AAState.WriteLine(" selected value from prompt was null "); } else if (strRetVal.OID == -1) { AAState.WriteLine(" Error in prompt form: " + strRetVal.Display); } else { AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorMess_14cf")); try { AAState.WriteLine(" trying to set value " + strRetVal.Value.ToString()); inObject.set_Value(intFldIdxs[0], strRetVal.Value); AAState.WriteLine(" " + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain147") + strRetVal.Value.ToString()); } 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.ToString()); } 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().Trim(); if (sourceLayerName != "") sourceLayerName = args[i].ToString().Trim(); 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, AAState._editor.Map.SpatialReference); 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.ToString()); } 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().Trim(); break; case 3: sourceLayerNames = args[0].ToString().Split(','); sourceFieldName = args[1].ToString().Trim(); 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().Trim(); Double.TryParse(args[2], out searchDistance); sourceMatField = args[3].ToString().Trim(); targetMatField = args[4].ToString().Trim(); 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().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) { sourceField = Globals.GetFieldIndex(sourceLayer.FeatureClass.Fields, sourceFieldName); if (sourceField > -1) { sFilter = Globals.createSpatialFilter(sourceLayer, inFeature, searchDistance, false, AAState._editor.Map.SpatialReference); 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") + sourceLayerName + 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.ToString()); } 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.ToString(), 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.ToString()); } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain186")); } try { if (intFldIdxs.Count > 0 && strFldNames.Count > 0) { for (int p = 0; p < strFldNames.Count; p++) { if ((intFldIdxs[p]) >= 0) { IRowChanges inChanges = inObject as IRowChanges; bool changed = inChanges.get_ValueChanged(intFldIdxs[p]); if (changed) try { object propNames = new object(); object propValues = new object(); AAState.lastValueProperties.GetAllProperties(out propNames, out propValues); object[] names = (object[])propNames; bool valuExist = false; for (int di = 0; di < names.Length; di++) { if (strFldNames[p].ToString() == names[di].ToString()) { valuExist = true; break; } } if (valuExist) { 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(" ------------------------------------------------"); } } } try { if (storeObject == true) { //Store the object after all rules have processed, used to handle previous value inObject.Store(); } } catch { } return true; } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain189") + System.Environment.NewLine + A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain190") + ex.ToString(), 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")); } } //Returns rows from defaults table which match this object's table name or wildcard private void getDefaultRows(ref IObject inObject, out ICursor outCursor) { outCursor = null; try { AAState._gentab = Globals.FindTable(ArcMap.Document.FocusMap, AAState._sequenceTableName); ITable tab = Globals.FindTable(ArcMap.Document.FocusMap, AAState._defaultsTableName); if (tab != null) { IDataset dataset = inObject.Class as IDataset; IQueryFilter qFilter = new QueryFilterClass(); IQueryFilterDefinition qFilterDef = qFilter as IQueryFilterDefinition; qFilterDef.PostfixClause = "ORDERBY TABLENAME"; string[] items = dataset.Name.Split('.'); string name = items[items.GetLength(0) - 1]; qFilter.WhereClause = "TABLENAME = '" + name + "' or TABLENAME = '*'"; outCursor = tab.Search(qFilter, true) as ICursor; } else { outCursor = null; } return; } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain192") + ex.ToString()); } } private void getView(DataTable dt) { try { DataView view = new DataView(dt); foreach (DataRowView drv in view) { Console.WriteLine(drv["OBJECTID"].ToString()); } view.RowFilter = "ValData = 'Evy'"; foreach (DataRowView drv in view) { Console.WriteLine(drv["OBJECTID"].ToString()); } } catch (Exception ex) { MessageBox.Show(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain193") + ex.ToString()); } } private void intersectLayerDetailsFunctions(ILayer pLay, List pGeos, AAState.intersectOptions strOpt, ref bool found, ref List strFiles, ref ESRI.ArcGIS.Geodatabase.IObject inObject, int intFldIdx, List MatchPattern) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain194") + pLay.Name); IRasterLayer pRasLay = null; IEnvelope pEnv = null; IRelationalOperator pRel = null; IRelationalOperator2 pRel2 = null; ISpatialFilter pSpatFilt = null; IFeatureLayer pFLay = null; try { if (pLay is IRasterLayer) { pRasLay = pLay as IRasterLayer; AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain195") + pRasLay.Name); pEnv = pRasLay.AreaOfInterest; pRel = pEnv as IRelationalOperator; pRel2 = pEnv as IRelationalOperator2; foreach (IGeometry pGeo in pGeos) { if (pRel.Crosses(pGeo) || pRel.Touches(pGeo) || pRel.Overlaps(pGeo) || pRel2.ContainsEx(pGeo, esriSpatialRelationExEnum.esriSpatialRelationExClementini)) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain196") + pRasLay.Name); string pathForLay = Globals.GetPathForALayer(pLay); string fcname = Globals.getClassName(pLay); switch (formatString) { case "P": if (MatchPattern == null) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay))) { strFiles.Add(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay)); } } else { inObject.set_Value(intFldIdx, pathForLay); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else if (MatchPattern.Count == 0) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay))) { strFiles.Add(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay)); } } else { inObject.set_Value(intFldIdx, pathForLay); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else { foreach (string MatPat in MatchPattern) { if (pathForLay.ToUpper().Contains(MatPat.ToUpper()) || pLay.Name.ToUpper().Contains(MatPat.ToUpper())) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay))) { strFiles.Add(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay)); } } else { inObject.set_Value(intFldIdx, pathForLay); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } } } break; case "N": if (MatchPattern == null) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pLay.Name, pLay.Name, pLay.Name))) { strFiles.Add(new Globals.OptionsToPresent(0, pLay.Name, pLay.Name, pLay.Name)); } } else { inObject.set_Value(intFldIdx, pLay.Name); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else if (MatchPattern.Count == 0) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pLay.Name, pLay.Name, pLay.Name))) { strFiles.Add(new Globals.OptionsToPresent(0, pLay.Name, pLay.Name, pLay.Name)); } } else { inObject.set_Value(intFldIdx, pLay.Name); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else { foreach (string MatPat in MatchPattern) { if (pathForLay.ToUpper().Contains(MatPat.ToUpper()) || pLay.Name.ToUpper().Contains(MatPat.ToUpper())) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pLay.Name, pLay.Name, pLay.Name))) { strFiles.Add(new Globals.OptionsToPresent(0, pLay.Name, pLay.Name, pLay.Name)); } } else { inObject.set_Value(intFldIdx, pLay.Name); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } } } break; case "F": if (MatchPattern == null) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, fcname, fcname, fcname))) { strFiles.Add(new Globals.OptionsToPresent(0, fcname, fcname, fcname)); } } else { inObject.set_Value(intFldIdx, fcname); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else if (MatchPattern.Count == 0) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, fcname, fcname, fcname))) { strFiles.Add(new Globals.OptionsToPresent(0, fcname, fcname, fcname)); } } else { inObject.set_Value(intFldIdx, fcname); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else { foreach (string MatPat in MatchPattern) { if (pathForLay.ToUpper().Contains(MatPat.ToUpper()) || fcname.ToUpper().Contains(MatPat.ToUpper())) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, fcname, fcname, fcname))) { strFiles.Add(new Globals.OptionsToPresent(0, fcname, fcname, fcname)); } } else { inObject.set_Value(intFldIdx, fcname); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } } } break; default: if (MatchPattern == null) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay))) { strFiles.Add(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay)); } } else { inObject.set_Value(intFldIdx, pathForLay); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else if (MatchPattern.Count == 0) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay))) { strFiles.Add(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay)); } } else { inObject.set_Value(intFldIdx, pathForLay); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else { foreach (string MatPat in MatchPattern) { if (pathForLay.ToUpper().Contains(MatPat.ToUpper()) || pLay.Name.ToUpper().Contains(MatPat.ToUpper())) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay))) { strFiles.Add(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay)); } } else { inObject.set_Value(intFldIdx, pathForLay); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } } } break; } } } } else if (pLay is IFeatureLayer) { pFLay = pLay as IFeatureLayer; if (pFLay.FeatureClass == inObject.Class) { } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain195") + pFLay.Name); foreach (IGeometry pGeo in pGeos) { pSpatFilt = new SpatialFilterClass(); pSpatFilt.GeometryField = pFLay.FeatureClass.ShapeFieldName; pSpatFilt.Geometry = pGeo as IGeometry; pSpatFilt.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; if (pFLay.FeatureClass.FeatureCount(pSpatFilt) > 0) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain196") + pFLay.Name); string pathForLay = Globals.GetPathForALayer(pLay); string fcname = Globals.getClassName(pLay); switch (formatString) { case "P": if (MatchPattern == null) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay))) { strFiles.Add(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay)); } } else { inObject.set_Value(intFldIdx, pathForLay); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else if (MatchPattern.Count == 0) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay))) { strFiles.Add(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay)); } } else { inObject.set_Value(intFldIdx, pathForLay); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else { foreach (string MatPat in MatchPattern) { if (pathForLay.ToUpper().Contains(MatPat.ToUpper()) || pLay.Name.ToUpper().Contains(MatPat.ToUpper())) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay))) { strFiles.Add(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay)); } } else { inObject.set_Value(intFldIdx, pathForLay); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } } } break; case "N": if (MatchPattern == null) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pLay.Name, pLay.Name, pLay.Name))) { strFiles.Add(new Globals.OptionsToPresent(0, pLay.Name, pLay.Name, pLay.Name)); } } else { inObject.set_Value(intFldIdx, pLay.Name); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else if (MatchPattern.Count == 0) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pLay.Name, pLay.Name, pLay.Name))) { strFiles.Add(new Globals.OptionsToPresent(0, pLay.Name, pLay.Name, pLay.Name)); } } else { inObject.set_Value(intFldIdx, pLay.Name); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else { foreach (string MatPat in MatchPattern) { if (pathForLay.ToUpper().Contains(MatPat.ToUpper()) || pLay.Name.ToUpper().Contains(MatPat.ToUpper())) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pLay.Name, pLay.Name, pLay.Name))) { strFiles.Add(new Globals.OptionsToPresent(0, pLay.Name, pLay.Name, pLay.Name)); } } else { inObject.set_Value(intFldIdx, pLay.Name); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } } } break; case "F": if (MatchPattern == null) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, fcname, fcname, fcname))) { strFiles.Add(new Globals.OptionsToPresent(0, fcname, fcname, fcname)); } } else { inObject.set_Value(intFldIdx, fcname); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else if (MatchPattern.Count == 0) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, fcname, fcname, fcname))) { strFiles.Add(new Globals.OptionsToPresent(0, fcname, fcname, fcname)); } } else { inObject.set_Value(intFldIdx, fcname); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else { foreach (string MatPat in MatchPattern) { if (pathForLay.ToUpper().Contains(MatPat.ToUpper()) || fcname.ToUpper().Contains(MatPat.ToUpper())) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, fcname, fcname, fcname))) { strFiles.Add(new Globals.OptionsToPresent(0, fcname, fcname, fcname)); } } else { inObject.set_Value(intFldIdx, fcname); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } } } break; default: if (MatchPattern == null) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay))) { strFiles.Add(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay)); } } else { inObject.set_Value(intFldIdx, pathForLay); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else if (MatchPattern.Count == 0) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay))) { strFiles.Add(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay)); } } else { inObject.set_Value(intFldIdx, pathForLay); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } else { foreach (string MatPat in MatchPattern) { if (pathForLay.ToUpper().Contains(MatPat.ToUpper()) || pLay.Name.ToUpper().Contains(MatPat.ToUpper())) { if (strOpt == AAState.intersectOptions.PromptMulti) { if (!strFiles.Contains(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay))) { strFiles.Add(new Globals.OptionsToPresent(0, pathForLay, pathForLay, pathForLay)); } } else { inObject.set_Value(intFldIdx, pathForLay); pRasLay = null; pEnv = null; pRel = null; pRel2 = null; found = true; return; } } } } break; } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain197") + pFLay.Name); } } } } else { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorChain198")); } } catch (Exception ex) { AAState.WriteLine(A4LGSharedFunctions.Localizer.GetString("AttributeAssistantEditorError_14a") + ex.ToString()); } finally { pRasLay = null; pEnv = null; pRel = null; pRel2 = null; pSpatFilt = null; pFLay = null; } } private void concatFunc(string val, ref string result, string ConcatDelim = ",") { if (result == "") { result += val.ToString(); } else if (!result.Contains(ConcatDelim)) { if (result != val.ToString()) { result += ConcatDelim + val.ToString(); } } else if (result.Contains(val.ToString() + ConcatDelim)) { } else if (result.Contains(ConcatDelim + val.ToString())) { } else { if (result == "") { result += val.ToString(); } else { result += ConcatDelim + val.ToString(); } } } //public void StartEditSession(IFeatureWorkspace featureWorkspace, esriMultiuserEditSessionMode editSessionMode) //{ // //perform edit tasks here, edit operations can be used // } // else MessageBox.Show("workspace does not support this type of edit session mode"); //} public void ListSchemaLocksForObjectClass(IDataset objectClass) { //Get an exclusive schema lock on the dataset. ISchemaLock schemaLock = (ISchemaLock)objectClass; // Get an enumerator over the current schema locks. IEnumSchemaLockInfo enumSchemaLockInfo = null; schemaLock.GetCurrentSchemaLocks(out enumSchemaLockInfo); // Iterate through the locks. ISchemaLockInfo schemaLockInfo = null; while ((schemaLockInfo = enumSchemaLockInfo.Next()) != null) { Console.WriteLine("{0} : {1} : {2}", schemaLockInfo.TableName, schemaLockInfo.UserName, schemaLockInfo.SchemaLockType); } } public long unversionedEdit(IQueryFilter qFilterGen, int sequenceColumnNum, int idxSeqField, string seqParam) { //ISchemaLock schemaLock = null; try { long sequenceValue = -1; ICursor search_cursor; IRow search_row = null; bool sdeWorkspace = ((IDataset)AAState._gentab).Workspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace; if (sdeWorkspace && AAState._generateIDStoreProceName != null && AAState._generateIDStoreProceName != "") { try { IQueryDef queryDef = ((IFeatureWorkspace)((IDataset)AAState._gentab).Workspace).CreateQueryDef(); queryDef.Tables = ((IDataset)AAState._gentab).BrowseName;// "UN.GENERATEID"; queryDef.SubFields = AAState._generateIDStoreProceName + "('" + seqParam + "')";// + AAState._seqCounterField; queryDef.WhereClause = qFilterGen.WhereClause; search_cursor = queryDef.Evaluate(); search_row = search_cursor.NextRow(); if (search_row != null) { sequenceValue = Convert.ToInt64(search_row.get_Value(0)); AAState.WriteLine(" store procedure return: " + sequenceValue + " - " + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture)); return sequenceValue; } } catch { AAState.WriteLine(" Accesing store procedure failed: " + AAState._generateIDStoreProceName + "('" + seqParam + "') - " + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture)); } } // ListSchemaLocksForObjectClass((IDataset)AAState._gentab); int sequenceInt = 1; IRow seq_row = null; // Use ITable.Update to create an update cursor. search_cursor = AAState._gentab.Search(qFilterGen, true); search_row = search_cursor.NextRow(); if (search_row != null) { if (idxSeqField > 0) { object seqInt = search_row.get_Value(idxSeqField); if (seqInt != null) { if (seqInt != DBNull.Value) try { sequenceInt = Convert.ToInt32(seqInt); } catch { } } } } System.Runtime.InteropServices.Marshal.ReleaseComObject(search_cursor); //if (AAState._generateIDStoreProceName != null && AAState._generateIDStoreProceName = "") { // IWorkspace pWorkSpace =(IWorkspace) AAState._gentabWorkspace; // pWorkSpace.ExecuteSQL("BEGIN" + AAState._generateIDStoreProceName + "(" + args + "); END;"; //IWorkSpace:ExecuteSQL "BEGIN .(""); END;" //} //schemaLock = (ISchemaLock)(IDataset)AAState._gentab; //try //{ // schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock); //} //catch (COMException comExc) //{ // AAState.WriteLine(" Error saving transaction to DB" + ": " + DateTime.Now.ToString("h:mm:ss tt")); // return -1; //} ITransactions transactions; transactions = (ITransactions)AAState._gentabWorkspace; long seqValCompare; object seqObj; bool startTrans = false; if (transactions.InTransaction) { startTrans = true; } else { transactions.StartTransaction(); } AAState.WriteLine(" search Started:" + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture)); ICursor seq_updateCursor = AAState._gentab.Update(qFilterGen, false); seq_row = seq_updateCursor.NextRow(); seqObj = seq_row.get_Value(sequenceColumnNum); sequenceValue = seqForm(seqObj); int checkCount = 1; bool val_set = false; for (checkCount = 0; checkCount <= 50; checkCount++) { sequenceValue = sequenceValue + sequenceInt; search_cursor = AAState._gentab.Search(qFilterGen, true); search_row = search_cursor.NextRow(); seqObj = search_row.get_Value(sequenceColumnNum); seqValCompare = seqForm(seqObj); if (sequenceValue > seqValCompare) { //ICursor seq_updateCursor = AAState._gentab.Update(qFilterGen, false); //comReleaser.ManageLifetime(seq_updateCursor); //seq_row = seq_updateCursor.NextRow(); seq_row.set_Value(sequenceColumnNum, sequenceValue); seq_updateCursor.UpdateRow(seq_row); System.Runtime.InteropServices.Marshal.ReleaseComObject(seq_updateCursor); transactions.CommitTransaction(); AAState.WriteLine(" " + sequenceValue + " is the existing value and the interval is " + sequenceInt + ": " + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fffff", CultureInfo.InvariantCulture)); //schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock); if (startTrans) { transactions.StartTransaction(); } AAState.WriteLine(" " + seq_row.Fields.get_Field(sequenceColumnNum).AliasName + " changed to " + sequenceValue + ": " + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fffff", CultureInfo.InvariantCulture) + " - loop count:" + checkCount.ToString()); //+ "/" + transCheck.ToString()); val_set = true; break; } else { AAState.WriteLine(" conflict found: " + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fffff", CultureInfo.InvariantCulture) + " - loop count:" + checkCount.ToString()); //+ "/" + transCheck.ToString()); } System.Runtime.InteropServices.Marshal.ReleaseComObject(search_cursor); } if (val_set == false) { AAState.WriteLine(" No records found in Generate ID table" + ": " + DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fffff", CultureInfo.InvariantCulture)); //if (schemaLock != null) //{ // schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock); //} return -1; } return sequenceValue; } catch (COMException comExc) { AAState.WriteLine(" Error saving transaction to DB" + ": " + DateTime.Now.ToString("h:mm:ss tt")); //if (schemaLock != null) //{ // schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock); //} return -1; } } private long seqForm(object seqValue) { if (seqValue == null) { return 0; } else if (seqValue.ToString() == "") { return 0; } else { try { return Convert.ToInt64(seqValue); } catch { return 0; } } } #endregion } }