Friday, June 29, 2012

Converting AD UTC time to DateTime

Convert local time to UTC

TimeZoneInfo.ConvertTimeToUtc(DateTime.Now.AddDays(15)).ToFileTimeUtc()
 
Result
129867569963464980

Convert UTC time to Local time

TimeZoneInfo.ConvertTimeToUtc(DateTime.Now)

Result:
{6/29/2012 4:29:09 PM}
    Date: {6/29/2012 12:00:00 AM}
    Day: 29
    DayOfWeek: Friday
    DayOfYear: 181
    Hour: 16
    Kind: Utc
    Millisecond: 954
    Minute: 29
    Month: 6
    Second: 9
    Ticks: 634765841499549823
    TimeOfDay: {16:29:09.9549823}
    Year: 2012

Wednesday, June 20, 2012

Deploy ASP.NET MVC App on Windows XP (IIS 5.1)

Thanks to
http://itscommonsensestupid.blogspot.com/2008/11/deploy-aspnet-mvc-app-on-windows-xp-iis.html

Deploying ASP.NET MVC application on Windows XP is definitely not easy; there are a lot of settings that need to be tuned. Not only that the application must be changed as well.

The first thing to do is to add the relevant mapping to the Application Configuration of the MVC application. To do this, one must go to Start-> Control Panel-> Administrative Tools-> Internet Information Services. Then, one should click on  the Internet Information Services icon, right-click on the MVC application, and select Properties. On the Virtual Directory Tab, choose Configuration, as shown below:



After clicking on the Configuration panel, choose the Executable to be the aspnet_isapi.ll, and the extension to be ".*", make sure that the "check that file exists" is unchecked. If the OK button is disabled, you must click on the textbox for the Executable, and only then the OK button is enabled.

Click OK all the way to close the Administrative tools.

One must also add a route to the RegisterRoutes static function. Here is the syntax that is compatible with ASP.NET MVC Beta
?
1
2
3
4
5
6
7
routes.Add(new Route
(
"{controller}.mvc/{action}/{id}",
new RouteValueDictionary(new { action = "Index", id = (string)null }),
new MvcRouteHandler()
));

Look through your MVC application, make sure that you don't have any hardcode reference to controller class or action method. If you are using

?
1

"/Home/uploadfiles"></form>


Make sure you change it to

?
1
"<%=Url.Action(new{controller=" home",="" })%>"=""></form>


If you have

?
1

Thursday, March 3, 2011

Creating a client from WCF service.. converting LIST<> to Array[]

A was getting the problem while downloading the contracts using the svcutil.exe, it was converting the List<> to Array[]. It happens because svcutil consider all lists to be array

So there is an option to download the List<> as well.

svcutil.exe /language:cs /out:g
eneratedProxy.cs /ct:System.Collections.Generic.List`1 http://satindersatty.com:1111/

Sunday, February 20, 2011

Update panel scroll problem solved

I have an updatepanel control in the middle of a page, and i have a link at the top of the same page. I refresh the updatepanel by clicking the link ;however, i want the updatepanel to scroll into view as well. My javascript scrollintoview method didnt work because updatepanel tries to keep the last position of the page after it is refreshed. So i searched google and found this script and added it to my page. It worked.

Friday, February 11, 2011

How to spoof a domain a domain name on your localhost

Hi,
Some time we need to check the live code on our local host and there are many API calls which works only on verified domains names, and when you run the same code on your localhost, those calls fails.

So there is an alternative to that. You can change the localhost name to original verified domain name. Thats called domain spoofing.

To do that, Just find the hosts file in your windows directory. Usually its available at following location

C:\WINDOWS\system32\drivers\etc\host

Open this file, you will see an entry for localhost, change localhost name to domain name you want to spoof.

Easy ... Right...

Friday, January 21, 2011

How to transfer data from CSV file to SQL

Hi,

First you need to create a table with similar number of columns (recommended), then create a format file from the table (using the bcp utility, already discussed in previous post), and then run the following command in sql management studio.

bulk insert tablename
from 'SourcetextfileCompletepath'
with (formatfile='formatfilelocation')

Tuesday, September 7, 2010

Creating format file to bulk insert data from text file

bcp DatabaseName.dbo.TableName format nul -c -f formatfilename -T

for example
bcp AdventureWorks2008R2.HumanResources.Department format nul -c -f Department-c.fmt -T


-T If you are using the window authentication
-c If you want format file to consider all data as char

If you are having more than one instance of the SQL server then you have to give the server name also like

C:\DOCUME~1\ssingh>bcp Northwind.dbo.ResponseTime_VarnishLog format nul -c -f va
rnishformat.fmt -T -S jfkmsc04\sql2008


Where
-S Server Name