Wednesday, April 25, 2012

WPF, Validation, and Adorner Decorator

So I was working on a little project in WPF, using Caliburn Micro.  Was coming along well, but I had yet to put together validation.  I managed to cobble something together based on

Paul Stovell's WPF Validation at Codeplex
Beth Massi on Displaying WPF Validation

and more specific to Caliburn Micro:

Lyquidity's Caliburn Micro Validation code

My App.xml looked a little like this:

but I was having a problem:

  • My errors were definitely being checked, and validation was "working"
  • Anything I added to  Style.Triggers  was changing the display of the element itself (e.g. the background colour)
  • Nothing I added to  Validation.ErrorTemplate  was changing anything else
After much wailing and gnashing of teeth, I found the following article:



All I needed to do was to wrap my control code in an <AdornerDecorator> tag...

- Gavin

Thursday, April 12, 2012

SharePoint 2010 - Explorer View / WebDAV slow

Is your Explorer View in SP2010 unbearably slow?
Do you go to a SP2010 WebDAV link (i.e. \\servername\davwwwroot\sites\sitename) and it takes up to 30 seconds to load?
Try removing the "Automatically Detect Settings" in IE

Settings -> Internet Options -> Connections -> Lan Settings -> Uncheck "Automatically Detect Settings"



Hopefully now you can do your work in peace at 100X the speed :)

- Gav

Tuesday, April 3, 2012

AXAPTA - Change Company Madness

Happened upon a frustrating little "feature" in Axapta 2009 today.  I'm pulling data from a CSV file into temporary tables in order to do further processing.  As the CSV file has data from multiple companies, I thought I'd use a single routine to modify all my companies data at once.  To do this, I'm using the "changeCompany" command in X++, and obviously I want to clean up the temporary space before I start.


 static void GPJ_Test2(Args _args)  
 {  
   ImportPurchaseOrder importTable;  
   ;  
     changeCompany("company1")  
     {  
       info(curExt());  
       delete_from importTable;  
     }  
     changeCompany("company2")  
     {  
       info(curExt());  
       delete_from importTable;  
     }  
 }  


Looks innocuous enough, right? You'll find that this simply does not work.  The reason - X++ seems to keep a tab on the company you last used the record for.  So, in this example, it will always delete records for "company1" but never for "company2" - because importTable still refers to "company1".  I found doing this works, instead:


 static void GPJ_Test2(Args _args)  
 {  
   ImportPurchaseOrder importTable;  
   ;  
     changeCompany("company1")  
     {  
       info(curExt());  
       importTable.clear();
       delete_from importTable;  
     }  
     changeCompany("company2")  
     {  
       info(curExt());  
       importTable.clear();
       delete_from importTable;  
     }  
 }  


I'm guessing it works, as it clears out that company reference. Bizarre, huh? 


P.S.
Oh, in case you're wondering, the best plan is to use separate variables for each company.  But when we simply substitute this code that's statically assigning the companies with a while loop - that's where things fall down. 


And by the way - if you're doing any querying or updates using this same variable and then deleting - give up now.  Do your deletes in a separate variable, it seems safest.


- Gavin