AyaNova service management & work order software
AyaNova Support Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        


12»»

Create a new workorder "save()" error Expand / Collapse
Author
Message
Posted 2/5/2010 7:29:03 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2/11/2010 10:43:02 AM
Posts: 7, Visits: 14
I've created an office add-in that allows a user to automatically create a new workorder from a selected object.  I've managed to successfully create the workorder in the Ayanova database (using the api), but my program continues to throw this error during the workorder.save():

"A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in CSLA.Server.DataPortal.DLL"

The .isSaveAllowed and .isSavable properties are true, and the save seems to be successful, but I'm having trouble figuring out how to prevent this error. 

Your recommendations are appreciated.  Thank you.

Post #5040
Posted 2/5/2010 11:53:19 PM
AyaNova Development & Support

AyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & Support

Group: Administrators
Last Login: 2/11/2010 12:27:00 PM
Posts: 140, Visits: 493
rhafer (2/5/2010)
I've created an office add-in that allows a user to automatically create a new workorder from a selected object. I've managed to successfully create the workorder in the Ayanova database (using the api), but my program continues to throw this error during the workorder.save():

"A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in CSLA.Server.DataPortal.DLL"

The .isSaveAllowed and .isSavable properties are true, andthe save seems to be successful, but I'm having trouble figuring out how to prevent this error.

Your recommendations are appreciated. Thank you.


Hi Rhafer, as is mentioned in the comments for the sample projects in the api examples download, but probably not enough everywhere else:

You need to "crack" exceptions coming from the AyaNova business object level because everything goes through a dataportal which enables the ability to work with remoting if configured that way.

This means that ever exception that comes back is coming from a chain that ends up going through the dataportal lastly which wraps the original exception inside the TargetInvocationException so if you get an exception while using the biz object library it will almost always be a target invocation exception, however, if you check inner exception property of the exception it will contain the actual error from the business object.

So what you would typically do is in your exception handler you'd have (pseudo c# typed off the top of my head guranteed not to compile) code like this:
try{
SomeThingInvolvingAyaNovaBusinessObjects();
}
catch(exception e)
{
while(e.InnerException!=null)
e=e.InnerException;

//Now e contains the actual exception from the business object level
}

Just guessing off the top of my head but it might be a rights issue or something, the inner exception should reveal the case.

Cheers!
Post #5041
Posted 2/5/2010 11:54:48 PM
AyaNova Development & Support

AyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & Support

Group: Administrators
Last Login: 2/11/2010 12:27:00 PM
Posts: 140, Visits: 493
P.S. don't forget if you intend to keep using that Workorder object after you save it to cast the return from the save operation to a Workorder and use that instead as outlined in the api docs.
Post #5042
Posted 2/9/2010 9:24:23 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2/11/2010 10:43:02 AM
Posts: 7, Visits: 14
Excellent!  Guess I should have known to do that.  Looks like I can get all the info I need.  Thank you John!
Post #5044
Posted 2/9/2010 9:46:37 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2/11/2010 10:43:02 AM
Posts: 7, Visits: 14
Before I get too confident, here is my exception message.  Can you see what i'm missing from this?

---> System.Data.SqlClient.SqlException: Cannot insert the value NULL into column 'ASAVEDMESSAGE', table 'AyaNova_Dev.dbo.ANOTIFYEVENT'; column does not allow nulls. INSERT fails.

Thanks again.

Post #5045
Posted 2/9/2010 10:33:48 AM
AyaNova Development & Support

AyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & Support

Group: Administrators
Last Login: 2/11/2010 12:27:00 PM
Posts: 140, Visits: 493
Hi, that sounds like a bug that was fixed in AyaNova 6.1. Are you running the latest version?
Post #5046
Posted 2/9/2010 10:47:36 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2/11/2010 10:43:02 AM
Posts: 7, Visits: 14
Yes, we're running 6.1.  Do I have to create a NotifyEvent to add to the workorder before I save it?
Post #5047
Posted 2/9/2010 11:40:22 AM
AyaNova Development & Support

AyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & Support

Group: Administrators
Last Login: 2/11/2010 12:27:00 PM
Posts: 140, Visits: 493
Weird, no you don't need to do anything, that's an internal bug that was fixed.

Your 6.1 schema update should have fixed it.
Are you using a FireBird database or a MS SQL one?
Is this your live data or are you working with a trial db or copy of your db for testing your code?
Are you 100% certain the database you get that error on has had AyaNova 6.1 run against it at least once?
Post #5049
Posted 2/9/2010 7:12:37 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2/11/2010 10:43:02 AM
Posts: 7, Visits: 14
I am using SQL 2008, and testing on a copy of our database, not the live one.  I have been running my 6.1 Ayanova software on this database without any problems. 
Post #5054
Posted 2/10/2010 9:52:10 AM
AyaNova Development & Support

AyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & SupportAyaNova Development & Support

Group: Administrators
Last Login: 2/11/2010 12:27:00 PM
Posts: 140, Visits: 493
Hi there, sorry for the delay but I've been researching this problem.
It appears that the asavedmessage column in the table anotifyevent is set to not allow nulls.
That was a bug that should have only existed in firebird db's as the mssql ones were correctly defined in the original schema update that added that column.

What I'm speculating happened in your case is your db was created from a firebird db from release 6.0 using the ToMSSQL utility we provide which would have copied that bad column null definition over.

I've made a case to put the same fix in we did for firebird in the 6.1 release for mssql in our upcoming 6.2 release.
In the mean time if you run the following sql against your sql db it will do the same fix:

alter table anotifyevent alter column asavedmessage nvarchar(1024) NULL

Or use sql server management studio to set ASAVEDMESSAGE to allow nulls, either way, same effect.

I'd like to know if this fixes the problem for you, it should and it would then confirm the problem. Also I'd like to know if my theory that it's a Firebird db converted to MSSQL at version 6.0 (at the time) is correct.

Cheers!

P.S. What I don't understand is why you don't get that error while running AyaNova and creating a workorder, you really should, it's the same code that you would be using through the API. Perhaps it's related to the client having notification turned on or the user account being used which is different but if you recreate the same thing you're doing in code in AyaNova it should give the same error.
Post #5058
« Prev Topic | Next Topic »

12»»

Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: AyaNova Sales & Support, John

Permissions Expand / Collapse

All times are GMT -8:00, Time now is 5:41pm

Powered by InstantForum.NET v4.1.4 © 2010
Execution: 0.094. 9 queries. Compression Disabled.