Beispiel #1
0
        /// <summary>
        /// Queries the meter for the first 20 missing blocks for a firmware
        /// download pending table.
        /// </summary>
        /// <param name="eFWType">Firmware type (0 = Register, 1 = RFLAN,
        /// 2 = Zigbee)</param>
        /// <param name="iNumberOfBlocksReceived"></param>
        /// <param name="lstMissingBlocks"></param>
        /// <returns>Result code written to table 08 after the procedure is
        /// initiated</returns>
        // Revision History
        // MM/DD/YY who Version Issue# Description
        // -------- --- ------- ------ ---------------------------------------
        // 02/05/10 jrf 2.40.12  N/A     Created
        //
        public ProcedureResultCodes GetFirstTwentyMissingBlocks(FirmwareType eFWType,
                                                                out int iNumberOfBlocksReceived, out List <int> lstMissingBlocks)
        {
            ProcedureResultCodes ProcResult = ProcedureResultCodes.INVALID_PARAM;

            byte[] ProcResponse;
            int    iBlockNumber = 0;

            ProcResult = GetFirstTwentyMissingBlocks(eFWType, out ProcResponse);

            lstMissingBlocks        = new List <int>();
            iNumberOfBlocksReceived = 0;

            if (ProcedureResultCodes.COMPLETED == ProcResult)
            {
                iNumberOfBlocksReceived = ProcResponse[0] | (ProcResponse[1] << 8);

                for (int iIndex = 2; iIndex < 42; iIndex += 2)
                {
                    iBlockNumber = ProcResponse[iIndex] | (ProcResponse[iIndex + 1] << 8);
                    if (0 != iBlockNumber)
                    {
                        lstMissingBlocks.Add(iBlockNumber);
                    }
                }
            }

            return(ProcResult);
        }
        private bool InitializeFrameworkService()
        {
            FirmwareType firmwareType = FirmwareType.FirmwareTypeUnknown;

            try
            {
                GetFirmwareType(ref firmwareType);
            }
            catch (Exception ex)
            {
                LogHelper.Log("SystemVerificationService:InitializeFrameworkService: Failed: StackTrace: {0}", ex.Message);
            }

            switch (firmwareType)
            {
            case FirmwareType.FirmwareTypeUefi:
                SimpleIoc.Default.Register <FirmwareServiceBase, EFIFirmwareService>();
                break;

            case FirmwareType.FirmwareTypeUnknown:
            case FirmwareType.FirmwareTypeMax:
            case FirmwareType.FirmwareTypeBios:
                SimpleIoc.Default.Register <FirmwareServiceBase, LegacyFirmwareService>();
                break;
            }

            return(supportedFirmwares.Contains(firmwareType));
        }
        /// <summary>
        /// Detects the type of system firmware which is equal to the boot type by calling the method <see cref="NativeMethods.GetFirmwareType"/>.
        /// </summary>
        /// <returns>Firmware type like Uefi or Bios.</returns>
        public static FirmwareType GetSystemFirmwareType()
        {
            FirmwareType firmwareType = default;

            _ = NativeMethods.GetFirmwareType(ref firmwareType);
            return(firmwareType);
        }
        ///// <summary>
        ///// /f ALL参数
        ///// </summary>
        ///// <param name="sourceDisk">指定 windows 系统根目录</param>
        ///// <param name="targetDisk">该参数用于指定要将启动环境文件复制到哪个目标系统分区。</param>
        ///// <param name="bcdboot">bcdboot文件名,默认传bcdboot字段</param>
        //public static void BcdbootWriteALLBootFile(string sourceDisk,string targetDisk,string bcdboot) 
        //{
        //    ProcessManager.ECMD(Application.StartupPath + "\\files\\" + bcdboot, sourceDisk + "windows  /s  " + targetDisk.Substring(0, 2) + " /f BIOS");
        //}
        ///// <summary>
        ///// /f UEFI参数
        ///// </summary>
        ///// <param name="sourceDisk">指定 windows 系统根目录</param>
        ///// <param name="targetDisk">该参数用于指定要将启动环境文件复制到哪个目标系统分区。</param>
        ///// <param name="bcdboot">bcdboot文件名,默认传bcdboot字段</param>
        //public static void BcdbootWriteUEFIBootFile(string sourceDisk, string targetDisk, string bcdboot)
        //{
        //    ProcessManager.ECMD(Application.StartupPath + "\\files\\" + bcdboot, sourceDisk + "windows  /s  " + targetDisk.Substring(0, 2) + " /f UEFI");
        //}


        /// <summary>
        /// BCDBOOT写入引导文件
        /// </summary>
        /// <param name="sourceDisk">例如E:\</param>
        /// <param name="targetDisk">例如E:</param>
        /// <param name="bcdbootFileName">例如bcdboot.exe</param>
        /// <param name="fwType"></param>
        public static void BcdbootWriteBootFile(string sourceDisk, string targetDisk, FirmwareType fwType)
        {

            StringBuilder args = new StringBuilder();
            args.Append(sourceDisk);
            args.Append("windows /s ");
            args.Append(targetDisk.Substring(0, 2));
            if (WTGModel.bcdbootFileName == "bcdboot.exe")
            {
                if (fwType == FirmwareType.ALL)
                {
                    args.Append(" /f all ");
                }
                else if (fwType == FirmwareType.BIOS)
                {
                    args.Append(" /f bios ");
                }
                else
                {
                    args.Append(" /f uefi ");
                }
            }
            args.Append(" /l zh-ch ");
            args.Append(" /v ");
            //这里不能直接调用系统BCDBOOT,原因未知
            //if (WTGModel.CurrentOS == OS.Win8_1_with_update || WTGModel.CurrentOS == OS.Win10 || WTGModel.CurrentOS == OS.Win8_without_update)
            //{
            //    ProcessManager.ECMD("bcdboot.exe", args.ToString());
            //}
            //else
            //{
            ProcessManager.ECMD(WTGModel.applicationFilesPath + "\\" + WTGModel.bcdbootFileName, args.ToString());
            //}
        }
Beispiel #5
0
 public DeviceBaseInfo(ushort id, string name, MacAddress mac, FirmwareType firmwareType)
 {
     ID           = id;
     Name         = name;
     Mac          = mac;
     FirmwareType = firmwareType;
 }
 internal static string ToSerializedValue(this FirmwareType value)
 {
     switch (value)
     {
     case FirmwareType.Presscontrol:
         return("Presscontrol");
     }
     return(null);
 }
 private void RetrieveInfo()
 {
     Hostname  = Environment.MachineName;
     OsName    = OperatingSystem.CimInstanceProperties["Caption"].Value.ToString();
     OsVersion = OperatingSystem.CimInstanceProperties["Version"].Value.ToString();
     CpuName   = ProcessorInfo.CimInstanceProperties["Name"].Value.ToString();
     CpuModel  = ProcessorInfo.CimInstanceProperties["Description"].Value.ToString();
     FwType    = FirmwareType.ToString();
     HvPresent = IsHypervisorPresent.ToString();
 }
Beispiel #8
0
        public static FirmwareType GetFirmwareType()
        {
            FirmwareType type = FirmwareType.FirmwareTypeUnknown;

            if (GetFirmwareType(ref type))
            {
                return(type);
            }
            return(FirmwareType.FirmwareTypeUnknown);
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 public SingleFirmware()
 {
     Model        = "";
     Type         = FirmwareType.Unknown;
     Version      = "";
     Binary       = "";
     ReleaseNotes = "";
     NotesContent = "";
     Size         = "";
 }
        /// <summary>
        /// This method activates the firmware download's pending table.
        /// </summary>
        /// <param name="FWType">The type of firmware to activate.</param>
        /// <returns>The result of the activate pending table procedure.</returns>
        //  Revision History
        //  MM/DD/YY Who Version ID Number Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  07/09/13 jrf 2.80.51 TC 15063  Created.
        //  08/24/16 PGH 4.70.15    701952 Added HAN OTA Firmware
        //
        public ProcedureResultCodes ActivateFW(FirmwareType FWType)
        {
            ProcedureResultCodes ProcResult = ProcedureResultCodes.INVALID_PARAM;
            byte byEventNumber = REGISTER_EVENT_NUMBER;

            switch (FWType)
            {
            case FirmwareType.RegisterFW:
            case FirmwareType.M2GTWY:
            case FirmwareType.DisplayFW:
            {
                byEventNumber = REGISTER_EVENT_NUMBER;
                break;
            }

            case FirmwareType.ZigbeeFW:
            {
                byEventNumber = ZIGBEE_EVENT_NUMBER;
                break;
            }

            case FirmwareType.RFLANFW:
            case FirmwareType.PLANFW:
            case FirmwareType.CiscoCommFW:
            case FirmwareType.CiscoCfgFW:
            case FirmwareType.ChoiceConnectFW:
            case FirmwareType.ICSFW:
            {
                byEventNumber = COMM_EVENT_NUMBER;
                break;
            }

            case FirmwareType.HAN_OTA_FW:
            case FirmwareType.HANDevFW:
            {
                byEventNumber = HAN_DEV_EVENT_NUMBER;
                break;
            }

            default:
            {
                throw new ArgumentException("Invalid Parameter", "FWType");
            }
            }

            // Activate the pending table
            ProcResult = ActivatePendingTable(false, false, byEventNumber,
                                              PendingEventRecord.PendingEventCode.NonTimeTrigger);

            return(ProcResult);
        }
Beispiel #11
0
        /// <summary>
        /// Queries the meter for the first 20 missing blocks for a firmware
        /// download pending table.
        /// </summary>
        /// <param name="eFWType">Firmware type (0 = Register, 1 = RFLAN,
        /// 2 = Zigbee)</param>
        /// <param name="ProcResponse">byte array containing the response from
        /// the meter</param>
        /// <returns>Result code written to table 08 after the procedure is
        /// initiated</returns>
        // Revision History
        // MM/DD/YY who Version Issue# Description
        // -------- --- ------- ------ ---------------------------------------
        // 10/02/06 AF 7.40.00  N/A     Created
        // 10/04/06 AF 7.40.00  N/A     Moved from CENTRON_AMI.cs
        //
        protected ProcedureResultCodes GetFirstTwentyMissingBlocks(FirmwareType eFWType,
                                                                   out byte[] ProcResponse)
        {
            ProcedureResultCodes ProcResult = ProcedureResultCodes.INVALID_PARAM;

            byte[] byParameters = new byte[1];  // The procedure takes 1 parameter
            byParameters[0] = (byte)eFWType;

            ProcResult = ExecuteProcedure(Procedures.GET_FIRST_20_MISSING_BLOCKS,
                                          byParameters,
                                          out ProcResponse);

            return(ProcResult);
        }
Beispiel #12
0
        public frmMain()
        {
            InitializeComponent();

            this.Text = "Restart2UEFI(WinForms)" + (typeof(Program).GetTypeInfo().Assembly.GetName().Version).ToString();

            try
            {
                int fwareT = int.Parse(FirmwareType.GetFirmwareType().ToString());
                switch (fwareT)
                {
                case 0:
                    errorNotUefi();
                    fwType = "0";
                    break;

                case 1:
                    errorNotUefi();
                    fwType = "1";
                    break;

                case 2:
                    firmWareUEFI();
                    break;

                case 3:
                    errorNotUefi();
                    fwType = "3";
                    break;

                default:
                    errorRetrive();
                    break;
                }
            }
            catch
            {
                errorRetrive();
            }
        }
Beispiel #13
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            //Get firmware return type FirmwareTypeUnknown  = 0, FirmwareTypeBios = 1, FirmwareTypeUefi = 2, FirmwareTypeMax = 3
            int fwareT = int.Parse(FirmwareType.GetFirmwareType().ToString());

            fwType = fwareT.ToString();

            try
            {
                switch (fwareT)
                {
                case 0:
                    errorNotUefi();
                    break;

                case 1:
                    errorNotUefi();
                    break;

                case 2:

                    firmWareUEFI();
                    break;

                case 3:
                    errorNotUefi();
                    break;

                default:
                    errorRetrive();
                    break;
                }
            }
            catch
            {
                errorRetrive();
            }
        }
        ///// <summary>
        ///// /f ALL参数
        ///// </summary>
        ///// <param name="sourceDisk">指定 windows 系统根目录</param>
        ///// <param name="targetDisk">该参数用于指定要将启动环境文件复制到哪个目标系统分区。</param>
        ///// <param name="bcdboot">bcdboot文件名,默认传bcdboot字段</param>
        //public static void BcdbootWriteALLBootFile(string sourceDisk,string targetDisk,string bcdboot)
        //{
        //    ProcessManager.ECMD(Application.StartupPath + "\\files\\" + bcdboot, sourceDisk + "windows  /s  " + targetDisk.Substring(0, 2) + " /f BIOS");
        //}
        ///// <summary>
        ///// /f UEFI参数
        ///// </summary>
        ///// <param name="sourceDisk">指定 windows 系统根目录</param>
        ///// <param name="targetDisk">该参数用于指定要将启动环境文件复制到哪个目标系统分区。</param>
        ///// <param name="bcdboot">bcdboot文件名,默认传bcdboot字段</param>
        //public static void BcdbootWriteUEFIBootFile(string sourceDisk, string targetDisk, string bcdboot)
        //{
        //    ProcessManager.ECMD(Application.StartupPath + "\\files\\" + bcdboot, sourceDisk + "windows  /s  " + targetDisk.Substring(0, 2) + " /f UEFI");
        //}
        /// <summary>
        /// BCDBOOT写入引导文件
        /// </summary>
        /// <param name="sourceDisk">例如E:\</param>
        /// <param name="targetDisk">例如E:</param>
        /// <param name="bcdbootFileName">例如bcdboot.exe</param>
        /// <param name="fwType"></param>
        public static void BcdbootWriteBootFile(string sourceDisk,string targetDisk,string bcdbootFileName,FirmwareType fwType)
        {
            StringBuilder args = new StringBuilder();
            args.Append(sourceDisk);
            args.Append("windows /s ");
            args.Append(targetDisk.Substring(0,2));
            if (fwType==FirmwareType.ALL)
            {
                args.Append(" /f all ");
            }
            else if(fwType==FirmwareType.BIOS)
            {
                args.Append(" /f bios ");
            }
            else
            {
                args.Append(" /f uefi ");

            }
            args.Append(" /l zh-ch ");
            args.Append(" /v ");
            ProcessManager.ECMD(WTGOperation.applicationFilesPath + "\\" + bcdbootFileName, args.ToString());
        }
