POST
|
Hi there, I got NullReferenceException Error when I tried to delete selected point. In my code: (1) check the status of the selected point (2) move it to the history layer (3) delete the point from live layer The whole function is shown below: Public Sub RemovePt(ByVal lpCreatWS As IWorkspace, ByVal lpFeatureLayer As IFeatureLayer, ByVal lpHistLyrName As String, ByVal lsFldName As String, ByVal lsLayerName As String, ByVal lpFeatCursor As IFeatureCursor, ByVal lbIsHor As Boolean) Dim lbIsPtDead, lbIsPtNull As Boolean Dim lbIsHistValuesInserted As Boolean Dim liSuccessFulDeletedPoint As Integer Dim liUnSuccessFulDeletedPoint As Integer Dim lsPtStatus As String Dim lsParentVersionName As String Dim lpObjGenClass As New clsGeneralClass Dim lpVerFC As IFeatureClass Dim lpObjSDEUtils As New clsSdeUtils Dim lpHistFeatureClass As IFeatureClass Dim lpVerFeat As IFeature Dim lpHistFeat As IFeature Dim lpFeature As IFeature Dim lpObjGeneralClass As New clsGeneralClass Dim lpCreatVer As IVersion Dim lpVersionEdit As IVersionEdit Dim lpWorkSpaceEdit As IWorkspaceEdit 'Get the Deafault Version lpCreatVer = lpCreatWS lpCreatVer.RefreshVersion() 'get the Version Edit lpVersionEdit = lpCreatWS 'Get the WS to be edited lpWorkSpaceEdit = lpCreatWS Try 'Iterate through the selected features in the Layer lpFeature = lpFeatCursor.NextFeature 'Delcare the new Collection Object gcolPtStatus = New Collection 'Start Editing Operation lpWorkSpaceEdit.StartEditing(True) Do Until lpFeature Is Nothing Call CheckPtStatus(lpFeature, lbIsPtDead, lbIsPtNull) 'Make the Status DEAD lpVerFC = lpObjSDEUtils.GetFeatureClass(lpCreatWS, lsLayerName) lpVerFeat = lpVerFC.GetFeature(lpFeature.OID) ' ==================== I can get the lpFeature.OID, but get error this line 'If Point Stauts is Live If lbIsPtDead = False And lbIsPtNull = False Then 'Check if Point History FeatureLayer is not Nothing If gpHistoryClass Is Nothing Then 'If Nothing,Get the Pt History layer lpHistFeatureClass = lpObjSDEUtils.GetFeatureClass(lpCreatWS, lpHistLyrName) End If 'Create a new History Class feature lpHistFeat = lpHistFeatureClass.CreateFeature lpHistFeat.Shape = lpFeature.Shape 'Insert the history feature values lbIsHistValuesInserted = lpObjGeneralClass.InsertValues(lpFeature, lpHistFeat) If lbIsHistValuesInserted = False Then 'Donot save the editing operations lpWorkSpaceEdit.StopEditing(False) 'Make the Collection Nothing gcolPtStatus = Nothing Exit Sub End If 'Update Point Status Call UpdatePtStatus(lpVerFeat) 'Frame the Control Point Status lsPtStatus = lpVerFeat.Value(lpVerFeat.Fields.FindField(lsFldName)) & " " & ": Deleted Successfully" 'Get the Count of Successfully Deleted Pt's liSuccessFulDeletedPt = liSuccessFulDeletedPt + 1 ElseIf lbIsPtDead = True And lbIsPtNull = False Then 'Frame the Control Point Status lsPtStatus = lpVerFeat.Value(lpVerFeat.Fields.FindField(lsFldName)) & " " & ": Error in Deleting (Already Dead)" 'Get the Count of UnSuccessfull Deleted Pt's liUnSuccessFulDeletedtP = liUnSuccessFulDeletedPt + 1 ElseIf lbIsPtDead = False And lbIsPtNull = True Then 'Frame the Control Point Status lsPtStatus = lpVerFeat.Value(lpVerFeat.Fields.FindField(lsFldName)) & " " & ": Error in Deleting (Status Null)" 'Get the Count of UnSuccessfull Deleted Pt's liUnSuccessFulDeletedPt = liUnSuccessFulDeletedPt + 1 End If 'Add to the Collection gcolPtStatus.Add(lsPointStatus) 'Iterate through the next feature lpFeature = lpFeatCursor.NextFeature Loop 'Chech if the Created version has parent If lpCreatVer.HasParent Then lsParentVersionName = lpCreatVer.VersionInfo.Parent.VersionName Else MsgBox("You can only reconcile a version that has a parent.") End If 'Get the SDE Default's Latest Version 'lpVersionEdit.Reconcile(lsParentVersionName) lpCreatVer.RefreshVersion() lpVersionEdit.Reconcile(lsParentVersionName) If lpVersionEdit.CanPost Then lpVersionEdit.Post(lsParentVersionName) End If 'StopEditing Operation lpWorkSpaceEdit.StopEditing(True) lpVersionEdit.RefreshVersion() 'Display the Log File WriteLogFile(liSuccessFulDeletedPt, liUnSuccessFulDeletedPt, lbIsHor) 'Refresh the Version Catch ex As Exception 'On Error, Display Error Message MsgBox("Error occured in remove control point(s) ") 'Donot save the editing operations lpWorkSpaceEdit.AbortEditOperation() lpWorkSpaceEdit.StopEditing(False) 'Make the Collection Nothing gcolPtStatus = Nothing Finally 'Release the Objects lpVerFC = Nothing lpCreatVer = Nothing lpVersionEdit = Nothing lpFeature = Nothing lpHistFeat = Nothing lpHistFeatureClass = Nothing lpFeatCursor = Nothing lpObjSDEUtils = Nothing lpObjGenClass = Nothing lpWorkSpaceEdit = Nothing AutoReleaseCom(lpVerFC) AutoReleaseCom(lpCreatVer) AutoReleaseCom(lpVersionEdit) AutoReleaseCom(lpFeature) AutoReleaseCom(lpHistFeat) AutoReleaseCom(lpHistFeatureClass) AutoReleaseCom(lpFeatCursor) AutoReleaseCom(lpWorkSpaceEdit) AutoReleaseCom(lpObjSDEUtils) AutoReleaseCom(lpObjGeneralClass) End Try End Sub thing may cause the error? thanks Any
... View more
08-24-2015
09:04 PM
|
0
|
1
|
2719
|
POST
|
Hi there, I need to export arcsde feature layer to mdb table, but I need to change the vertex xy value (2 decimals and need to run down on the 3rd value. What I can do now is set th xy resolution to 0.01, but by using this method if the 3rd decimal is 5-9, the 2nd decimal will add 1, what I want is no matter what is the 3rd decimal value, just remove it). I am using .net arcobjects 9.2. Is it possible to get the result I want? Thanks in advance.
... View more
08-24-2015
12:15 AM
|
0
|
1
|
2575
|
POST
|
Hi Mody, Thank you for the reminding. I will put it in the arcobjects part. Currently my problem is how can I get the xy value for all vertex before I perform further calculation.
... View more
08-24-2015
12:07 AM
|
0
|
1
|
446
|
POST
|
Hi there, I need to export arcsde feature layer to mdb table, but I need to change the vertex xy value (2 decimals and need to run down on the 3rd value. What I can do now is set th xy resolution to 0.01, but by using this method if the 3rd decimal is 5-9, the 2nd decimal will add 1, what I want is no matter what is the 3rd decimal value, just remove it). I am using .net arcobjects 9.2. Is it possible to get the result I want? Thanks in advance.
... View more
08-23-2015
06:23 PM
|
0
|
3
|
2957
|
POST
|
Hello Robert, Finally realize I am so stupid, I put what I want to reload in init(), which should in sharedDataUpdated and sharedDataUpdated2, thank you so much for the sharing.
... View more
01-09-2015
01:34 AM
|
0
|
0
|
308
|
POST
|
Thank you so much Robert. Now my related code is: AppEvent.addListener(AppEvent.DATA_NEW_PUBLISHED,sharedDataUpdated); AppEvent.addListener(AppEvent.DATA_SENT,sharedDataUpdated2); fetchSharedData(); private function sharedDataUpdated(event:AppEvent):void { var dataTable:Hashtable = event.data.data as Hashtable; if (dataTable.containsKey("QueryState")) { var recAC:ArrayCollection = dataTable.find("QueryState") as ArrayCollection; var obj:Object = recAC[0]; getSqlQuery = obj.sql; dataTable.remove("QueryState"); } } private function sharedDataUpdated2(event:AppEvent):void { var dataTable:Hashtable = event.data as Hashtable; if (dataTable.containsKey("QueryState")) { var recAC:ArrayCollection = dataTable.find("QueryState") as ArrayCollection; var obj:Object = recAC[0]; getSqlQuery = obj.sql; dataTable.remove("QueryState"); } } But the result still the same, only pass the parameter at the first time. Want to cry.
... View more
12-21-2014
05:44 PM
|
0
|
0
|
308
|
POST
|
Thank you Robert for the clarification, unfortunately I still cannot get it worked. I still have something to confirm: (1) I the widget B init() function, should I use: AppEvent.addListener(AppEvent.DATA_PUBLISH, sharedDataUpdated); AppEvent.addListener(AppEvent.DATA_NEW_PUBLISHED, sharedDataUpdated2); OR use: AppEvent.addListener(AppEvent.DATA_NEW_PUBLISHED, sharedDataUpdated2); AppEvent.addListener(AppEvent.DATA_SENT, sharedDataUpdated2); (2) The 2 methods: private function sharedDataUpdated(event:AppEvent):void { var data:Object = event.data; if (data.key == "QueryState") { var theObj:Object = data.collection[0]; getSqlQuery = theObj.sql; } } private function sharedDataUpdated2(event:AppEvent):void // DATA_NEW_PUBLISHED { var dataTable:Hashtable = event.data.data as Hashtable; if (dataTable.containsKey("QueryState")) { var recAC:ArrayCollection = dataTable.find("QueryState") as ArrayCollection; var theObj:Object = recAC[0]; getSqlQuery = theObj.sql; } } The fact is if I use var data:Object = event.data.data; I can get the shared data. But if I use var dataTable:Hashtable = event.data.data as Hashtable; I can't get the shared data, in this case cause error. So sorry for the trouble caused, thanks a lot! It is so strange that I can add code in the edit view but it is messy after I publish it (there is no tab before the code). Seems I am so stupid.
... View more
12-17-2014
05:42 PM
|
0
|
3
|
308
|
POST
|
Hi Robert, Is the function of sharedDataUpdated and sharedDataUpdated2 exactly the same? I have modified my code according to your answer. The surprise thing is when I use event.data.data instead of event.data, it will cause error and the shared string not pass to the other widget. So sorry to trouble you again, thousands of thanks.
... View more
12-16-2014
05:39 PM
|
0
|
5
|
693
|
POST
|
Hi Robert, So sorry I haven't found how to add an attachment, hence I post the code below (also cannot find how to post in code made, SearchCustomer.mxml public static var queryStr:String; public function customerInputEvent():void { queryStr = "SELECT CUSTOMER_NAME, CUSTOMER_IC, CUSTOMER_EMAIL, CUSTOMER_ADDRESS, CUSTOMER_INTEREST FROM dbo.CUSTOMER WHERE "; if(userName.text){ queryStr = queryStr + " CUSTOMER_NAME= '" + userName.text + "'" } if (userIC.text){ if (!userName.text){ queryStr = queryStr + " CUSTOMER_IC= '" + userIC.text + "'" }else{ queryStr = queryStr + " and CUSTOMER_IC = '" + userIC.text + "'" } } if (userEmail.text){ if ((!userName.text) && (!userIC.text)){ queryStr = queryStr + " CUSTOMER_EMAIL = " + userEmail.text }else{ queryStr = queryStr + " and CUSTOMER_EMAIL = " + userEmail.text } } if (userAddress.text){ if ((!userName.text) && (!userIC.text) && (!userEmail.text)){ queryStr = queryStr + " CUSTOMER_ADDRESS = '" + userAddress.text + "'" }else{ queryStr = queryStr + " and CUSTOMER_ADDRESS = '" + userAddress.text + "'" } } trace("sql Query to be passed to result widget = " + queryStr); // share data var queryArr:ArrayCollection = new ArrayCollection(); var queryConfig:Object = { sql: String(queryStr) }; queryArr.addItem(queryConfig); addSharedData("QueryState", queryArr); var widgetId:Number = ViewerContainer.getInstance().widgetManager.getWidgetId("Customer Result"); AppEvent.dispatch(AppEvent.WIDGET_RUN, widgetId); this.setState("closed"); } } CustomerResult.mxml import widgets.Customer.SearchCustomer.SearchCustomer; public var getSqlQuery:String; public function init():void { AppEvent.addListener(AppEvent.DATA_PUBLISH, sharedDataUpdated); AppEvent.addListener(AppEvent.DATA_SENT, sharedDataUpdated2); fetchSharedData(); Alert.show("query get from customer input = " + getSqlQuery); webservice.CustomerDetail(getSqlQuery); } private function sharedDataUpdated(event:AppEvent):void { var data:Object = event.data; if (data.key == "QueryState") { var theObj:Object = data.collection[0]; getSqlQuery = theObj.sql; } } private function sharedDataUpdated2(event:AppEvent):void { var dataTable:Hashtable = event.data as Hashtable; if (dataTable.containsKey("QueryState")) { var recAC:ArrayCollection = dataTable.find("QueryState") as ArrayCollection; var theObj:Object = recAC[0]; getSqlQuery = theObj.sql; } } public function CustomerDetail(event:ResultEvent):void { CustomerDetail.dataProvider = event.result; } public function fault(event:FaultEvent):void { Alert.show(event.toString()); } Thank you very much in advance.
... View more
12-16-2014
02:13 AM
|
0
|
8
|
693
|
POST
|
Hello Robert, I have an urgent meeting now, will post the source code as long as I am back, thank you!
... View more
12-15-2014
08:15 PM
|
0
|
0
|
693
|
POST
|
Hi Robert, So happy to get response from you. I use exact the same code as in your answer (11th reply in the reference link). If I use 1 listener (sharedDataUpdated) only, it never pass the parameter to the other widget. Don't know what is wrong.
... View more
12-15-2014
05:49 PM
|
0
|
11
|
693
|
POST
|
Hi, I follow the link to share data between widgets : https://community.esri.com/thread/34393 But I can only pass the shared data the first time. I have Input.widget (widget A) and Records.widget(widget B), and shared object pass from widget A to widget B. The first time I open widget A and click "OK" button, the data pass to widget B, widget A closed and widget B opened and init() of widget B called. But the second time when I open widget A and click "OK" button,widget A closed and widget B opened, but the init() function in widget B not called. It is because I haven't release widget B when it is reload? How can I solve the issue? Sorry for the poor English, thank you in advance.
... View more
12-14-2014
08:52 PM
|
0
|
13
|
5240
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|