Tim

Footprints in the snow of a warped mind

Tim

Where to find me

Flickr Icon  Twitter Icon  Linked In Icon  FaceBook Icon  Windows Live Alerts Butterfly  RSS 2.0 

The Site Doctor is Hiring!

Enjoy what you read here?
Think you can do better?
Join our team and get paid
up-to £35,000.
Apply now.

Tag Cloud

AJAX (4) Analysis (3) ASP (6) ASP.Net (59) Error Reporting (4) Web Service (2) WSDL (1) Atlas (2) Azure (1) Born In The Barn (1) Business (95) Business Start-up Advice (37) Client (17) Expanding Your Business (24) Recruitment (1) C# (25) Canoeing (4) Canoe Racing (5) Cheshire Ring Race (5) Racing (2) Training (4) Christmas (1) CIMA (1) Cisco (1) 7970G (1) CMS (1) Code Management (1) Cohorts (4) Commerce4Umbraco (1) Content (1) Content Management (1) Content Management System (1) CSS (4) dasBlog (5) DDD (2) DDDSW (1) Design (12) Icons (1) Development (28) Domain Names (1) eCommerce (13) Email (1) Employment (2) Festive Sparkle (1) General (39) Christmas (6) Fun and Games (11) Internet (22) Random (46) RX-8 (8) Git (2) Google (1) Google AdWords (1) Google Analytics (1) Hacking (1) Helpful Script (3) Home Cinema (2) Hosting (2) HTML (3) IIS (11) iPhone (1) JavaScript (5) jQuery (2) LINQPad (1) Marketing (6) Email (1) Multipack (1) MVC (3) Networking (3) Nintendo (1) Nuget (1) OS Commerce (1) Payment (1) Photography (1) PHP (1) Plugin (1) PowerShell (3) Presentation (1) Press Release (1) Productivity (3) Random Thought (1) Script (2) Security (2) SEO (6) Server Maintenance (7) Server Management (12) Social Media (2) Social Networking (3) Experiment (1) Software (11) Office (5) Visual Studio (14) Windows (6) Vista (1) Source Control (2) SQL (13) SQL Server (19) Starting Something New (2) Statistics (2) Stored Procedure (1) Sublime Text 2 (1) SVN (1) TeaCommerce (1) Testing (2) The Cloud (1) The Site Doctor (140) Turnover Challenge (1) Twitter (3) uCommerce (20) Umbraco (37) 2009 (1) 2011 (1) Useful Script (6) Virtual Machine (1) Web Development (72) WebDD (33) Wii (1) Windows Azure (1) XSLT (1)

Blog Archive

Search

<November 2014>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

Recent Comments

Blog Archive

Various Links

Google+

Blogs I Read

[Feed] Google Blog
Official Google Webmaster Central Blog
[Feed] Matt Cutts
Gadgets, Google, and SEO
[Feed] Ol' Deano's Blog
My mate Dean's blog on my space, equally as random as mine but not off on as much of a tangent!
[Feed] Sam's Blog
Sam is one of my younger brothers studying Product Design and Manufacture at Loughborough, this is his blog :) Enjoy!

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

newtelligence dasBlog 2.2.8279.16125

Send mail to the author(s) Email Me (Tim Gaunt)

© 2014 Tim Gaunt.