Beispiel #15
0
        /// <summary>
        /// Возвращает базовую инфу об устройстве
        /// </summary>
        /// <returns></returns>
        public async Task <DeviceBaseInfo> GetDeviceInfoFromDeviceAsAP()
        {
            return(await Task.Run(async() =>
            {
                DeviceBaseInfo device = null;
                Communicator communicator = new Communicator();

                OperationResult result = await communicator.SendToDevice(_ip, CommandNames.GetInfo);

                if (result.Success)
                {
                    string[] info = result.ResponseMessage.Split('&');

                    ushort id = ushort.Parse(info[0]);
                    FirmwareType firmwareType = (FirmwareType)int.Parse(info[1]);
                    string mac = info[2];
                    string name = info[3];

                    device = new DeviceBaseInfo(id, name, new MacAddress(mac), firmwareType);
                }

                return device;
            }));
        }
Beispiel #16
0
        ///// <summary>
        ///// /f ALL参数
        ///// </summary>
        ///// <param name="sourceDisk">指定 windows 系统根目录</param>
        ///// <param name="targetDisk">该参数用于指定要将启动环境文件复制到哪个目标系统分区。</param>
        ///// <param name="bcdboot">bcdboot文件名,默认传bcdboot字段</param>
        //public static void BcdbootWriteALLBootFile(string sourceDisk,string targetDisk,string bcdboot)
        //{
        //    ProcessManager.ECMD(Application.StartupPath + "\\files\\" + bcdboot, sourceDisk + "windows  /s  " + targetDisk.Substring(0, 2) + " /f BIOS");
        //}
        ///// <summary>
        ///// /f UEFI参数
        ///// </summary>
        ///// <param name="sourceDisk">指定 windows 系统根目录</param>
        ///// <param name="targetDisk">该参数用于指定要将启动环境文件复制到哪个目标系统分区。</param>
        ///// <param name="bcdboot">bcdboot文件名,默认传bcdboot字段</param>
        //public static void BcdbootWriteUEFIBootFile(string sourceDisk, string targetDisk, string bcdboot)
        //{
        //    ProcessManager.ECMD(Application.StartupPath + "\\files\\" + bcdboot, sourceDisk + "windows  /s  " + targetDisk.Substring(0, 2) + " /f UEFI");
        //}


        /// <summary>
        /// BCDBOOT写入引导文件
        /// </summary>
        /// <param name="sourceDisk">例如E:\</param>
        /// <param name="targetDisk">例如E:</param>
        /// <param name="bcdbootFileName">例如bcdboot.exe</param>
        /// <param name="fwType"></param>
        public static void BcdbootWriteBootFile(string sourceDisk, string targetDisk, FirmwareType fwType)
        {
            StringBuilder args = new StringBuilder();

            args.Append(sourceDisk);
            args.Append("windows /s ");
            args.Append(targetDisk.Substring(0, 2));
            if (WTGModel.bcdbootFileName == "bcdboot.exe")
            {
                if (fwType == FirmwareType.ALL)
                {
                    args.Append(" /f all ");
                }
                else if (fwType == FirmwareType.BIOS)
                {
                    args.Append(" /f bios ");
                }
                else
                {
                    args.Append(" /f uefi ");
                }
            }
            args.Append(" /l zh-ch ");
            args.Append(" /v ");
            //这里不能直接调用系统BCDBOOT,原因未知
            //if (WTGModel.CurrentOS == OS.Win8_1_with_update || WTGModel.CurrentOS == OS.Win10 || WTGModel.CurrentOS == OS.Win8_without_update)
            //{
            //    ProcessManager.ECMD("bcdboot.exe", args.ToString());
            //}
            //else
            //{
            ProcessManager.ECMD(WTGModel.applicationFilesPath + "\\" + WTGModel.bcdbootFileName, args.ToString());
            //}
        }
