Search This Blog

Friday, October 11, 2013

Loop through SQL values without a cursor.


3rd Time I had to recreate this example so I'm posting it now.


   1:   
   2:  DECLARE @Users TABLE( 
   3:    [RowNumber] Int  PRIMARY KEY,
   4:    [UserId] uniqueidentifier)
   5:   
   6:  DECLARE @iCount Int
   7:   
   8:  INSERT INTO @Users (RowNumber, UserId)
   9:  SELECT rank() Over (order by UserId)
  10:          ,UserId
  11:  FROM Profile
  12:  WHERE PropertyValuesString like '%ReportPending%'
  13:   
  14:   
  15:  SET @iCount=1
  16:  WHILE ((SELECT MAX(RowNumber) FROM @Users) >= @iCount)
  17:  BEGIN
  18:   
  19:          SELECT * FROM @Users WHERE RowNumber = @iCount
  20:          SET @iCount=@iCount+1
  21:  END

Wednesday, October 9, 2013

Working on my first WPF application from scratch

At work, the project I manage (MVC web app has a WPF installer) had a couple of installer related issues.  I've been on this project ~2 years  and up to now I had no reason to modify the WPF installer app.  I need to determine if the project is going to keep the WPF installer or go with a NSIS based installer.  I reviewed the code and came to the conclusion I know very little about WPF.

So last Friday, I started a small WPF project.  I have a little Lego Parts app I have rewritten a couple of times that currently has a WinForms MDI UI.  Obviously my Lego app needs a WPF UI client.

I thought I would capture my thoughts on WPF.

WPF Cons

  • On controls, renamed Text properly to Content.  This is just annoying.
  • Not all controls (example DataGridColumn) have a Name property.
  • XAML - Maybe unfair on day 1 to say this and yes I'm using yesterday;s tech with VS 2010 but it can be so sloooooow.
  • Property windows for WPF controls/Pages etc...  is terrible.  No really good way to getting to the properties I really use often.
  • Unavoidable not annoying differences in names of method and properties differences between a WPF control and its WinForm counterpart.
  • WPF UI is still a bit slower than its WinForms alternative even on a i7 CPU 3.3 Ghz with a middle of the road video card.


WPF Pros

  • XAML - (4 hrs in).  Now I get it.  Once you know a control / page / window property you want to modify just edit the XML.  This is a huge time saver for repetitive tasks.  Plus this compensates for the terrible VS 2010 properties sheet UI.
  • UI elements.  I like page view paradigm.  
    • I really like DataGrid.  Fantastic that the grid keeps its position when itemsource is updated.
  • Extracting InvokeRequired from UI.  This is completely different in WPF but I like the change. It should never have been married to the Control in WinForms.
  • Data Binding approach is streamlined and simple.
  • Basic settings for UI controls moves so far beyond WinForms.  Colored backgrounds, transparency etc...


Bottom line, in under 8 hours, I managed to restructure an existing C# solution to keep the existing WinForms UI project, move common code out of WinForms UI project, and create the basic elements of WPF UI in a new project.

  

Tuesday, October 1, 2013

Snipe Hunt: Finding best way to delete large number of files in Windows 7

Attempting to defrag my hard drive recent and one of the largest fragmented folders was:

C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.IE5

Turns out this folder had over 39 million files taking up 60 GB of drive space.
So it begs the question how do you delete a huge number of files from Windows 7.

Turns out this is the approach I am currently using:

del /f/s/q %1 > nul 
rmdir /s/q %1

from http://www.anushand.com/2012/09/a-faster-way-to-delete-large-folders-in.html

I've estimated it will take ~ 4 days to delete all of these files.

My steps:

1. Rename folder Content.IE5 to (old) Content.IE5
2. Run
                del /f/s/q %1 > nul 
                rmdir /s/q %1

                del /f/s/q "(old) Content.IE5\CAY*.*"