- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Management;
- using System.Net.Http;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace Quanjiang.DigitalScholl.WebLicense
- {
- public class LicenseManager
- {
- public static bool GetNowTime(string lcdate)
- {
- bool islc = false;
- try
- {
- HttpClient client = new HttpClient();
- var data = client.GetStringAsync("http://cgi.im.qq.com/cgi-bin/cgi_svrtime").Result;
- if (!string.IsNullOrEmpty(data))
- {
- var dt = DateTime.Parse(data);
- islc = dt < DateTime.Parse(lcdate);
- }
- return islc;
- }
- catch
- {
- if (DateTime.Now >= DateTime.Parse(lcdate))
- {
- return false;
- }
- return true;
- }
- }
-
- public static string GetCPUSerialNumber()
- {
- try
- {
- string cpuSerialNumber = string.Empty;
- ManagementClass mc = new ManagementClass("Win32_Processor");
- ManagementObjectCollection moc = mc.GetInstances();
- foreach (ManagementObject mo in moc)
- {
- cpuSerialNumber = mo["ProcessorId"].ToString();
- break;
- }
- mc.Dispose();
- moc.Dispose();
- return cpuSerialNumber;
- }
- catch (Exception e)
- {
- return "bjqjcpuid";
- }
-
- }
-
- public static string GetHardDriverNumber()
- {
- try
- {
- ManagementClass mc = new ManagementClass("Win32_PhysicalMedia");
- ManagementObjectCollection moc = mc.GetInstances();
- string strID = string.Empty;
- foreach (ManagementObject mo in moc)
- {
- strID = mo.Properties["SerialNumber"].Value.ToString();
- break;
- }
- mc.Dispose();
- moc.Dispose();
- return strID;
-
- }
- catch (Exception e)
- {
- return "bjqjharddriverid";
- }
- }
- public static string GetBoisNumber()
- {
- try
- {
-
- ManagementClass mc = new ManagementClass("Win32_BIOS");
- ManagementObjectCollection moc = mc.GetInstances();
- string strID = string.Empty;
- foreach (ManagementObject mo in moc)
- {
- strID = mo.Properties["SerialNumber"].Value.ToString();
- break;
- }
- mc.Dispose();
- moc.Dispose();
- return strID;
- }
- catch (Exception e)
- {
- return "bjqjbiosid";
- }
- }
- public static string GetMachineName()
- {
- try
- {
- return System.Environment.MachineName;
- }
- catch (Exception e)
- {
- return "unknowmachine";
- }
- }
- }
- }
|