|
POST
|
OK, so I've created a work around for this but regardless of whether I create an Editor Extension, or just an Extension, I cannot get the extension to toggle on/off....even when it is showing in the Extensions Window with the toggle checkbox. What I am going with is an Editor Extension, and I have created a way for the user to 'disable' the functionality when they start editing by answering a question to a MessageBox: void Events_OnStartEditing()
{
maximoTracking = false;
if (MessageBox.Show("Would you also like to enable the Maximo edit tracking?", "Enable Maximo Tracking?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
return;
else
maximoTracking = true; I'm thinking there has got to be a better way to do this, but for now this is working. I did find some ideas in this thread, but nothing seemed to work: https://community.esri.com/t5/arcobjects-sdk-questions/add-in-custom-editor-extension-does-not-show-in-the-toolbar/td-p/172604 Thanks,
... View more
12-15-2020
05:41 AM
|
0
|
0
|
1881
|
|
POST
|
Hi, I've created an Editor Extension add-in. I have created the following in the config.daml but the extension is not showing up in the "Customize - Extensions" menu: <AddIn language="CLR" library="MaximoEditorExtension.dll" namespace="MaximoEditorExtension">
<ArcMap>
<Editor>
<Extensions>
<Extension id="Works_-_Tech_MaximoEditorExtension_Maximo_Editor_Extension" class="Maximo_Editor_Extension" productName="Maximo Editor Extension" showInExtensionDialog="true">
<Description>Updates Maximo fields and Editor Tracking information.</Description>
</Extension>
</Extensions>
</Editor>
</ArcMap>
</AddIn> So whenever I start editing the extension is always 'enabled', but I would like the user to be able to toggle it on/off as desired. If I remove the <Editor> and </Editor> tags, the extensions will then show up, but it doesn't always disable when I 'uncheck' it from the Extensions window. How do I get it to show up and function properly. Thanks,
... View more
12-14-2020
10:22 AM
|
0
|
4
|
1896
|
|
POST
|
Hi Wolf, OK, so things seem to be working better now. Since most of these tools I create are shared, I actually have them all sitting on a shared folder on the network. All the users connect to the folder to bring in the tools to ArcGIS Pro. Correct me if I am wrong, but if I update the "Version" in the config.daml when I am updating the tools on my PC, when I go to Build/Debug the project won't ArcGIS Pro see the updated version sitting in my AddIns folder and load up that one and NOT the one sitting on the network (with the older version #)?? Otherwise, the .ConnectionStatus does seem to be working with the new code you sent me. The only difference I see is using FeatureLayer instead of BasicFeatureLayer. Is that the issue??
... View more
12-09-2020
09:55 AM
|
0
|
0
|
2568
|
|
POST
|
Hi. Just saw this thread and I would say that most of my tools definitely have a delay the first time you run them too. I create all mine in Visual Studio (C#). If there is anything to try to help improve the performance of that 'first click', I'd be interested too. Thanks,
... View more
12-09-2020
06:07 AM
|
0
|
0
|
2817
|
|
POST
|
And just to add to my comment above, if I remove the 'broken' layer from the Map and run the tool, all is good. But then I will 'Undo' to get the broken layer back in the Map and run the tool, then it fails again with the NullReference exception.
... View more
12-09-2020
05:49 AM
|
0
|
1
|
2575
|
|
POST
|
Hi Wolf, Well I still get the NullReference exception, but at a different line of code.....see below. Basically with this tool, I was trying to add a way to detect a 'broken' layer. As the code was, it would always crash when a broken layer was in the Map, so I just wanted to notify the user to fix the layer before proceeding. I guess I could just throw an Exception handler in there. I'm not quite clear on what is happening here.
... View more
12-09-2020
05:39 AM
|
0
|
0
|
2575
|
|
POST
|
12-08-2020
10:50 AM
|
0
|
0
|
3240
|
|
POST
|
Hi Wolf, When using your code, on a button with only that code on it, it works as expected and I see the 'Broken' status in the debug window. If I take your code and plug it into mine, which is also the click event of a button, I still get the NullReference error. I'll paste all of my code below, but it must be something in my code that is the problem....I'm just not really sure what, or why. There's a fair bit going on here, but I've tried to highlight (******) where the issues are.....just in the OnClick() portion as far as I can tell. using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ArcGIS.Core.CIM;
using ArcGIS.Core.Data;
using ArcGIS.Core.Geometry;
using ArcGIS.Desktop.Catalog;
using ArcGIS.Desktop.Core;
using ArcGIS.Desktop.Editing;
using ArcGIS.Desktop.Extensions;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework.Contracts;
using ArcGIS.Desktop.Framework.Dialogs;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Mapping;
using System.Collections;
using System.Windows.Input;
namespace ArcPro_DSM_Settings
{
internal class FacilityID_Button : Button
{
FeatureLayer localMunicipalityLayer;
string gridNumber, structureType;
int sequenceNumber;
string settlementArea, vlsFolder;
protected override void OnClick()
{
Map map = MapView.Active.Map;
//******* where I have inserted your code
foreach (Layer layer in map.GetLayersAsFlattenedList().OfType<FeatureLayer>())
{
//var currentLayer = map.FindLayers(layer.Name).FirstOrDefault() as BasicFeatureLayer;
var currentLayer = layer as BasicFeatureLayer;
System.Diagnostics.Debug.WriteLine($@"Name: {currentLayer.Name} Type: {currentLayer.GetType()} Connect status: {currentLayer.ConnectionStatus}");
}
return;
int featureCount = 0;
int rejectedCount = 0;
Cursor theCursor = Cursors.Wait;
try
{
QueuedTask.Run(() =>
{
//Get each layer that needs to be part of the intersection as a FeatureLayer
FeatureLayer gridLayer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Name.Equals("GISWRKS1.WORKS.LAND_Grid", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
localMunicipalityLayer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Name.Equals("GISWRKS1.WORKS.LAND_LocalMunicipality", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
FeatureLayer administrativeAreaLayer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Name.Equals("GISWRKS1.WORKS.LAND_AdministrativeArea", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
FeatureLayer communitiesLayer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Name.Equals("GISWRKS1.WORKS.LAND_Communities", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
FeatureLayer depotAreaLayer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Name.Equals("GISWRKS1.WORKS.LAND_DepotArea", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
FeatureLayer pressureZoneLayer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Name.Equals("GISWRKS1.WORKS.WAT_PressureZone", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
FeatureLayer vlsLayer = map.GetLayersAsFlattenedList().OfType<FeatureLayer>().Where(l => l.Name.Equals("GISWRKS1.WORKS.VLS_Points", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
//Check to make sure they are all in the map
if (gridLayer == null || localMunicipalityLayer == null || administrativeAreaLayer == null || communitiesLayer == null || depotAreaLayer == null || pressureZoneLayer == null)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Please add the LAND and Water Pressure Zone layers before proceeding.", "Missing Layers");
return;
}
//Create the MAIN edit operation...this will show up on the Undo Stack
var editOperation = new ArcGIS.Desktop.Editing.EditOperation();
editOperation.Name = "Create new Facility IDs";
editOperation.ProgressMessage = "Calculating FacilityID's...";
editOperation.ShowProgressor = true;
editOperation.CancelMessage = "Operation Cancelled";
editOperation.ErrorMessage = "Error Creating FacilityIDs";
editOperation.EditOperationType = ArcGIS.Desktop.Editing.EditOperationType.Long;
ArcGIS.Desktop.Editing.EditOperation chainedOp = null;
//create the Inspector Object
var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector();
//create a flag to track the 'main' operation
bool isMainOperation = true;
//Check for any Joins on layers with a selected feature
Boolean joinExists = false;
Boolean brokenExists = false;
foreach (Layer layer in map.GetLayersAsFlattenedList().OfType<FeatureLayer>())
{
var currentLayer = map.FindLayers(layer.Name).FirstOrDefault() as BasicFeatureLayer;
//***** where my original code get the NullReference exception
if (currentLayer.ConnectionStatus == ConnectionStatus.Broken)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(currentLayer.Name.ToString() + " has a missing data source. Please remove or fix this layer before continuing.", "Missing Data Source");
brokenExists = true;
}
if ((currentLayer.GetTable().IsJoinedTable() == true) && (currentLayer.SelectionCount > 0))
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(currentLayer.Name.ToString() + " has a joined table. Please remove any joins before continuing.", "Joined table detected");
joinExists = true;
}
}
if (joinExists || brokenExists)
return;
//Go through each layer in the map
foreach (Layer layer in map.GetLayersAsFlattenedList().OfType<FeatureLayer>())
{
var currentLayer = map.FindLayers(layer.Name).FirstOrDefault() as BasicFeatureLayer;
//Does current layer have FACILITYID field??
Boolean facID_field = false;
facID_field = currentLayer.GetFieldDescriptions().Any(f => f.Name == "FACILITYID");
#region FACILITYID using FieldDescription
//Does current layer have FACILITYID field??
//Boolean facID_field = false;
//List<FieldDescription> theFields = currentLayer.GetFieldDescriptions();
//foreach (var fieldName in theFields)
//{
// if (fieldName.Name.ToString() == "FACILITYID")
// facID_field = true;
//}
#endregion
//if the FACILITYID field exists AND there is a selection, then continue....otherwise, look at next layer
if (currentLayer.SelectionCount > 0 && facID_field == true)
{
var selection = currentLayer.GetSelection();
IReadOnlyList<long> selectedOIDs = selection.GetObjectIDs(); //save the selected OBJECTIDs to a list.
structureType = GetFeatureClassCode(currentLayer);
//Loop through each selected OBJECTID, and pass the DRAWING and FACILITYID fields to the OpenDrawing method.
foreach (var oid in selectedOIDs)
{
inspector.Clear();
inspector.Load(currentLayer, oid);
MapPoint intersectPoint = null;
if (inspector["FACILITYID"].ToString() == "")
{
//if (inspector.GeometryAttribute.GeometryType == GeometryType.Polyline || inspector.GeometryAttribute.GeometryType == GeometryType.Polygon) //for polyline
//{
// var pointCollection = ((Multipart)inspector.Shape).Points;
// intersectPoint = pointCollection[0];
//}
//else
//{
// intersectPoint = inspector.Shape as MapPoint; //for point
//}
intersectPoint = GeometryEngine.Instance.Centroid(inspector.Shape);
//Make some of the initial edits
inspector["GRIDNO"] = GetIntersectingField(intersectPoint, "GRIDNO", gridLayer);
inspector["LOCALMUNICIPALITY"] = GetIntersectingField(intersectPoint, "LOCALMUNICIPALITY", localMunicipalityLayer);
inspector["SETTLEMENTAREA"] = GetIntersectingField(intersectPoint, "NAME", communitiesLayer);
inspector["DEPOTAREA"] = GetIntersectingField(intersectPoint, "DEPOTAREA", depotAreaLayer);
//Need to pass a FeatureCLass to the GetNextFaciltyID procedure
FeatureLayer currFLayer = currentLayer as FeatureLayer;
FeatureClass currFClass = currFLayer.GetFeatureClass();
//This is where the sequence number will get incremented each time (in the GetNextFacilityID)
inspector["FACILITYID"] = GetNextFacilityID(currFClass, gridNumber);
inspector["SEQUENCENO"] = sequenceNumber;
//make some more edits
inspector["STRUCTURETYPE"] = structureType;
if (Properties.Settings.Default.facIDContractNumberSetting == true)
inspector["CONTRACTNO"] = GetIntersectingField(intersectPoint, "CONTRACTNO", administrativeAreaLayer);
//Some more edits based on the current layer
if ((currentLayer.Name == "GISWRKS1.WORKS.SAN_Eff_Watermain") || (currentLayer.Name == "GISWRKS1.WORKS.SAN_Eff_WaterService") || (currentLayer.Name == "GISWRKS1.WORKS.SAN_Eff_Fitting") || (currentLayer.Name == "GISWRKS1.WORKS.SAN_Eff_ControlValve") || (currentLayer.Name == "GISWRKS1.WORKS.SAN_Eff_Hydrant"))
inspector["WATERTYPE"] = "NONPOT";
if (currentLayer.Name == "GISWRKS1.WORKS.SAN_Eff_Hydrant")
inspector["SUBTYPECD"] = 3;
if (currentLayer.Name == "GISWRKS1.WORKS.WAT_ControlValve")
inspector["PRESSUREZONE"] = GetIntersectingField(intersectPoint, "WPZ", pressureZoneLayer);
#region Code for VLS Points
if (currentLayer.Name == "GISWRKS1.WORKS.VLS_Points")
{
//Need to get the layer as a FeatureClass to do stats
FeatureClass vlsFC = vlsLayer.GetFeatureClass();
FeatureClassDefinition fcd = vlsFC.GetDefinition();
//Setup the the fields and Statistics Description
Field fldVLS_NO_1 = fcd.GetFields().First(x => x.Name.Equals("VLS_NO_1"));
StatisticsDescription vlsMaxDesc = new StatisticsDescription(fldVLS_NO_1, new List<StatisticsFunction>() { StatisticsFunction.Max });
TableStatisticsDescription tsd = new TableStatisticsDescription(new List<StatisticsDescription>() { vlsMaxDesc });
IReadOnlyList<TableStatisticsResult> vlsStatsResult = vlsFC.CalculateStatistics(tsd);
//Get the stat you are looking for
int vlsMax = (int)vlsStatsResult.First().StatisticsResults.First().Max + 1;
//Edit fields in the VLS with the new #
inspector["VLS_NO_1"] = vlsMax;
inspector["VLS_NO"] = vlsMax.ToString();
switch (inspector["SETTLEMENTAREA"].ToString())
{
case "AJAX":
settlementArea = "AJA";
vlsFolder = "AJAX";
break;
case "BLACKSTOCK":
settlementArea = "BKSTK";
vlsFolder = "CLARINGTON";
break;
case "BEAVERTON":
settlementArea = "BROBE";
vlsFolder = "BROCK";
break;
case "CANNINGTON":
settlementArea = "BROCA";
vlsFolder = "BROCK";
break;
case "SUNDERLAND":
settlementArea = "BROSL";
vlsFolder = "BROCK";
break;
case "BOWMANVILLE":
settlementArea = "CLB";
vlsFolder = "CLARINGTON";
break;
case "COURTICE":
settlementArea = "NEWCT";
vlsFolder = "CLARINGTON";
break;
case "NEWCASTLE":
settlementArea = "NEWNE";
vlsFolder = "CLARINGTON";
break;
case "ORONO":
settlementArea = "NEWOR";
vlsFolder = "CLARINGTON";
break;
case "NEWTONVILLE":
settlementArea = "NEWTON";
vlsFolder = "CLARINGTON";
break;
case "OSHAWA":
settlementArea = "OSH";
vlsFolder = "OSHAWA";
break;
case "PICKERING":
settlementArea = "PIC";
vlsFolder = "PICKERING";
break;
case "SCUGOG":
settlementArea = "SCU";
vlsFolder = "SCUGOG";
break;
case "GREENBANK":
settlementArea = "SCUGB";
vlsFolder = "SCUGOG";
break;
case "PORT PERRY":
settlementArea = "SCUPP";
vlsFolder = "SCUGOG";
break;
case "UXBRIDGE":
settlementArea = "UXB";
vlsFolder = "UXBRIDGE";
break;
case "UXVILLE":
settlementArea = "UXB";
vlsFolder = "UXBRIDGE";
break;
case "WHITBY":
settlementArea = "WHI";
vlsFolder = "WHITBY";
break;
case "BROOKLIN":
settlementArea = "WHIBR";
vlsFolder = "WHITBY";
break;
case "SEATON":
settlementArea = "PICSEA";
vlsFolder = "PICKERING";
break;
default:
settlementArea = "ERROR";
break;
}
inspector["FILENAME"] = settlementArea + vlsMax.ToString() + ".pdf";
inspector["COMMENTS"] = @"G:\OPERATIO\Data Systems Management\Valve Location System\PDF\" + vlsFolder + @"\" + settlementArea + vlsMax.ToString() + ".pdf";
inspector["DWGMXD"] = @"http://cctvweb/cctv/VLS/PDF/" + vlsFolder + @"\" + settlementArea + vlsMax.ToString() + ".pdf";
}
#endregion
if (isMainOperation)
{
editOperation.Modify(inspector);
bool result = editOperation.Execute();
//change the flag so we use the ChainedOp next
isMainOperation = false;
}
else
{
chainedOp = editOperation.CreateChainedOperation();
//queue up a Modify
chainedOp.Modify(inspector);
chainedOp.Execute();
}
//Increase the feature count for the final tally
featureCount++;
}
else
{
rejectedCount++;
}
} //go to next selected feature in current layer
} //end of if (currentLayer.SelectionCount > 0 && facID_field == true)
} //Go to the next layer in the map
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(featureCount.ToString() + " FacilityID's created. " + rejectedCount + " features already had FacilityID's.", "Process Complete");
}); //end of QueuedTask
}
catch (Exception ex)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(ex.ToString());
}
finally
{
}
}
//This does a SpatialQuery using the current feature point and a layer to get the intersecting field value
public string GetIntersectingField(MapPoint point, string fieldName, FeatureLayer sourceLayer)
{
try
{
SpatialQueryFilter spatialFilter = new SpatialQueryFilter();
spatialFilter.FilterGeometry = point;
spatialFilter.SpatialRelationship = SpatialRelationship.Intersects;
spatialFilter.SubFields = fieldName;
string fieldValue = "";
int i = 0;
RowCursor gridCursor = sourceLayer.Search(spatialFilter);
Feature feature;
while (gridCursor.MoveNext())
{
using (feature = (Feature)gridCursor.Current)
{
int fieldPosition = feature.FindField(fieldName);
fieldValue = feature[fieldPosition].ToString();
i++;
}
}
//if CONTRACTNO and more than one intersecting boundary, then show a message box and populate field with nothing
if ((fieldName == "CONTRACTNO") && (i > 1))
{
fieldValue = null;
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("There is more than one intersecting Contract Boundary for ??. Please enter this field in manually.", "Contract Number");
}
//if fieldName = NAME and it is blank, then find the SettlementArea by looking at the LocalMunicipality layer
if ((fieldName == "NAME") && (fieldValue == ""))
fieldValue = GetIntersectingField(point, "LOCALMUNICIPALITY", localMunicipalityLayer);
//set the gridNumber so we can use it again when we create the FACILITYID
if (fieldName == "GRIDNO")
gridNumber = fieldValue;
return fieldValue;
}
catch (Exception ex)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(ex.ToString());
return null;
}
}
//This will return the next FacilityID
public string GetNextFacilityID(FeatureClass fClass, string gridNum)
{
try
{
QueryFilter queryFilter = new QueryFilter();
queryFilter.WhereClause = "GRIDNO ='" + gridNum + "'";
queryFilter.SubFields = "SEQUENCENO";
//create an array to hold all of the SEQUENCENO; give it's first member the value zero
ArrayList idList = new ArrayList();
idList.Add(int.Parse("0"));
RowCursor rCursor = fClass.Search(queryFilter);
Feature feature;
while (rCursor.MoveNext())
{
using (feature = (Feature)rCursor.Current)
{
int sequencePosition = feature.FindField("SEQUENCENO");
idList.Add(Convert.ToInt32(feature[sequencePosition]));
}
}
//sort the list so we can get the highest value of SEQUENCENO
idList.Sort();
//the next # we want is the current highest number + 1
int number = (int)idList[idList.Count - 1] + 1;
sequenceNumber = number;
//convert it to a string so we can add the zero placeholders to the front of it....it needs to be 4 digits.
string finalNum = number.ToString();
switch (finalNum.Length)
{
case 1:
finalNum = "000" + finalNum;
break;
case 2:
finalNum = "00" + finalNum;
break;
case 3:
finalNum = "0" + finalNum;
break;
}
//return the full facility id, with the STRUCTURETYPE, GRIDNO, and SEQUENCENO
return structureType + "-" + gridNumber + "-" + finalNum;
}
catch (Exception ex)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(ex.ToString());
return null;
}
}
//This will return the StructureTypeCode for a layer
public string GetFeatureClassCode(Layer layer)
{
switch (layer.Name)
{
case "GISWRKS1.WORKS.SAN_Chamber":
return "SCH";
case "GISWRKS1.WORKS.SAN_Fitting":
return "SFT";
case "GISWRKS1.WORKS.SAN_Manhole":
return "MH";
case "GISWRKS1.WORKS.SAN_ControlValve":
return "SCV";
case "GISWRKS1.WORKS.SAN_ReliefValve":
return "SRV";
case "GISWRKS1.WORKS.SAN_InletOutletStructure":
return "IO";
case "GISWRKS1.WORKS.SAN_WWTFacility":
return "WTP";
case "GISWRKS1.WORKS.SAN_WWTFeature":
return "WWTF";
case "GISWRKS1.WORKS.SAN_PumpingStation":
return "SPS";
case "GISWRKS1.WORKS.SAN_Cleanout":
return "SCO";
case "GISWRKS1.WORKS.SAN_ServicePoint":
return "SPS"; //SAME AS SAN_PUMPINGSTATION
case "GISWRKS1.WORKS.SAN_SystemMeter":
return "SMTR"; //MISSING CODE IN GISWRKS1.WORKS.STRUCTTYPECODE
case "GISWRKS1.WORKS.ForceMain":
return "FM";
case "GISWRKS1.WORKS.GravitySewer":
return "SL";
case "GISWRKS1.WORKS.SAN_SewerService":
return "SSL";
case "GISWRKS1.WORKS.VLS_Points":
return "VLS";
case "GISWRKS1.WORKS.WAT_SystemMeter":
return "MTR";
case "GISWRKS1.WORKS.WAT_ServicePoint":
return "SP";
case "GISWRKS1.WORKS.WaterSupplyFacility":
return "WSP";
case "GISWRKS1.WORKS.WAT_PumpingStation":
return "WPS";
case "GISWRKS1.WORKS.WAT_TestStation":
return "TST";
case "GISWRKS1.WORKS.WAT_ControlValve":
return "WCV";
case "GISWRKS1.WORKS.WAT_ReliefValve":
return "WRV";
case "GISWRKS1.WORKS.WAT_Hydrant":
return "HYD";
case "GISWRKS1.WORKS.WAT_Fitting":
return "WFT";
case "GISWRKS1.WORKS.WaterMain":
return "WM";
case "GISWRKS1.WORKS.WaterService":
return "WSL";
case "GISWRKS1.WORKS.WAT_StorageFacility":
return "WST";
case "GISWRKS1.WORKS.WAT_Feature":
return "WF";
case "GISWRKS1.WORKS.WAT_Drainpipe":
return "DRNP";
case "GISWRKS1.WORKS.WAT_BulkFillingStation":
return "BFS";
case "GISWRKS1.WORKS.ssCleanOut":
return "STCO";
case "GISWRKS1.WORKS.ssLateralPoint":
return "LP";
case "GISWRKS1.WORKS.ssSystemValve":
return "SV";
case "GISWRKS1.WORKS.ssControlValve":
return "CV";
case "GISWRKS1.WORKS.ssMeter":
return "ME";
case "GISWRKS1.WORKS.ssPump":
return "PMP";
case "GISWRKS1.WORKS.ssCatchBasin":
return "SCB";
case "GISWRKS1.WORKS.ssFitting":
return "SSFT";
case "GISWRKS1.WORKS.ssMaintenanceHole":
return "STMH";
case "GISWRKS1.WORKS.ssInletOutlet":
return "SIO";
case "GISWRKS1.WORKS.ssLateralLine":
return "SLL";
case "GISWRKS1.WORKS.ssPressurizedMain":
return "SPM";
case "GISWRKS1.WORKS.ssGravityMain":
return "STM";
case "GISWRKS1.WORKS.Clearwell":
return "CW";
case "GISWRKS1.WORKS.Pump":
return "PU";
case "GISWRKS1.WORKS.ssStormNetworkStructure":
return "SNS";
case "GISWRKS1.WORKS.ssStormService":
return "SSL";
case "GISWRKS1.WORKS.SAN_Eff_ControlValve":
return "EFCV";
case "GISWRKS1.WORKS.SAN_Eff_Fitting":
return "EFFT";
case "GISWRKS1.WORKS.SAN_Eff_Hydrant":
return "EFHYD";
case "GISWRKS1.WORKS.SAN_Eff_Watermain":
return "EFWM";
case "GISWRKS1.WORKS.SAN_Eff_WaterService":
return "EFWSL";
case "GISWRKS1.WORKS.TBM_Chamber":
return "TBM";
case "GISWRKS1.WORKS.TBM_Chamber_poly":
return "TBM";
default:
return null;
}
}
}
}
... View more
12-08-2020
09:56 AM
|
0
|
0
|
3240
|
|
POST
|
Hi Wolf, No, there is nowhere in my code where I am doing anything with the object. I have been messing around, checking for the broken layer in different way, but I always get a NullReference error. Since I also need to check for joined tablets, I am using the BasicFeatureLayer object which also uses .ConnectionStatus, but still the same problem. Can you post your code you are using and I will try that?? Here is mine below, all running in a QueuedTask. The error happens right at the start of the first If statement. foreach (Layer layer in map.GetLayersAsFlattenedList().OfType<FeatureLayer>())
{
var currentLayer = map.FindLayers(layer.Name).FirstOrDefault() as BasicFeatureLayer;
if (currentLayer.ConnectionStatus == ConnectionStatus.Broken)
{ //THE ERROR HAPPENS HERE!!!!!
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(currentLayer.Name.ToString() + " has a missing data source. Please remove or fix this layer before continuing.", "Missing Data Source");
return;
}
if ((currentLayer.GetTable().IsJoinedTable() == true) && (currentLayer.SelectionCount > 0))
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(currentLayer.Name.ToString() + " has a joined table. Please remove any joins before continuing.", "Joined table detected");
joinExists = true;
}
} In Debug mode it seems like the values are getting read properly, yet I still get the NullReference exception.
... View more
12-08-2020
08:00 AM
|
0
|
0
|
3253
|
|
POST
|
Hi Wolfgang, Just to follow up on this, I did work with esri Canada on this and the end result is that the TEST environment I was using must have some flaw in it. esri Canada also could not reproduce the issue, and after trying the exact same code in our PRODUCTION environment there were no issues. So I guess a rebuild of our TEST environment is in order, which should happen soon. Thanks for all your help with this.
... View more
12-04-2020
11:20 AM
|
0
|
0
|
844
|
|
POST
|
Hi, This is my first day in the 'new' community. In the 'old' community it was really easy to find your old posts. I think they showed up in 'My Content' (or something like that). Is there a way that I can see all of my old posts in the new community?? Thanks,
... View more
12-04-2020
11:08 AM
|
1
|
1
|
1006
|
|
POST
|
Hi Wolfgang, I am also using a FileGeodatabase. When I debug it gets past the first layer, which is "Connected", but on the second layer (the one with the missing data source), I get the exception below thrown. With mine, I am editing the name of the FeatureClass, not changing the folder name the FGDB sits in. Not sure if that would be the difference??
... View more
12-04-2020
08:36 AM
|
0
|
0
|
3303
|
|
POST
|
Hi, I'm using the following code to determine which layers in my project might have a missing data source, so that my code doesn't crash later and I can present the user with a message to fix the problem. But when I call Layer.ConnectionStatus I get a 'NullReference' exception. Which I guess makes sense, since the layer is missing the data source. Am I just not using the ConnectionStatus properly?? foreach (Layer layer in map.GetLayersAsFlattenedList().OfType<FeatureLayer>())
{
if (layer.ConnectionStatus == ConnectionStatus.Broken)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("SOME KIND OF ERROR MESSSAGE");
}
... View more
12-04-2020
06:54 AM
|
0
|
17
|
5885
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 04-14-2026 08:54 AM | |
| 2 | 08-18-2023 08:57 AM | |
| 1 | 04-19-2018 05:53 AM | |
| 1 | 04-13-2018 10:07 AM | |
| 1 | 04-13-2018 10:04 AM |
| Online Status |
Offline
|
| Date Last Visited |
04-14-2026
08:53 AM
|