Friday, September 3, 2010

To make round corners of div or Text box.

Round corners div or text box we usaully see on websites. Earlier i was thinking it is possible only with the help of images. but now i come to know it is quite possible with the help of css. here is the two propertis that we need to set in our css class to make text box round corners.
-moz-border-radius: 5px;
-webkit-border-radius: 5px;

By setting above two properties we can get round corner boxes easily.

Friday, June 18, 2010

window service for USB detection using C#

USB has no notion of a "port number". Enumerating USB devices and getting notifications that one was attached or removed normally requires heavy-duty C++ code.

In .net when we insert a usb drive to computer shell detect it give a message to operating system, it calls the “WndProc” of bcl.
WM_ChangedDevice message is broadcasted whenever something relevant occurs in a device connected to Microsoft windows. For this matter, there are two events which we will need to trap, the DBT_DEVICEARRIVAL and the DBT_DEVICEREMOVECOMPLETE.
Both events are handled the same way, the only difference being that DBT_DEVICEARRIVAL detects a volume being inserted, and the DBT_DEVICEREMOVECOMPLETE detects that a volume was removed.
Here we will discuss how to detect a USB device and find its vendorID(VID) and productID(PID).
First create a window service in C#. Go in constructor of window service file and use the following code there.
InitializeComponent();
if (!System.Diagnostics.EventLog.SourceExists("DoDyLogSourse"))
System.Diagnostics.EventLog.CreateEventSource("DoDyLogSourse",
"DoDyLog");

eventLog1.Source = "DoDyLogSourse";
// the event log source by which

//the application is registered on the computer

eventLog1.Log = "DoDyLog";


use onstart and onstop events of window service to make log file for this service. follow this code:
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("My service is started now");
InsertUSBHandler();
RemoveUSBHandler();
}


protected override void OnStop()
{
eventLog1.WriteEntry("My service is going to stop now");
}
//Defination for InsertUSBHandler
static void InsertUSBHandler()
{

WqlEventQuery wqlEventQueryObj;
ManagementScope scope = new ManagementScope("root\\CIMV2");
scope.Options.EnablePrivileges = true;

try
{

wqlEventQueryObj = new WqlEventQuery();
wqlEventQueryObj.EventClassName = "__InstanceCreationEvent";
wqlEventQueryObj.WithinInterval = new TimeSpan(0, 0, 3);
wqlEventQueryObj.Condition = @"TargetInstance ISA 'Win32_USBControllerdevice'";
managementEventWatcherObj = new ManagementEventWatcher(scope, wqlEventQueryObj);
managementEventWatcherObj.EventArrived += new EventArrivedEventHandler(USBAdded);
managementEventWatcherObj.Start();

}
catch (Exception e)
{
if (managementEventWatcherObj != null)
managementEventWatcherObj.Stop();
}

}


public static void USBAdded(object sender, EventArgs e)
{

MessageBox.Show("New USB found");
USBSerialNumber usb = new USBSerialNumber();
//string serial = usb.getSerialNumberFromDriveLetter("f:");
usb.FindVendorID();
}

Here in USB added method we are showing a message that "New USB found". by doing all this we can detect a usb that is inserted. but we can also find its serial number and usb's vendor ID and Product ID. By doing this we can show any particular message or run any particular application on insertion of particular USB. so that our window service bound to particular device. i have done all this and it is in running state now.
We can also implement more functionality regarding USB here depending upon requirement. Please let me know if it helps you or is there any way to do all these. i am always for your help.Happy coding!!!!!:)

Thursday, May 6, 2010

Update a share point list through asp.net application

To update a sharepoint list very first requirement is to reach upto that list. This can be possible with the help of sharepoint webservices. Share point webservice cannot called without authorization. If a user has full permission for sharepoint server access then by using his/her credentials we can call the share point webservices. First we need to add the required web service in our asp.net application. After adding webservices we get classes access of that webservice. Then call authentication webservice. This webservice is used for authentication of the user. Call to sharepoint webservices also depend upon the subsite process or subfolder process. So be careful during the call to subsites.
After successful authentication of the user a ticket will be generated by the sharepoint service for future operations. By using this ticket a user can call another webserice of sharepoint server. To update a list user need to call the lists.asmx webservce. By using authentication ticket of authentication.asmx websevice one can get list of all lists under root or subdomain. With the help of user defined xml one can update the required list of sharepoint server by using Update method of lists.asmx webservice.

Tuesday, April 20, 2010

Web Site Setup

Hi Friends,

To make a website set up in .net is quite easy. .net gave its own inbuilt tool for this purpose. Go to file add new project , go on Other project type select set up and deployment and from right hand side select webset up project. By doing this a webset project wil add in your website. After doing this you can add your website(s) in this project for which you want to create set up. When you run this websetup on windows it will ask for virtual directory name and then it will create your virtual directory in your iis and add website pages that you add in setup. This set can also create database in sqlserver. and configure your website on run time. i have done all this code and test it many times. Luckily it is working fine every where. Contact me to get that code.