private KeyErrorType ValidImportToolReportKey(OA3ToolReportKeyInfo.Key key, KeyInfo keyinfo) { if (key.ProductKeyID <= 0) return KeyErrorType.Invalid; else if (key.ProductKeyState != (byte)KeyState.Bound) return KeyErrorType.FileStateInvalid; else if (keyinfo == null) return KeyErrorType.NotFound; else if (keyinfo.KeyInfoEx.KeyType != KeyType.Standard) return KeyErrorType.KeyTypeInvalid; else if (!ValidateKeyState(() => keyinfo.FactoryFloorBoundKey(true))) return KeyErrorType.StateInvalid; else return KeyErrorType.None; }
// Will be invoked when oa tool run 'oa3tool.exe /report' in command line. public bool OaToolReportKey(KeyInfo key, KeyState keyState, string hardwareId, OemOptionalInfo oemOptionalInfo, string trackingInfo) { bool isFailed = false; if (keyState != KeyState.Bound && keyState != KeyState.Returned) throw new NotSupportedException(string.Format("oa3tool.exe to {0} is not supported", keyState)); try { bool isBound = keyState == KeyState.Bound; key.FactoryFloorBoundKey(isBound); if (isBound) keyRepository.UpdateKey(key, null, null, hardwareId, oemOptionalInfo, trackingInfo, true); else keyRepository.UpdateKey(key, null, null, string.Empty, new OemOptionalInfo(), null, true); } catch (Exception ex) { ExceptionHandler.HandleException(ex); isFailed = true; } return !isFailed; }