Business Rules in MonoDroid

Business Rules in MonoDroid

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


katalun4o posted on Thursday, August 16, 2012

Hello,

I am trying to add business rules in Monodroid project for a CSLA root class. The rule just checks if a string is valid. It seems to be working with context.AddErrorResult(PrimaryProperty,"Tax number is not correct"); and context.AddSuccessResult(false); but when i call context.AddWarningResult(PrimaryProperty, "Tax number is not correct"); my BeginSave method always throws TimedOut exception. Any suggestions ?

JonnyBee replied on Thursday, August 16, 2012

Which version of CSLA do you use?

Is your app N-tier or Edge application?

The most likely cause is something to do with serialization/deserialization and sometimes also WCF configuration. The Exception typically means that the client never get an answer from the server. So - assuming that it is N-tier - the next thing to check is that the message gets to the server and what happens on the server.

katalun4o replied on Friday, August 17, 2012

I am using the latest version for monodroid 4.3.13. And i still doesnt have WCF and server, this is simple class that is fetching and updating data on sqlite database and i have a simple rule that checks if a string (Tax Number) is valid (the reminder of the sum of first 8 digits devided to 11 should be equal to last digit) and I want this to be a warning. But if i call context.AddWarningResult in my business rule and after that i call BeginSave i get TimedOut exception.. it is workig with context.AddErrorResult without any errors.

JonnyBee replied on Friday, August 17, 2012

Well, if you call AddErrorResult (broken rule with severity Error) you are not allowed to call BeginSave.

So I'll assume that when:

If all above is true then I would suspect some serialization/cloning issue with BrokenRulesCollection/BrokenRule.

If  you call

var obj2 = obj.Clone();

on your business object (before the BeginSave call) - does the Clone run OK?

 

katalun4o replied on Monday, August 20, 2012

Calling var obj2 = obj.Clone(); raises the same exception...

JonnyBee replied on Monday, August 20, 2012

What is the exception you get? Is it still a Timeout exception on the Clone method?

It does seem like a serialization issue with the BrokenRulesCollection.

Copyright (c) Marimer LLC