Wrox Programmer Forums
|
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
 
Old December 6th, 2006, 12:30 PM
Authorized User
 
Join Date: Aug 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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();
          }
      }

 
Old December 6th, 2006, 08:29 PM
Registered User
 
Join Date: Dec 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

 
Old December 10th, 2006, 10:02 AM
amr amr is offline
Registered User
 
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ewelling :YOU ARE THE MAN !

many thanks :D

 
Old November 9th, 2007, 01:36 PM
Registered User
 
Join Date: Nov 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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"





Similar Threads
Thread Thread Starter Forum Replies Last Post
401.3 Access denied due to Access Control List cforsyth .NET Framework 2.0 8 May 28th, 2009 01:56 PM
SqlArticlesProvider vs SqlStoreProvider ? kalel_4444 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 May 22nd, 2008 12:57 AM
Access Denied tys MySQL 4 April 6th, 2007 08:31 AM
Access is Denied khautinh General .NET 1 March 26th, 2004 04:44 PM
Access Denied tys MySQL 0 March 25th, 2004 03:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.