Sign In

    # Tuesday, June 03, 2014

    Bulk delete products by SKU in uCommerce

    Tuesday, June 03, 2014 8:10:28 PM (GMT Daylight Time, UTC+01:00)

    You may already have come across my script to Quickly delete all products and orders from uCommerce but sometimes you need to delete just a set of products by SKU so here's a new one for you

    BEGIN TRAN
    
    DECLARE @ProductIds TABLE (Id int)
    INSERT INTO @ProductIds (Id)
    SELECT p.ProductId 
    FROM uCommerce_Product AS p 
    WHERE p.Sku IN ('EXAMPLE1','EXAMPLE2')
    
    DELETE prc FROM uCommerce_ProductReviewComment prc JOIN uCommerce_ProductReview AS pr ON prc.ProductReviewId = pr.ProductReviewId WHERE ProductId IN (SELECT Id FROM @ProductIds)
    DELETE FROM uCommerce_ProductReview WHERE ProductId IN (SELECT Id FROM @ProductIds)
    DELETE uCommerce_ProductRelation WHERE ProductId IN (SELECT Id FROM @ProductIds)
    DELETE uCommerce_ProductProperty WHERE ProductId IN (SELECT Id FROM @ProductIds)
    DELETE pdp FROM uCommerce_ProductDescriptionProperty pdp JOIN uCommerce_ProductDescription AS pd ON pdp.ProductDescriptionId = pd.ProductDescriptionId WHERE ProductId IN (SELECT Id FROM @ProductIds)
    DELETE uCommerce_ProductDescription WHERE ProductId IN (SELECT Id FROM @ProductIds)
    DELETE uCommerce_CategoryProductRelation WHERE ProductId IN (SELECT Id FROM @ProductIds)
    DELETE uCommerce_PriceGroupPrice WHERE ProductId IN (SELECT Id FROM @ProductIds)
    DELETE FROM uCommerce_Product WHERE ProductId IN (SELECT Id FROM @ProductIds)
    
    -- Just double check things have gone
    SELECT * FROM uCommerce_Product p WHERE ProductId IN (SELECT Id FROM @ProductIds)
    
    -- For safety's sake, run it in a transaction just in case you change your mind
    ROLLBACK TRAN
    -- When happy it works, uncomment this line and comment out the ROLLBACK
    --COMMIT TRAN
     

    Don't forget to follow me on Twitter.

    Bulk delete products by SKU in uCommerce
    Useful Links:  #  digg it!  del.icio.us  Technorati  email it!  Post CommentsComments [0]  Trackback LinkTrackback
    CategoriesTags: SQL | uCommerce
    # Friday, May 30, 2014

    Stop windows lowering the music volume when a call starts

    Friday, May 30, 2014 10:39:38 AM (GMT Daylight Time, UTC+01:00)

    We've started using Sqwiggle to aid remote working which is awesome. The only issue is recently I've noticed that when someone starts a conversation or sends an instant message Spotify and Windows Media player reduced their volume and wouldn't come back up. Turns out the fix is pretty simple if you want to keep control:

    1. Open your "Playback devices" options by right clicking the speaker icon in your toolbar:

    image

    2. Click the "Communications" tab at the top:

    image

    3. Set the option to "Do nothing"

    image

    You're done! Enjoy

     

    Don't forget to follow me on Twitter.

    # Wednesday, May 21, 2014

    How To: Bulk delete orders in uCommerce

    Wednesday, May 21, 2014 5:32:08 AM (GMT Daylight Time, UTC+01:00)

    Sometimes things go wrong in testing but you don't want to delete all orders so here's a little script that will help you quickly delete orders based on your own criteria. In this example I'm deleting orders from customers without a billing email address but you can change the select statement to anything you like.

    DECLARE @OrderIds TABLE (OrderId int)
    INSERT INTO @OrderIds (OrderId)
    -- Change this to whatever select statement you need
    SELECT DISTINCT po.OrderId
    FROM uCommerce_PurchaseOrder po LEFT JOIN uCommerce_OrderAddress oa ON po.BillingAddressId = oa.OrderAddressId 
    WHERE oa.EmailAddress = ''
    
    BEGIN TRAN
    
    UPDATE a SET ShipmentId = NULL FROM uCommerce_OrderLine a WHERE OrderId IN (SELECT OrderId FROM @OrderIds)
    UPDATE uCommerce_PurchaseOrder SET BillingAddressId = NULL WHERE OrderId IN (SELECT OrderId FROM @OrderIds)
    DELETE a FROM uCommerce_Shipment a WHERE OrderId IN (SELECT OrderId FROM @OrderIds)
    DELETE a FROM uCommerce_OrderAddress a WHERE OrderId IN (SELECT OrderId FROM @OrderIds)
    DELETE a FROM uCommerce_OrderProperty a WHERE OrderId IN (SELECT OrderId FROM @OrderIds)
    DELETE a FROM uCommerce_OrderLine a WHERE OrderId IN (SELECT OrderId FROM @OrderIds)
    DELETE pp FROM uCommerce_PaymentProperty pp JOIN uCommerce_Payment p ON pp.PaymentId = p.PaymentId WHERE p.OrderId IN (SELECT OrderId FROM @OrderIds)
    DELETE a FROM uCommerce_Payment a WHERE OrderId IN (SELECT OrderId FROM @OrderIds)
    DELETE a FROM uCommerce_OrderStatusAudit a WHERE OrderId IN (SELECT OrderId FROM @OrderIds)
    DELETE FROM uCommerce_PurchaseOrder WHERE OrderId IN (SELECT OrderId FROM @OrderIds)
    
    --Uncomment this
    --COMMIT TRAN
    
    --And comment out this
    ROLLBACK TRAN
     

    Don't forget to follow me on Twitter.

    # Thursday, May 08, 2014

    Quickly delete Umbraco nodes by document type in SQL

    Thursday, May 08, 2014 2:53:41 PM (GMT Daylight Time, UTC+01:00)

    Ever needed to delete all nodes by a document type or delete all nodes from the recycle bin in Umbraco? This little script should help.

    Delete Umbraco nodes by Document Type Alias

    BEGIN TRAN
     
    DECLARE @Nodes TABLE (NodeId int)
     
    INSERT INTO @Nodes (NodeId)
    SELECT top 1000 n.id
    FROM cmsContent C 
    	INNER JOIN cmsContentType CT ON C.contentType = CT.nodeId 
    	INNER JOIN umbracoNode N ON C.nodeId = N.id
    WHERE CT.alias = '[Your Document Type Alias Here]'
     
    select id, [text] from umbracoNode where id in (select NodeId from @Nodes)
     
    delete from cmsPreviewXml where nodeId in (select NodeId from @Nodes)
    delete from cmsContentVersion where contentId in (select NodeId from @Nodes)
    delete from cmsDocument where nodeId in (select NodeId from @Nodes)
    delete from cmsContentXML where nodeId in (select NodeId from @Nodes)
    delete from cmsContent where nodeId in (select NodeId from @Nodes)
    delete from cmsPropertyData where contentNodeId in (select NodeId from @Nodes)
    delete from umbracoRelation where parentId in (select NodeId from @Nodes) OR childId in (select NodeId from @Nodes)
    delete from cmsTagRelationship where nodeId in (select NodeId from @Nodes)
    delete from umbracoNode where id in (select NodeId from @Nodes)
     
    DELETE FROM @Nodes
     
    ROLLBACK TRAN

    Delete Umbraco nodes from recycle bin

    BEGIN TRAN
     
    DECLARE @Nodes TABLE (NodeId int)
     
    INSERT INTO @Nodes (NodeId)
    SELECT top 1000 n.id
    FROM umbracoNode n
    WHERE n.path like '%-20%' and id!=-20
     
    select id, [text] from umbracoNode where id in (select NodeId from @Nodes)
     
    delete from cmsPreviewXml where nodeId in (select NodeId from @Nodes)
    delete from cmsContentVersion where contentId in (select NodeId from @Nodes)
    delete from cmsDocument where nodeId in (select NodeId from @Nodes)
    delete from cmsContentXML where nodeId in (select NodeId from @Nodes)
    delete from cmsContent where nodeId in (select NodeId from @Nodes)
    delete from cmsPropertyData where contentNodeId in (select NodeId from @Nodes)
    delete from umbracoRelation where parentId in (select NodeId from @Nodes) OR childId in (select NodeId from @Nodes)
    delete from cmsTagRelationship where nodeId in (select NodeId from @Nodes)
    delete from umbracoNode where id in (select NodeId from @Nodes)
     
    DELETE FROM @Nodes
     
    ROLLBACK TRAN
     

    Don't forget to follow me on Twitter.

    # Tuesday, May 06, 2014

    To 08xx or not 08xx that is the question

    Tuesday, May 06, 2014 3:55:49 PM (GMT Daylight Time, UTC+01:00)

    Alternative-Numbers-To-0870-Save-Money-On-Phone-CallsAt some point, when setting up a new website or business you need to give some thought to your telephone number.

    In the UK we have numbers that start with 08 which have different charging rates (free, local, national etc) and I've been asked several times in the past what's best -some people perceive having an 08xx number as being more professional and easier to remember.

    There are cases when an 08xx number is a good idea but generally if you're running a local business, I would use a local number i.e. one that starts with 01 or 02 (not 03 -I'll explain why later).

    Why 01xx/02xx over 08xx? Simply put, many phone contracts (mobile and landline) don't include 08xx numbers in their "free" call plan and customers with those that do (there are a few) often aren't aware whether it's included or not. Adding any form of barrier to the customer contacting you has to be a no-no.

    Don't forget people object to 08** numbers so much there's even a website dedicated to giving you alternatives to the 08** number - http://www.saynoto0870.com/.

    So why not 03 numbers as they're local numbers as well right? Yes they are but as with anything unusual, it acts as another barrier to people contacting your business.

     

    Don't forget to follow me on Twitter.

    # Wednesday, April 23, 2014

    No basket exist for the current user when checking out in uCommerce

    Wednesday, April 23, 2014 3:29:49 PM (GMT Daylight Time, UTC+01:00)

    Stupidly this had me going for a while today so this is partly a post to act as a reminder not to do it again but also hopefully to help someone else from doing the same.

    A site we are working on was sending the order confirmation email -and processing the rest of the checkout pipeline however it would then error saying that there was no basket for the current user.

    The most likely reason for this is that you've set the "Pipeline" on the Payment Method selection like this:

    image

    To fix the issue, just clear the Pipeline value and all should work wonderfully again.

     

    2014-04-15 13:43:02,248 [7] ERROR xxxx.www.Controllers.CheckoutController - System.ArgumentException: No basket exist for the current user.
       at UCommerce.Transactions.TransactionLibraryInternal.Checkout()
       at Castle.Proxies.Invocations.TransactionLibraryInternal_Checkout.InvokeMethodOnTarget()
       at Castle.DynamicProxy.AbstractInvocation.Proceed()
       at UCommerce.Infrastructure.Interceptor.ExceptionLoggingInterceptor.Intercept(IInvocation invocation)
       at Castle.DynamicProxy.AbstractInvocation.Proceed()
       at Castle.Proxies.TransactionLibraryInternalProxy.Checkout()
       at xxxx.www.Controllers.CheckoutController.BillingInformation(BillingInformationViewModel data) in d:\xxxx\www\Controllers\CheckoutController.cs:line 612
    
     

    Don't forget to follow me on Twitter.

    # Tuesday, April 15, 2014

    Illegal characters in path in MVC view

    Tuesday, April 15, 2014 2:10:37 PM (GMT Daylight Time, UTC+01:00)

    I initially thought that this was an issue with Umbraco's implementation on MVC but it turns out that if you have an IEnumerable property on your view model then you may get an error similar to the below.

    I've done a little searching around in the past but I didn't find a great deal to help. It turns out that the issue and fix is actually rather simple. Instead of using IEnumerable, use ICollection (or IList) and that's it, problem solved!

    [ArgumentException: Illegal characters in path.]
       System.IO.Path.Combine(String path1, String path2) +14355737
       System.Web.Compilation.DiskBuildResultCache.GetBuildResult(String cacheKey, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) +41
       System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) +253
       System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate) +132
       System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +91
       System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +203
       System.Web.Compilation.BuildManager.GetObjectFactory(String virtualPath, Boolean throwIfNotFound) +180
       System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath) +18
       Microsoft.Web.Mvc.ViewEngineFixWorker`1.FileExists(ControllerContext controllerContext, String virtualPath) +23
       System.Web.WebPages.DefaultDisplayMode.GetDisplayInfo(HttpContextBase httpContext, String virtualPath, Func`2 virtualPathExists) +55
       System.Linq.WhereSelectListIterator`2.MoveNext() +245
       System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +215
       System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func`2 virtualPathExists, IDisplayMode currentDisplayMode) +27
       Microsoft.Web.Mvc.ViewEngineFixWorker`1.GetPathFromGeneralName(ControllerContext controllerContext, List`1 locations, String name, String controllerName, String areaName, String cacheKey, String[]& searchedLocations) +450
       Microsoft.Web.Mvc.ViewEngineFixWorker`1.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations) +990
       Microsoft.Web.Mvc.ViewEngineFixWorker`1.FindPartialView(ControllerContext controllerContext, String partialViewName, Boolean useCache) +180
       System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths) +177
       System.Web.Mvc.Html.TemplateHelpers.ExecuteTemplate(HtmlHelper html, ViewDataDictionary viewData, String templateName, DataBoundControlMode mode, GetViewNamesDelegate getViewNames, GetDefaultActionsDelegate getDefaultActions) +660
       System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData, ExecuteTemplateDelegate executeTemplate) +1371
       System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData) +107
       System.Web.Mvc.Html.TemplateHelpers.TemplateFor(HtmlHelper`1 html, Expression`1 expression, String templateName, String htmlFieldName, DataBoundControlMode mode, Object additionalViewData) +155
       System.Web.Mvc.Html.EditorExtensions.EditorFor(HtmlHelper`1 html, Expression`1 expression) +95
       ASP._Page_Views_Category_ProductsInCategory_cshtml.Execute() in \...\Views\Category\ProductsInCategory.cshtml:3
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
       System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +126
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +181
       System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378
       System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +33
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +853420
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +853420
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +853420
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
       System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +853472
       System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__19() +40
       System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +15
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +65
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +51
       System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +51
       System.Web.Mvc.<>c__DisplayClass4.<Wrap>b__3() +15
       System.Web.Mvc.ServerExecuteHttpHandlerWrapper.Wrap(Func`1 func) +41
       System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) +1411
    
     

    Don't forget to follow me on Twitter.

    Illegal characters in path in MVC view
    Useful Links:  #  digg it!  del.icio.us  Technorati  email it!  Post CommentsComments [0]  Trackback LinkTrackback
    CategoriesTags: C# | Development | MVC
    # Friday, March 21, 2014

    How to: Delete duplicate products from a category in uCommerce

    Friday, March 21, 2014 10:25:29 AM (GMT Standard Time, UTC+00:00)

    I was looking into an issue with one of our sites that couldn't delete a product from a category in uCommerce today and noticed that there were a lot of duplicate product-category relationships in the table.

    Deleting them is fairly simple so I thought I'd share the code in case you want to clear it down as well.

    BEGIN TRAN
    
    -- Check for any duplicates
    SELECT
    	d.*
    FROM (
    	SELECT 
    		cr.CategoryId, cr.ProductId, cr.CategoryProductRelationId,
    		ROW_NUMBER() OVER (PARTITION BY cr.CategoryId, cr.ProductId ORDER BY cr.CategoryProductRelationId) AS Position
    	FROM [dbo].[uCommerce_CategoryProductRelation] cr
    ) AS d
    WHERE Position != 1
    
    -- Delete the duplicates
    DELETE FROM uCommerce_CategoryProductRelation 
    WHERE CategoryProductRelationId IN (
    	SELECT
    		d.CategoryProductRelationId
    	FROM (
    		 SELECT 
    			cr.CategoryProductRelationId,
    			ROW_NUMBER() OVER (PARTITION BY cr.CategoryId, cr.ProductId ORDER BY cr.CategoryProductRelationId) AS Position
    		 FROM [dbo].[uCommerce_CategoryProductRelation] cr
    	) AS d
    	WHERE Position != 1
    )
    
    -- Double check the duplicates have been deleted
    SELECT
    	d.*
    FROM (
    	SELECT 
    		cr.CategoryProductRelationId,
    		ROW_NUMBER() OVER (PARTITION BY cr.CategoryId, cr.ProductId ORDER BY cr.CategoryProductRelationId) AS Position
    	FROM [dbo].[uCommerce_CategoryProductRelation] cr
    ) AS d
    WHERE Position != 1
    
    ROLLBACK TRAN
     

    Don't forget to follow me on Twitter.