Friday, December 18, 2009
Test: Spectral Core Documenter
Documenter generates documentation of database info, assemblies, user data types, roles, schemas, views, triggers, synonyms, tables, columns, indexes, foreign keys, contraints, rules, procedures and functions! The latest version even supports encrypted procedures.
When I tested the application I ran into a small problem and contacted the support team. Just a few hours later the problem was fixed and I could download a new version from their web site. Impressing!
The product is worth every dollar! If you need to document a database, I would recommend this product!
Read more about all the features here.
Friday, August 14, 2009
Time and date in XML
When he tried DateTime.Parse(), the timesone was added to the time, resulting in a string like this: "05.08.2009 20:00:00".
When he tried DateTime.ParseExact(), he could not find a CultureInfo-string that matched the date format.
After some searching he found that the XML namespace also had some date functions. The result was to use the ToDateTimeOffset function in the XML namespace, like this:
System.Xml.XmlConvert.ToDateTimeOffset("2009-08-05T19:00:00+01:00").ToString("yyyy-MM-dd hh:mm s")
After even more research he came up with the final soultion:
DateTimeOffset.Parse("2003-10-29T17:44:00+01:00")
This format is often called the XML format.
Thursday, March 5, 2009
Safe XML
System.Security.SecurityElement.Escape(your string);
The System.Security namespace also have a lot of other nice functions - take a look, and I bet you will find some nice functions you have handcoded yourselv before.
Monday, November 3, 2008
Access WebGuide4 from the web
My MCE runs on an internal computer in my network at home. I also have a web server (IIS6) hosting mye web pages. Since I onlye have one IP-address to my ADSL-router, I hade to find a way to get access to WebGuide, without using a different post that port 80. Why, you may wonder? I didn't want to access WebGuide using an address like: www.mydomain.com:8080. A much sexier way is to create an alias and access the regular pages on: www.mydomain.com and the WebGuide on webguide.mydomain.com.
Ok, so far, so good! But - the WebGuide software is running on a different box than my regular pages. The solution: Install a Reverse Proxy on the webguide-alias on the IIS server.
After some googeling I found a Reverse Proxy that had all the features I needed: ManagedFusion Rewriter. This software have all the features the mod_rewrite module in Apache has.
I also had to install IIS on my MCE, because the Cassini web server included in the WebGuide setup did not work with the reverse proxy. A description on how to set up IIS, is described in the FAQ on the WebGuide pages.
If I access my webguide.mydomain.com now, my IIS6-installation is taking the request, then proxies it down to my MCE-machine. The IIS7 installation on my MCE machine sends the result back to the proxy, that sends it to the client.
I can now access my webguide, even from my mobile, without having to remember any port numbers or anything else...
Friday, June 6, 2008
T-SQL performance problems and solutions
Friday, May 30, 2008
Iterate through Enumeration C#
First create the array using following code:
Array lstProvider = System.Enum.GetValues( typeof(CommonShared.EnumProvider));
Then you can directly call the following foreach loop:
foreach (CommonShared.EnumProvider enProvider in lstProvider)
{
// do something...
}
Monday, May 5, 2008
Pseudo streaming of H.264
A search on Google gave me a few hits, where the most interesting one was: http://h264.code-shop.com/trac. This article states that you have to use a special web server and a plugin on this server. Since we already run IIS, I wanted to find out if IIS could also handle this kind of requests.
I have done a similar thing before with Flash-video, and the code back then was pretty straight forward:
context.Response.ContentType = "video/H264";
string filename = context.Request.QueryString["fil"];
byte[] buffer = new byte[4096];
using (FileStream stream = File.OpenRead(filename)) {
using (MemoryStream memoryStream = new MemoryStream()) {
int count = 0;
do {
count = stream.Read(buffer, 0, buffer.Length);
memoryStream.Write(buffer, 0, count);
} while (count != 0);
memoryStream.WriteTo(context.Response.OutputStream);
}
}
My first attemt using this code was not a success! To find out why, I tried to download the mp4-file from the above URL. I then modified my Flash player to play this mp4-file. Cliked "Play" and ... Yes, it played!!
Why? The difference between my mp4 test file and the one I downloaded from http://h264.code-shop.com/trac was the encoding - not the code or the web server. Take a look at: http://h264.code-shop.com/trac/wiki/Encoding to find out how you should encode the mp4 video, and you will be able to pseudo stream H.264 with standard IIS and a few lines of C# code.
Wednesday, April 16, 2008
Ajax in .NET (Gaia) - High performance
The challange is when you want to use postback to post data with ajax in yoyr page. If you don't need the postback functionality, you should probably just go for Jquery og Prototype. If you need the postback on your page you have to select a framework to do the job for you.
1) You could use Jquery og Prototype for this functionality as well, but you will end up coding a lot of javascript by hand and you have to build webservices to recieve the data.
2) You could use the .NET Ajax framework. This will do the job for you, but a big drawback is that the framwork generates a lot of javascript-references (who is not cached by default). This is slow and I would not recommend it.
3) You could use (and in my opinion should use) a library called Gaia. Basicly this library has the same functionality as .NET Ajax, but in the last release you will have the ability to generate the javascript before you deploy the application, and put it on any webserver you want. The reference to the file will go in the end of the body (where you should put all your javascript refereneces).
Thanx to the Gaia-team and the performence-issues we found in our project, our application could handle over 1200 req/sec during a stresstest, as opposed to 70-80 with the .NET ajax! On the same server, and the same code in the application...
If you need postback and end up using Gaia, I would recommend not using JQuery or Prototype by hand. Do all your Ajax-work with Gaia instead.
So my tip - check out Gaia!! http://ajaxwidgets.com/
Don't use DateTime.Parse(), use DateTime.ParseExact() instead
It seems that very few people know that DateTime.Parse() is COM dependent, evil one. Moreover, even in Microsoft.NET, there is no assurance that such string that DateTime.Parse() accepts on your machine is acceptable under other machines. Basically DateTime.Parse() is for newbies who don't mind unpredictable behavior.
Yes,
DateTime.ParseExact (datestr, CultureInfo.CurrentCulture.DateTimeFormat.GetAllDateTimePatterns(), CultureInfo.CurrentCulture);
instead of
DateTime.Parse(datestr);
is quite annoying because of its lengthy parameters. But first thing you should do right now is to prepare your own MyDateTime.Parse() that just returns the same result of the above. It's also true to several culture-dependent String methods (IndexOf, LastIndexOf, Compare, StartsWith, EndsWith - all of them are culture sensitive, even with InvariantCulture) to avoid unexpected matches/comparisons.
http://msdn.microsoft.com/msdnmag/issues/05/03/CultureInfo/default.aspx?side=true#a
Tuesday, April 1, 2008
10 Tips for Writing High-Performance Web Applications
Tip 1—Return Multiple Resultsets
Tip 2—Paged Data Access
Tip 3—Connection Pooling
Tip 4—ASP.NET Cache API
Tip 5—Per-Request Caching
Tip 6—Background Processing
Tip 7—Page Output Caching and Proxy Servers
Tip 8—Run IIS 6.0 (If Only for Kernel Caching)
Tip 9—Use Gzip Compression
Tip 10—Server Control View State
http://msdn.microsoft.com/msdnmag/issues/05/01/ASPNETPerformance/toc.asp
