Cameron Fletcher

Random thoughts and dicussions on the things that interest me
Use the ActionName Attribute, Already

You heard.

I've done a bit of MVC in my time but Neville (who knows more than I do about Oracle but less than I do about MVC) just told me about the ActionName attribute. Here's the lowdown: http://haacked.com/archive/2008/08/29/how-a-method-becomes-an-action.aspx.

That is all.

Posted: Jul 29 2010, 14:48 by flet0496 | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: .NET
TF255440: The following account has a SQL Server login, but the login was denied access

I just got this error when trying to add an Administration Console User to TFS 2010 installed on Windows 7 using a SQL Server database on a different server:

TF255440: The following account has a SQL Server login, but the login was denied access: TEST\cameron.fletcher. The server selected to host the databases for Team Foundation Server is: SQL. The SQL Server login associated with the user account must be granted access to the SQL Server instance on that server.

It turns out that although I have a login specifically assigned to me on the SQL box because I am also a member of a SQL administrators group there appears to be some issue with the TFS logic when verifying the connection. The solution? I simply deleted the login and it worked for me.

Posted: Apr 26 2010, 22:10 by flet0496 | Comments (105) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: .NET
File Transfer via Clipboard Text

I have recently been involved in some work that requires me to program on a Remote Desktop (via RDP over an SSL connection) so there is no development software installed locally. One of the downsides is that due to the restricted nature of the connection only text based copy and paste works, so it is not possible to transfer files onto the development environment. Not only this, but although the local machine has access to the internet, the development environment has none.

The solution? I wrote a console based application called MemCopy to copy files to and from the clipboard as text. It does this by either encoding the file as Base64 then saving it as text on the clipboard, or decoding it from the clipboard.

I'd only written this in one of the environments, so I had to decode it in the other before I could use it - a bit chicken and egg, if you ask me. Anyway, I have attached a link to the encoded text here (you didn't think I was going to give you the solution on a plate did you?)

The code below is all that was required to decode it. I placed the encoding into the resources as a file.

byte[] buffer = Convert.FromBase64String(Resources.Encoding);
FileStream stream = new FileStream("memcopy.zip", FileMode.Create,FileAccess.ReadWrite);
BinaryWriter writer = new BinaryWriter(stream);
writer.Write(buffer);
writer.Close();

For those of you without the technical acumen to decode the above source, I have attached a working copy MemCopy as a zip file here. Simply download and extract MemCopy to a folder of your choosing, copy the contents of the encoded text (above) into memory, then execute MemCopy from the extracted location using the following command:

MemCopy /decode MemCopy.zip

The result? Awesomeness.

Posted: Sep 24 2009, 18:27 by flet0496 | Comments (267) RSS comment feed |
  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: .NET
The [IT] Stig?

Andy Aitken in his normal working attire.

Posted: Sep 07 2009, 12:21 by flet0496 | Comments (0) RSS comment feed |
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:
#500 Firewall Error ##

Occasionally I have received the following error when trying to send emails to other organisation from Exchange 2007:

Diagnostic information for administrators:
Generating server: exchange-server.internal.domain.com
enduser@externaldomain.com
external.mail.server.domain.com #500 Firewall Error ##

It turns out that this is actually due to the Cisco router inspecting SMTP traffic. Entering the command below into IOS fixed the issue:

no ip inspect name SDM_LOW esmtp

Posted: Aug 22 2009, 15:11 by flet0496 | Comments (1) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: Cisco
Technical Skills Datasheet

I am finding it increasingly hard to illustrate my technical skills on my CV due to the large amount of software I have had exposure to – and I don’t mean just sat next to. So I have created my own technical skills datasheet to accompany my CV a copy of which can be found here.

Evidently, you'll notice that my technical prowess do not extend to creation of well formatted PDF files, as upon resizing or come to print the document the font sizing, spacing, and subsequent readability goes haywire. I blame Adobe.

Posted: Aug 14 2009, 11:51 by flet0496 | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: .NET
Catastrophic Failure

Andy Aitken, a guy I work with, evidently abused his copy of Visual Studio 2008 to breaking point and got this message in return. Hats off.

Andy Aitken's Exception

UPDATE: It turns out that a week later I too rose to the dizzy heights of Aitken's abuse:

Cameron Fletcher's Exception

Posted: Aug 11 2009, 16:20 by flet0496 | Comments (0) RSS comment feed |
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: .NET
Converting a CTE T-SQL statement into Linq2Sql

Below is the SQL statement including the common table expression that I need to re-write using Linq2Sql for an application I’m working on. The query identifies the subset of most up-to-date records using a group by query in a CTE. It then performs a join back to the booking table to return the full list of most up-to-date records.What is noticeable about this particular piece of code is the join between table and CTE making use of the isnull keyword.

with cte (RootBookingID, CreatedTime)
as
(
    select
        isnull(ParentBookingID, BookingID),
        max(CreatedTime) -- get the latset version
    from [system].Booking
    where Deleted = 0
    group by isnull(ParentBookingIDBookingID)
)
select b.*
from [system].Booking b inner join cte
on cte.RootBookingID = isnull(b.ParentBookingID, b.BookingID)
       and cte.CreatedTime = b.CreatedTime;

When rewriting this in C#, we first declare the query for the CTE as its own variable.

//define the cte to use as an anchor
var cte = from b in this.Model.Bookings
          where b.Deleted == false
          group b by b.ParentBookingID ?? b.ID into g
          select new
          {
              BookingID = g.Key,
              CreatedTime = g.Max(b => b.CreatedTime)
          };

We can then reuse this variable within our core query (below). Notice how the join on isnull is created by explicitly defining the name of the anonymous type.

//perform a join on the cte to get the results
var qry = from b in this.Model.Bookings
          joinin cte
                  on new
                  {
                      ID = (b.ParentBookingID ?? b.ID),
                      b.CreatedTime
                  } equals new
                  {
                      ID = c.BookingID,
                      c.CreatedTime
                  }
          order by b.PickUpTime
          select b;

The post here explains the stumbling blocks I encountered:

To join multi-valued keys you need to construct an anonymous type on both sides of the 'equals' that is the same type. The anonymous type initializer expression infers both type and name of members from the expressions that are supplied. Using the name = value syntax in the initializer you can specify the name the compiler uses when creating the type. If all members, types, and names are the same then the anonymous types are the same type.

Posted: Jul 21 2009, 13:03 by flet0496 | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: .NET
Flip-flops, beer, and a bottle opener

I bought got my brother to buy some flip-flops at the weekend. Check them out:

And guess what is located on the sole of the them? That’s right, a bottle opener. One per flip-flop:

Now I just need a beer. And a holiday…

Posted: Jul 13 2009, 21:32 by flet0496 | Comments (1) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under:
Hard drive weight increasing?

Possibly the funniest technical question I've seen posted on a technical message board. Ever. Worth a look and you're guaranteed a laugh. 

http://social.answers.microsoft.com/Forums/en-US/vistahardware/thread/720108ee-0a9c-4090-b62d-bbd5cb1a7605

Posted: Jul 08 2009, 08:43 by flet0496 | Comments (0) RSS comment feed |
  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: