private static List <OhrKey> FromOemOptionalInfo(long keyId, OemOptionalInfo info)
        {
            List <OhrKey> result = new List <OhrKey>();

            //if (!string.IsNullOrEmpty(info.ZCHANNEL_REL_ID))
            //{
            //    result.Add(new OhrKey(keyId, OemOptionalInfo.ZChannelRelIdName, info.ZCHANNEL_REL_ID));
            //}
            //if (!string.IsNullOrEmpty(info.ZMANUF_GEO_LOC))
            //{
            //    result.Add(new OhrKey(keyId, OemOptionalInfo.ZManufGeoLocName, info.ZMANUF_GEO_LOC));
            //}
            //if (!string.IsNullOrEmpty(info.ZOEM_EXT_ID))
            //{
            //    result.Add(new OhrKey(keyId, OemOptionalInfo.ZOemExtIdName, info.ZOEM_EXT_ID));
            //}
            //if (!string.IsNullOrEmpty(info.ZPGM_ELIG_VALUES))
            //{
            //    result.Add(new OhrKey(keyId, OemOptionalInfo.ZPgmEligValuesName, info.ZPGM_ELIG_VALUES));
            //}
            if (!string.IsNullOrEmpty(info.ZFRM_FACTOR_CL1))
            {
                result.Add(new OhrKey(keyId, OemOptionalInfo.ZFrmFactorCl1Name, info.ZFRM_FACTOR_CL1));
            }
            if (!string.IsNullOrEmpty(info.ZFRM_FACTOR_CL2))
            {
                result.Add(new OhrKey(keyId, OemOptionalInfo.ZFrmFactorCl2Name, info.ZFRM_FACTOR_CL2));
            }
            if (!string.IsNullOrEmpty(info.ZTOUCH_SCREEN))
            {
                result.Add(new OhrKey(keyId, OemOptionalInfo.ZTouchScreenName, info.ZTOUCH_SCREEN));
            }
            if (!string.IsNullOrEmpty(info.ZSCREEN_SIZE))
            {
                result.Add(new OhrKey(keyId, OemOptionalInfo.ZScreenSizeName, info.ZSCREEN_SIZE));
            }
            if (!string.IsNullOrEmpty(info.ZPC_MODEL_SKU))
            {
                result.Add(new OhrKey(keyId, OemOptionalInfo.ZPcModelSkuName, info.ZPC_MODEL_SKU));
            }
            return(result);
        }
