Now I have a very very useful Microsoft VX-1000 webcam!

Microsoft VX-1000 LifeCam - Photo taken from http://images.amazon.com/images/G/01/electronics/detail-page/LCVX1.jpg After ages, finally I’ve bought a new Microsoft VX-1000 webcam and as I’m checking it out, think it’s out of this world!
As a matter of fact, it’s not the latest release of Microsoft webcams but I think this is what I was looking for!

Here’s some of its features I can see in its user-manual:

Photo Swap

Share and swap photos in real time with your friends and family using Windows Live Messenger—right in the video call window!

Windows Live™ Call Button

It’s simple to start video calls. One touch of the Windows Live Call Button lets you see who’s online, and you’re on your way to making a video call.

LifeCam Dashboard

Add special effects and control your webcam—all from the Windows Live Messenger window.

One-Touch Blogging

Upload photos to your blog on Windows Live™ Spaces with any of your photos at the simple click of your mouse.

Superior Video and Photo Quality

See the smiles clearly with 640 × 480 pixels video and photo resolution.

Optimized for Windows Live Messenger

Seamlessly integrated with Windows Live Messenger for easy setup and use.

Universal Attachment Base

It’s a snap to attach the LifeCam to any monitor.

Built-In Microphone

The built-in microphone automatically picks up your voice with remarkable clarity.

Video Effects

Discover a fun way to express yourself with these entertaining video effects built into the LifeCam dashboard.

How to convert DateTime to a specific culture using CLR integration

During my Pocket PC project development, I needed to convert Gregorian date to Persian date. It’s easy to do such a thing in Windows or Web applications using System.Globalization namespace (PersianCalendar class) but this feature is not available when developing a Pocket PC application. I’ve tried a lot of things such as web services, windows services, etc but none of them is as good as converting it in your database and fortunately my database is Microsoft SQL Server 2005. So I decided to use CLR integration and create an UDF (User-Defined Function) in order to do so. In this post I wanted to show you how you can use CLR to create a function in .NET environment and execute it in SQL Server 2005-2008 environments.

The first thing you need is to create a SQL Server project which is available in Database node in new Project window:

Creating a SQLServer Project

Note that I used .NET Framework 2 because I wanted to create a CLR function in SQL Server 2005. If you’re using SQL Server 2008, there’s no problem to use .NET Framework 3.5 (SP1).

After you create a SQL Server project you can add any object that is common in SQL Server to your project by right click on the project and point to add; so you add a UDF, SP, etc:

Adding a new object 

As I mentioned before, we want to create an application which converts DateTime to another culture so I need to create a UDF. I select User-Defined Function and name it “PersianDateConvertor”. As you can see, Visual Studio will create a class named UserDefinedFunctions and add a method with the name you just specified:

using System;using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString PersianDateConvertor()
{
}
};

Now you need to convert a DateTime to a Persian DateTime like before using System.Globalization.PersianCalendar class. So our class will be something like this:

