Transaction Commit problem


Author
Message
dgsoft
dgsoft
StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)
Group: StrataFrame Users
Posts: 93, Visits: 236
This is complete method code



In my case llNewUser = .F. and pmks_form_id has correct integer value



_

Public Function mmks_save() As String

Dim lcErrorMessage As String = "SUCCESS"

Dim llNewUser As Boolean = pmks_form_Id < 0

Dim lSaveResult As MicroFour.StrataFrame.Data.SaveUndoResult

Dim lcUploadErrorMessage As String = ""

Dim loPSOFormStoreBO As PSOFormStoreBO = New PSOFormStoreBO()

If llNewUser Then

loPSOFormStoreBO.Add()

Else

loPSOFormStoreBO.FillByPrimaryKey(pmks_form_Id)

End If



If Me.FileUploadPng.HasFile() = True Then

Dim lcFormName As String = Me.PSOForm_filename.Text

Dim lcFormStem As String = ""

If lcFormName.IndexOf(".") > 0 Then

Dim lcFormStems As String() = lcFormName.Split(".")

lcFormStem = lcFormStems(0)

Else

lcFormStem = lcFormName

End If



If Not String.IsNullOrEmpty(lcFormStem) Then

Dim rootpath As String = Server.MapPath("~/")

Dim lcMandatorPath As String = rootpath + Session("session_mandator_name") + "\"

Dim loDirectoryInfo As DirectoryInfo = New DirectoryInfo(lcMandatorPath)

If Not loDirectoryInfo.Exists() Then

loDirectoryInfo.Create()

End If

Dim lcFormPath As String = lcMandatorPath + lcFormStem + "\"

loDirectoryInfo = New DirectoryInfo(lcFormPath)

If Not loDirectoryInfo.Exists() Then

loDirectoryInfo.Create()

End If

Try

Me.FileUploadPng.PostedFile.SaveAs(lcFormPath + Path.GetFileName(Me.FileUploadPng.FileName))

Catch ex As Exception

lcUploadErrorMessage = ex.Message

End Try



End If



End If







Try

BusinessLayer.TransactionBegin("PENSOLUTIONOFFICE", "PENSOLUTIONOFFICE", Data.IsolationLevel.ReadCommitted)

mmks_updatePSOForm(loPSOFormStoreBO)



lSaveResult = loPSOFormStoreBO.Save(True, "PENSOLUTIONOFFICE")

If lSaveResult = MicroFour.StrataFrame.Data.SaveUndoResult.Success Then

BusinessLayer.TransactionCommit("PENSOLUTIONOFFICE", "PENSOLUTIONOFFICE")

lcErrorMessage = "SUCCESS"

Else

Throw New Exception("An error happen during save data!")

End If

Catch ex As Exception

lcErrorMessage = ex.Message

BusinessLayer.TransactionRollback("PENSOLUTIONOFFICE", "PENSOLUTIONOFFICE")

End Try

Return (lcErrorMessage)

End Function
dgsoft
dgsoft
StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)
Group: StrataFrame Users
Posts: 93, Visits: 236
Sorry.. I copy wrong code Smile)))







_

Public Function mmks_save() As String

Dim lcErrorMessage As String = "SUCCESS"

Dim lcTransactionKey As String = Guid.NewGuid().ToString()

Dim llNewUser As Boolean = pmks_form_Id < 0

Dim lSaveResult As MicroFour.StrataFrame.Data.SaveUndoResult

Dim lcUploadErrorMessage As String = ""

Dim loPSOFormStoreBO As PSOFormStoreBO = New PSOFormStoreBO()

If llNewUser Then

loPSOFormStoreBO.Add()

Else

loPSOFormStoreBO.FillByPrimaryKey(pmks_form_Id)

End If



If Me.FileUploadPng.HasFile() = True Then

Dim lcFormName As String = Me.PSOForm_filename.Text

Dim lcFormStem As String = ""

If lcFormName.IndexOf(".") > 0 Then

Dim lcFormStems As String() = lcFormName.Split(".")

lcFormStem = lcFormStems(0)

Else

lcFormStem = lcFormName

End If



If Not String.IsNullOrEmpty(lcFormStem) Then

Dim rootpath As String = Server.MapPath("~/")

Dim lcMandatorPath As String = rootpath + Session("session_mandator_name") + "\"

Dim loDirectoryInfo As DirectoryInfo = New DirectoryInfo(lcMandatorPath)

If Not loDirectoryInfo.Exists() Then

loDirectoryInfo.Create()

End If

Dim lcFormPath As String = lcMandatorPath + lcFormStem + "\"

loDirectoryInfo = New DirectoryInfo(lcFormPath)

If Not loDirectoryInfo.Exists() Then

loDirectoryInfo.Create()

End If

Try

Me.FileUploadPng.PostedFile.SaveAs(lcFormPath + Path.GetFileName(Me.FileUploadPng.FileName))

Catch ex As Exception

lcUploadErrorMessage = ex.Message

End Try



End If



End If







Try

BusinessLayer.TransactionBegin("PENSOLUTIONOFFICE", lcTransactionKey, Data.IsolationLevel.ReadCommitted)

mmks_updatePSOForm(loPSOFormStoreBO)

MicroFour.StrataFrame.Data.DataBasics.DataSources("PENSOLUTIONOFFICE").SetDebugOn("c:\DebugFile.html", True)

lSaveResult = loPSOFormStoreBO.Save(True, lcTransactionKey)

If lSaveResult = MicroFour.StrataFrame.Data.SaveUndoResult.Success Then

BusinessLayer.TransactionCommit("PENSOLUTIONOFFICE", lcTransactionKey)

lcErrorMessage = "SUCCESS"

Else

