/// <summary>
/// 根据 User Agent 获取操作系统名称
/// </summary>
private static string GetOsName(string userAgent)
{
string osVersion = "Unknown";
if (string.IsNullOrEmpty(userAgent))
{
return osVersion;
}
if (userAgent.Contains("Windows NT 6.1"))
{
osVersion = "Windows 7";
}
else if (userAgent.Contains("Windows NT 6.0"))
{
osVersion = "Windows Vista/Server 2008";
}
else if (userAgent.Contains("Windows NT 5.2"))
{
osVersion = "Windows Server 2003";
}
else if (userAgent.Contains("Windows NT 5.1"))
{
osVersion = "Windows XP";
}
else if (userAgent.Contains("Windows NT 5"))
{
osVersion = "Windows 2000";
}
else if (userAgent.Contains("Windows NT 4"))
{
osVersion = "Windows NT4";
}
else if (userAgent.Contains("Windows Me"))
{
osVersion = "Windows Me";
}
else if (userAgent.Contains("Windows 98"))
{
osVersion = "Windows 98";
}
else if (userAgent.Contains("Windows 95"))
{
osVersion = "Windows 95";
}
else if (userAgent.Contains("Windows"))
{
osVersion = "Windows";
}
else if (userAgent.Contains("Mac"))
{
osVersion = "Mac";
}
else if (userAgent.Contains("Unix"))
{
osVersion = "UNIX";
}
else if (userAgent.Contains("Linux"))
{
osVersion = "Linux";
}
else if (userAgent.Contains("SunOS"))
{
osVersion = "SunOS";
}
return osVersion;
}