Beispiel #1
0
        public static bool CheckIsWIN8(IHierarchicalBOM bom)
        {
            string site = GetSite();
            IList<IBOMNode> P1BomNodeList = bom.GetFirstLevelNodesByNodeType("P1");
            bool bWIN8 = false;
            if (site == "IPC")
            {
                foreach (IBOMNode bomNode in P1BomNodeList)
                {
                    if (bomNode.Part.Descr.StartsWith("ECOA"))
                    {
                        bWIN8 = true;
                        break;
                    }
                }
             }
            else
            {
                foreach (IBOMNode bomNode in P1BomNodeList)
                {
                    if (bomNode.Part.Descr.ToUpper().Contains("COA (WIN8)") )
                    {
                        bWIN8 = true;
                        break;
                    }
                }
            }
            return bWIN8;

        }
Beispiel #2
0
        private IList<string> GetWirelessAndFCCID(IHierarchicalBOM bom, IProduct p, string dn)
        {
            //Wireless:在Model BOM中按照Model取下阶,得到
            //BomNodeType=’AV’ and PartInfo.InfoType=’Descr’ and PartInfo.InfoValue=’BLUETOOTH’
            //的记录,Wireless=获取PartInfo.InfoType=’AV’对应的InfoValue值(只考虑得到一条)。
            string ret1 = "";
            string ret2 = "";
            IList<IBOMNode> AVBomNodeList = bom.GetFirstLevelNodesByNodeType("AV");
            foreach (IBOMNode bomNode in AVBomNodeList)
            {
                string attrDescr = getAttrValue(bomNode.Part, "Descr");
                if (attrDescr != null && attrDescr == "BLUETOOTH")
                {
                    string attrAV = getAttrValue(bomNode.Part, "AV");
                    if (attrAV != null && attrAV != "")
                    {
                        ret1 = attrAV;
                        break;
                    }
                }
            }

            //FCCID:当Wireless<>””时且该model在Model BOM中的下阶存在
            //BomNodeType in('P1','BM','KP') and Part.Descr like ’BLUETOOTH%’
            //时,才需要获取FCCID
            bool bNeedFCCID = false;
            for (int loop = 0; loop < 3; loop++)
            {
                if (bNeedFCCID) break;
                IList<IBOMNode> BomNodeList = new List<IBOMNode>();
                if (loop == 0) BomNodeList = bom.GetFirstLevelNodesByNodeType("P1");
                if (loop == 1) BomNodeList = bom.GetFirstLevelNodesByNodeType("BM");
                if (loop == 2) BomNodeList = bom.GetFirstLevelNodesByNodeType("KP");

                foreach (IBOMNode bomNode in BomNodeList)
                {
                    if (bomNode.Part.Descr.StartsWith("BLUETOOTH"))
                    {
                        if (ret1 != "")
                        {
                            bNeedFCCID = true;
                        }
                        else
                        {
                            //UC Exception 7
                            throw new FisException("PAK116", new string[] { dn });
                        }
                        break;
                    }
                }
            }

            //FCCID获取方法: Model BOM从model展2阶,得到
            //BomNodeType=’KP’ and Part.Descr like ’BLUETOOTH%’ and 该part对应的’FCC ID’不等于空
            //的记录,FCCID=’FCC ID’对应的属性值
            if (bNeedFCCID)
            {
                bool bFoundFCCID = false;
                IList<IBOMNode> L1BomNodeList = bom.FirstLevelNodes;    //展1阶
                foreach (IBOMNode bomNode in L1BomNodeList)
                {
                    if (bFoundFCCID) break;
                    IList<IBOMNode> L2BomNodeList = bomNode.Children;   //展2阶
                    foreach (IBOMNode bomNode1 in L2BomNodeList)
                    {
                        if (bFoundFCCID) break;
                        IPart tmpPart = bomNode1.Part;
                        if (tmpPart.BOMNodeType == "KP" && tmpPart.Descr.StartsWith("BLUETOOTH"))
                        {
                            string val = getAttrValue(tmpPart, "FCC ID");
                            if (val != null && val != "")
                            {
                                ret2 = val;
                                bFoundFCCID = true;
                            }
                        }
                    }
                }
                //UC Exception 2
                if (!bFoundFCCID)
                {
                    throw new FisException("PAK112", new string[] { p.Model });
                }
            }

            //注:只要FCCID=’’时,Wireless=’’
            if (ret2 == "") ret1 = "";

            //再来获取Wireless part:当Model BOM按照Model展下阶存在Part.Descr=’WIRELESS’时,
            //若获取Model下阶BomNodeType= ’AV’ and 其Descr属性值like ‘WIRELESS%’的part对应的AV属性值@wireless不等于””时,
            //作以下处理:
            bool bExistWLPart = false;
            string wlval = "";
            foreach (IBOMNode bomNode in bom.FirstLevelNodes)
            {
                if (bomNode.Part.Descr == "WIRELESS")
                {
                    bExistWLPart = true;
                    break;
                }
            }

            if (bExistWLPart)
            {
                foreach (IBOMNode bomNode in AVBomNodeList)
                {
                    string attrDescr = getAttrValue(bomNode.Part, "Descr");
                    if (attrDescr != null && attrDescr.StartsWith("WIRELESS"))
                    {
                        string attrAV = getAttrValue(bomNode.Part, "AV");
                        if (attrAV != null && attrAV != "")
                        {
                            wlval = attrAV;
                            break;
                        }
                        //UC Exception 5
                        else
                        {
                            throw new FisException("PAK114", new string[] { dn });
                        }
                    }
                }
            }

            if (wlval != "")
            {
                //If Wireless=’’
                //  Wireless=@wireless
                //  FCCID=IMES_FA..Product_Part.PartNo对应的Part.BomNodeType=’KP’ and Part.Descr like ‘WIRELESS%’ and [FCC ID]属性值不等于空的part,得到其[FCC ID]属性值@fccid
                //Else
                //  Wireless=Wireless+’\’+@wireless
                //  FCCID=FCCID+’\’+@fccid

                string fccid = "";
                bool bFoundFCCID = false;
                foreach (IProductPart part in p.ProductParts)
                {
                    IPart tmp = partRepository.GetPartByPartNo(part.PartID);
                    if (tmp.BOMNodeType == "KP" && tmp.Descr.StartsWith("WIRELESS"))
                    {
                        string attrFCCID = getAttrValue(tmp, "FCC ID");
                        if (attrFCCID != null && attrFCCID != "")
                        {
                            bFoundFCCID = true;
                            fccid = attrFCCID;
                            break;
                        }
                        //UC Exception 6
                        else
                        {
                            throw new FisException("PAK115", new string[] { dn });
                        }
                    }
                }

                /*
                 * Answer to: ITC-1360-0903
                 * Description: Throw fis exception if WIRELESS not empty but FCCID is null.
                 */
                //UC Exception 8
                if (!bFoundFCCID)
                {
                    throw new FisException("PAK117", new string[] { dn });
                }

                if (ret1 == "")
                {
                    ret1 = wlval;
                    ret2 = fccid;
                }
                else
                {
                    ret1 += "\\" + wlval;
                    ret2 += "\\" + fccid;
                }
            }

            IList<string> ret = new List<string>();
            ret.Add(ret1);
            ret.Add(ret2);
            return ret;
        }
