SqlSiteMapProvider - OnSiteMapChanged event never fires? - asp.net

I'm doing the Wicked Code implementation of SqlSiteMapProvider, except in VB.NET.
There's a few things with the code that are causing issues, and I don't understand how it is supposed to work the way it's written in the article. I've provided the code straight from the article provided below. I've pasted the code here for ease of viewing
First issue - the depedency is instantiated BEFORE (lines 134-137) the tree is created (151-160) - so as soon as you add the depedency to the http.cache (165-167), the OnSiteMapChanged event (242) fires immmediately - making the entire proccess run again - and this loops many times until finally something makes it stop. (i stepped through it and counted the code looping at least 20 times before I gave up on trying to guess when it hit last)
OK, so to fix this I just moved the code to the create the dependency to AFTER the tree is built, right before inserting to http.cache (so HasChanged property is false when adding to http.cache, and you don't get stuck in this psuedo-ifinite-loop).
I still have a problem though - every time a page loads, the BuildSiteMap() hits and line 121 checks if _root is not null - it seems it is never null after it is first built... this is good because I don't want to hit the DB each time. Now, I insert a record into the table... the OnSiteMapChanged event never fires. As I browse pages on the app, the sitemap does not reflect the newly inserted record - stepping through the code, I see that the check at line 121 is still causing the function to short circuit... The sitemap will only refresh if i re-start Visual Studio, which causes the private _root field to become null again, and re-builds the sitemap, reflecting the new changes.. (refreshing the browser or starting new browser instances does not work)...
EDIT: THE ISSUE STEMMED FROM A SILLY 'SET NOCOUNT ON' LINE IN THE TOP OF MY STORED PROC. APPARENTLY THIS BREAKS THE QUERY NOTIFICATION. It seems that this statement is seen as a result set and that the second, actual query statement invalidates the result set resulting in a notification. This was very hard to find and nowhere in the MSDN documentation until I added the comment. Hope this saves someone else the miser I went through!

THE ISSUE STEMMED FROM A SILLY 'SET NOCOUNT ON' LINE IN THE TOP OF MY STORED PROC. APPARENTLY THIS BREAKS THE QUERY NOTIFICATION. It seems that this statement is seen as a result set and that the second, actual query statement invalidates the result set resulting in a notification. This was very hard to find and nowhere in the MSDN documentation until I added the comment. Hope this saves someone else the miser I went through!

Related

Table methods not working anymore

I have a table with different methods, for example, one of them is validateWrite, when setting Field A to value X, Field B and C has to be filled in.
Suddenly (without changing code, I have compared the code with the test enviroment, it does work there) the validateWrite has stopped working.
I have tried to recompile the table, but that did not work.
Any idea why it suddenly (without making other modifications in this enviroment, or generating a CIL) stopped working and what i can try to solve it?
If some piece of code is calling table.doInsert(), it skips the validateWrite() method.
If the environments are truly identical, then I would try closing your AX client and deleting your user caches (see http://dynamics-ax-live.blogspot.com/2010/03/more-information-about-auc-file.html) where you delete all of the *.auc files located at C:\Users\[Username]\AppData\Local
In addition to what that tells you to delete, I'd also remove the *.kti file and all of the files & folders inside of C:\Users\[UserName]\AppData\Local\Microsoft\Dynamics Ax
Then open AX, see if the problem still exists. Then full system compile, CIL build, and delete your usage data.
The preferred route though would be to just drop a breakpoint in and debug the code to see what the execution stack is.

XPages Dojo DataGrid and REST Service do not save editable columns changes

We have a REST Service and Dojo DataGrid that does not save the changes to editable columns on the initial load -- meaning the XPage loads and changes are made. The only way the changes are saved is after the close() or revert() method for the REST service is called, then the save() method is called. The REST Service is pointing to another database on the same server, and uses the keys property:
<xe:restService id="rsVictims" pathInfo="rsVictimsData">
<xe:this.service>
<xe:viewItemFileService defaultColumns="true"
viewName="InvoiceGridVictims" contentType="application/json"
databaseName="voca\vocadatastore.nsf" keys="k28ts71zrjsw">
</xe:viewItemFileService>
</xe:this.service>
</xe:restService>
Here is the DataGrid:
<xe:djxDataGrid id="djxDataGrid1" storeComponentId="rsVictims"
autoHeight="90">
<xe:djxDataGridColumn id="djxDataGridColumn1"
label="Target" width="35px" field="victimTarget">
</xe:djxDataGridColumn>
<xe:djxDataGridColumn id="djxDataGridColumn2"
label="Oct" width="35px" field="month_10" editable="true">
</xe:djxDataGridColumn>
</xe:djxDataGrid>
It flows like this:
Open the XPage with the REST service and DataGrid
Make changes to the editable columns
Click the Save button which calls this code (code is copied from Brad Balassaitis' demo, 06 Custom Control):
<xp:button value="Save Changes" id="victimsSaveButton">
<xp:eventHandler event="onclick" submit="false">
<xp:this.script><![CDATA[// Save the changes...
editedRows = [-1];
var args = {onError: function() {alert('error!');}};
rsVictims.save(args);
//Refresh the grid
rsVictims.close();
dijit.byId('#{id:djxDataGrid1}')._refresh();]]></xp:this.script>
</xp:eventHandler>
</xp:button>
DataGrid is closed, refreshed, but changes are NOT saved
Make changes again and click the Save button
DataGrid is closed, refreshed, and changes are now saved
What I have noticed is that the DataGrid is loaded twice when the XPage is opened -- I see this is Firebug in the Net tab. On the first GET, it retrieves the grid correctly -- the Response is correct, the JSON is formatted correctly, and the start=0 with a count=25.
On the second GET, it seems to lose the grid -- the Response is empty, the JSON items is empty, and the start=25 with the count=25. I have tried setting the start property in the REST Service to 0, but that does not do anything. I have tried setting the count property to 500 as well, but that does not fix it either.
The interesting fact about this is, when the view is moved inside the current database -- so the databaseName property on the REST Service is not used -- the Save button works perfectly. Also, there is only one GET when loading the DataGrid, not two GETs when pointing to a view in another database on the same server. I know there are some issues when looking to another server, but these databases are on the same server.
I know I have posted about this topic before, but I did not get an answer that worked. I am hoping this sheds some more light on what I may be missing.
Thanks in advance!
Dan,
I have nearly an identical situation in my current project. I have mine working perfect so I think I can help. I assume that you already took Per Lausten's suggestion in your previous SO. You wouldn't be able to save at all if you didn't.
The difference between your code and mine is that I am using a xe:viewJSONService instead of a xe:viewFileItemService. The extention library book says that you have to use the viewFileItem if you want it updatable, but this is NOT true.
I had nothing but trouble with the viewItemFileService, see this blog post for the issues I had (http://notesspeak.blogspot.com/2013/07/going-with-extjs-grid-and-giving-up-on.html) I nearly gave up entirely on the dojo grid, but came back to it because it works on mobile.
Using the viewJSONService just works. Instead of a keys property, use the category filter. For you category have code similar to this:
var category:String = lineItemBean.getThisUNID();
if(category == null){
return "show nothing"
} else {
return lineItemBean.getThisUNID();
}
//prevents all records from being returned
You need to be careful, because if the category is null, all records are returned, which could be a big problem or security hole. In my example, I pull from a bean, but you could put a document reference there as well.

Access Front MySql Back Runtime Error 7878

RunTime Error The Data has been changed.
I`m having a difficult time with one of my sub-forms. It used to work without complaints but I guess now it decided to be a little verbose. On this form I have a subform that has a variety of checkbox options. Whenever the user enters a checkbox option and then exits to the main form there is an On Exit Event which runs. It combines some textboxes from various forms and then puts that value in a textbox on the main form.
var1 = [Form1]![Textbox].Value
var2 = [Form2]![Textbox].Value
var3 = [Form3]![Textbox].Value
Me.[TextBox].Value = var1 & var2 & var3
For some reason upon exiting the subform I am getting the Runtime error.
The pattern is not apparent.
I can navigate from the subform to the main form without making any changes in either without receiving an error message.
If I go into the subform, make a change, exit the subform, the textbox will be updated with no complaint, however if I go back into the subform, do not make a change and then go back to the main form, then I get the runtime error
similarly after making sure that behavior 1 is true I can go into the subform, change something come back out, but if I try to go back into the subform and make an additional change I will get a complaint. (I was able to fix this by making an on enter event refresh the subform)
I am unable to get the Runtime Error fixed though... :(
I see that this is an issue for many people with no solution. Here was my work around.
From my observation the form that was having it's Textbox.value updated is somehow silently updated by either the on enter or on exit of it's subform so when the on exit action of updating that textbox occurs it complains that the main form was updated, thus leaving me to conclude that when that form is updated it is not shown to the user.
Thus, my work around is to requery the main form on the subform's exit in order to get that new data loaded and changed.
Caveat!! Requery will by default bring you back to the first record thus presenting the possibility of changing the textbox of the wrong record. Thus as part of the requerying process, if you choose this hack, you will have to bookmark the current open record, requery, and then fetch that record again. I used the code from this webpage in order to achieve the desired effect. Thus circumnavigating the 7878.
Requery and stay on record:
http://www.baldyweb.com/Requery.htm

how to use QTable::editCell()

I don't understand how QTable::editCell() should be used. I am trying to do some error checking based on entries made by user in a QTable as mentioned in my another question.
I would like to give user an opportunity to re-edit the cell which has error. For example, if name column entry has some special characters such as '(', the user should be prompted for the error and the control should go back to same cell in edit mode. I tried using QTable::editCell() in my code as shown below.
Table->editCell(row, 0, TRUE);
name = Table->text(row, 0);
However, this doesn't work as expected. The control doesn't stay in the cell at all and obviously the name is not correctly collected. So, my question is how to ensure from within code that a cell of QTable can be edited so that the edited contents can be accessed immediately in next statement (as shown in above code).
Note: I am working with qt 3.3.8 only.
I don't think you can do that. You'll have to go back to the event loop, and wait for one of the signals (like valueChanged(row,col)) to be fired to re-validate the data.
A blocking wait on a GUI object is often not a good approach (except for modal dialogs).
I know I'm a little late here but you should use the following connect statement with your own custom function to do your specific needs such as below. You can also use this method to disable users from entering in special characters within you custom function. That way they wont ever have to correct undesirable characters.
connect(ui->tableWidget, SIGNAL(cellChanged(int,int)), this, SLOT(customFunction(int,int)));
void updateTable
{
//remove invalid characters
}

"Failed to enable constraints" Error keeps cropping up (seemingly randomly) in my ASP.Net project

I have a weird problem where the "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." error sometimes pops up when I am trying to build my project.
The line in question throwing the error was auto-generated code in the designer file for the dataset. To find out the offending table, I used the following code:
Try
Me.Adapter.Fill(dataTable) <--Breakpoint here on the offending line
Catch ex As Exception
For Each TRow As DataRow In dataTable.Rows
If TRow.HasErrors Then
Trace.Write(TRow.RowError)
End If
Next
End Try
Funnily enough, as soon as I run the project after putting in the above code and breakpoint, the error disappears. I assume this has something to do with the code being regenerated. All data is presented successfully, and the project compiles without errors.
However, this has happened often enough for me to frustrate me. Anybody know what might be causing the error and how I can isolate it?
What unique constraint are you placing on the datatable and have you verified that the data your passing in doesn't have any duplicates? If this is coming from a shared database perhaps someone else is modifying the data which could be causing the randomness.
Edit
If that code is exactly as what you have (And forgive me my vb.net is not as strong as my C#). Wouldn't it swallow the exception? In C# we need to rethrow the error.
Add a Trace.Write() right before you go into your for loop.
You are probably working with a typed dataset, or have some code configuration on it. Also you might be reading from one table, and then adding data from another.
In any of those cases, you really want to look into any inconsistencies between the schema. If it is a typed dataset / or configured in code, check its definition, and look for anything different from the sql table. If you are reading from 2 different tables, check the definition of both tables.
Figured it out finally!
The reason the breakpoint wasn't being hit was because the code in question was auto-generated, and had the attribute "DebuggerNonUserCodeAttribute". In addition, in my VS settings, I had set the debugger to "Just my code".
When I ran the code again, and the breakpoint wasn't hit, I noticed the breakpoint icon had changed to a warning. Hovering showed this:
"The breakpoint will currently not be hit. Breakpoints cannot be set in a method or class with the 'DebuggerNonUserCode' attribute when the debugger option 'Just My Code' is enabled."
Ouch!
Once I had removed the "Just My Code" debugging option, the breakpoint was hit, and I discovered that one of the rows had a NULL value in one of the columns which had a non-null constraint. Stupid ole' me!
You should use this code before you fill DataTable :
var dt = new System.DataTable.DataTable();
dt.Clear();
dt.Rows.Clear();
dt.Columns.Clear();

Resources