[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString PersianDateConvertor(DateTime dt)
{
PersianCalendar p = new PersianCalendar();
return String.Format("{0}/{1}/{2}",
p.GetYear(dt).ToString(),
p.GetMonth(dt).ToString(),
p.GetDayOfMonth(dt).ToString());
}

By the way, As you can see our method is a static method and it returns a SqlString. You can change the return type if you want.

You’ve created you CLR library! Now it’s time to use it in Microsoft SQL Server. By default, you cannot use CLR libraries in SQL Server unless you enable it. In order to enable CLR integration, you need to make use of sp_configure system stored-procedure:

EXECUTE sp_configure 'clr enabled' , '1'

Note: In order to enable CLR, you need administrative privileges.

In order to make use of an external assembly in SQL Server, you have to create an assembly like following:

CREATE ASSEMBLY DateConvertorFROM 'D:\MMR.CRL.DateConvertor.dll'WITH PERMISSION_SET = SAFE;GO

After you’ve created your assembly, you need to use it in an UDF, SP, etc:

CREATE FUNCTION dbo.GetPersianDate(@date datetime)
RETURNS nvarchar(max)AS EXTERNAL NAME DateConvertor.UserDefinedFunctions.PersianDateConvertor;
GO

You’re DONE! now you can use your UDF and the result will be something like this:

SELECT dbo.GetPersianDate(GetDate())

Result:

————————————————————-

1387/12/2

(1 row(s) affected)

The first hard-working experience in 2009

Photo taken from: http://www1.istockphoto.com/file_thumbview_approve/3886489/2/istockphoto_3886489_hard_working_man.jpg It’s about 2-3 weeks that I’m very busy and I have no time to do anything! As a matter of fact, I’m handling 3 applications in one time and it’s very difficult to manage these works together. In this post I’m going to describe a little about my projects.

Pocket PC application

As I mentioned before, I’ve developed an application based on Windows Mobile which enables waiters to take customer’s orders much easier and without any paper. Most of this application’s sections are as same as other applications except that, they have lots of specific accounting calculations and some of them are extremely difficult to implement.

System.Web.Portal

This self-project needs a lot of codes! I’ve finished a starting point of its engine and one of its modules and currently I’m currently working on the second module of this portal. For more information about System.Web.Portal, you can check out my previous post about it.

Travel Agency Application

My main work is a reservation application for a travel agency. In fact, it has a lot to do and the application is so big! It’s about 4-5 months that I’m working on it and it doesn’t finished yet!

My usual work

It’s a natural thing that I’m working for a company; so I have to go to work every morning and come back every afternoon. This part waist my time a lot but it’s necessary and company doesn’t care about my other applications so I have to do my best at work.

Moonlight 1.0 released – Open source implementation of Microsoft Silverlight for UNIX systems

It might be the best news for web developers who’re developing applications under UNIX/Linux platforms that Moonlight 1.0 has been released today.

Moonlight 1.0 preview - Photo taken from http://tirania.org/tmp/xjgdwt.png

Moonlight is an open source implementation of Silverlight (http://silverlight.net), primarily for Linux and other Unix/X11 based operating systems. In September of 2007, Microsoft and Novell announced a technical collaboration that includes access to Microsoft's test suites for Silverlight and the distribution of a Media Pack for Linux users that will contain licensed media codecs for video and audio.

I have to thank all Novel Moonlight development team for this release.

You can download it right now by click here

Split function in SQL Server

A while ago, when I was working in a company with my friend Omid Mafakher, he developed a table function which works just link split function in other languages such as VB.NET, C#, C++, etc.

After I get permission from Omid, I decided to publish it as a blog post. Here’s the function:

-- This stored procedure splits a string value with the specified delimiter.
-- Copyright 2007 Omid Mafakher.
Create Function [dbo].[Split] (@String nvarchar(MAX), @Delimiter char(1))
Returns @Results Table (Items nvarchar(MAX))
As
Begin
    Declare @Index int
    Declare @Slice nvarchar(4000) 

    Set @Index = 1
    If @String Is NULL Return 

    While @Index != 0 Begin
        Select @Index = CharIndex(@Delimiter, @String)
        If (@Index != 0) Begin
            Select @Slice = left(@String, @Index - 1)
        End else Begin
            Select @Slice = @String
        End
        Insert into @Results(Items) Values (@Slice)
        Select @String = right(@String, Len(@String) - @Index) 

        If Len(@String) = 0 break
    End
    Return
End

SplitFunction.sql (1.38 kb)

Overweight is hurting me

It’s about a year that I really upset about my weight and I did anything to solve this issue but nothing happened. I went to a doctor whose profession was nutrition and asked him to do something. He told me to take a blood test for my thyroid gland but after I took the result of that test, found out that my thyroid gland has no problem.

I started to exercise in order to lose fat by registering in a bodybuilding club but some stuff like my job, family problems, etc. prevented me to continue. I also used to go to a park near my house and ran for an hour every night but it had no effect.

There are a lot of websites which give you lots of information about losing fat and I think the best one is MSN Health. I read a lot of articles there and tried to control my eating but as a matter of fact, I am a developer who’re spending a lot time behind a table and developing applications. For instance, I spend about 4 hours on my new project (System.Web.Portal) today because I’m going to release the first beta version in few weeks and as I know, there is no way!

A few days ago, I decided to go outdoors more and walk on 10 PM every night because I’m busy every day until that time. If you have any idea about how can I lose fat, please comment it.

Are you satisfied of Windows 7?

I'm not satisfied of Windows 7 - Photo taken from: http://images.elfwood.com/art/c/a/cappon/cartoonsadperson.jpg Few months ago, Microsoft released a beta version of Windows 7 and encouraged everyone especially developers to install it. “This version is out of this world!” said Microsoft. So I downloaded and installed it and I was decided to migrate from Windows Vista SP1 to 7.

Everything was fine and Windows installed successfully; so I saw the Windows 7’s new look and said “WOW! What a look!” Then checked out some new features such as its calculator, the new Windows Gadget Box, Multi-Photo background and more I thought that Windows 7 will be a good Windows.

The problems started when want to install my drivers. I started to install my Creative Sound Blaster and suddenly the Windows crashed and showed me the blue screen! I restarted my computer and saw that Windows was trying to send some information about my issue to Microsoft. I selected OK. My cell phone rang and I started to talk to one of my friends for about 15mins. I came back and saw that Windows still send anonymous information about my issue to Microsoft! So I checked my network traffic and realized that the information was about 100Mb (WHAT THE HELL!!!).

I canceled the operation and continued to install some applications such as Antivirus but I couldn’t because it doesn’t support my Antivirus software (Trend Micro PC-Cillin 2008). I tried to install Windows Live OneCare because I thought that Microsoft may have done something for this issue at least on its own Antivirus but when I started to install it, said that “Windows Live OneCare doesn’t support your operating system”. “OH MY GOD, WHAT SHOULD I DO NOW?” I said.

I continued without any Antivirus software and I decided to synchronize my music to my device using the new Windows Media Player 12. I’m converting my music to WMA 64Kb/s whenever want to synchronize to my device because of its capacity (Only 4 GB). I’m using Windows Media Player for Windows Vista in order to do so but that time when I wanted to so such a thing in Windows 7, it showed me an error!

Those were some of problems I had when tried Windows 7. No sound card, No Antivirus, etc. In my opinion, Windows 7 is not reliable at least at this point (Beta version) and because of that, I removed it and moved back to Windows Vista SP1.