Sad day very sad day. David Beckham Injured and ruled out from World Cup :(


Fabio Capello has offered words of support to David Beckham who has been ruled out of the World Cup finals after suffering a ruptured Achilles tendon.

Beckham will undergo surgery in Finland on Monday but the doctor who will perform the procedure has revealed it will take a minimum of four months to recover – ruling him out of the World Cup.

Capello spoke to Beckham shortly after the midfielder picked up his injury playing for Milan and the Italian is already planning for South Africa without the 34-year-old.

“We have to wait for the results of the scan, but it looks like he is out of the World Cup,” said the England coach. “I spoke with him after the game on Sunday night to offer my support, as did Franco Baldini.

“David is a great professional and has worked very hard to be ready for the World Cup, so missing it will be a big blow.”

Beckham’s spokesman told the Sun: “He’s devastated by the injury. He’s fearful of what it could mean for his World Cup hopes. We will see the full extent of the injury. Victoria is flying out to him immediately because of the injury. She’s naturally worried about him.”

The surgeon due to operate on Beckham on Monday says the injury will prevent the LA Galaxy midfielder, who is on loan at Milan, from playing for up to four months. Beckham is expected to arrive in Finland at around 1100 GMT and will be operated on Dr Sakari Orava.

“To start kicking and playing football about three months,” Dr Orava said. “For maximal performances and maximum kicks and jumps, maybe it takes one month more, three to four months before one is able to do light playing.

“It’s a total tear of the Achilles tendon. If there is any weakness then… a graft can be taken from the calf and put over the injury site to make it stronger. This kind of procedure is planned.”

While England’s medical team will await the results of scans and Monday’s planned operation, Milan are in no doubt that the serious injury will prevent Beckham from appearing in South Africa.

“Dr Orava is the foremost specialist in the world for this kind of injury, we want to get David to see him as quickly as possible,” Jean Pierre Meersseman, Milan’s club doctor, said. “But as far as the World Cup is concerned, he’s definitely out.”

Beckham rejoined Milan on a second loan spell in January and is a popular figure at San Siro. Rossoneri chief executive Adriano Galliani expects Beckham to be absent for “five to six months” but has already told the midfielder he will be welcomed back for a third spell in Serie A.

“I gave him a big hug and told him that he is a part of our family and that, if he wants to come back to Milan next year, there will be a place for him here,” Galliani said in the Times. “It’s horrible, for two consecutive years he has come to play for us for one reason only, to stay fit for the World Cup and to further his England career. And now something like this happens. Football can be so cruel.”

Getting Parent Process ID from Child without passing any arguments


In C#, Parent runs ProcessChild through System.Diagonastics.Process and ProcessChild has following codes to find its Parent process Id without use of any arguments.

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Collections;
using System.Diagnostics;

namespace ProcessChild
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(GetParentProcess().Id);
Console.Read();
}

private static Process GetParentProcess()
{
int iParentPid = 0;
int iCurrentPid = Process.GetCurrentProcess().Id;

IntPtr oHnd = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

if (oHnd == IntPtr.Zero)
return null;

PROCESSENTRY32 oProcInfo = new PROCESSENTRY32();

oProcInfo.dwSize =
(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(PROCESSENTRY32));

if (Process32First(oHnd, ref oProcInfo) == false)
return null;

do
{
if (iCurrentPid == oProcInfo.th32ProcessID)
iParentPid = (int)oProcInfo.th32ParentProcessID;
}
while (iParentPid == 0 && Process32Next(oHnd, ref oProcInfo));

if (iParentPid > 0)
return Process.GetProcessById(iParentPid);
else
return null;
}

static uint TH32CS_SNAPPROCESS = 2;

[StructLayout(LayoutKind.Sequential)]
public struct PROCESSENTRY32
{
public uint dwSize;
public uint cntUsage;
public uint th32ProcessID;
public IntPtr th32DefaultHeapID;
public uint th32ModuleID;
public uint cntThreads;
public uint th32ParentProcessID;
public int pcPriClassBase;
public uint dwFlags;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szExeFile;
};

[DllImport(“kernel32.dll”, SetLastError = true)]
static extern IntPtr CreateToolhelp32Snapshot(uint dwFlags, uint th32ProcessID);

[DllImport(“kernel32.dll”)]
static extern bool Process32First(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);