Beispiel #3
0
        public bool CheckIsWIN8(IHierarchicalBOM bom)
        {
            IList<IBOMNode> P1BomNodeList = bom.GetFirstLevelNodesByNodeType("P1");
            bool bWIN8 = false;
             foreach (IBOMNode bomNode in P1BomNodeList)
                {
                    if (bomNode.Part.Descr.ToUpper().Contains("COA (WIN8)"))
                    {
                        bWIN8 = true;
                        break;
                    }
                }
           
            return bWIN8;

        }
Beispiel #4
0
        private bool CheckOA3Key(IHierarchicalBOM bom, IProduct p, string fkiPath, CredentialCache FKICredentialCache, string editor, UnitOfWork uow)
        {
            bool bWIN8 = false;
            IList<IBOMNode> P1BomNodeList = bom.GetFirstLevelNodesByNodeType("P1");
            //foreach (IBOMNode bomNode in P1BomNodeList)
            //{
            //    if (bomNode.Part.Descr.StartsWith("ECOA"))
            //    {
            //        bWIN8 = true;
            //        break;
            //    }
            //}
            CommonImpl2 cm2 = new CommonImpl2();
            bWIN8 = cm2.CheckIsWIN8(bom);


            if (!bWIN8) return true;

            if (fkiPath == "") return true; //Switch off checking by FKIServer.
            string thisURI = "";
            if (fkiPath.EndsWith("/"))
            {
                thisURI = fkiPath + "UnitStatus";
            }
            else
            {
                thisURI = fkiPath + "/UnitStatus";
            }

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(thisURI);
            req.AllowAutoRedirect = true;
            req.CookieContainer = new CookieContainer();
            req.ContentType = "application/plain; charset=utf-8";
            req.Accept = "*/*";
            req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
            req.KeepAlive = true;
            req.Method = "POST";
            req.Credentials = FKICredentialCache.GetCredential(new Uri(fkiPath), "NTLM");

            string XMLInputData = "<?xml version='1.0' encoding='utf-8' ?>";
            XMLInputData += "<UnitStatusRequest xmlns='http://HP.ITTS.OA30/digitaldistribution/2011/08'>";
            XMLInputData += "<HPSerialNumber>";
            XMLInputData += p.CUSTSN;
            XMLInputData += "</HPSerialNumber>";
            XMLInputData += "<ProductKeyID>";
            XMLInputData += "";
            XMLInputData += "</ProductKeyID>";
            XMLInputData += "</UnitStatusRequest>";
            Encoding encoding = Encoding.Default;
            byte[] buffer = encoding.GetBytes(XMLInputData);
            req.ContentLength = buffer.Length;
            req.GetRequestStream().Write(buffer, 0, buffer.Length);

            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            XmlTextReader xmlr = new XmlTextReader(res.GetResponseStream());
            string status = "";
            string rc = "";
            bool bError = false;
            bool bFound = false;
            StringBuilder str = new StringBuilder("Formatted Response:\n");

            while (xmlr.Read())
            {
                switch (xmlr.NodeType)
                {
                    case XmlNodeType.Element:
                        if (xmlr.IsEmptyElement)
                            str.AppendFormat("<{0}/>", xmlr.Name);
                        else
                            str.AppendFormat("<{0}>", xmlr.Name);
                        break;
                    case XmlNodeType.Text:
                        str.Append(xmlr.Value);
                        break;
                    case XmlNodeType.CDATA:
                        str.AppendFormat("<![CDATA[{0}]]>", xmlr.Value);
                        break;
                    case XmlNodeType.ProcessingInstruction:
                        str.AppendFormat("<?{0} {1}?>", xmlr.Name, xmlr.Value);
                        break;
                    case XmlNodeType.Comment:
                        str.AppendFormat("<!--{0}-->", xmlr.Value);
                        break;
                    case XmlNodeType.XmlDeclaration:
                        str.AppendFormat("<?xml version='1.0'?>");
                        break;
                    case XmlNodeType.DocumentType:
                        str.AppendFormat("<!DOCTYPE{0} [{1}]>", xmlr.Name, xmlr.Value);
                        break;
                    case XmlNodeType.EntityReference:
                        str.Append(xmlr.Name);
                        break;
                    case XmlNodeType.EndElement:
                        str.AppendFormat("</{0}>", xmlr.Name);
                        break;
                    case XmlNodeType.Whitespace:
                        str.Append("\n");
                        break;
                }

                if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ReturnCode"))
                {
                    xmlr.Read();
                    str.Append(xmlr.Value);
                    rc = xmlr.Value.Trim();
                    if (rc != "000") bError = true;
                    continue;
                }

                if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ReturnMessage"))
                {
                    if (bError)
                    {
                        xmlr.Read();
                        str.Append(xmlr.Value);
                        string msg = xmlr.Value;
                        xmlr.Close();
                        throw new Exception("[" + rc + "]:" + msg);
                    }
                }

                if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ProductKeyStateName"))
                {
                    xmlr.Read();
                    str.Append(xmlr.Value);
                    status = xmlr.Value;
                    // Marked this by Benson at 2013/3/8
                    //  if (status == "NotifiedBound")
                    if (status == "NotifiedBound" || status == "FKIErrorBound")
                    {
                        //只能有一行状态为"Bound"/"NotifiedBound"/"PendingBound" --OLD
                        //只能有一行状态为"Bound"/"NotifiedBound"/"PendingBound/FKIErrorBound" --NEW add by Benson at 2013/3/8

                        if (bFound)
                        {
                            xmlr.Close();
                            return false;
                        }
                        bFound = true;
                        continue;
                    }


                    if (status == "Bound" || status == "PendingBound")
                    {
                        //只能有一行状态为"Bound"/"NotifiedBound"/"PendingBound"
                        if (bFound)
                        {
                            xmlr.Close();
                            return false;
                        }
                        bFound = true;

                        //对于状态为Bound/PendingBound的Product需要记录到ProductInfo中
                        IMES.FisObject.FA.Product.ProductInfo item = new IMES.FisObject.FA.Product.ProductInfo();
                        item.ProductID = p.ProId;
                        item.InfoType = "Win8KeyState";
                        item.InfoValue = status;
                        item.Editor = editor;
                        if (productRepository.CheckExistProductInfo(p.ProId, "Win8KeyState"))
                        {
                            IMES.FisObject.FA.Product.ProductInfo cond = new IMES.FisObject.FA.Product.ProductInfo();
                            cond.ProductID = p.ProId;
                            cond.InfoType = "Win8KeyState";
                            productRepository.UpdateProductInfoDefered(uow, item, cond);
                        }
                        else
                        {
                            productRepository.InsertProductInfoDefered(uow, item);
                        }

                        continue;
                    }
                    //Returned 或PendingReturn或NotifiedReturned或FKIErrorReturn --Mantis0001691
                    // Marked this by Benson at 2013/3/8
                    //   if (status != "Returned" && status != "NotifiedReturned" && status != "PendingReturn")
                    if (status != "Returned" && status != "NotifiedReturned" && status != "PendingReturn" && status != "FKIErrorReturn")
                    {
                        xmlr.Close();
                        return false;
                    }
                }
            }
            xmlr.Close();
            Console.Write(str.ToString());
            return bFound;
        }
