IT stuff

No more then a few paragraphs of things I want to archive (instead of try to remember)

Tuesday, October 11, 2011

Tools used for presenting

One tool that I cannot live without during presentations is ZoomIt. This tool supports screen zooming and annotations for technical presentations. It has a very small footprint and will not impede your presentation. Here is a good YouTube vid of ZoomIt usage.

A great timer application is always helpful for sticking to a schedule. Focus Boost makes a small, simple, free timer.

Please add comments with other tools you have used during your technical presentations.

Monday, September 19, 2011

Serializing an object to file

I'm always trying to compare two objects of the same type with different situations. An easy way to do this is to kick out the serialized version of each object and diff them with Araxis (or your diffing tool of choice). However, I always forget the snippet used to do this. Keep in mind, you have to have your object decorated with Serializable to do this.

vm = GetViewModel(Client, groupProposal, gpgDashboard);
 
/* start serialization */
var serializer = new XmlSerializer(typeof(GroupProposalGridViewModel));
var output = new StringWriter(new System.Text.StringBuilder());
var xmlTempDocument = new XmlDocument();
 
serializer.Serialize(output,vm);
xmlTempDocument.LoadXml(output.ToString());
xmlTempDocument.Save(@"C:\Temp\GroupProposal.xml");
/* end serialization */
 

Thursday, April 7, 2011

Multiple DIV center technique

I always have a hard time finding CSS specific to my neeeds. Below is an example that will center n-amount of DIVs:

<style type="text/css">
body {
font-family: Verdana,Arial;
font-size: 12px;
letter-spacing: -0.04em;
}

#product-list-outer-container {
background-color: #F7F4EF;
position: relative;
width: 100%;
height: 75px;
}

#product-list-container {
position: absolute;
left: 50%;
}

#product-list-inner-container {
position: relative;
left: -50%;
width: 245px;
height: 75px;
}

.product {
background-color: #EEE6DC;
float: left;
margin: 5px 5px;
padding: 5px 5px;
}
</style>


<div id="product-list-outer-container">
<div id="product-list-container">
<div id="product-list-inner-container">
<div class="product">Shoes</div>
<div class="product">Jacket</div>
<div class="product">Socks</div>
<div class="product">Hat</div>
</div>
</div>
</div>

Tuesday, February 9, 2010

How to deal with an ambiguous method exception in MVC

This was sent to me by a friend at work, Andy Pickett, and I thought it deemed worthy of Brain.Save:

Ok, I wanted to have these URLs both be valid:

1) http://localhost/ProposalGrid.mvc/display/2/15418
- Get the latest Active Proposal for borrower
2) http://localhost/ProposalGrid.mvc/display/2/15418/26
- Get the Proposal with ProposalId = 26 (assume borrowerid matches)

I think these may be common scenarios throughout CARRS given the way we’ve set up route masks (ignore for the moment that there are Primary Keys in our URLs ;) )

I wanted 2 different action methods (instead of a single action with a switch stmt):

A) public ActionResult Display()
B) public ActionResult Display(int id)

but by default mvc doesn’t like that and can’t figure out which method to call for the #2 URL above, it throws an ambiguous method exception at runtime (note: #1 works fine and always goes to (A)). So I found this on StackOverflow, and I think it makes some sense.

http://stackoverflow.com/questions/1045316/asp-net-mvc-ambiguous-action-methods

So I added and modified their RequireRequestValueAttribute to check if the Route has data for “id” (has to be an positive int per route mapping). And then by adding it to the action method like so:

[RequireRequestValue("id")]
public ActionResult Display(int id)

then URL (1) gets routed to Action (A), and URL (2) goes to (B). So far it works the way I want it to, but it may not be the preferred “MVC way”. If there’s alternatives out there please let me know. Otherwise, feel free to use this attrib for your own overloads.

Monday, January 11, 2010

x64 IIS7 MVC 404

Hopefully this will save people time when setting up MVC to work with IIS7 using the .MVC extension. Most of these steps are well documented elsewhere, but the x64 thing took a while to figure out (Thanks Jeff Diercks).




  1. Add the .MVC extension to the [Handler Mappings] of the website, and make sure to use the same ISAPI DLL as the .ASPX extension within the Website settings.


  2. Make sure [Network Service] has full access to the filesystem directory IIS is pointing to.


  3. Make sure [Managed Pipeline Mode] is set to [Classic] in the Application Pool settings.


  4. In 64-bit OS, make sure to set the [Enable 32-Bit Applications] to [True] in the Application Pool settings.



If you find any other settings that you had change, please add comments.

Monday, December 14, 2009

Crystal Reports on Visual Studio 2010

Our boss is allowing us to install and use Visual Studio 2010 (in beta). That said, Crystal Reports is not yet available for VS 2010. Uggg. Thought this was going to be a deal breaker, but it seems that you can install the CRRedist2008_x86.msi and continue to use Crystal Reports, but just not edit the reports themselves. That said, here is the official documentation that we put in our Wiki:


Crystal Reports Configuration:
As we all know, Crystal Reports is a necessary evil for the ERS applications we have such as NAO and IO for example. This document was created to walk a developer / System engineer through the installation process and debugging steps.

Installation steps:

Run the MSI installer package called "CRRedist2008_x86.msi".

Important to note is that the installer will install files in two different locations.

  1. .Net assemblies in the GAC
  2. COM objects under the Program Files\Business Objects directory.

Also important to note is the Crystal Report .Net assemblies use COM interOP with the Crystal Reports COM objects.

If things go well, everything should work but typically is not the case. Below are a number of steps to try in case things don't go according to plan.

  1. In the folder “c:\program files\ business objects\” make sure the local group on the server called “Users” has full control of it and its subdirectories. (Read permissions will not suffice)
  2. Look into the GAC using Windows Explorer at “C:\WINNT\assembly”. Scroll through the list of assemblies and look for ones starting with the words CrystalDecisions.xxxxx. If you don’t see any, run the “CRRedist2008_x86.msi” installer again. If you do see some, make sure you see the version number of 10.5.3700.0. If you see an earlier version, you most likely used the wrong MSI installer package.
  3. If step 1 and 2 don’t work, look at the file system security settings of the root of the website. Add the local account of “Network Services” and give it full permissions. Make sure the sub directories inherit from the root folder.

Please keep in mind that Crystal reports may install on some servers with no problems but not on others. It can be both perplexing and frustrating as to why this is. As far as we know, there is no rhyme or reason on why this is. Our one suggestion is to give yourself ample time for the Crystal reports installation.

Lastly, if things do work you should see a shiny new PDF document pop up if you selected PDF on the reports creation page. If you see a dialog box asking you to save instead, that just means you don’t have Adobe Acrobat Reader on your computer.

Thursday, May 14, 2009

Shrinking SQL DB with scripts

Today I went through the fun exercise of Restoring a multi-gig SQL database from Backup.

5+ hours later, I knew I didn’t want to go through it again! Anywise, long story short, we had some scripts at work that truncates unused tables, truncates the transaction log, and shrinks the data file. I slightly modified this script to work with the currently selected database.

-- truncate unneeded tables
--TRUNCATE TABLE {tablename}
--GO
-- truncate transaction log
DECLARE @LOG_FILENAME VARCHAR(200)
SELECT @LOG_FILENAME = FILE_NAME (2)

BACKUP LOG NAO WITH Truncate_only
DBCC SHRINKFILE (@LOG_FILENAME)
GO

-- shrink data file
DECLARE @DATA_FILENAME VARCHAR(200)
SELECT @DATA_FILENAME = FILE_NAME (1)

DBCC SHRINKFILE (@DATA_FILENAME)
GO