Throw New Exception("An error happen during save data!")

End If

Catch ex As Exception

lcErrorMessage = ex.Message

BusinessLayer.TransactionRollback("PENSOLUTIONOFFICE", lcTransactionKey)

End Try

Return (lcErrorMessage)




Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
I really don't see anything wrong, so at this point is just to try and error unless Trent or somebody else have another suggestion.



Try moving the code mmks_updatePSOForm(loPSOFormStoreBO) before the TransactionBegin...





mmks_updatePSOForm(loPSOFormStoreBO)

BusinessLayer.TransactionBegin("PENSOLUTIONOFFICE", lcTransactionKey, Data.IsolationLevel.ReadCommitted)






Edhy Rijo

dgsoft
dgsoft
StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)
Group: StrataFrame Users
Posts: 93, Visits: 236
Now I get closer to my problem..



Please look...

[code]

Try

BusinessLayer.TransactionBegin("PENSOLUTIONOFFICE", lcTransactionKey, Data.IsolationLevel.ReadCommitted)

''' ************************************************************************************

''' HERE I UPDATE BUSINESS OBJECT PROPERTIES mmks_updatePSOForm(loPSOFormStoreBO)

''' IF I UPDATE ONE or ANY PROPERTIES OF BO - then SAVE() works perfect but TransactionCommit - FAIL

'' IF I DO NOT UPDATE ANY PROPERTIES OF BO - then TransactionCommit SUCCESS!!!!!

''' *************************************************************************************

MicroFour.StrataFrame.Data.DataBasics.DataSources("PENSOLUTIONOFFICE").SetDebugOn("c:\DebugFile.html", True)

lSaveResult = loPSOFormStoreBO.Save(True, lcTransactionKey)

If lSaveResult = MicroFour.StrataFrame.Data.SaveUndoResult.Success Then

BusinessLayer.TransactionCommit("PENSOLUTIONOFFICE", lcTransactionKey)

lcErrorMessage = "SUCCESS"

Else

Throw New Exception("An error happen during save data!")

End If

Catch ex As Exception

lcErrorMessage = ex.Message

BusinessLayer.TransactionRollback("PENSOLUTIONOFFICE", lcTransactionKey)

End Try

[code]



The diffrence between developer machine and customer machine where I currently debug it with Visual Studio..



on development machine I have included PenSolutionOfficeBO as Project.. but

on customer machine - its only DLL which located in BIN folder.



So.. any ideas now?



Thanks!

dgsoft
dgsoft
StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)
Group: StrataFrame Users
Posts: 93, Visits: 236
Please look my last comment.. I thinking I localize the problem untill one line of code Smile
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Good, so the problem is here:



Private Sub mmks_updatePSOForm(ByVal toBO As PSOFormStoreBO)



Dim lcXformXML As String = ""

If Me.FileUploadXForm.HasFile() = True Then

Dim loStreadReader As StreamReader = New StreamReader(Me.FileUploadXForm.PostedFile.InputStream)

lcXformXML = loStreadReader.ReadToEnd()

End If



toBO.filename = Me.PSOForm_filename.Text

toBO.formsetid = Me.PSOForm_formsetid.Text

toBO.validForm = Me.PSOForm_validFrom.Value

toBO.validto = Me.PSOForm_validTo.Value

toBO.papersize = Me.PSOForm_Papersize.Value

toBO.topage = Me.PSOForm_topage.Value

toBO.frompage = Me.PSOForm_fromPage.Value

toBO.comment = Me.PSOForm_HtmlEditor1.Text



If Not String.IsNullOrEmpty(lcXformXML) Then

toBO.xformxml = lcXformXML

End If



End Sub





As I understand it you are sending your BO as toBO to update some properties. Did you try calling mmks_updatePSOForm() before TransactionBeign...?


Edhy Rijo

dgsoft
dgsoft
StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)
Group: StrataFrame Users
Posts: 93, Visits: 236
Yes.

Even if I leave only one line for update

toBO.filename = Me.PSOForm_filename.Text



TransactionCommit fail in any case..



Yes. I change order of lines and try update befor TransactionBegin.. it does not help...

For this business object I use RowVersionOrTimestampColumn - timestamp

UpdateConcurrencyType - OptimisticTimestamp
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
This quote is from the "Using Transactional Processing" topic in the SF help file:

Transaction processing is often used to implement pessimistic concurrency. Database tables participating in the transaction can be locked, depending on the IsolationLevel used when the transaction was started. This prevents client applications other than the transaction owner from modifying the tables while the transaction is processing.




Since you are using ReadCommitted Isolation Level and then modifying the BO properties, then the transaction triggers an error. I believe you have two options here:

1-Move mmks_updatePSOForm() before TransactionBeign

2-Change the Isolation Level to ReadUncommitted



Also check this KB: http://msdn.microsoft.com/en-us/library/ms173763.aspx



Try boths and let me know.




Edhy Rijo

dgsoft
dgsoft
StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)
Group: StrataFrame Users
Posts: 93, Visits: 236
I made so

mmks_updatePSOForm(loPSOFormStoreBO)

BusinessLayer.TransactionBegin("PENSOLUTIONOFFICE", lcTransactionKey, Data.IsolationLevel.ReadUncommitted)



and have no success.. same error.. about transaction end and can't be used..



I give up for today.. now is 01:19 am in Moscow Smile Maybe morning bring something Smile

Thanks for your help!

See ya!

Denis
dgsoft
dgsoft
StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)StrataFrame User (147 reputation)
Group: StrataFrame Users
Posts: 93, Visits: 236
This is error message details..

Transaction still does not work. I had restart a SQL Server.

What is ZombieCheck is?
Attachments
TransactionError.JPG (110 views, 141.00 KB)
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