 |
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0  | This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

December 6th, 2006, 12:30 PM
|
|
Authorized User
|
|
Join Date: Aug 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here's my InsertOrder() method in BLL/Store/Order.cs. I have not thoroughly tested it, but it seems to work fine. Realize there is another TransactionScope() in UpdateOrder().
public static int InsertOrder(ShoppingCart shoppingCart,
string shippingMethod, decimal shipping, string shippingFirstName,
string shippingLastName, string shippingStreet, string shippingPostalCode,
string shippingCity, string shippingState, string shippingCountry,
string customerEmail, string customerPhone, string customerFax, string transactionID)
{
//using (TransactionScope scope = new TransactionScope())
//{
ServiceConfig svcConfig = new ServiceConfig();
svcConfig.TrackingEnabled = true;
svcConfig.TrackingAppName = "JimGraden'sKarate";
svcConfig.TrackingComponentName = "MB.TheBeerHouse.BLL.Store";
//svcConfig.Transaction = TransactionOptions.RequiresNew;
svcConfig.IsolationLevel = TransactionIsolationLevel.ReadCommitted;
ServiceDomain.Enter(svcConfig);
try
{
string userName = BizObject.CurrentUserName;
// insert the master order
OrderDetails order = new OrderDetails(0, DateTime.Now,
userName, 1, "", shippingMethod, shoppingCart.Total, shipping,
shippingFirstName, shippingLastName, shippingStreet, shippingPostalCode,
shippingCity, shippingState, shippingCountry, customerEmail, customerPhone,
customerFax, DateTime.MinValue, transactionID, "");
int orderID = SiteProvider.Store.InsertOrder(order);
// insert the child order items
foreach (ShoppingCartItem item in shoppingCart.Items)
{
OrderItemDetails orderItem = new OrderItemDetails(0, DateTime.Now, userName,
orderID, item.ID, item.Title, item.SKU, item.UnitPrice, item.Quantity);
SiteProvider.Store.InsertOrderItem(orderItem);
}
BizObject.PurgeCacheItems("store_order");
//scope.Complete();
ContextUtil.SetComplete();
return orderID;
}
//}
catch (Exception e)
{
// rollback the transaction
ContextUtil.SetAbort();
return 0;
}
finally
{
ServiceDomain.Leave();
}
}
|
|

December 6th, 2006, 08:29 PM
|
|
Registered User
|
|
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks very much for your quick response.
Basically, I copied the code in the InsertOrder area, and changed JimGa.... to Neno, then when tried to run first time, 1 error, basically had to replace System.EnterpriseServices.ContextUtil and all calls to System.EnterpriseServices. After doing that......
Yes, It worked  . Hope his makes sense. Thanks alot.
However; I'm a newbie to programming, so sorry if this question is odd.
You mentioned that there is also another TransactionScope() in UpdateOrder(). I have noticed this, but have not done nothing to that area, should I?.
Once again thanks very much
Quick question, have you tried running the shopping cart via FireFox, basically, when press submit button to go to PayPal, just remains on same page (on the order summary page)cannot submit payment. Works fine in IE7. (Please note, this was always the case, nothing to do with the code from you) Just never worked via FireFox.
|
|

December 10th, 2006, 10:02 AM
|
|
Registered User
|
|
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ewelling :YOU ARE THE MAN !
many thanks :D
|
|

November 9th, 2007, 01:36 PM
|
|
Registered User
|
|
Join Date: Nov 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I know its been a while since anyone has posted to this thread, but did anyone ever find a way to work add transactions back into this code without using Transaction Scope? I know that what appears to be happening is that the transaction is forcing DTS to be called. My shared hosting provider does not support this.
I would also like to thank ewelling for the insight into the Order Statuses table. I have been trying to figure this out for a while now.
The site I am working on will probably be ok if part of the transaction fails because they deal with such limited quantities and can pretty much keep a handle on things, but I would like to use the code for other sites that may not be able to manage so well.
Do I need to re-write a lot of this to simulate a transaction, or is there an easier way?
Ancient Eskimo Proverb:
"If it happens to you, it's your fault"
|
|
 |