Beispiel #17
0
 internal static extern bool GetFirmwareType(out FirmwareType type);
        /// <summary>
        /// Get all links from page
        /// </summary>
        /// <param name="url">URL for get links</param>
        /// <param name="model">Model name</param>
        /// <param name="type">Firmware type</param>
        /// <returns>List of firmwares</returns>
        private async Task <List <SingleFirmware> > GetAllLinks(string url, string model, FirmwareType type)
        {
            List <SingleFirmware> retval = new List <SingleFirmware>();

            using (WebClient client = new WebClient())
            {
                string modelData = await client.DownloadStringTaskAsync(url);

                //Get all links from page
                Regex           allLinksRegex   = new Regex(@"<tr><td.+?href=\""(?<link>.+?).+?</td></tr>", RegexOptions.Singleline);
                MatchCollection matchCollection = allLinksRegex.Matches(modelData);
                bool            rcFound         = false;
                foreach (Match match in matchCollection)
                {
                    Match  currentLineMatch = Regex.Match(match.Value, @"<tr><td.+?href=\""(?<link>.+?)"".+align=""right"">(?<size>.+?)<", RegexOptions.Singleline);
                    string link             = currentLineMatch.Groups["link"].Value;
                    string size             = currentLineMatch.Groups["size"].Value;
                    if (link == "RC/")
                    {
                        //RC folder found. Download it later
                        rcFound = true;
                        continue;
                    }
                    if (!(link.EndsWith(".bin") || link.EndsWith(".txt") || link.EndsWith(".tar")))
                    {
                        continue;
                    }
                    //Add data
                    string         version        = Regex.Match(link, "V(?<version>.+?)_", RegexOptions.Singleline).Groups["version"].Value;
                    SingleFirmware singleFirmware = new SingleFirmware
                    {
                        Model   = model,
                        Type    = type,
                        Version = version
                    };
                    //Process binary item
                    if (link.EndsWith(".bin") || link.EndsWith(".tar"))
                    {
                        //Get existing item if any
                        int previousIndex = retval.FindIndex(item => item.Model == singleFirmware.Model && item.Version == singleFirmware.Version && item.Type == singleFirmware.Type);
                        singleFirmware.Binary = url + link;
                        singleFirmware.Size   = size;
                        if (previousIndex == -1)
                        {
                            //If no previous item exist - add
                            retval.Add(singleFirmware);
                        }
                        else
                        {
                            //If previous item exist - modify
                            retval[previousIndex].Binary = singleFirmware.Binary;
                            retval[previousIndex].Size   = size;
                        }
                    }
                    //Process note item
                    if (link.EndsWith(".txt"))
                    {
                        //Get existing item if any
                        int previousIndex = retval.FindIndex(item => item.Model == singleFirmware.Model && item.Version == singleFirmware.Version && item.Type == singleFirmware.Type);
                        singleFirmware.ReleaseNotes = url + link;
                        using (WebClient notesClient = new WebClient())
                        {
                            string notesText = await notesClient.DownloadStringTaskAsync(singleFirmware.ReleaseNotes);

                            notesText = notesText.Replace("\n", "\r\n");
                            singleFirmware.NotesContent = notesText;
                            if (previousIndex == -1)
                            {
                                //If no previous item exist - add
                                retval.Add(singleFirmware);
                            }
                            else
                            {
                                //If previous item exist - modify
                                retval[previousIndex].ReleaseNotes = singleFirmware.ReleaseNotes;
                                retval[previousIndex].NotesContent = singleFirmware.NotesContent;
                            }
                        }
                    }
                }
                //If RC directory found - process RC with Firmware type = RC
                if (rcFound)
                {
                    retval.AddRange(await GetAllLinks(url + "RC/", model, FirmwareType.RC));
                }
            }
            return(retval);
        }
Beispiel #19
0
 public virtual extern int CheckFirmwarePresent(
     [ComAliasName("BstkTypeLib.FirmwareType"), In] FirmwareType aFirmwareType,
     [MarshalAs(UnmanagedType.BStr), In] string aVersion,
     [MarshalAs(UnmanagedType.BStr)] out string aUrl,
     [MarshalAs(UnmanagedType.BStr)] out string aFile);
        internal static VirtualMachineTemplateData DeserializeVirtualMachineTemplateData(JsonElement element)
        {
            Optional <ExtendedLocation>  extendedLocation = default;
            Optional <string>            kind             = default;
            IDictionary <string, string> tags             = default;
            AzureLocation      location          = default;
            ResourceIdentifier id                = default;
            string             name              = default;
            ResourceType       type              = default;
            SystemData         systemData        = default;
            Optional <string>  uuid              = default;
            Optional <string>  vCenterId         = default;
            Optional <string>  moRefId           = default;
            Optional <string>  inventoryItemId   = default;
            Optional <string>  moName            = default;
            Optional <int>     memorySizeMB      = default;
            Optional <int>     numCPUs           = default;
            Optional <int>     numCoresPerSocket = default;
            Optional <OSType>  osType            = default;
            Optional <string>  osName            = default;
            Optional <string>  folderPath        = default;
            Optional <IReadOnlyList <NetworkInterface> > networkInterfaces = default;
            Optional <IReadOnlyList <VirtualDisk> >      disks             = default;
            Optional <string>       customResourceName          = default;
            Optional <string>       toolsVersionStatus          = default;
            Optional <string>       toolsVersion                = default;
            Optional <FirmwareType> firmwareType                = default;
            Optional <IReadOnlyList <ResourceStatus> > statuses = default;
            Optional <string> provisioningState = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("extendedLocation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    extendedLocation = ExtendedLocation.DeserializeExtendedLocation(property.Value);
                    continue;
                }
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("uuid"))
                        {
                            uuid = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("vCenterId"))
                        {
                            vCenterId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("moRefId"))
                        {
                            moRefId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("inventoryItemId"))
                        {
                            inventoryItemId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("moName"))
                        {
                            moName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("memorySizeMB"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            memorySizeMB = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("numCPUs"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            numCPUs = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("numCoresPerSocket"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            numCoresPerSocket = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("osType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            osType = new OSType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("osName"))
                        {
                            osName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("folderPath"))
                        {
                            folderPath = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("networkInterfaces"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <NetworkInterface> array = new List <NetworkInterface>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(NetworkInterface.DeserializeNetworkInterface(item));
                            }
                            networkInterfaces = array;
                            continue;
                        }
                        if (property0.NameEquals("disks"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <VirtualDisk> array = new List <VirtualDisk>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(VirtualDisk.DeserializeVirtualDisk(item));
                            }
                            disks = array;
                            continue;
                        }
                        if (property0.NameEquals("customResourceName"))
                        {
                            customResourceName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("toolsVersionStatus"))
                        {
                            toolsVersionStatus = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("toolsVersion"))
                        {
                            toolsVersion = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("firmwareType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            firmwareType = new FirmwareType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("statuses"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ResourceStatus> array = new List <ResourceStatus>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ResourceStatus.DeserializeResourceStatus(item));
                            }
                            statuses = array;
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            provisioningState = property0.Value.GetString();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new VirtualMachineTemplateData(id, name, type, systemData, tags, location, extendedLocation.Value, kind.Value, uuid.Value, vCenterId.Value, moRefId.Value, inventoryItemId.Value, moName.Value, Optional.ToNullable(memorySizeMB), Optional.ToNullable(numCPUs), Optional.ToNullable(numCoresPerSocket), Optional.ToNullable(osType), osName.Value, folderPath.Value, Optional.ToList(networkInterfaces), Optional.ToList(disks), customResourceName.Value, toolsVersionStatus.Value, toolsVersion.Value, Optional.ToNullable(firmwareType), Optional.ToList(statuses), provisioningState.Value));
        }
Beispiel #21
0
 internal static extern bool GetFirmwareType(ref FirmwareType firmwareType);
Beispiel #22
0
        internal static VirtualMachineData DeserializeVirtualMachineData(JsonElement element)
        {
            Optional <ExtendedLocation> extendedLocation      = default;
            Optional <string>           kind                  = default;
            Optional <SystemAssignedServiceIdentity> identity = default;
            IDictionary <string, string>             tags     = default;
            AzureLocation                location             = default;
            ResourceIdentifier           id                     = default;
            string                       name                   = default;
            ResourceType                 type                   = default;
            SystemData                   systemData             = default;
            Optional <string>            resourcePoolId         = default;
            Optional <string>            templateId             = default;
            Optional <string>            vCenterId              = default;
            Optional <PlacementProfile>  placementProfile       = default;
            Optional <OSProfile>         osProfile              = default;
            Optional <HardwareProfile>   hardwareProfile        = default;
            Optional <NetworkProfile>    networkProfile         = default;
            Optional <StorageProfile>    storageProfile         = default;
            Optional <GuestAgentProfile> guestAgentProfile      = default;
            Optional <string>            moRefId                = default;
            Optional <string>            inventoryItemId        = default;
            Optional <string>            moName                 = default;
            Optional <string>            folderPath             = default;
            Optional <string>            instanceUuid           = default;
            Optional <string>            smbiosUuid             = default;
            Optional <FirmwareType>      firmwareType           = default;
            Optional <string>            powerState             = default;
            Optional <string>            customResourceName     = default;
            Optional <string>            uuid                   = default;
            Optional <IReadOnlyList <ResourceStatus> > statuses = default;
            Optional <string> provisioningState                 = default;
            Optional <string> vmId = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("extendedLocation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    extendedLocation = ExtendedLocation.DeserializeExtendedLocation(property.Value);
                    continue;
                }
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    identity = JsonSerializer.Deserialize <SystemAssignedServiceIdentity>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = new AzureLocation(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = new ResourceIdentifier(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = new ResourceType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("systemData"))
                {
                    systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString());
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("resourcePoolId"))
                        {
                            resourcePoolId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("templateId"))
                        {
                            templateId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("vCenterId"))
                        {
                            vCenterId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("placementProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            placementProfile = PlacementProfile.DeserializePlacementProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("osProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            osProfile = OSProfile.DeserializeOSProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("hardwareProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            hardwareProfile = HardwareProfile.DeserializeHardwareProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("networkProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            networkProfile = NetworkProfile.DeserializeNetworkProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("storageProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            storageProfile = StorageProfile.DeserializeStorageProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("guestAgentProfile"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            guestAgentProfile = GuestAgentProfile.DeserializeGuestAgentProfile(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("moRefId"))
                        {
                            moRefId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("inventoryItemId"))
                        {
                            inventoryItemId = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("moName"))
                        {
                            moName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("folderPath"))
                        {
                            folderPath = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("instanceUuid"))
                        {
                            instanceUuid = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("smbiosUuid"))
                        {
                            smbiosUuid = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("firmwareType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            firmwareType = new FirmwareType(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("powerState"))
                        {
                            powerState = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("customResourceName"))
                        {
                            customResourceName = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("uuid"))
                        {
                            uuid = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("statuses"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                property0.ThrowNonNullablePropertyIsNull();
                                continue;
                            }
                            List <ResourceStatus> array = new List <ResourceStatus>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ResourceStatus.DeserializeResourceStatus(item));
                            }
                            statuses = array;
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            provisioningState = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("vmId"))
                        {
                            vmId = property0.Value.GetString();
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new VirtualMachineData(id, name, type, systemData, tags, location, extendedLocation.Value, kind.Value, identity, resourcePoolId.Value, templateId.Value, vCenterId.Value, placementProfile.Value, osProfile.Value, hardwareProfile.Value, networkProfile.Value, storageProfile.Value, guestAgentProfile.Value, moRefId.Value, inventoryItemId.Value, moName.Value, folderPath.Value, instanceUuid.Value, smbiosUuid.Value, Optional.ToNullable(firmwareType), powerState.Value, customResourceName.Value, uuid.Value, Optional.ToList(statuses), provisioningState.Value, vmId.Value));
        }
Beispiel #23
0
 private static extern bool GetFirmwareType(ref FirmwareType FirmwareType);
Beispiel #24
0
        private static List <string> GetExpectedHashes(FirmwareType type)
        {
            switch (type)
            {
            case FirmwareType.CX4: return(new List <string>()
                {
                    "AE8D4D1961B93421FF00B3CAA1D0F0CE7783E749772A3369C36B3DBF0D37EF18"
                });

            case FirmwareType.DSP1: return(new List <string>()
                {
                    "91E87D11E1C30D172556BED2211CCE2EFA94BA595F58C5D264809EF4D363A97B"
                });

            case FirmwareType.DSP1B: return(new List <string>()
                {
                    "D789CB3C36B05C0B23B6C6F23BE7AA37C6E78B6EE9CEAC8D2D2AA9D8C4D35FA9"
                });

            case FirmwareType.DSP2: return(new List <string>()
                {
                    "03EF4EF26C9F701346708CB5D07847B5203CF1B0818BF2930ACD34510FFDD717"
                });

            case FirmwareType.DSP3: return(new List <string>()
                {
                    "0971B08F396C32E61989D1067DDDF8E4B14649D548B2188F7C541B03D7C69E4E"
                });

            case FirmwareType.DSP4: return(new List <string>()
                {
                    "752D03B2D74441E430B7F713001FA241F8BBCFC1A0D890ED4143F174DBE031DA"
                });

            case FirmwareType.ST010: return(new List <string>()
                {
                    "FA9BCED838FEDEA11C6F6ACE33D1878024BDD0D02CC9485899D0BDD4015EC24C"
                });

            case FirmwareType.ST011: return(new List <string>()
                {
                    "8B2B3F3F3E6E29F4D21D8BC736B400BC988B7D2214EBEE15643F01C1FEE2F364"
                });

            case FirmwareType.ST018: return(new List <string>()
                {
                    "6DF209AB5D2524D1839C038BE400AE5EB20DAFC14A3771A3239CD9E8ACD53806"
                });

            case FirmwareType.Satellaview: return(new List <string>()
                {
                    "27CFDB99F7E4252BF3740D420147B63C4C88616883BC5E7FE43F2F30BF8C8CBB",                     //Japan, no DRM
                    "A49827B45FF9AC9CF5B4658190E1428E59251BC82D8A63D8E9E0F71E439F008F",                     //English, no DRM
                    "3CE321496EDC5D77038DE2034EB3FB354D7724AFD0BC7FD0319F3EB5D57B984D",                     //Japan, original
                    "77D94D64D745014BF8B51280A4204056CDEB9D41EA30EAE80DBC006675BEBEF8",                     //English, DRM
                });

            case FirmwareType.Gameboy: return(new List <string>()
                {
                    "CF053ECCB4CCAFFF9E67339D4E78E98DCE7D1ED59BE819D2A1BA2232C6FCE1C7", "26E71CF01E301E5DC40E987CD2ECBF6D0276245890AC829DB2A25323DA86818E"
                });

            case FirmwareType.GameboyColor: return(new List <string>()
                {
                    "B4F2E416A35EEF52CBA161B159C7C8523A92594FACB924B3EDE0D722867C50C7", "3A307A41689BEE99A9A32EA021BF45136906C86B2E4F06C806738398E4F92E45"
                });

            case FirmwareType.Sgb1GameboyCpu: return(new List <string>()
                {
                    "0E4DDFF32FC9D1EEAAE812A157DD246459B00C9E14F2F61751F661F32361E360"
                });

            case FirmwareType.Sgb2GameboyCpu: return(new List <string>()
                {
                    "FD243C4FB27008986316CE3DF29E9CFBCDC0CD52704970555A8BB76EDBEC3988"
                });

            case FirmwareType.SGB1: return(new List <string>()
                {
                    "BBA9C269273BEDB9B38BD5EB23BFAA6E509B8DECC7CB80BB5513905AF04F4CEB",                     //Rev 0 (Japan)
                    "C6C4DAAB5C899B69900C460787DE6089EDABE94B760F96D9F583D30CC0A5BB30",                     //Rev 1 (Japan+USA)
                    "A75160F7B89B1F0E20FD2F6441BB86285C7378DB5035EF6885485EAFF6059376",                     //Rev 2 (World)
                });

            case FirmwareType.SGB2:
                return(new List <string>()
                {
                    "C172498A23D1176672931BAB33B629C7D28F914A43DCA9E540B8AF1B37CCF2C6",                     //SGB2 (Japan)
                });
            }
            throw new Exception("Unexpected firmware type");
        }
Beispiel #25
0
        private static List <string> GetExpectedHashes(FirmwareType type)
        {
            switch (type)
            {
            case FirmwareType.CX4: return(new List <string>()
                {
                    "AE8D4D1961B93421FF00B3CAA1D0F0CE7783E749772A3369C36B3DBF0D37EF18"
                });

            case FirmwareType.DSP1: return(new List <string>()
                {
                    "91E87D11E1C30D172556BED2211CCE2EFA94BA595F58C5D264809EF4D363A97B"
                });

            case FirmwareType.DSP1B: return(new List <string>()
                {
                    "D789CB3C36B05C0B23B6C6F23BE7AA37C6E78B6EE9CEAC8D2D2AA9D8C4D35FA9"
                });

            case FirmwareType.DSP2: return(new List <string>()
                {
                    "03EF4EF26C9F701346708CB5D07847B5203CF1B0818BF2930ACD34510FFDD717"
                });

            case FirmwareType.DSP3: return(new List <string>()
                {
                    "0971B08F396C32E61989D1067DDDF8E4B14649D548B2188F7C541B03D7C69E4E"
                });

            case FirmwareType.DSP4: return(new List <string>()
                {
                    "752D03B2D74441E430B7F713001FA241F8BBCFC1A0D890ED4143F174DBE031DA"
                });

            case FirmwareType.ST010: return(new List <string>()
                {
                    "FA9BCED838FEDEA11C6F6ACE33D1878024BDD0D02CC9485899D0BDD4015EC24C"
                });

            case FirmwareType.ST011: return(new List <string>()
                {
                    "8B2B3F3F3E6E29F4D21D8BC736B400BC988B7D2214EBEE15643F01C1FEE2F364"
                });

            case FirmwareType.ST018: return(new List <string>()
                {
                    "6DF209AB5D2524D1839C038BE400AE5EB20DAFC14A3771A3239CD9E8ACD53806"
                });

            case FirmwareType.Satellaview: return(new List <string>()
                {
                    "27CFDB99F7E4252BF3740D420147B63C4C88616883BC5E7FE43F2F30BF8C8CBB",                     //Japan, no DRM
                    "A49827B45FF9AC9CF5B4658190E1428E59251BC82D8A63D8E9E0F71E439F008F",                     //English, no DRM
                    "3CE321496EDC5D77038DE2034EB3FB354D7724AFD0BC7FD0319F3EB5D57B984D",                     //Japan, original
                    "77D94D64D745014BF8B51280A4204056CDEB9D41EA30EAE80DBC006675BEBEF8",                     //English, DRM
                });

            case FirmwareType.Gameboy: return(new List <string>()
                {
                    "CF053ECCB4CCAFFF9E67339D4E78E98DCE7D1ED59BE819D2A1BA2232C6FCE1C7", "26E71CF01E301E5DC40E987CD2ECBF6D0276245890AC829DB2A25323DA86818E"
                });

            case FirmwareType.GameboyColor: return(new List <string>()
                {
                    "B4F2E416A35EEF52CBA161B159C7C8523A92594FACB924B3EDE0D722867C50C7", "3A307A41689BEE99A9A32EA021BF45136906C86B2E4F06C806738398E4F92E45"
                });
            }
            throw new Exception("Unexpected firmware type");
        }
Beispiel #26
0
 public static extern bool GetFirmwareType(ref FirmwareType FirmwareType);
Beispiel #27
0
 private static extern bool GetFirmwareType(ref FirmwareType FirmwareType);