Monday, November 21, 2011

Writing Custom Code in SQL Server Reporting Services

To add code to a report 

1.On the Report menu, click Report Properties. 
  Note If the Report menu is not available,
  click within the report design area. 
2.On the Code tab, in Custom Code, type the code.

Methods in embedded code must be written in Visual Basic .NET. The following is a sample function to calculate Last Monday.

Public Function StartDate()
StartDate = Today.AddDays(-6 - Today.DayOfWeek())
End Function

Writing Custom Code in SQL Server Reporting Services

Friday, November 18, 2011

Run MS Test via the command-line tool MSTest.exe

  • Right-click the ‘List of Tests’ option in the tree view on the left and select the ‘New Test List…’ option.
  • Fill out the dialog with a meaningful name and description.
  • Click the ‘All Loaded Tests’ option in the tree view to display a list of available tests. Right click on the displayed list and select the menu item.
  • Running MSTest at the command prompt with the ‘testmetadata’ option pointing to your new vsmdi file will run the tests.
"C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\MSTest.exe" /testmetadata:%1.vsmdi

Wednesday, November 09, 2011

Replay an IIS web server log

  1. Click Test and then click New Test.
    The Add New Test dialog box is displayed.
  2. Under Add to Test Project, choose one of the options for creating a new test project. For example, click Create a new Visual C# Test Project.
    Note:
    By default, the type of test project shown under Add to Test Project is the type that is currently set as the default in the Options dialog box, which is available onthe Tools menu. For more information, see How to: Configure Test Project Creation.
  3. In the Templates pane, select the type of test you want to add.
  4. Click OK.
    The New Test Project dialog box appears.
  5. Enter a name for the new test project, or accept the default name, and click Create.
  6. Depending on the type of test you chose, you can either hand-code or generate the newly added test.
Microsoft.VisualStudio.TestTools.WebTesting namespace is in
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\ Microsoft.VisualStudio.QualityTools.WebTestFramework.dll
Application must target .NET Framework 4.

To reference the Log Parser, look for the “MS Utility 1.0 Type Library – LogParser Interfaces collection” COM component in the Add Reference dialog.


MSDN: Create a Test Project
Josh Christie: Replay an IIS web server log
VS 2010 compiler error: Interop type XXX cannot be embedded. Use the applicable interface instead.

Thursday, October 13, 2011

Prevent popup appearing before the page is fully rendered.

StringBuilder strScript = new StringBuilder();
strScript.Append(" ");
ClientScript.RegisterStartupScript(this.GetType(), "Pop", strScript.ToString());

When you click the Save button, the popup may appear immediately after the postback with the white screen background.


Solution 1:
StringBuilder strScript = new StringBuilder();
strScript.Append(" ");
ClientScript.RegisterClientScriptBlock(this.GetType(), "Pop", strScript.ToString());

Solution 2: Add a timer to the alert

strScript.Append("window.setTimeout('displayMessage()', 1000);\n");

Monday, September 19, 2011

Registry Edits for Windows XP

Windows XP - Fix Suddenly lost the ability to minimize programs onto the taskbar


Registry Edits for Windows XP

Thursday, September 15, 2011

WYSIWYG HTML editors

elRTE is a WYSIWYG HTML editor for the Web written using jQuery. It features rich text editing, options for changing its appearance and style, insertion and management of various HTML elements with formatting (images, tables, lists, etc.), support for viewing and editing HTML code, and normal and full-screen modes.
elRTE

TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under LGPL by Moxiecode Systems AB.
TinyMCE

PATCH .trim() in JavaScript not working in IE


if (typeof String.prototype.trim !== 'function')
{
String.prototype.trim = function()
{
return this.replace(/^\s+\s+$/g, '');
}
}

Tuesday, August 02, 2011

Change List data to IQueryable data

Change List data to IQueryable data

Public Function SortPolicyList(ByVal piNotes As List(Of PolicyDetail), ByVal piSortExpression As String) As List(Of PolicyDetail)
Dim policies As IQueryable(Of PolicyDetail)
policies = piNotes.AsQueryable() ' Change List data to IQueryable data
policies = policies.OrderBy(piSortExpression) ' Require System.Linq.Dynamic
Return policies.ToList
End Function

Wednesday, June 22, 2011

Smart Color Tool

If you want a nicely color-coordinated Web application, try Behr's Smart Color tool. It will help you pick a perfectly coordinated, tri-chromatic color palette.

Monday, June 13, 2011

T4: Text Template Transformation Toolkit

T4 is a Visual Studio code-generation language which was introduced with Visual Studio 2005. T4 templates are used in the Entity Framework and MVC and can be useful for your own development purposes.

Oleg Sych

Oleg Sych - MSBuild Integration

Visual Studio 2010 offers a new capability to perform template-based code generation at build-time with a set of MSBuild extensions available as part of the Visualization and Modeling SDK.

Friday, June 10, 2011

Calling WCF Web Services from JavaScript

Whenever you need to consume a WCF web service from a web page, you have (at least) three options:

