Concurrency, NULLs and Custom properties.


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
This is likely because I don't fully understand how the concurrency handler works, but I'm having trouble with two issues related to concurrency:



1. I have a table that has several date fields in it. These fields can all be NULL, because the dates can be NOT set. I have a SetDefaultValues handlers that provides my NULL replacement date for them. All is fine...until I have a concurrency conflict (I'm using row version concurrency). If one of the conflicting fields is a date and one of the values of that field is NULL, I get a type conversion error. How do I handle NULLs in this case?



2. Same form (hitting same table) also has a couple of custom properties defined. These properties get their data from some extra columns that might be available when the BO is filled. I check if the column exists before attempting to get the value and if the data table doesn't have the column, I return a default. This works great. However, with concurrency again, when there is a conflict, I'm getting an error that one of these custom fields isn't in "Table1" (default table name of a table in a data set I assume). Apparently, the concurrency handler is accessing this custom field, but not using my custom getter, somehow going directly to the data table. Any ideas on how to handle this better ( Unsure er...at all)?



I'm trying to release this into production, so this is fairly urgent!



Thanks!
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
More info. The type conversion exception occurs if server value is NULL and the local value isn't. It occurs in the BuildFieldCollisions method.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Bump...this is kind of urgent, any help would be appreciated! Thanks!
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I've looked into this a lot more. I'm thinking that there is a "bug" in the BuildFieldCollisions method in DataLayer, in that it can't handle NULLs (at least for dates).



There are definitely situations were the best choice is to have a NULL value in the database for a date. This means the date hasn't been set. I have a deliverables table with a delivery date. Until the deliverable is actually delivered, there should be NO delivery date. It should be NULL. Also, a reporting tool will be used to report on this table. The users can build their own reports. This means that either:



- I have to train users to use 1/1/1800 if they want a date that isn't set

- I have to somehow embedd this in the reporting tool, which means if it ever changes, I have to remember to change it in two places.



So, I really think BuildFieldCollisions should be able, some how, to handle NULLs.



BTW, I found the RetrieveConcurrencyRowHandler property on BusinessLayer and this can be used to massage the server row so there are no nulls, but I don't see any way to fix the current, local row, without ending up actually saving my alternate value into the db. Maybe I'm missing something.... Blink



Finally, I'm starting to think that the issue with the custom field property is some weirdness on one of my tester/users machines. The custom field should never be checked (as near as I can tell) based on the code (it uses the server row, which normally won't include any additional custom rows). However, I'd really like confirmation on this or any other concurrency issues I might need to deal with when using custom fields.



Thanks!
StrataFrame Team
S
StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
OK, looking at the code, it wouldn't take much to check on whether either of the values was DBNull.Value within the BuildFieldCollisions method.

As for the problem of the column not existing in "Table1" I'm not sure on that one.  Does the stack trace on that error indicate that it's coming from BuildFieldCollisions as well?  Or is something else causing the error?  That method does iterate over the server's rows and only check the columns that match up with the local columns, so, I'm not sure where that one's coming from.  Could you send the stack trace for the exception?

As for the NULL issue, I can get that one fixed.  From what I understand, we'll be releasing a new 1.6.6 build (probably non-beta) next week, and I can include it.  Get me the other stack trace, and we'll fix the second one, too Smile

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Thanks for the reply Ben...beginning to wonder if anyone was alive! Tongue



Excellent on the fix to support NULLs. Looking forward to it! BigGrin



OK, on the vendor ID issue (a custom field), something weird is going on. Here's the stack trace:



BusinessLayerException

An error occurred while saving an the data to the server.

DataLayerSavingException

Column 'VendorID' does not belong to table Table1.

ArgumentException

Column 'VendorID' does not belong to table Table1.



Source : MicroFour StrataFrame Business



Stack Trace:

at System.Data.DataRow.GetDataColumn(String columnName)

at System.Data.DataRow.get_Item(String columnName)

at MicroFour.StrataFrame.Data.DataLayer.ApplyCollisionDecisionToRow(RowCollision Collision, DataRow LocalRow, DataRow ServerRow, Boolean IsUpdate)

at MicroFour.StrataFrame.Data.DataLayer.HandleConcurrencyException(DataRow LocalRow)

at MicroFour.StrataFrame.Data.SqlDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand)

at MicroFour.StrataFrame.Data.DbDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler)

at MicroFour.StrataFrame.Data.Enterprise.EnterpriseDataSourceItem.UpdateRow(QueryInformation QueryInfo, DataRow RowToUpdate, ConcurrencyExceptionHandler ConcurrencyHandler, AddRowErrorHandler RowErrorHandler, Boolean RecreateCommand)

at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTableThread(Object ThreadParams)

at MicroFour.StrataFrame.Data.DataLayer.UpdateDataTable(DataTable TableToUpdate, Boolean Transactional, String TransactionKey)

at MicroFour.StrataFrame.Data.DataLayer.SaveByForm(DataTable TableToSave, Boolean Transactional, String TransactionKey)

at MicroFour.StrataFrame.Business.BusinessLayer.SaveByForm(Boolean Transactional, String TransactionKey)

at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save(Boolean Transactional, String TransactionKey)

at MicroFour.StrataFrame.UI.Windows.Forms.BaseForm.Save()

at MicroFour.StrataFrame.UI.Windows.Forms.MaintenanceFormToolStrip.cmdSave_Click(Object sender, EventArgs e)

at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)

at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)

at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)

at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)

at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)

at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)

at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

at System.Windows.Forms.ToolStrip.WndProc(Message& m)

at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)

at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)

at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)




It is important to note that the soft collision dialog is NOT presented with this error. Click save...boom error occurs.



Also, VendorID is a custom READONLY field in the BO.



Finally, this is not happening on all machines. It either very reliably works or very reliably fails. We've tried reinstalling our app and .NET with no effect. I'm stumped... Crazy
StrataFrame Team
S
StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Aha, the ApplyCollisionDecisionToRow method goes through a different loop when it starts to copy over the values of the colisions back to the business object.  That tells me where to fix it.  Thanks.

We'll let you know when the update is available.

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Thanks Ben!
StrataFrame Team
S
StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)StrataFrame Developer (4.4K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
OK, Greg, the update is posted to the updates thread.

http://forum.strataframe.net/FindPost19412.aspx

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Ben,



Is should I use the update or is this in the official 1.6.6 release?
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search