[DllImport(“kernel32.dll”)]
static extern bool Process32Next(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);

}
}

Sharepoint subsite with urlname ‘images’, ‘m’, ‘lists’, ‘IWConvertedForms’ etc


In sharepoint, if we try to create subsite with urlname ‘images’, ‘m’, ‘lists’, ‘IWConvertedForm’ etc. Some of them are SharePoint reserved name. (These names are not the name of list like ‘Document Library’, ‘Calender’ etc), it doesn’t allow us to create. This is because these all folders already exist under RootFolder of web.

Programmatically this lists can be extracted as

public string[] GetAllSubFoldersFromRootFolder(string spSite)
{
try
{
using (SPWeb spWeb = new SPSite(spSite).OpenWeb())
{
if (spWeb == null)
return null;
if (spWeb.RootFolder == null)
return null;
string[] folderNames = null;
for (int i = 0; i < spWeb.RootFolder.SubFolders.Count; i++)
{
folderNames[i] = spWeb.RootFolder.SubFolders[i].Name;
}
return folderNames;
}
}
catch
{
return null;
}
}

‘Self – Service Site Creation’ in SharePoint 2003


First of all ‘Self-Service Site Creation’ service is available only for WSS 2.0 top level site in ‘/’ not for Portal Site. So this right is only visible in WSS 2.0 top level site in ‘/’ but not in Portal site even service is enabled.

We cannot use ‘Self-Service Site Creation’ for the Portal site like ‘http://server:Port/ default.aspx’ even it is top level site in path ‘/’. It must be WSS site. And more important is for PORTAL sites like ‘http://server:Port/default.aspx’, there is no meaning of Enabling/Disabling ‘Self-Service Site Creation’. There will be no facility and NO RIGHTS about ‘Self-Service Site Creation’ available in RIGHTS list UI. Programmatically, this can be verified by reading PermissionMask of the group we created and ANDing with individual RIGHTS.

‘Self-Service Site Creation’ is the Site RIGHTS and will be available in UI only for the Top-Level WSS Site in ‘/’ (E.g. ‘http://server:Port/default.aspx’) where it was enabled. When it is enabled, there an announcement will be added to the Announcements list on the home page of the top-level Web site. The announcement will provide a link to the site creation page (scsignup.aspx in the _layouts directory).

Among default five groups: Reader, Contributor, Web Designer, Administrator and Guest (Invisible in UI), by default it is enabled for all groups expect Guest. However, we can enable/disable later for Reader, Contributor and Web Designer (AND any group we added) if site support this feature. However for others Portals also, Permission Mask is same for default groups as WSS 2.0.

Extract Content Type of file using its extension


In C# we can use registry to get ContentType of any file using its extenstion.

public static string getMimeType(string sExtension)
{
string extension = sExtension.ToLower();
RegistryKey key = Registry.ClassesRoot.OpenSubKey(“MIME\\Database\\Content Type”);

foreach (string keyName in key.GetSubKeyNames())
{
RegistryKey temp = key.OpenSubKey(keyName);
if (extension.Equals(temp.GetValue(“Extension”)))
{
return keyName;
}
}
//no success
return string.Empty;
}

Nullable and null coalescing operator


Null coalescing operator
———————–
in C# there exists an operator ‘??’ which is null coalescing operator. This operator has two operands. If first is null then it takes second and if not then it takes first.
Eg. If we want to assign our ‘previousForm’ variable to new variable ‘form’ if it is not null and if it is create new and assign then we can write as

Form form = null;
if(previousForm ! = null)
form = previousForm;
else
form = new Form();

also we can write

Form form = previousForm == null ? new Form() : prevousForm;

Now using null coalescing operator, we can write as

Form form = previousForm ?? new Form();

is more effecient.

Nullable type
————-
If we want to pass null parameter in bool field through function, it cannot be done easily because bool can either false or true but not null.

This issue can be resolved by using ‘?’ operator as in following example

using System;
using System.Collections.Generic;
using System.Text;

namespace ConApp.NullCoal
{
class Program
{
static void Main(string[] args)
{
NullableBoolCheck(false);
NullableBoolCheck(null); //We can pass null as bool parameter
NullableBoolCheck(true);

Console.Read();
}

static void NullableBoolCheck(bool? param)
{
Console.WriteLine(param);
}

}
}