コード例 #1
0
ファイル: SAPService.cs プロジェクト: wra222/testgit
 SAPUploadSN.ZWS_ZSDSN_IN_LINE copyUploadSAPSN(UploadSAPSN sn)
 {
     SAPUploadSN.ZWS_ZSDSN_IN_LINE ret = new IMES.SAP.Implementation.SAPUploadSN.ZWS_ZSDSN_IN_LINE()
     {
          SERIALNUMBER =sn.SERIALNUMBER,
           ACNUM=sn.ACNUM,
           ASSET_NO=sn.ASSET_NO,
           BMAC=sn.BMAC,
           BOX_ID=sn.BOX_ID,
           BUILDER_VER=sn.BUILDER_VER,
           CARTON_NO =sn.CARTON_NO,
           CUST_PALLET=sn.CUST_PALLET,
           DLV_ITM=sn.DLV_ITM,
           DLV_NO=sn.DN,
           ERAC=sn.ERAC,
           FCCID=sn.FCCID,
           FDA=sn.FDA,
           HEX_MEID= sn.HEX_MEID,
            ICCID=sn.ICCID,
            IMEI_CODE =sn.IMEI_CODE,
            MACADDRESS=sn.MACADDRESS,
            MACADDRESS2= sn.MACADDRESS2,
            MANUFACTURE_DATE =sn.MANUFACTURE_DATE,
             ODMAT=sn.ODMAT,
            PALLET_NO=sn.PALLET_NO,
             PALLET_ORDINAL =sn.PALLET_ORDINAL,
              PBOX_ID= sn.PBOX_ID,
              PO_NO=sn.PO_NO,
               QTY =sn.QTY,
                SERNO=sn.SERNO,
                SERNO2=sn.SERNO2,
                SIMLOCK_CODE=sn.SIMLOCK_CODE,
                SOFTWARE_PN=sn.SOFTWARE_PN,
                SOFTWARE_VER=sn.SOFTWARE_VER,
                TYPE=sn.TYPE,
                UUID=sn.UUID,
                WARRANTY_DT=sn.WARRANTY_DT,
                WARRANTY_ID=sn.WARRANTY_ID,
                WLMAT=sn.WLMAT,
                WMAC=sn.WMAC
     };
     return ret;
 }
