Example #1
0
 // Will be invoked when oa tool run 'oa3tool.exe /assembly' in command line.
 public bool OaToolAssembleKey(KeyInfo key)
 {
     bool isFailed = false;
     try
     {
         key.FactoryFloorAssembleKey();
         keyRepository.UpdateKey(key, null, null, null, null);
     }
     catch (Exception ex)
     {
         ExceptionHandler.HandleException(ex);
         isFailed = true;
     }
     return !isFailed;
 }
Example #2
0
        // 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;
        }
Example #3
0
 private KeyErrorType ValidateRevertKey(KeyInfo key)
 {
     if (key == null)
         return KeyErrorType.NotFound;
     else if (!ValidateKeyState(
         () =>
         {
             key.FactoryFloorRevertKey();
             key.HardwareHash =string.Empty;
             key.OemOptionalInfo = new OemOptionalInfo();
             key.TrackingInfo = string.Empty;
         }))
         return KeyErrorType.StateInvalid;
     else
         return KeyErrorType.None;
 }
Example #4
0
 private KeyErrorType ValidateUnassignKey(KeyInfo key)
 {
     if (key == null)
         return KeyErrorType.NotFound;
     else if (key.KeyInfoEx.IsInProgress)
         return KeyErrorType.AlreadyAssigned;
     else if (!ValidateKeyState(key.UlsUnassigningKey))
         return KeyErrorType.StateInvalid;
     else
         return KeyErrorType.None;
 }
Example #5
0
 private bool ValidateIfCarbonCopyKey(KeyInfo key)
 {
     if (Constants.InstallType != InstallType.Oem)
         return false;
     if (key.KeyInfoEx.ShouldCarbonCopy.HasValue)
         return true;
     return false;
 }
        private Dictionary<DateTime, string> GetKeyHistoryDetails(KeyInfo keyInfo)
        {
            Dictionary<DateTime, string> result = new Dictionary<DateTime, string>();

            var keyHistories = keyInfo.KeyHistories.OrderBy(k => k.StateChangeDate).ToList();
            keyHistories.ForEach(p => { result.Add(p.StateChangeDate, ((KeyState)p.KeyStateId).ToString()); });
            return result;
        }
Example #7
0
        private KeyErrorType ValidImportReturnAckKey(KeyInfo key)
        {
            KeyInfo keyInDb = keyRepository.GetKey(key.KeyId);

            if (key.KeyId <= 0 || key.KeyState != KeyState.Fulfilled)
                return KeyErrorType.Invalid;
            if (keyInDb != null && keyInDb.ModifiedDate >= key.ModifiedDate)
                return KeyErrorType.DuplicateImport;
            if (keyInDb != null)
                return KeyErrorType.Duplicate;
            else
                return KeyErrorType.None;
        }
Example #8
0
 private KeyErrorType ValidImportBoundKeyInUls(KeyInfo key, KeyInfo keyInDb)
 {
     if (key.KeyId <= 0 || key.KeyState != KeyState.Bound || string.IsNullOrEmpty(key.HardwareHash))
         return KeyErrorType.Invalid;
     if (keyInDb == null)
         return KeyErrorType.NotFound;
     if (keyInDb != null && keyInDb.ModifiedDate >= key.ModifiedDate && keyInDb.KeyState == KeyState.Bound)
         return KeyErrorType.DuplicateImport;
     if (!ValidateKeyState(keyInDb.UlsReceivingBoundKey))
         return KeyErrorType.StateInvalid;
     else
         return KeyErrorType.None;
 }
Example #9
0
 public void CopyKeyState(KeyInfo key)
 {
     KeyStateWrapper = key.KeyState;
 }
Example #10
0
 private KeyErrorType ValidExportConsumedKey(KeyInfo key, KeyInfo keyInDb)
 {
     if (keyInDb == null)
         return KeyErrorType.NotFound;
     else if (!ValidateKeyState(keyInDb.FactoryFloorAssembleKey))
         return KeyErrorType.StateInvalid;
     else
         return KeyErrorType.None;
 }
Example #11
0
 private KeyErrorType ValidateReportedBoundKey(KeyInfo key, KeyInfo keyInDb)
 {
     if (keyInDb == null)
         return KeyErrorType.NotFound;
     else if (!ValidateKeyState(keyInDb.UlsReportingBoundKeyToMs))
         return KeyErrorType.StateInvalid;
     else
         return KeyErrorType.None;
 }
Example #12
0
 private KeyErrorType ValidateExportBoundKey(KeyInfo key, KeyInfo keyInDb)
 {
     if (keyInDb == null)
         return KeyErrorType.NotFound;
     else if (!ValidateKeyState(keyInDb.DlsReportingBoundKeyToUls))
         return KeyErrorType.StateInvalid;
     else if (string.IsNullOrEmpty(keyInDb.HardwareHash))
         return KeyErrorType.Invalid;
     else
         return KeyErrorType.None;
 }
Example #13
0
 private void RecordExportLog(KeyInfo key, ExportParameters exportParameters, string fileContent, string fileName)
 {
     RecordExportLog(new List<KeyInfo>() { key }, exportParameters, fileContent, fileName);
 }