Exemplo n.º 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;
        }
        public static OemOptionalInfo ToOemOptionInfo(this IEnumerable <OhrKey> ohrKeys)
        {
            var dic = ohrKeys.ToDictionary(k => k.Name, v => v.Value);

            OemOptionalInfo info = new OemOptionalInfo();

            if (dic.ContainsKey(OemOptionalInfo.ZFrmFactorCl1Name))
            {
                info.ZFRM_FACTOR_CL1 = dic[OemOptionalInfo.ZFrmFactorCl1Name];
            }
            if (dic.ContainsKey(OemOptionalInfo.ZFrmFactorCl2Name))
            {
                info.ZFRM_FACTOR_CL2 = dic[OemOptionalInfo.ZFrmFactorCl2Name];
            }
            if (dic.ContainsKey(OemOptionalInfo.ZTouchScreenName))
            {
                info.ZTOUCH_SCREEN = dic[OemOptionalInfo.ZTouchScreenName];
            }
            if (dic.ContainsKey(OemOptionalInfo.ZScreenSizeName))
            {
                info.ZSCREEN_SIZE = dic[OemOptionalInfo.ZScreenSizeName];
            }
            if (dic.ContainsKey(OemOptionalInfo.ZPcModelSkuName))
            {
                info.ZPC_MODEL_SKU = dic[OemOptionalInfo.ZPcModelSkuName];
            }
            //if (dic.ContainsKey(OemOptionalInfo.ZOemExtIdName))
            //    info.ZOEM_EXT_ID = dic[OemOptionalInfo.ZOemExtIdName];
            //if (dic.ContainsKey(OemOptionalInfo.ZManufGeoLocName))
            //    info.ZMANUF_GEO_LOC = dic[OemOptionalInfo.ZManufGeoLocName];
            //if (dic.ContainsKey(OemOptionalInfo.ZPgmEligValuesName))
            //    info.ZPGM_ELIG_VALUES = dic[OemOptionalInfo.ZPgmEligValuesName];
            //if (dic.ContainsKey(OemOptionalInfo.ZChannelRelIdName))
            //    info.ZCHANNEL_REL_ID = dic[OemOptionalInfo.ZChannelRelIdName];

            return(info);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Set product key info from key store, called from KeyProviderListener.
        /// </summary>
        /// <param name="parameters">Optional parameter for use by OEMs</param>
        /// <param name="productKeyInfo">XML with product key info to store</param>
        /// <returns></returns>
        public int UpdateKey(string parameters, string productKeyInfo)
        {
            try
            {
                MessageLogger.LogSystemRunning("UpdateKey", "Parameters = " + parameters);

                XDocument param = ParseAndValidateXML(parameters, parameterSchema);

                if (param == null)
                {
                    return Convert.ToInt32(
                        ReturnValue.MSG_KEYPROVIDER_XML_SCHEMA_FORMAT_VIOLATION);
                }

                XDocument dm = ParseAndValidateXML(productKeyInfo, productKeyInfoSchema);

                if (dm == null)
                {
                    return Convert.ToInt32(
                        ReturnValue.MSG_KEYPROVIDER_XML_SCHEMA_FORMAT_VIOLATION);
                }

                // Get XML bound by DMTool.
                foreach (XElement element in dm.Descendants("Key"))
                {
                    long productKeyId = Convert.ToInt64(GetXElementValue(element, "ProductKeyID"));

                    KeySearchCriteria query = new KeySearchCriteria();
                    query.PageSize = 1;
                    query.KeyId = productKeyId;

                    query = AttachParameters(query, param);

                    var keys = keyProxy.SearchKeys(query);

                    if (keys == null || keys.Count <= 0)
                    {
                        return Convert.ToInt32(
                           ReturnValue.MSG_KEYPROVIDER_NO_KEYS_AVAILABLE_FOR_SPECIFIED_PARAMETERS);
                    }
                    var key = keys.FirstOrDefault();

                    if (key == null)
                    {
                        return Convert.ToInt32(
                           ReturnValue.MSG_KEYPROVIDER_NO_KEYS_AVAILABLE_FOR_SPECIFIED_PARAMETERS);
                    }

                    var newHardwareId = GetXElementValue(element, "HardwareHash");
                    var newOEMOptionalInfo = new OemOptionalInfo(GetXElementValue(element, "OEMOptionalInfo"));
                    var newKeyState = (KeyState)Convert.ToByte(GetXElementValue(element, "ProductKeyState"));
                    if (!keyProxy.UpdateReportKey(key, newKeyState, newHardwareId, newOEMOptionalInfo))
                        return Convert.ToInt32(ReturnValue.MSG_KEYPROVIDER_INVALID_PRODUCT_KEY_STATE_TRANSITION);
                }

            }
            catch (Exception ex)
            {
                ExceptionHandler.HandleException(ex);

                if (ex.GetType() == typeof(EntityException))
                {
                    return Convert.ToInt32(ReturnValue.MSG_KEYPROVIDER_FAILED_DB_CONNECTION);
                }

                return Convert.ToInt32(ReturnValue.MSG_KEYPROVIDER_FAILED);
            }

            return Convert.ToInt32(ReturnValue.MSG_KEYPROVIDER_SUCCESS);
        }
Exemplo n.º 5
0
        public List<KeyOperationResult> UpdateOemOptionInfo(List<KeyInfo> keys, OemOptionalInfo optionalInfo)
        {
            ValidateIfEmpty(keys);
            if (keys.Any(k => k.KeyState != KeyState.Bound))
                throw new ApplicationException("States are invalid when saving keys.");

            var result = new List<KeyOperationResult>();

            foreach (var key in keys)
            {
                KeyErrorType keyErrorType = KeyErrorType.None;
                KeyInfo currentKey = keyRepository.GetKey(key.KeyId);
                if (currentKey == null)
                    keyErrorType = KeyErrorType.NotFound;
                else if (currentKey.KeyState != KeyState.Bound)
                    keyErrorType = KeyErrorType.StateInvalid;
                else
                    keyRepository.UpdateKey(key, null, null, null, optionalInfo);

                result.Add(new KeyOperationResult()
                {
                    Failed = (keyErrorType != KeyErrorType.None),
                    FailedType = keyErrorType,
                    Key = key,
                    KeyInDb = currentKey
                });
            }
            return result;
        }
Exemplo n.º 6
0
 public static DC.CbrKey FromServiceContract(this Binding binding)
 {
     string strOptionInfo = string.Empty;
     if (binding.OEMOptionalInfo != null && binding.OEMOptionalInfo.Length > 0)
     {
         DC.OemOptionalInfo oemOptionInfo = new DC.OemOptionalInfo();
         if (binding.OEMOptionalInfo.SingleOrDefault(r => r.Name == "ZPC_MODEL_SKU") != null)
             oemOptionInfo.ZPC_MODEL_SKU = binding.OEMOptionalInfo.SingleOrDefault(r => r.Name == "ZPC_MODEL_SKU").Value;
         if (binding.OEMOptionalInfo.SingleOrDefault(r => r.Name == "ZOEM_EXT_ID") != null)
             oemOptionInfo.ZOEM_EXT_ID = binding.OEMOptionalInfo.SingleOrDefault(r => r.Name == "ZOEM_EXT_ID").Value;
         if (binding.OEMOptionalInfo.SingleOrDefault(r => r.Name == "ZMANUF_GEO_LOC") != null)
             oemOptionInfo.ZMANUF_GEO_LOC = binding.OEMOptionalInfo.SingleOrDefault(r => r.Name == "ZMANUF_GEO_LOC").Value;
         if (binding.OEMOptionalInfo.SingleOrDefault(r => r.Name == "ZPGM_ELIG_VAL") != null)
             oemOptionInfo.ZPGM_ELIG_VALUES = binding.OEMOptionalInfo.SingleOrDefault(r => r.Name == "ZPGM_ELIG_VAL").Value;
         if (binding.OEMOptionalInfo.SingleOrDefault(r => r.Name == "ZCHANNEL_REL_ID") != null)
             oemOptionInfo.ZCHANNEL_REL_ID = binding.OEMOptionalInfo.SingleOrDefault(r => r.Name == "ZCHANNEL_REL_ID").Value;
         strOptionInfo = oemOptionInfo.ToString();
     }
     return new DC.CbrKey()
     {
         KeyId = binding.ProductKeyID,
         HardwareHash = binding.HardwareHash,
         OemOptionalInfo = strOptionInfo
     };
 }