コード例 #2
0
ファイル: SendSAPCustSN.cs プロジェクト: wra222/testgit
        /// <summary>
        /// 获取记入c:\serial.txt的信息
        /// </summary>
        /// <param name="dns">DN list</param>
        /// <param name="editor">editor</param>
        /// <param name="txId">txId</param>
        private IList<UploadSAPSN> GenUploadSNData(IList<UploadDNInfo> dns, string editor, string txId)
        {
            IProductRepository productRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IDeliveryRepository deliveryRepository = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>();
            IPartRepository partRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
            IBOMRepository bomRep = RepositoryFactory.GetInstance().GetRepository<IBOMRepository>();
            IList<UploadSAPSN> ret = new List<UploadSAPSN>();

            Session session = CurrentSession;

            bool bNeedCheckEOA = false;
            bool bNeedCheckOA3 = false;
            string fkiPath = "";
            //ignore the certificate check (FOR CQ)
            #region Get OA3 setting value
            ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
            CredentialCache FKICredentialCache = new CredentialCache();

            try
            {
                fkiPath = System.Configuration.ConfigurationManager.AppSettings["FKIServicePath"].Trim();
                if (fkiPath != "")
                {
                    try
                    {
                        string fkiUser = System.Configuration.ConfigurationManager.AppSettings["FKIAuthUser"].Trim();
                        string fkiPwd = System.Configuration.ConfigurationManager.AppSettings["FKIAuthPassword"].Trim();
                        if (fkiUser != "")
                        {
                            if (fkiUser.Contains("\\"))
                            {
                                string user = fkiUser.Substring(fkiUser.IndexOf('\\') + 1);
                                string domain = fkiUser.Substring(0, fkiUser.IndexOf('\\'));
                                FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(user, fkiPwd, domain));
                            }
                            else
                            {
                                FKICredentialCache.Add(new System.Uri(fkiPath), "NTLM", new System.Net.NetworkCredential(fkiUser, fkiPwd));
                            }
                        }
                    }
                    catch { }
                    bNeedCheckEOA = true;
                }
            }
            catch { }
            #endregion

            #region Check Need Send OA3 or not
            try
            {

                IList<ConstValueInfo> cvInfo = new List<ConstValueInfo>();

                ConstValueInfo cvCond = new ConstValueInfo();
                cvCond.type = "CheckOA3State";
                cvCond.name = "OA3UpSAP";
                cvInfo = partRepository.GetConstValueInfoList(cvCond);
                if (cvInfo == null || cvInfo.Count == 0)
                {
                    bNeedCheckOA3 = true;
                }
                else
                {

                    bool findN = false;
                    foreach (ConstValueInfo tmp in cvInfo)
                    {
                        if (tmp.value.ToUpper() == "N")
                        {
                            findN = true;
                            bNeedCheckOA3 = false;
                            break;
                        }
                    }
                    if (findN == false)
                    {
                        bNeedCheckOA3 = true;
                    }
                }
            }
            catch { }
            #endregion

            try
            {
                               
                string tmpDn;
                ActivityCommonImpl utl = ActivityCommonImpl.Instance;
                IList<Regex> lstRegexTablet = utl.GetRegexByProcReg("Tablet");
                IList<Regex> lstRegexSKUorThinClient = utl.GetRegexByProcReg("SKU,ThinClient");

                foreach (UploadDNInfo sDnUdt in dns)
                {
                    tmpDn = sDnUdt.DeliveryNo;
                    IList<string> subRet = new List<string>();
                    int caseNoByDN = 2; //0 - case A; 1 - case B; 2 - case C

                    Delivery dlv = deliveryRepository.Find(tmpDn);
                    ////Check Udt..
                    //if (sDnUdt.Udt != dlv.Udt)
                    //{
                    //    throw new FisException("PAK173", new string[] { tmpDn });

                    //}
                    ////Check Udt..


                    //GetBom,与BOM相关的都尚未确定
                    IList<DNInfoForUI> dlvInfoList = deliveryRepository.GetDNInfoList(tmpDn);
                    string SW = "";
                    foreach (DNInfoForUI tmpInfo in dlvInfoList)
                    {
                        //SW:DeliveryInfo.InfoType=’PartNo’对应的InfoValue值,14位开始取7位
                        if (tmpInfo.InfoType.Equals("PartNo"))
                        {
                            //Add by Benson for Mantis0001733: UpLoad Shipment Data to SAP页面在save的时候报错提示不准确
                            string infoV = tmpInfo.InfoValue.Trim();
                            if (infoV.Length < 14 || string.IsNullOrEmpty(infoV.Substring(13, 7)))
                            { throw new FisException("PAK178", new string[] { tmpDn }); }
                            SW = tmpInfo.InfoValue.Substring(13, 7);

                            //SW = tmpInfo.InfoValue.Substring(13, 7);
                        }
                        if (tmpInfo.InfoType.Equals("Flag") && tmpInfo.InfoValue.Equals("N"))
                        {
                            caseNoByDN = 1;
                        }
                    }

                    IList<IProduct> proList = productRepository.GetProductListByDeliveryNo(tmpDn);
                    foreach (IProduct p in proList)
                    {
                        bool isTablet = utl.CheckModelByProcReg(p.Model, ref lstRegexTablet);
                        bool isSKUorThinClient = utl.CheckModelByProcReg(p.Model, ref lstRegexSKUorThinClient);

                        int caseNo = caseNoByDN;
                        IHierarchicalBOM bom = bomRep.GetHierarchicalBOMByModel(p.Model);
                        IList<IBOMNode> PLBomNodeList = bom.GetFirstLevelNodesByNodeType("PL");
                        foreach (IBOMNode bomNode in PLBomNodeList)
                        {
                            if (bomNode.Part.Descr == "ATT LABEL" || bomNode.Part.Descr == "VERIZON LABEL")
                            {
                                caseNo = 0;
                                break;
                            }
                        }

                        //string s = "";
                        UploadSAPSN sapSN = new UploadSAPSN();

                        #region get SN data
                        string palletNo = "";
                        string cartonNo = "";
                        //UC Exception 1
                        if (p.PalletNo.Equals(""))
                        {
                            throw new FisException("PAK111", new string[] { tmpDn });
                            //subRet.Clear();
                            //subRet.Add(tmpDn + " Pallet Qty is error!");
                            //break;
                        }
                        else
                        {
                            //PalletNo:若Product.PalletNo的前两位等于NA or BA时,PalletNo=’~’+Product.PalletNo从第3位开始取10位;否则PalletNo=Product.PalletNo+’~’
                            if (p.PalletNo.StartsWith("NA") || p.PalletNo.StartsWith("BA"))
                            {
                                //palletNo = "~" + p.PalletNo.Substring(2, 10);
                                cartonNo = p.PalletNo.Substring(2, 10);
                            }
                            else
                            {
                                //palletNo = p.PalletNo + "~";
                                palletNo = p.PalletNo;
                            }
                        }

                        if (isSKUorThinClient) // mantis 2061, Tablet機型不檢查 COA&OA3 狀態
                        {
                            if (!CheckCOACombine(bom, p, tmpDn))
                            {
                                //For Mantis0001733: UpLoad Shipment Data to SAP页面在save的时候报错提示不准确
                                throw new FisException("PAK179", new string[] { p.CUSTSN, tmpDn });
                                //throw new FisException("PAK158", new string[] { p.CUSTSN, tmpDn });
                            }
                            if (bNeedCheckOA3)
                            {
                                if (bNeedCheckEOA && !CheckOA3Key(bom, p, fkiPath, FKICredentialCache, editor, session.UnitOfWork))
                                {
                                    throw new FisException("PAK158", new string[] { p.CUSTSN, tmpDn });
                                }
                            }
                        }

                        string boxId = "";
                        string MEID = "";
                        string UUID = "";
                        string WM = "";
                        string IMEI = "";
                        string ICCID = "";

                        IList<IMES.FisObject.FA.Product.ProductInfo> pInfoList = new List<IMES.FisObject.FA.Product.ProductInfo>();
                        IProduct tmpPrd = productRepository.Find(p.ProId);
                        if (tmpPrd != null)
                        {
                            pInfoList = tmpPrd.ProductInfoes;
                        }

                        foreach (IMES.FisObject.FA.Product.ProductInfo tmpInfo in pInfoList)
                        {
                            //Boxid:ProductInfo里InfoType=BoxId或UCC对应的InfoValue
                            if (tmpInfo.InfoType.Equals("BoxId") || tmpInfo.InfoType.Equals("UCC"))
                            {
                                boxId = tmpInfo.InfoValue;
                                continue;
                            }

                            //MEID:ProductInfo.InfoValue where infoType=’MEID’ (情况B和情况C为空)
                            if (tmpInfo.InfoType.Equals("MEID"))
                            {
                                MEID = (caseNo == 0) ? tmpInfo.InfoValue : "";
                                continue;
                            }

                            //UUID:ProductInfo.InfoValue where infoType=’UUID’ (情况B和情况C为空)
                            if (tmpInfo.InfoType.Equals("UUID"))
                            {
                                UUID = (caseNo == 0) ? tmpInfo.InfoValue : "";
                                continue;
                            }

                            //WM:ProductInfo.InfoValue where infoType=’WM’ (情况B和情况C为空)
                            if (tmpInfo.InfoType.Equals("WM"))
                            {
                                WM = (caseNo == 0) ? tmpInfo.InfoValue : "";
                                continue;
                            }

                            //IMEI:ProductInfo.InfoValue where infoType=’IMEI’(情况B和情况C为空)
                            if (tmpInfo.InfoType.Equals("IMEI"))
                            {
                                IMEI = (caseNo == 0) ? tmpInfo.InfoValue : "";
                                continue;
                            }

                            //ICCID:ProductInfo.InfoValue where infoType=’ICCID’ (情况B和情况C为空)
                            if (tmpInfo.InfoType.Equals("ICCID"))
                            {
                                ICCID = (caseNo == 0) ? tmpInfo.InfoValue : "";
                                continue;
                            }
                        }

                        //Descr:不知道如何获取?? 暂时写””
                        string Descr = "";

                        //ODD:
                        string ODD = "";
                        //try
                        //{
                        ODD = GetODD(bom, tmpDn);
                        //}
                        //catch (FisException e)
                        //{
                        //subRet.Clear();
                        /*
                         * Answer to: ITC-1360-0910
                         * Description: Should use mErrmsg to get error msg of FisException.
                         */
                        //subRet.Add(e.mErrmsg);
                        //break;
                        //}

                        //Wireless and FCCID:
                        string Wireless = "";
                        string FCCID = "";
                        //try
                        //{
                        IList<string> wlAndFcc = GetWirelessAndFCCID(bom, p, tmpDn);
                        Wireless = wlAndFcc[0];
                        FCCID = wlAndFcc[1];
                        //}
                        //catch (FisException e)
                        //{
                        //subRet.Clear();
                        /*
                         * Answer to: ITC-1360-0903, ITC-1360-0913, ITC-1360-0914, ITC-1360-0916, ITC-1360-0922
                         * Description: Should use mErrmsg to get error msg of FisException.
                         */
                        //subRet.Add(e.mErrmsg);
                        //break;
                        //}

                        //ODD_Accession and ODD_Mftld
                        string ODD_Accession = "";
                        string ODD_Mftld = "";
                        //try
                        //{
                        IList<string> oddAccAndMft = GetODDAccessionAndMftId(p);
                        ODD_Accession = oddAccAndMft[0];
                        ODD_Mftld = oddAccAndMft[1];

                        //Add by Benson for fix Mantis 1543


                        foreach (IProductPart ele in p.ProductParts)
                        {
                            if (ele.CheckItemType == "ODD")
                            {
                                if (string.IsNullOrEmpty(ODD_Accession) || string.IsNullOrEmpty(ODD_Mftld) || string.IsNullOrEmpty(ODD))
                                {
                                    throw new FisException("PAK169", new string[] { tmpDn });

                                }

                            }
                        }




                        //Add by Benson for fix Mantis 1543

                        //}
                        //catch (FisException e)
                        //{
                        //subRet.Clear();
                        //subRet.Add(e.mErrmsg);
                        //break;
                        //}

                        //UC Exception 4 (deleted UC)
                        /*  Delete by kaisheng --2012/03/20:miniRun need --
                        if (ODD != "" && (ODD_Accession == "" || ODD_Mftld == ""))
                        {
                            subRet.Clear();
                            subRet.Add("ODD Accession No. or ManufactureId missing!!" + tmpDn);
                            break;
                        }
                        */
                        //AST:unit绑定的AST sn,IMES_FA.Product_Part.PartSn where BomNodeType=’AT’
                        string AST = "";
                        foreach (IProductPart ele in p.ProductParts)
                        {
                            if (ele.BomNodeType == "AT")
                            {
                                AST = ele.PartSn;
                                break;
                            }
                        }

                        //MFD:机器产生CustomerSN的时间,格式为YYYYMMDD。数据获取方法ProductLog.Cdt where Station=’58’(情况B为空)
                        string MFD = "";
                        if (caseNo != 1)
                        {
                            /*
                             * Answer to: ITC-1360-1449
                             * Description: Get logs by station.
                             */
                            IList<ProductLog> logs = productRepository.GetProductLogs(p.ProId, "58");
                            if (logs.Count > 0)
                            {
                                MFD = logs[0].Cdt.ToString("yyyyMMdd");
                            }
                        }
                        #endregion

                        sapSN.SERIALNUMBER = txId;
                        //s += dlv.DeliveryNo.Substring(0, 10);
                        sapSN.DN = dlv.DeliveryNo.Substring(0, 10);
                        //s += "~";
                        //s += dlv.DeliveryNo.Substring(dlv.DeliveryNo.Length - 6);
                        sapSN.DLV_ITM = dlv.DeliveryNo.Substring(dlv.DeliveryNo.Length - 6);
                        //s += "~";
                        //s += dlv.PoNo;
                        sapSN.PO_NO = dlv.PoNo;
                        //s += "~";
                        //s += palletNo;
                        sapSN.PALLET_NO = palletNo;

                        sapSN.CARTON_NO = cartonNo;
                        //s += "~";
                        //s += p.CUSTSN;
                        sapSN.SERNO = p.CUSTSN; 
                        //s += "~";
                        //s += boxId;
                        sapSN.BOX_ID = boxId;
                        //s += "~1~";
                        sapSN.QTY = "1";
                        // mantis 2061
                        //s += p.Model.StartsWith("PC") ? "C" : "O";
                        if (p.Model.Substring(1, 1) == "C")
                            //s += "C";
                            sapSN.TYPE = "C";
                        else
                            //s += "O";
                            sapSN.TYPE = "O";


                        //s += "~";
                        //s += Descr;
                        sapSN.PBOX_ID = Descr;
                        //s += "~";
                        //s += AST;  //10
                        sapSN.ASSET_NO = AST;
                        //s += "~";
                        //s += Wireless;
                        sapSN.WLMAT = Wireless;
                        //s += "~";
                        //s += ODD;
                        sapSN.ODMAT = ODD;
                        //s += "~";
                        //s += ODD_Accession;
                        sapSN.ACNUM = ODD_Accession;
                        //s += "~";
                        //s += ODD_Mftld;
                        sapSN.FDA = ODD_Mftld;
                        //s += "~";
                        //s += FCCID; //5
                        sapSN.FCCID = FCCID;
                        //s += "~~~";//2,7
                        //s += (caseNo == 0) ? p.MAC : ""; //9
                        sapSN.MACADDRESS = (caseNo == 0) ? p.MAC : "";
                        //s += "~~~~~";//4,13
                        //s += MEID;
                        sapSN.HEX_MEID = MEID;
                        //s += "~";
                        //s += MFD;//15
                        sapSN.MANUFACTURE_DATE = MFD;
                        //s += "~";
                        //s += UUID;
                        sapSN.UUID = UUID;
                        //s += "~";
                        //s += WM;
                        sapSN.MACADDRESS2 = WM;
                        //s += "~";
                        //s += IMEI;
                        sapSN.IMEI_CODE = IMEI;
                        //s += "~";
                        //s += (caseNo == 0) ? "1.0" : "";
                        sapSN.BUILDER_VER = (caseNo == 0) ? "1.0" : "";
                        //s += "~";
                        //s += (caseNo == 0) ? "EMBDSIM" : "";
                        sapSN.SIMLOCK_CODE = (caseNo == 0) ? "EMBDSIM" : "";
                        //s += "~";
                        //s += (caseNo == 0) ? SW : "";
                        sapSN.SOFTWARE_VER = (caseNo == 0) ? SW : "";
                        //s += "~";
                        //s += ICCID;
                        sapSN.ICCID = ICCID;
                        //s += "~";//8
                        //subRet.Add(s);
                        ret.Add(sapSN);
                    }
                    //foreach (string ele in subRet)
                    //{
                    //    ret.Add(ele);
                    //}
                }

                //   Check Udt again
                //foreach (UploadDNInfo dnUdt in dns)
                //{
                //    Delivery dnObj = deliveryRepository.Find(dnUdt.DeliveryNo);
                //    if (dnUdt.Udt != dnObj.Udt || (dnObj.Status != "98" && dnObj.Status != "88"))
                //    {
                //        throw new FisException("PAK173", new string[] { dnUdt.DeliveryNo });

                //    }
                //}

                //Check Udt again

                //uow.Commit();
                return ret;
            }
            catch (FisException e)
            {
                throw new Exception(e.mErrmsg);
            }

            catch (System.Net.WebException)
            {
                //throw new SystemException("無法連接HP OA3 Server,請聯繫測試PE處理");
                throw new FisException("CHK1119", new List<string> { "HP" });
            }

            catch (Exception e)
            {
                throw new SystemException(e.Message);
            }
            finally
            {

            }
        }