Beispiel #5
0
        private bool CheckCOACombine(IHierarchicalBOM bom, IProduct p, string dn)
        {
            bool bNeedCOA = false;
            string pnCOA = "";
            IList<IBOMNode> P1BomNodeList = bom.GetFirstLevelNodesByNodeType("P1");
            IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository>();
            IList<SysSettingInfo> siteList = partRep.GetSysSettingInfoes(new SysSettingInfo() { name = "Site" });
            string site = "IPC";
            if (siteList != null && siteList.Count > 0)
            {
                site = siteList[0].value;
            }
            foreach (IBOMNode bomNode in P1BomNodeList)
            {
                //Vincent Change Check WIN7 or WIN8 log
                if (site == "IPC")
                {
                    if (bomNode.Part.Descr.StartsWith("COA"))
                    {
                        bNeedCOA = true;
                        pnCOA = bomNode.Part.PN;
                        break;
                    }
                }
                else
                {
                    if (bomNode.Part.Descr.ToUpper().Contains("WIN7"))
                    {
                        bNeedCOA = true;
                        pnCOA = bomNode.Part.PN;
                        break;
                    }
                }
            }

            if (!bNeedCOA) return true;

            if (partRepository.CheckExistInternalCOA(dn, "DN")) return true;

            if (partRepository.CheckExistInternalCOA(p.CUSTSN, "SN")) return true;

            foreach (IProductPart tmp in p.ProductParts)
            {
                if (tmp.PartID == pnCOA) return true;
            }

            return false;
        }
