Hooking Custom Class into Able objects

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Hooking Custom Class into Able objects

Post by jmestep » Thu Jan 08, 2009 6:12 pm

I'm trying to extend some of the Able objects with other datafields from additional tables I have added to the database. For example, I have a CustomWebpageType table with two fields-- a webpageId and a webpageType. I've followed the pattern on the Wiki for a data access layer and I have over 2000 lines of code written in a class for all these new objects but I'm stumped now. Every time I get to this point, I can't go further.
In this instance, I'm trying to add the data in the webpageType field into a text box on the edit webpage page in the admin.
I've put the dll from the custom class into the bin folder of the website
I've put in a using Custom.Objects; on the EditWebpage.aspx.cs

In the code, I've added in my code like this:

Code: Select all

 private int _WebpageId;
    private Webpage _Webpage;
    private WebpageType _WebpageType;
protected void Page_Init(object sender, EventArgs e)
    {
        _WebpageId = AlwaysConvert.ToInt(Request.QueryString["WebpageId"]);
        _Webpage = WebpageDataSource.Load(_WebpageId);
       _WebpageType = WebpageTypeDataSource.Load(_WebpageId);
 
        CancelButton.NavigateUrl = "Browse.aspx?CategoryId=" + PageHelper.GetCategoryId().ToString();
     
        _WebpageType = WebpageTypeDataSource.Load(_WebpageId);
This all colors fine with intellisense and the project builds. (The Custom Object class built OK also)

Then down in the code for if (!Page.IsPostBack)

I have added to the listing
TextBoxType.Text = _WebpageType.ToString();

I always get a System.StackOverflowException was unhandled error and can't figure out why or how to debug it.

Where would I start to figure out what the problem is? It's been 2 1/2 days typing all this code and my brain is fried.

Thanks
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Hooking Custom Class into Able objects

Post by mazhar » Fri Jan 09, 2009 8:05 am

Make sure you do not have an infinite loop or infinite recursion some where in code.

User avatar
nickc
Captain (CAPT)
Captain (CAPT)
Posts: 276
Joined: Thu Nov 29, 2007 3:48 pm

Re: Hooking Custom Class into Able objects

Post by nickc » Fri Jan 09, 2009 10:09 am

can't figure out why or how to debug it
Dumb questions maybe...
- a breakpoint set at the top of Page_Init doesn't get hit?
- Is your class in App_Code or a separate dll?

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Hooking Custom Class into Able objects

Post by AbleMods » Fri Jan 09, 2009 10:58 am

Run it in debugger mode and the stack overflow should trigger you to where the call stack is getting overwhelmed. Most likely the issue is a call inside your class is calling another part of the same class which someone calls the original function and creates an infinite loop.

Put a breakpoint on the first line in Page_Init (or Page_Load) and step line by line until you're into your new class. Then start watching carefully line by line - you should see the debugger never leave your new class code. In other words, somehow a loop has formed and the stack eventually overflows.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Hooking Custom Class into Able objects

Post by jmestep » Fri Jan 09, 2009 12:06 pm

Thanks, guys I'll try that. I wasn't even sure how to run with debugger.
The DAL code is in a class library that I have copied to the bin folder of the site. If I can't get it de-bugging, I think I'll copy the DAL code for just one of the objects into the codebehind for an edit page and see what I get there. I've got one class for a table with only two fields, so I'll try that one first.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Hooking Custom Class into Able objects

Post by mazhar » Fri Jan 09, 2009 12:11 pm

put both the class library project and website within single solution. Mark the website project as start up project and then run the project in debug mode. Now it will let you debug the source code within class library as well.

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Hooking Custom Class into Able objects

Post by AbleMods » Fri Jan 09, 2009 12:13 pm

Debugger is pretty intelligent. When I'm running two VS instances, I can put breakpoints in one instance and it'll catch it when the code executes in the DLL of the other instance.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Hooking Custom Class into Able objects

Post by jmestep » Fri Jan 09, 2009 12:34 pm

It worked, it worked, it worked!!!!!!!!!!!!
I was using a Load method that needed two arguments instead of a LoadForProduct that only took one.

Thanks so much!
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Hooking Custom Class into Able objects

Post by AbleMods » Fri Jan 09, 2009 12:38 pm

Odd.

Intellisense should have picked that up. Although if you're coding in C-Sharp, I've seen it delay intellisense until after you've saved the file. VB doesn't seem to have that issue so I dunno if it's a setting in my VS setup or what.

Grats on getting it debugged though ;)
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
nickc
Captain (CAPT)
Captain (CAPT)
Posts: 276
Joined: Thu Nov 29, 2007 3:48 pm

