package com.youchain.modules.license;

import java.util.Scanner;

/**
 * <p>用于获取客户Windows服务器的基本信息</p>
 * @author 92525
 */
public class WindowsServerInfos extends AGxServerInfos {



    @Override
    protected String getCpuSerial() throws Exception {
        //序列号
        String serialNumber = "";

        try{
            //使用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();
        }catch (Exception e){
            serialNumber = "";
        }

        return serialNumber;
    }

    @Override
    protected String getMainBoardSerial() throws Exception {
        //序列号
        String serialNumber = "";

        try{
            //使用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();
        }catch (Exception e){

        }

        return serialNumber;
    }


}
