/**
 * 
 */
package org.springblade.core.license.system;

import java.util.Scanner;

import org.springblade.core.license.IServerInfo;

/**
 * @author wookvn
 *
 */
public class WindowServerInfo implements IServerInfo {

	@Override
	public String getCPUSerial() throws Exception {
		//序列号
        String serialNumber = "000";
        //使用WMIC获取CPU序列号
        Process process = Runtime.getRuntime().exec("wmic cpu get processorid");
        process.getOutputStream().close();
        Scanner scanner = new Scanner(process.getInputStream());
        if(scanner.hasNext()){
            scanner.next();
        }
        if(scanner.hasNext()){
            serialNumber = scanner.next().trim();
        }
        scanner.close();
        return serialNumber;
	}

	@Override
	public String getMainBoardSerial() throws Exception {
		//序列号
        String serialNumber = "111";
        //使用WMIC获取主板序列号
        Process process = Runtime.getRuntime().exec("wmic baseboard get serialnumber");
        process.getOutputStream().close();
        Scanner scanner = new Scanner(process.getInputStream());
        if(scanner.hasNext()){
            scanner.next();
        }
        if(scanner.hasNext()){
            serialNumber = scanner.next().trim();
        }
        scanner.close();
        return serialNumber;
	}

}