Example #14
0
 private string GenerateSubDirectory(KeyInfo key, string path, bool isDefaultPath)
 {
     var subDirectory = path;
     var partNumberName = string.IsNullOrEmpty(key.OemPartNumber) ? string.Empty : key.OemPartNumber;
     subDirectory = isDefaultPath ? Path.Combine(subDirectory, partNumberName, KeyManagerHelper.DefaultToolKeyAllocateFolderName) : subDirectory;
     KeyManagerHelper.CreateDirectory(subDirectory);
     return subDirectory;
 }
Example #15
0
        private string GenerateKeysToFile(KeyInfo key, string path, out string subFullFileName)
        {
            var directoryName = path;
            var isDefaultPath = directoryName == Path.Combine(Directory.GetCurrentDirectory(), KeyManagerHelper.DefaultToolKeyFolderName) ? true : false;

            var subDirectoryName = GenerateSubDirectory(key, path, isDefaultPath);
            var subFileName = string.Format("{0}.xml", key.KeyId);
            subFullFileName = Path.Combine(subDirectoryName, subFileName);

            var toolKeys = key.ToToolKey();
            Serializer.WriteToXml(toolKeys, subFullFileName);
            return KeyManagerHelper.GetXmlResult(toolKeys);
        }
Example #16
0
 protected KeyOperationResult GenerateKeyOperationResult(KeyInfo key, List<KeyInfo> keysInDb, Func<KeyInfo, KeyInfo, KeyErrorType> validateFunc)
 {
     var keyInDb = GetKey(key.KeyId, keysInDb);
     KeyErrorType errorType = validateFunc(key, keyInDb);
     return new KeyOperationResult()
     {
         Failed = errorType == KeyErrorType.None ? false : true,
         FailedType = errorType,
         Key = key,
         KeyInDb = keyInDb,
     };
 }
Example #17
0
 private KeyErrorType ValidExportFulfilledKeyInUls(KeyInfo key, KeyInfo keyInDb)
 {
     if (keyInDb == null)
         return KeyErrorType.NotFound;
     else if (!ValidateKeyState(keyInDb.UlsExportingFulfilledKey))
         return KeyErrorType.StateInvalid;
     else
         return KeyErrorType.None;
 }
Example #18
0
 private KeyErrorType ValidExportReturnKey(KeyInfo key, KeyInfo keyInDb)
 {
     if (keyInDb == null)
         return KeyErrorType.NotFound;
     else if (!ValidateKeyState(keyInDb.ULsReturningKey))
         return KeyErrorType.StateInvalid;
     else
         return KeyErrorType.None;
 }
 private void InitOptionalInfo(KeyInfo key)
 {
     if (key != null)
     {
         this.ZCHANNEL_REL_ID = key.ZCHANNEL_REL_ID;
         this.ZMAUF_GEO_LOC = key.ZMANUF_GEO_LOC;
         this.ZOEM_EXT_ID = key.ZOEM_EXT_ID;
         this.ZPC_MODEL_SKU = key.ZPC_MODEL_SKU;
         this.ZPGM_ELIG_VALUES = key.ZPGM_ELIG_VALUES;
     }
 }
Example #20
0
 protected KeyErrorType ValidateKeyAfterRetrieveAck(KeyInfo key, KeyInfo keyInDb)
 {
     if (keyInDb == null)
         return KeyErrorType.NotFound;
     else
         return KeyErrorType.None;
 }
Example #21
0
 private KeyErrorType ValidImportFulfilledKeyInDls(KeyInfo key, KeyInfo keyInDb)
 {
     if (key.KeyId <= 0 || key.KeyState != KeyState.Fulfilled)
         return KeyErrorType.Invalid;
     if (keyInDb != null && keyInDb.ModifiedDate >= key.ModifiedDate)
         return KeyErrorType.DuplicateImport;
     if (keyInDb != null)
         return KeyErrorType.Duplicate;
     else
         return KeyErrorType.None;
 }
Example #22
0
 private KeyErrorType ValidateAssignKey(KeyInfo key)
 {
     if (key == null)
         return KeyErrorType.NotFound;
     else if (key.KeyInfoEx.IsInProgress)
         return KeyErrorType.StateInvalid;
     else if (key.KeyInfoEx.SsId.HasValue)
         return KeyErrorType.AlreadyAssigned;
     else if (!ValidateKeyState(key.UlsAssigningKey))
         return KeyErrorType.StateInvalid;
     else if (ValidateIfCarbonCopyKey(key))
         return KeyErrorType.Invalid;
     else
         return KeyErrorType.None;
 }
Example #23
0
 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;
 }
Example #24
0
 /// <summary>
 /// Gets the History By SelectedKeyId property
 /// </summary>
 private void GetKeyHistoryById(KeyInfo keyInfo)
 {
     //If Selected Key Count is exactly ONE, Then Get History
     if (null != keyInfo)
     {
         try
         {
             //Get the Selected Key
             KeyHistoryInformation = GetKeyHistoryDetails(keyInfo);
         }
         catch (Exception ex)
         {
             ex.ShowDialog();
             ExceptionHandler.HandleException(ex);
         }
     }
 }