Have the ASP.NET ScriptManager generate a strongly-typed JavaScript proxy to the service that you can call directly.
Use your own JavaScript, or some third party, library such as jQuery to invoke a service in REST style.
Use your own JavaScript to invoke a service using SOAP.

The first two require that you have control over the bindings specified in the Web.config file or the factory in the .svc file.


Call the service in JavaScript:

var svc = new WcfAjaxServices.TestService();

svc.GetTest('a', 'b',
function(result, context, functionName)
{
window.alert('A: ' + result.A);
},
function (error, context, methodName)
{
window.alert('error: ' + error);
}, null);


The methods look like the ones defined in the contract plus 3 additional arguments:
- a function to call in case of success
- a function to call in case of error
- an optional context

result and error are JavaScript objects
methodName is the name of the function that started the request.

Development With A Dot

Tuesday, June 07, 2011

Log parser

Log parser is a powerful, versatile tool that provides universal query access to text-based data such as log files, XML files and CSV files, as well as key data sources on the Windows® operating system such as the Event Log, the Registry, the file system, and Active Directory®. You tell Log Parser what information you need and how you want it processed. The results of your query can be custom-formatted in text based output, or they can be persisted to more specialty targets like SQL, SYSLOG, or a chart.

Common use:
logparser <options> <SQL expression>

Example:
"C:\Program Files\Log Parser 2.2\logparser.exe" -i:W3C -o:W3C -e:10 "SELECT date, time, cs-username, sc-status, cs-uri-stem, cs-uri-query INTO FT_*.log FROM *.log WHERE cs-uri-stem LIKE '%%.aspx' ORDER BY date, time"

Friday, May 20, 2011

Cannot create/shadow copy 'File Name' when that file already exists

Workarounds

Configure hostingEnvironment in Web.config

<system.web>
<hostingEnvironment
idleTimeout="120"
shutdownTimeout="30"
shadowCopyBinAssemblies="false" />
</system.web>

Add these lines in the pre-build event command line, which basically unlocks the DLL within Visual Studio.

IF EXIST $(TargetPath).LOCKED (del $(TargetPath).LOCKED)
ELSE (IF EXIST $(TargetPath) (move $(TargetPath) $(TargetPath).LOCKED))

Friday, May 06, 2011

The path maps to a directory outside this application, which is not supported.

Problem
Error thrown when virtual folder has trailing backslash at end of Local Path setting in IIS.

Solution
Remove trailing backslash at end of Local Path setting in IIS of virtual folder.

Error message in ASP.NET v2.0

Server Error in '/MyBadVirtualFolder/MyApplicationFolder' Application.
The path '/MyBadVirtualFolder/MyApplicationFolder/App_GlobalResources/' maps to a directory outside this application, which is not supported.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Thursday, March 17, 2011

Host MVC App on IIS 5.1 (XP Professional)

There is some wierd little bug in that form so you have to click back inside the executable text box after you navigate to the .dll and select it. Otherwise the “OK” button stays grayed out, i don’t know why it does it or why click back into the box works, but it does. For extension, put “.*” and make sure that “Check that file exists” is unchecked.

Host MVC App on IIS 5.1

JavaScript Garden

JavaScript Garden is a growing collection of documentation about the most quirky parts of the JavaScript programming language. It gives advice to avoid common mistakes, subtle bugs, as well as performance issues and bad practices that non-expert JavaScript programmers may encounter on their endeavours into the depths of the language.

JavaScript Garden

Friday, February 25, 2011

Computer Keyboards Designed To Prevent Repetitive Strain Injury (RSI)

Computer Keyboards Designed To Prevent Repetitive Strain Injury (RSI)

An ergonomic keyboard is a computer keyboard designed with ergonomic considerations to minimize muscle strain and a host of related problems.

Kinesis

TouchStream LP QWERTY

Repetitive Strain Injury (RSI)

Monday, February 21, 2011

Unix Power Tools

Don't Confuse Regular Expressions with Wildcards.

Both the shell and programs that use regular expressions have special meanings for the asterisk *, question mark ?, parentheses ( ), square brackets [ ], square brackets { } and vertical bar |.

Multiple commands can be issued on the command line, separated by a semicolon (;).

Q & A: newline
Q & A: others

sed tutorial
Unix Power Tools
Searching for Text with grep
sed scripts
IBM: sed by example
sed examples

Thursday, February 10, 2011

VB.NET: Import and Export Excel Data with LINQ to XML

Embedded VB.NET Expressions

In Visual Basic 9.0, an XML literal is considered an expression. If you want to assign a value to an object representing an XML tree, you can simply write that value as an assigned expression, as
follows:

Dim customers = _
From customer In Me.CustomersDataSet.Customers _
Where customer.RowState <> DataRowState.Deleted _
AndAlso Not customer.IsAbbrevNull _
Order By customer.Abbrev _
Select <Row>
<Cell><Data ss:Type="String"><%= customer.Abbrev %></Data></Cell>
<Cell><Data ss:Type="String"><%= If(customer.IsNameNull, "", customer.Name)%> </Data></Cell>
<Cell><Data ss:Type="String"><%= If(customer.IsPhoneNull, "", customer.Phone)%> </Data></Cell>
<Cell><Data ss:Type="String"><%= If(customer.IsCountryNull, "",customer.Country)%> </Data></Cell>
</Row>

