Visual Studio javascript extensions

by Victor 23. July 2014 20:39

This one adds AngularJS intelisense:

http://madskristensen.net/post/angularjs-intellisense-in-visual-studio-2012

 


This one adds outlining for regions, brackets, braces, and comments:

 

http://visualstudiogallery.msdn.microsoft.com/4be701d8-af03-40a4-8cdc-d2add5cde46c?SRC=VSIDE

 

Tags: , ,

Getting full path in Windows Service

by Victor 14. July 2014 18:53
AppDomain.CurrentDomain.BaseDirectory

If you need the application path inside of a Windows Service you can use this property to get it. Something I always forget so here it is for easy reference.

Tags: , ,

.NET | C# | Software Development

Return a JSON object using mixedCase properties

by David 16. May 2014 20:17

Normally if you were to use JObject or something similar to return a JSON Object, the properties are formatted in whatever way you have them originally saved. So if you return an object from your Mongo or SQL database and they contain properties such as FirstName or CreditCard, the JObject returns them in exactly that manner, which may not match the naming scheme you use for Javascript, which may be mixedCase instead of CamelCase. 

The following code lets you do just that, return your code in mixedCase.

var jsonSerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };

var json = JsonConvert.SerializeObject(design, Formatting.Indented, jsonSerializerSettings);

Tags:

Convenient C# .NET Regular Expression Tester

by Ethan 7. May 2014 01:51

Found a nice regular expression tester specifically for the .NET engine here.  It'll even give you the C# code to replicate what you tested!

Tags: , ,

.NET | C#

The version of SQL Server in use does not support datatype 'date'

by Rod 29. October 2013 20:51

Hey everybody!

It's been a while since I last blogged... anything, so I decided to post something a bit odd that happened to me today.

I've been developing software for over 3 years, and overall involved in professional industry for over 5 years, yet everyday there is always something that amazes me and leaves me wondering how did this program ever work?

In this particular case, I ran into the error "The version of SQL Server in use does not support datatype 'date'" when trying to deploy a windows service that worked perfectly on my local environment. The error was appearing when calling a stored procedure with a datetime as an input parameter VIA LINQ.

After a bit of research, it appears that the "Date" datatype was added to SQL Server 2008 and this error might appear then. Before the datatypes were smalldatetime and datetime. So I verify this:

My local environment was running SQL Server 2008. Check

The server I was deploying to was running SQL Server 2005. Wonderful. Upgrading the SQL server to 2008 was not an option.

So another bit of research and I found such a simple solution that throws the WTF alarm off: I changed the Dbtype parameter definition on the generated DBML designer.cs file (go to definition on the offending method accessed from the datacontext) from "Date" to "Datetime".

In other words I changed this:

[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.GetMethod")]
public ISingleResult<GetMethodResult> GetMethod([global::System.Data.Linq.Mapping.ParameterAttribute(Name = "UpdateDate", DbType = "Date")] System.Nullable<System.DateTime> updateDate)
{
 IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), updateDate);
 return ((ISingleResult<GetMethodResult>)(result.ReturnValue));
}

To
[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.GetMethod")]
public ISingleResult<GetMethodResult> GetMethod([global::System.Data.Linq.Mapping.ParameterAttribute(Name = "UpdateDate", DbType = "Datetime")] System.Nullable<System.DateTime> updateDate)
{
 IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), updateDate);
 return ((ISingleResult<GetMethodResult>)(result.ReturnValue));
}

 

That's it! Problem solved.

Until the next time,

Stay programming my friends!

Tags:

ASP.NET | Linq | Software Development | SQL

Excel - Trim all cells

by Victor 31. May 2013 07:52

Here's a macro to trim all selected cells:

 

Sub TrimCells()
    Dim R As Range
    Application.EnableEvents = False
    On Error GoTo ErrH:
    If TypeOf Selection Is Excel.Range Then
        For Each R In Selection.Cells
            If R.HasFormula = False Then
                R.Value = Trim(R.Value)
            End If
        Next R
    End If
ErrH:
    Application.EnableEvents = True
End Sub

Tags: ,

Detecting the File Download Dialog in the Browser

by Victor 11. January 2013 19:22

I ran into a scenario in which I needed to know when a PDF file finished "rendering" to the browser. Actually, it was being served as an attachment. Either way, I needed to know when the client got the response back from the server. This stumped me for a while until I found this extremely useful block post describing a very elegant solution using a cookie. The gist of it is to create a token on the client side and send it to the server with your file request. I did it via the query string. On the server side, when the pdf is done, add a cookie with the value of the token. Back on the client side, poll for a cookie with the token. That's it! Check out the full explanation here.

Tags: ,

javascript | jQuery | Software Development | Web Development

Visual Studio Conditional Pre-Build Event

by Victor 9. January 2013 08:35

Say, for example, you want to execute a pre-build event if the current configuration is not Debug. Then you can do it like so:

 

if not '$(ConfigurationName)' == 'Debug' [YOUR PRE-BUILD STATEMENT]

Sorting with CanJS

by Victor 20. December 2012 18:06

I need to sort a list based on the selected value of a dropdown. I didn't find anything built in in CanJS. The can.Model.List does not have a sort method. Luckily, Curtis created a fiddle that does sorting. I adapted his code a bit and added the dropdown.

 

You can see the jsfiddle here

Tags: , ,

Web Development | javascript

"Invalid column name 'CreatedOn'" - Entity Framework Code First

by Victor 7. September 2012 16:53

I started getting this error in a production system a day ago but nothing had changed in that application. The application is a REST web service and hasn't been touched in months. BUT, I did deploy a different application that uses the same database. The new application uses Entity Framework 5.0 and the existing application uses 4.3. Also, the new application uses Code First Migrations so a new table called __MigrationHistory was automatically added. It turns out that the existing application had automatic migration enabled. So, all I had to do was turn that off using this line of code and redeploy the dll.

 

Database.SetInitializer<MyModelContext>(null);
 
I don't think automatic migrations should be enabled by default but I suppose some people would want it. Sometimes I think MS tries to put too many "automagic" features in their frameworks...

Tags: , ,

Entity Framework | Software Development | Web Development

Powered by BlogEngine.NET 2.5.0.6

About Us

Wuji Touch is a software consulting firm based in Delray Beach, Florida. We specialize in Microsoft technologies, but we also have experience with Progress OpenEdge, iOS, and Android development. This is our blog. These are the tales of the pains and pleasures we experience daily in our journey through 1s and 0s.

Month List