Sql Server Session State and Business Rule not braking, works good on InProc. CSLA version 2.1.4.0

Sql Server Session State and Business Rule not braking, works good on InProc. CSLA version 2.1.4.0

Old forum URL: forums.lhotka.net/forums/t/4617.aspx


Soumya posted on Friday, April 04, 2008

Hi All,

  I have a serialized Invoice Class inherited BusinessBase class and a member InvoiceDetailsList (BusinessListBase) of InvoiceDetail(BusinessBase) is define withevents.

And also defined business rule as If Invoice amount and Detials.sum donot match brake the rule.

And in AddBusinessRules Added Rule as

 ValidationRules.AddRule(Of Invoice)(AddressOf ExpenseSumRule(Of Invoice), "InvoiceAmount")

ValidationRules.AddDependantProperty("Details", "InvoiceAmount", True)

And also defined in Invoice class

  Private Sub Details_ListChanged(ByVal sender As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) Handles m_details.ListChanged

PropertyHasChanged("Details")

End Sub

When I change my value in my details grid, and Invoice amoutn, mismatch detail sum business rule validation should be checked, and should brake rule. Its working in InProc session state and  its failing on Sql Server Sessiion state.  It seems PropertyHasChanged on detail is never getting fired and My Business rule is not braking. Where as in Save ( in DataPortal_Insert) Details and Invoice Amounts coming different. How should I handle this behavior. some other business rules which also braking on SQL server Session State.

I'm using 2.1.4.0 version (VB.NET 2005 - Framework 2.0) Is there any solution for it. I read something about Customizing Deserialzation, but couldn't follow. I'm new to CSLA. Please provide me sample

Thanks,

Regards

Soumya

 

 

xAvailx replied on Friday, April 04, 2008

See this post...

http://forums.lhotka.net/forums/thread/16992.aspx

Soumya replied on Friday, April 04, 2008

Thanks but I donot want to make any change at CSLA.dll level. I rather prefer change in my Business Object. Can you provide me a sample? It seems even list change event is not getting fired for SS sesion state. Do I do same for that?

xAvailx replied on Sunday, April 13, 2008

Soumya:

Thanks but I donot want to make any change at CSLA.dll level. I rather prefer change in my Business Object. Can you provide me a sample? It seems even list change event is not getting fired for SS sesion state. Do I do same for that?



In your BO, implement the interface.

public class YourBO : BusinessBase, IDeserializationCallback

Then re-attach your rules:

public virtual void OnDeserialization(object sender) {
  // do things here - re-hook parents, etc.
   AddBusinessRules();
 }

If you don't fix in csla, then I would suggest you create a base class and implement there, otherwise all your businessbase bos will need this.

HTH.

sergeyb replied on Sunday, April 13, 2008

Actually, all you have to do is re-attach event handlers after BO for Invoice has been de-serialized.  You would overrides OnDeserialzed of Invoice class and re-attach the handler there as in

 

Sub Protected Overrides OnDesizerilized ….

 

AddHandler m_details.ListChanged, AddressOf Details_ListChanged

 

End Sub

 

Sergey Barskiy

Senior Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: xAvailx [mailto:cslanet@lhotka.net]
Sent: Sunday, April 13, 2008 8:32 PM
To: Sergey Barskiy
Subject: Re: [CSLA .NET] Sql Server Session State and Business Rule not braking, works good on InProc. CSLA version 2.1.4.0

 

Soumya:

Thanks but I donot want to make any change at CSLA.dll level. I rather prefer change in my Business Object. Can you provide me a sample? It seems even list change event is not getting fired for SS sesion state. Do I do same for that?



In your BO, implement the interface.

public class YourBO : BusinessBase, IDeserializationCallback

Then re-attach your rules:

public virtual void OnDeserialization(object sender) {
  // do things here - re-hook parents, etc.
   AddBusinessRules();
 }

If you don't fix in csla, then I would suggest you create a base class and implement there, otherwise all your businessbase bos will need this.

HTH.


RockfordLhotka replied on Sunday, April 13, 2008

In CSLA .NET 2.0 and higher you don't need to implement IDeserializationCallback. Microsoft changed the serializers to use an attribute-based scheme, and BusinessBase already takes care of the hard parts. You just need to override OnDeserialized() in your code to rehook events, etc.

In CSLA .NET 3.5 you don't need to do anything - CSLA takes care of rehooking child events and other child object details automatically.

xAvailx replied on Monday, April 14, 2008

Ah, I am still on 1.53 for .net 2. Had to make this change so the business rules wouldn't dissapear after serializing when using database for session. Also had to re-hook OnChildIsDirty in BusinessCollectionBase in the Deserialized method.

Thx.




Anderson replied on Thursday, April 10, 2008

hello Soumya,

as here you are facing problems about inherited Business Base rules, it would be better to have a knowledge based business suite working for your rules based systems. I had faced some similar technical problems while working for my organization after which I moved to few solution providers. And as I know some of providers, one is Easyrules that provides Business knowledge management software and it’s totally user friendly software and I am almost satisfied with this software.

WillC replied on Saturday, June 14, 2008

Anderson:

hello Soumya,

as here you are facing problems about inherited Business Base rules, it would be better to have a knowledge based business suite working for your rules based systems. I had faced some similar technical problems while working for my organization after which I moved to few solution providers. And as I know some of providers, one is Easyrules that provides Business knowledge management software and it’s totally user friendly software and I am almost satisfied with this software.



Hi Anderson,

You have mentioned about some easyrules software for Business Knowledge Management
Can you focus on how does it help for business management. I have refered the link you have put. I want to know something on your experience using this software for your organization!

Cheers!
Will C

Copyright (c) Marimer LLC