Re: Hooking Custom Class into Able objects

Post by nickc » Fri Jan 09, 2009 1:07 pm

You VB coders and your fancy background compiling. Real little girls wait 3 minutes for their Able C# website solution to build :)

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Hooking Custom Class into Able objects

Post by jmestep » Fri Jan 09, 2009 4:00 pm

Well, I'm on to step 2. I can pull from the database, but am having trouble saving back. No error- just nothing happens. I've using the Save()method similar to the Affiliate code on the wiki and calling it from a Finish button on a supplemental page that has had the productid sent to it and it includes all the new fields. The table has an identity field for the key and the productid is a foreign key. On the finish button, I've picked up all the data from the text input fields.
Is there something else I would need to do or a different type of Save method?

Thanks
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Hooking Custom Class into Able objects

Post by AbleMods » Fri Jan 09, 2009 5:31 pm

Tough to troubleshoot when it's not throwing any exceptions at all. Make sure you have the web.config set so that it doesn't hide errors.

Some things to try:
1. Build a simple ASPX page and use the Page_Load() to test writing a single record. You should be able to populate the required properties and initiate a .Save() that way. Much faster to test and eliminates your user-interface code as culprit. Also helps establish the class itself is working or not.

2. Use the SQL logger to see what SQL command is being sent to the server during .Save(). Then copy/paste that into a SQL command window and execute it - see if SQL itself will throw any errors.

3. Breakpoint the .ExecuteNonQuery() in your .Save() method and see what the result variable returned is. It should be a 1 to indicate 1 record was affected.

4. Check your .IsDirty() logic. If the IsDirty property isn't being set within the individual public properties, the .Save() will do nothing. Might help to breakpoint the .Save() and look at the value of IsDirty() to make sure it's set to True.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Hooking Custom Class into Able objects

Post by jmestep » Mon Jan 12, 2009 7:29 am

Thanks for the help on this. I didn't have to do any debugging in Able5-- I just threw in some response.write() and figured it out. I'm working with it on a product edit which is on a separate page like the product templates in the admin. I'll try this on a category edit where the new fields are on the same page as the Able fields.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

afm
Captain (CAPT)
Captain (CAPT)
Posts: 339
Joined: Thu Nov 03, 2005 11:52 pm
Location: Portland, OR
Contact:

Re: Hooking Custom Class into Able objects

Post by afm » Mon Jan 12, 2009 9:44 am

jmestep wrote:I didn't have to do any debugging in Able5-- I just threw in some response.write() and figured it out.
That is often the most effective debugging technique.
Andy Miller
Structured Solutions

Shipper 3 - High Velocity Shipment Processing

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Hooking Custom Class into Able objects

Post by jmestep » Mon Jan 12, 2009 4:41 pm

Now I've got it to save edited data if the Able category has data already entered into the parallel table, which has an autonumber id and a foreign key which is the Able categoryId. (Merchant insists on the autonumber field). I think what I have to do is create a new parallel object when the edit category page needs to save form data back into it for a category that doesn't have an entry already in the parallel table. Someone told me he thought it was because I couldn't have a composite key made up of an autonumber field and a non-autonumber field, which I don't believe is the right info.
Anyway, I need to create the new object, then save the parallel data into that table.
Since I'm following the DAL coding pattern from Able, how/where can I pull an identity field for a new object into the edit category page?
Thanks
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Hooking Custom Class into Able objects

Post by jmestep » Mon Jan 12, 2009 5:34 pm

I got the code to work for a new parallel object. I created a new object if the object was null, picked up the category id for the page, saved, then did a response.redirect back and the code works fine for new and existing objects.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx

Post Reply