Beispiel #6
0
        private string GetODD(IHierarchicalBOM bom, string dn)
        {
            //ODD:在Model BOM中按照Model取下阶,得到

            //BomNodeType=’AV’ and PartInfo.InfoType=’Descr’ and PartInfo.InfoValue=’ODD’
            //的记录,获取PartInfo.InfoType=’AV’对应的InfoValue值,当存在多条时,用’\’分割串起来
            string ret = "";
            IList<IBOMNode> AVBomNodeList = bom.GetFirstLevelNodesByNodeType("AV");
            foreach (IBOMNode bomNode in AVBomNodeList)
            {
                /*
                 * Answer to: ITC-1360-0907
                 */
                string attrDescr = getAttrValue(bomNode.Part, "Descr");
                if (attrDescr != null && attrDescr == "ODD")
                {
                    string val = getAttrValue(bomNode.Part, "AV");
                    if (val != null && val != "") ret += val + "\\";
                    //UC Exception 
                    else if (!bomNode.Part.PN.StartsWith("ZM"))
                    {
                        throw new FisException("PAK113", new string[] { dn });
                    }
                }
            }

            if (ret.EndsWith("\\")) ret = ret.Remove(ret.Length - 1);
            return ret;
        }
Beispiel #7
0
        private bool CheckOA3Key(IHierarchicalBOM bom, IProduct p, string fkiPath, CredentialCache FKICredentialCache)
        {
            bool bWIN8 = false;
            IList<IBOMNode> P1BomNodeList = bom.GetFirstLevelNodesByNodeType("P1");
            foreach (IBOMNode bomNode in P1BomNodeList)
            {
                if (bomNode.Part.Descr.StartsWith("ECOA"))
                {
                    bWIN8 = true;
                    break;
                }
            }

            if (!bWIN8) return true;

            if (fkiPath == "") return true; //Switch off checking by FKIServer.
            string thisURI = "";
            if (fkiPath.EndsWith("/"))
            {
                thisURI = fkiPath + "UnitStatus";
            }
            else
            {
                thisURI = fkiPath + "/UnitStatus";
            } 

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(thisURI);
            req.AllowAutoRedirect = false;
            req.CookieContainer = new CookieContainer();
            //req.Headers.Add("Content-Type", "application/plain; charset=utf-8");
            req.Accept = "*/*";
            req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
            req.KeepAlive = false;
            req.Method = "POST";
            req.Credentials = FKICredentialCache;

            string XMLInputData = "<?xml version='1.0' encoding='utf-8' ?>";
            XMLInputData += "<UnitStatusRequest xmlns='http://HP.ITTS.OA30/digitaldistribution/2011/08'>";
            XMLInputData += "<HPSerialNumber>";
            XMLInputData += p.CUSTSN;
            XMLInputData += "</HPSerialNumber>";
            XMLInputData += "<ProductKeyID>";
            XMLInputData += p.ProId;
            XMLInputData += "</ProductKeyID>";
            XMLInputData += "</UnitStatusRequest>";


            MemoryStream memoryStream = new MemoryStream();
            StreamWriter writer = new StreamWriter(memoryStream);
            writer.Write(XMLInputData);
            using (Stream stream = req.GetRequestStream())
            {
                memoryStream.WriteTo(stream);
            }

            HttpWebResponse res = (HttpWebResponse)req.GetResponse();
            XmlTextReader xmlr = new XmlTextReader(res.GetResponseStream());
            string status = "";
            bool bFound = false;
            while (xmlr.Read())
            {
                if (xmlr.NodeType == System.Xml.XmlNodeType.Element && xmlr.LocalName.Equals("ProductKeyStateName"))
                {
                    xmlr.Read();
                    status = xmlr.Value;

                    if (status == "Bound" || status == "NotifiedBound" || status == "PendingBound")
                    {
                        bFound = true;
                        continue;
                    }

                    if (status != "Returned" && status != "NotifiedReturned" && status != "PendingReturn")
                    {
                        xmlr.Close();
                        return false;
                    }
                }
            }
            xmlr.Close();

            return bFound;
        }
Beispiel #8
0
        private bool CheckCOACombine(IHierarchicalBOM bom, IProduct p, string dn)
        {
            bool bNeedCOA = false;
            string pnCOA = "";
            IList<IBOMNode> P1BomNodeList = bom.GetFirstLevelNodesByNodeType("P1");
            foreach (IBOMNode bomNode in P1BomNodeList)
            {
                if (bomNode.Part.Descr.StartsWith("COA"))
                {
                    bNeedCOA = true;
                    pnCOA = bomNode.Part.PN;
                    break;
                }
            }

            if (!bNeedCOA) return true;
            
            if (partRepository.CheckExistInternalCOA(dn, "DN")) return true;

            if (partRepository.CheckExistInternalCOA(p.CUSTSN, "SN")) return true;

            foreach (IProductPart tmp in p.ProductParts)
            {
                if (tmp.PartID == pnCOA) return true;
            }

            return false;
        }