VB.NET: Import and Export Excel Data with LINQ to XML

Wednesday, February 09, 2011

Writing a long string in multiple lines

Writing a long string will always produce scrollbars in the editor. So it’s better to split it to multiple lines which is more easy to read.

String LongLine = @”...............
...................................
..................................."

You can escape ” by using "".

Tuesday, February 08, 2011

Moq

Moq (pronounced "Mock") is the mocking library for .NET developed from scratch to take full advantage of .NET 3.5 (i.e. Linq expression trees) and C# 3.0 features (i.e. lambda expressions) that make it the most productive, type-safe and refactoring-friendly mocking library available. And it supports mocking interfaces as well as classes.

Codeproject C#: Mock a database repository using Moq

Monday, February 07, 2011

Designing and Building RESTful Web Services with WCF 3.5

When you design a RESTful service, you focus on the resources that make up your system, their URIs, and their representations.

RESTful services conform to the HTTP uniform interface – you simply need to decide which of those methods you’ll support for each resource.

In order to remove humans from the equation, you’ll need to use resource representations that are easy to programmatically consume.

MSDN: A Guide to Designing and Building RESTful Web Services with WCF 3.5

Wednesday, February 02, 2011

Find Duplicate Image Files On Windows PC

If you are a quick fingered photo-snapper or a wallpaper junkie then the thousand of images on your hard drive could be a treasure hoard. But scattered among them could also be a few hundred duplicate images eating up space on your hard drive. Even worse, un-optimized raw images could be eating up chunks of bytes and can be officially called junk.

So, how do we go about covering up our laziness and cleaning up our image folders?

Here’s a list of software apps in no relative order of merit
that can find duplicate image files.

MAKEUSEOF: 5 Ways To Find Duplicate Image Files On Windows PC

Tuesday, February 01, 2011

Map and unmap XML elements in Excel

To import and export XML data files in Excel, you must create an XML map, and then map and unmap XML elements to cells to get the results that you want.

Microsoft Office Excel 2007

By using XML maps, you can easily add, identify, and extract specific pieces of business data from Excel documents

Monday, January 31, 2011

Microsoft Visual Studio 2010 Visualization & Modeling

Visual Studio 2010 Feature Pack 2 (MSDN Subscribers Only)

Use the Generate Code command to generate skeleton code from elements on UML class diagrams. You can use the default transformations, or you can write custom transformations to translate UML types into code.

Create UML class diagrams from existing code.

Domain Specific Language (DSL)

Example: VHSIC hardware description languages

MSDB: Browse and Navigate Graph Documents

Friday, January 28, 2011

Fiddler Web Debugger

Fiddler is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP(S) traffic, set breakpoints, and "fiddle" with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language.

Fiddler Web Debugger

Tuesday, January 25, 2011

LINQ to SQL Debug Visualizer

LINQ to SQL developer may use a "debug visualizer" to hover over a LINQ expression while in the VS 2008 debugger and inspect the raw SQL that the ORM will ultimately execute at runtime when evaluating the LINQ query expression.

LINQ to SQL Debug Visualizer

Monday, January 10, 2011

Web Performance Test Using Visual Studio

Performance of an application is very important for a multi-user application.
We need to consider the speed of execution, load and concurrency aspects.

Visual Studio Test edition or Visual Studio 2010 Ultimate provides the support for test automation.

Debugging support in Unit Testing


All test classes/methods can be run under debug mode. Simply put a break point where the code needs to stop and start the test by clicking “Debug Tests in Current Context” button located in the toolbar or “Tests in Current Context” menu of Debug option under Test menu.


Web Performance Test Using Visual Studio - Part I
Web Performance Test Using Visual Studio - Part II
MSDN: Report Visual Studio Team System Load Test Results Via A Configurable Web Site
MSDN: How to Create a Results Repository Using SQL
MSDN: A Unit Testing Walkthrough with Visual Studio Team Test
MSDN: How to Create a Data-Driven Unit Test

Monday, January 03, 2011

Working Around Windows Vista’s "Shrink Volume" Inadequacy Problems

Run the Disk Cleanup Wizard, making sure to remove the hibernation file and all restore points.

Disable System Restore

Disable the pagefile ( Open up System in Control Panel, then Advanced System Settings \ Advanced \ Performance \ Advanced \ Change \ No Paging File.

In the same Advanced Settings, go to Startup and Recovery \ Settings and then change the Write debugging information drop-down to “None” to disable the kernel memory dump.

Disable Hibernation mode in your power options \ advanced power options screen.

Reboot the machine, and then delete your c:\pagefile.sys file, following these instructions if you are having issues.


howtogeek.com

Ubuntu

Ubuntu is an ancient African word meaning 'humanity to others'. It also means 'I am what I am because of who we all are'. The Ubuntu operating system brings the spirit of Ubuntu to the world of computers.

2004, Mark Shuttleworth gathered a small team of developers from Debian Linux project to create an easy-to-use Linux desktop, Ubuntu.

Ubuntu