StrataFrame Forum

Big bug is BusinessObject!!

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

By dgsoft - 2/28/2011

Hi,

For me it seems there is a big bug for businessobject code.

Look there:

Businesslayer.vb IsDirty property




<Browsable(False), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public ReadOnly Property IsDirty() As Boolean

Get
If Me._IsSavedOnTransaction
Then Return False

Else
Return ChangesExistOnCurrentDataTable()
End If
End Get


End Property




So, getter return me always FALSE when Me._IsSavedOnTransaction!

Ok...  look next the Me._IsSavedOnTransaction set to False only in the ResetIsSavedOnTransactionFlagOnBusinessObjects Otherwise - Me._IsSavedOnTransaction is TRUE




Now look the SAVE

Public Overridable Function Save(ByVal Transactional As Boolean, ByVal TransactionKey As String) As SaveUndoResult

.....

If Transactional Then
'-- Set the flag on this business object
Me._IsSavedOnTransaction = True

Dim list As List(Of BusinessLayer) = Nothing
SyncLock _BosOnTransaction
If _BosOnTransaction.TryGetValue(Me._DataSourceKey & "|" & TransactionKey, list) AndAlso _
Not list.Contains(Me) Then
list.Add(Me)
End If
End SyncLock
End If





Here - we set the ME._IsSavedOnTransaction = TRUE.. and nowhere its reset.... No.. its resets.. but just  in one place




Public Shared Sub TransactionCommit(ByVal DataSourceKey As String, ByVal TransactionKey As String)
ResetIsSavedOnTransactionFlagOnBusinessObjects(DataSourceKey, TransactionKey)

'-- Commit the transaction on the data source
DataLayer.TransactionCommit(DataSourceKey, TransactionKey)
End Sub





Public Shared Sub TransactionRollback(ByVal DataSourceKey As String, ByVal TransactionKey As String)

<--- ON MY PRIVATE LOOK - HERE MUST BE A CALL TO RESET IsSavedOnTransaction  flag..
DataLayer.TransactionRollback(DataSourceKey, TransactionKey)


End Sub





And Finaly look my code




Dim lcTransactionId As String = Guid.NewGuid.ToString
Try
'-- Start the transaction
   BusinessLayer.TransactionBegin("ERPDATA", lcTransactionId, System.Data.IsolationLevel.ReadCommitted)

'-- Save the business objects on the transaction
If Bestell_kopfBO1.Save(True, lcTransactionId) = MicroFour.StrataFrame.Data.SaveUndoResult.Success Then
   ...............................................
Else

If Bestell_kopfBO1.BrokenRules.Count > 0 Then
Throw New Exception(String.Format("A business rule broken : {0} ", Me.Bestell_kopfBO1.BrokenRules.ToArray(0).Description))
Else
Throw New Exception()
End If

End If

BusinessLayer.TransactionCommit("ERPDATA", lcTransactionId)
DevExpress.XtraEditors.XtraMessageBox.Show("The data completed saved!")

Catch ex As Exception
'-- If an exception occurs during the saving of the records, then
' abort the transaction.
BusinessLayer.TransactionRollback("ERPDATA", lcTransactionId)
'TODO: Translate messagebox
DevExpress.XtraEditors.XtraMessageBox.Show(String.Format("The data can't be saved. Reason: {0}", ex.Message))
End Try








First time broken rules exist (>0), so - SAVE is fail.. and EditState still "Adding" but IsDirty = FALSE!!!!!!!!!!!!!!

BECAUSE  Me._IsSavedOnTransaction Still TRUE after TransactionRollback.

Then I change some data and click SAVE again.. and after  this - my SAVE don't check any BUsinessRules and Saves the data, because isDirty = FALSE, and business object

does not check changes!




Please let us know ASAP about this problem.

Can't belive nobody has such problem!

Thanks

Denis


P.S.


Sorry for mistake in topic subject.. "I mean "Big bug in BusinessObject" Smile) not "is"