Ejemplo n.º 1
0
        public static BomStatus RequestUPSSendBOM(UPSPOBOM po,List<string> avPartList)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}()", methodName);
            try
            {
                UPSPrimaryServiceSoapClient soapClient = new UPSPrimaryServiceSoapClient("UPS");
                string txnId = DateTime.Now.ToString("yyyyMMddhhmmss.fff");
                string bom = "";
                
                foreach (string av in avPartList)
                {
                    bom = bom + string.Format("<BomItem><PartNumber>{0}</PartNumber></BomItem>", av);
                }           
                
                bom =string.Format("<BOM>{0}</BOM>",bom);
                logger.InfoFormat("UPSSendBOM txnId:{0} HPPO:{1} CustPO:{2} IECPO:{3} Qty:{4} Bom:{5}", 
                                                txnId, po.HPPO, po.CustPO,po.IECPO??"",  po.Qty.ToString(), bom);
                return   soapClient.UPSSendBOM(txnId, po.HPPO, po.CustPO, po.Qty, bom);               
                
            }
            catch (Exception e)
            {
                logger.Error(methodName, e);
                throw e;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }

        }
Ejemplo n.º 2
0
        private static List<UPSPOBOM> ReadFile(string file, AppConfig config, List<string> supportAVList)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            logger.InfoFormat("BEGIN: {0}()", methodName);

            List<UPSPOBOM> ret = new List<UPSPOBOM>();
            try
            {
                string[] data = File.ReadAllLines(file);
                foreach (string s in data)
                {
                    try
                    {

                        string[] column = s.Split(new char[] { '~' });
                        if (column.Length < 10)
                        {
                            throw new Exception(string.Format("字串格式錯誤 '~' 字元只有幾:{0}", column.Length));
                        }

                        UPSPOBOM item = new UPSPOBOM();
                        item.Plant = column[0].Trim();
                        item.POType = column[1].Trim();
                        item.HPPO = column[2].Trim();
                        item.CustPO = column[3].Trim();
                        item.IECPO = column[4].Trim();
                        item.CustPOItem = column[5].Trim();
                        item.HPSku = column[6].Trim();
                        item.IECSku = column[7].Trim();
                        item.Qty = (int)double.Parse(column[8].Trim());

                        string avStr = column[9].Trim();
                        if (!string.IsNullOrEmpty(avStr))
                        {
                            IList<string> partList = avStr.Split(new char[] { ',' }).Select(x => x.Trim()).ToList();

                            item.PartNoList = partList.Where(x => supportAVList.Contains(x)).ToList();
                        }
                        ret.Add(item);                      

                    }
                    catch (Exception e)
                    {
                        logger.Info("Raw data =>" + s);
                        logger.Error(methodName, e);
                        throw e;
                    }
                }

                return ret;
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                logger.InfoFormat("END: {0}()", methodName);
            }
        }
Ejemplo n.º 3
0
        public static void SendVerifyPOStatus(AppConfig config, UPSPOBOM poBom)
        {
            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}()", methodName);
            try
            {
                logger.InfoFormat("Start UPSVerifyPOReady PO:{0}", poBom.HPPO);

                //6.UPSVerifyPO
                BomStatus validatePoStatus = UPSWS.RequestUPSVerifyPOReady(poBom);
                UPSWS.ValidatePoStatus(validatePoStatus, poBom, config);

                if (poBom.State == SendBOMState.VerifyOK)
                {
                    //verify ok;
                }
                else
                {
                    logger.ErrorFormat("Start UPSVerifyPOReady PO:{0} State:{1} !!", poBom.HPPO, poBom.State.ToString());
                }
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }  
        }
Ejemplo n.º 4
0
        public static void SendOSIStatus(AppConfig config, UPSPOBOM poBom)
        {
            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}()", methodName);
            try
            {
                 logger.InfoFormat("Start UPSSendOSI PO:{0}", poBom.HPPO);
                 //5.UPSSendOSI 
                string osiSpec =UPSWS.ValidateGetOSIStatus(UPSWS.RequestUPSVerifyPOReady(poBom), poBom);
                if (poBom.State == SendBOMState.GetOSIOK)
                {
                    if (string.IsNullOrEmpty(osiSpec))
                    {
                        poBom.State = SendBOMState.SendOSIOK;
                    }
                    else
                    {
                        //產生OSI String ??????
                        //HP說目前OS只有CustomerPO欄位
                        //string osiString = "<CustomerPO>{0}</CustomerPO>";
                        //osiString = string.Format(osiString, poBom.CustPO);
                        string osiString = UPSWS.GenOSIString(poBom, osiSpec, config);
                        UPSWS.ValidateSendOSIStatus(UPSWS.RequestUPSSendOSI(poBom, osiString), poBom);
                    }
                }

                if (poBom.State == SendBOMState.SendBOMOK ||             
                    poBom.State == SendBOMState.SendOSIOK)
                {
                    //6.UPSVerifyPO
                    BomStatus validatePoStatus = UPSWS.RequestUPSVerifyPOReady(poBom);
                    //7.UPSGetRange
                    UPSWS.ValidatePoStatus(validatePoStatus, poBom, config);               
                    if (poBom.State == SendBOMState.VerifyOK)
                    {
                        //verify ok;
                    }
                    else
                    {
                        logger.ErrorFormat("Start UPSVerifyPOReady PO:{0} State:{1} !!", poBom.HPPO, poBom.State.ToString());
                    }
                }
                else   // Send email notify 
                {
                    logger.ErrorFormat("Start SendBOM PO:{0} State:{1} !!", poBom.HPPO, poBom.State.ToString());
                }          
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            } 
        }
Ejemplo n.º 5
0
        public static void SendCreatePOStatus(AppConfig config, UPSPOBOM poBom)
        {
            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}()", methodName);
            try
            {
                logger.InfoFormat("Start SendBOM PO:{0} CustomPO:{1}", poBom.HPPO, poBom.CustPO);
                //5.UPSSendBOM/UPSSendOSI
                BomStatus SendBomstatus = UPSWS.RequestUPSSendBOM(poBom, poBom.PartNoList);
                UPSWS.ValidateSendBomStatus(SendBomstatus, poBom, config);
               
                if (poBom.State == SendBOMState.SendBOMHolding)
                {
                    logger.InfoFormat("Start SendBOM PO:{0} Waiting {1} seconds ...", poBom.HPPO, config.DelayVerifyPo.ToString());
                    return;
                }

                if (poBom.State == SendBOMState.SendBOMOK ||
                    poBom.State == SendBOMState.SendBOMHolding ||
                    poBom.State == SendBOMState.SendOSIOK)
                {
                    //6.UPSVerifyPO
                    BomStatus validatePoStatus = UPSWS.RequestUPSVerifyPOReady(poBom);
                    //7.UPSGetRange
                    UPSWS.ValidatePoStatus(validatePoStatus, poBom, config);                   
                    if (poBom.State == SendBOMState.VerifyOK)
                    {
                        //verify ok;
                    }
                    else
                    {
                        logger.ErrorFormat("Start UPSVerifyPOReady PO:{0} State:{1} !!", poBom.HPPO, poBom.State.ToString());
                    }
                }
                else   // Send email notify 
                {
                    logger.ErrorFormat("Start SendBOM PO:{0} State:{1} !!", poBom.HPPO, poBom.State.ToString());
                }

            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }         
        }
Ejemplo n.º 6
0
        public static UPSPOBOM GenUPSPoBom(HPPO po)
        {
            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}()", methodName);
            try
            {
                UPSPOBOM poBom = new UPSPOBOM
                {
                    CustPO = po.PO.EndCustomerPO,
                    HPPO = po.PO.HPPO,
                    Qty = po.PO.Qty,
                    HPSku = po.PO.HPSKU,
                    Plant = po.PO.Plant,
                    POType = po.PO.POType,
                    State = (SendBOMState)Enum.Parse(typeof(SendBOMState), po.PO.Status, true),
                    PartNoList = po.PartNoList.Select(x => x.AVPartNo).ToList()
                };

                if (po.isWithdraw)
                {
                    poBom.Qty = po.PO.WithdrawQty;
                    poBom.PartNoList = po.WithdrawPartNoList.Select(x=>x.AVPartNo).ToList();
                }
                return poBom;
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                throw;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }
        }
Ejemplo n.º 7
0
        public static void UpdateUPSModel(AppConfig config,
                                                                UPSDatabase db,
                                                                HPPO dbPo,
                                                                 UPSPOBOM poBom,
                                                                 string editor)
        {

            DateTime now = DateTime.Now;
            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}()", methodName);
            try
            {
                if (db.Connection.State == System.Data.ConnectionState.Closed)
                {
                    db.Connection.Open();
                }
               db.Transaction = db.Connection.BeginTransaction();
               dbPo.IECPOList.ForEach(n =>
                    {
                        n.Udt = now;
                        var upsModel = db.UPSModelEntity.Where(x => x.Model == n.Model).FirstOrDefault();
                        if (upsModel == null)
                        {
                            upsModel = new UPSModel
                            {
                                Model = n.Model,
                                FirstReceiveDate = dbPo.PO.ReceiveDate,
                                LastReceiveDate = dbPo.PO.ReceiveDate,
                                Remark = "NEW",
                                Status = EnumUPSModelStatus.Enable.ToString(),
                                Editor = dbPo.PO.Editor,
                                Cdt = now,
                                Udt = now
                            };
                            db.UPSModelEntity.InsertOnSubmit(upsModel);
                            db.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
                        }
                        //else
                        //{
                        //    upsModel.LastReceiveDate = dbPo.PO.ReceiveDate;
                        //    upsModel.Udt = now;
                        //}
                    });
                

                db.Transaction.Commit();
                //db.Connection.Close();
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                if (db.Transaction != null && db.Transaction.Connection != null)
                {
                    db.Transaction.Rollback();
                }
                throw;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }
        }
Ejemplo n.º 8
0
        public static void UpdateUPSHPPO(AppConfig config, 
                                                                UPSDatabase db, 
                                                                HPPO dbPo, 
                                                                 UPSPOBOM poBom, 
                                                                 string editor)
        {
            DateTime now = DateTime.Now;
            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}()", methodName);
            try
            {
                //UPSDatabase db = new UPSDatabase(config.DBConnectStr);

                if (db.Connection.State == System.Data.ConnectionState.Closed)
                {
                    db.Connection.Open();
                }
                
                db.Transaction = db.Connection.BeginTransaction();

                if (dbPo.PO.Status != poBom.State.ToString())
                {
                    dbPo.PO.Status = poBom.State.ToString();
                    dbPo.PO.ErrorText = poBom.ErrorText;
                    dbPo.PO.Udt = now;
                    //db.UPSHPPOEntity.Attach(dbPo.PO, true);
                }

                if (poBom.State == SendBOMState.VerifyOK)
                {
                    //產生UPSCombinePO
                    List<UPSCombinePO> UPSCombinePOList = new List<UPSCombinePO>();
                    List<UPSIECPO> IECPOList = null;
                    if (dbPo.isWithdraw)
                    {
                        IECPOList = dbPo.WithdrawIECPOList;
                        foreach (UPSIECPO iecpo in dbPo.IECPOList)
                        {
                            if (iecpo.Editor == "Withdraw")
                            {
                                iecpo.Editor = "UPS-" + iecpo.Editor;
                                iecpo.Udt = now;
                            }
                        }

                        foreach (UPSPOAVPart avpart in dbPo.PartNoList)
                        {
                            if (avpart.Editor == "Withdraw")
                            {
                                avpart.Editor = "UPS-" + avpart.Editor;
                                avpart.Udt = now;
                            }
                        }
                    }
                    else
                    {
                        IECPOList = dbPo.IECPOList;
                    }

                    IECPOList.ForEach(n =>
                    {
                        //n.Status = SendBOMState.VerifyOK.ToString();
                        n.Udt = now;
                        var upsModel = db.UPSModelEntity.Where(x => x.Model == n.Model).FirstOrDefault();
                        if (upsModel == null)
                        {
                            upsModel = new UPSModel
                            {
                                Model = n.Model,
                                FirstReceiveDate = dbPo.PO.ReceiveDate,
                                LastReceiveDate = dbPo.PO.ReceiveDate,
                                Remark = string.Empty,
                                Status = EnumUPSModelStatus.Enable.ToString(),
                                Editor = dbPo.PO.Editor,
                                Cdt = now,
                                Udt = now
                            };
                            db.UPSModelEntity.InsertOnSubmit(upsModel);
                        }
                        else
                        {
                            upsModel.LastReceiveDate = dbPo.PO.ReceiveDate;
                            upsModel.Udt = now;
                        }

                        int qty = n.Qty;
                        for (int i = 0; i < qty; i++)
                        {
                            UPSCombinePO combinePO = new UPSCombinePO
                            {
                                HPPO = dbPo.PO.HPPO,
                                IECPO = n.IECPO,
                                IECPOItem = n.IECPOItem,
                                Model = n.Model,
                                ReceiveDate = dbPo.PO.ReceiveDate,
                                ProductID = string.Empty,
                                CUSTSN = string.Empty,
                                Station = string.Empty,
                                IsShipPO = "N",
                                Status = EnumCombinePoState.Free.ToString(),
                                Remark = string.Empty,
                                Editor = editor,
                                Cdt = now,
                                Udt = now
                            };
                            UPSCombinePOList.Add(combinePO);
                        }
                    });

                    DataTableHelper.BulkCopyToDatabase(UPSCombinePOList,
                                                                                "UPSCombinePO",
                                                                                (SqlConnection)db.Connection,
                                                                                (SqlTransaction)db.Transaction);
                }
               
                db.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
                
                db.Transaction.Commit();
                // db.Connection.Close();
            }
            catch (Exception e)
            {
                logger.Error(e.Message, e);
                if (db.Transaction != null && db.Transaction.Connection != null)
                {
                    db.Transaction.Rollback();
                }
                
                throw;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }
        }
Ejemplo n.º 9
0
        public static string GenOSIString(UPSPOBOM poBOM, string osiSpec, AppConfig config)
        {
            string osiString = "";
            string osiFormat = "<{0}>{1}</{0}>";
            int index = 0;
            string methodName = MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}()", methodName);
            try
            {
                logger.InfoFormat("UPS OSI Spec:{0}, Config OSI Tag Name:{1} Config OSI Map Value:{2}",
                                            osiSpec, 
                                            string.Join (",",config.OSITagName),
                                            string.Join(",",config.OSITagNameMapValue));
                foreach (string name in config.OSITagName)
                {
                    if (!string.IsNullOrEmpty(name) && osiSpec.Contains(name))
                    {
                        string value="";
                        if (config.OSITagNameMapValue.Length > index)
                        {
                            if (config.OSITagNameMapValue[index].ToLower() == "customerpo")
                            {
                                value = poBOM.CustPO;
                            }
                            else
                            {
                                value = config.OSITagNameMapValue[index];
                            }
                        }
                        osiString = osiString + string.Format(osiFormat, name, value);

                    }

                    index++;
                }
                logger.InfoFormat("OSI String:{0}", osiString);
                return osiString;
            }
            catch (Exception e)
            {
                logger.Error(methodName, e);
                throw e;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }
        }
Ejemplo n.º 10
0
 public static void patchRangeError(string strConnect,
                                                       UPSPOBOM poBom,
                                                       string avPartNo,
                                                       string startAst,
                                                      string endAst,
                                                     string mask)
 {
     string pattern = @"^(?<prefix>\w*)%(?<digit>\d+)d(?<postfix>\w*)$";
     Match m = Regex.Match(mask, pattern);
     if (m.Success)
     {
         AstRange astRange = new AstRange();
         astRange.avPartNo = avPartNo;
         astRange.AstDigitCount = m.Groups["digit"].Value.Trim();
         astRange.AstPostFix = m.Groups["postfix"].Value.Trim();
         astRange.AstPreFix = m.Groups["prefix"].Value.Trim();
         astRange.StartAst = startAst;
         astRange.EndAst = endAst;
         astRange.State = SendBOMState.GetAstRangeOK;
         logger.InfoFormat("Ast Range prefix:{0} digit:{1} postfix:{2}", astRange.AstPreFix, astRange.AstDigitCount, astRange.AstPostFix);
         InsertAssetRange(strConnect, poBom.HPPO, poBom.IECPO, astRange);
     }
 }
Ejemplo n.º 11
0
        public static void ValidateAstRangeStatus(string strConnect, ATRPStruct status, UPSPOBOM poBom,string avPartNo)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            string msgFormat="HPPO:{0} AV:{1} Ast Range RangeStart:{2} RangeEnd:{3} Mask:{4} Error:{5}";
            logger.DebugFormat("BEGIN: {0}()", methodName);
            logger.InfoFormat("HPPO:{0} AV:{1} Reply ValidateAstRangeStatus Return Code:{2} Version:{3} Message:{4} tagdata:{5}",
                                                  poBom.HPPO, avPartNo, status.retcode, status.version, status.message, status.tagdata.GetXml());
            try
            {
                
                if (status.retcode == 0) //Holding process need waiting time
                {
                    //poBom.State = SendBOMState.GetAstRangeOK;
                    if (status.tagdata.Tables[0].Rows.Count > 0)
                    {
                        DataRow dr = status.tagdata.Tables[0].Rows[0];
                        string startAst = dr["RangeStart"].ToString();
                        string endAst = dr["RangeEnd"].ToString();
                        string mask = dr["Mask"].ToString();
                        logger.InfoFormat(msgFormat, poBom.HPPO, avPartNo, startAst, endAst, mask, "");

                        string pattern = @"^(?<prefix>\w*)%(?<digit>\d+)d(?<postfix>\w*)$";
                        Match m = Regex.Match(mask, pattern);
                        if (m.Success)
                        {
                            AstRange astRange = new AstRange();
                            astRange.avPartNo = avPartNo;
                            astRange.AstDigitCount = m.Groups["digit"].Value.Trim();
                            astRange.AstPostFix = m.Groups["postfix"].Value.Trim();
                            astRange.AstPreFix = m.Groups["prefix"].Value.Trim();
                            astRange.StartAst = startAst;
                            astRange.EndAst = endAst;
                            astRange.State = SendBOMState.GetAstRangeOK;
                            logger.InfoFormat("HPPO:{0} IECPO:{1} AV:{2} Ast Range prefix:{3} digit:{4} postfix:{5}",
                                                          poBom.HPPO, poBom.IECPO, avPartNo, astRange.AstPreFix, astRange.AstDigitCount, astRange.AstPostFix);
                            poBom.AstRangeList.Add(astRange);
                            InsertAssetRange(strConnect, poBom.HPPO,  poBom.IECPO,  astRange);
                        }
                        else
                        {
                            AstRange astRange = new AstRange();
                            astRange.avPartNo = avPartNo;
                            astRange.State = SendBOMState.GetAstRangeResultFail;
                            astRange.ErrorText = string.Format(msgFormat, poBom.HPPO, avPartNo, startAst, endAst, mask, "Mask Pattern is wrong");
                            poBom.AstRangeList.Add(astRange);
                            logger.ErrorFormat(msgFormat, poBom.HPPO, avPartNo, startAst, endAst, mask, "Mask Pattern is wrong");
                        }
                    }
                    else  // No Asset Range data
                    {
                        AstRange astRange = new AstRange();
                        astRange.avPartNo = avPartNo;
                        astRange.State = SendBOMState.NoAstRange;
                        astRange.ErrorText = string.Format("HPPO:{0} AV:{1} Reply ValidateAstRangeStatus (No Asset Range) Return Code:{2} Version:{3} Message:{4}",
                                                                                 poBom.HPPO, avPartNo, status.retcode, status.version, status.message);
                        logger.ErrorFormat("HPPO:{0} AV:{1} Reply ValidateAstRangeStatus (No Asset Range) Return Code:{2} Version:{3} Message:{4}",
                                                   poBom.HPPO, avPartNo, status.retcode, status.version, status.message); 
                    }
                }
                else
                {
                    logger.ErrorFormat("HPPO:{0} AV:{1} Reply ValidateAstRangeStatus Fail Return Code:{2} Version:{3} Message:{4}",
                                                  poBom.HPPO, avPartNo,status.retcode, status.version, status.message);
                    AstRange astRange = new AstRange();
                    astRange.avPartNo = avPartNo;
                    astRange.State = SendBOMState.GetAstRangeFail;
                    astRange.ErrorText = string.Format("HPPO:{0} AV:{1}  Reply ValidateAstRangeStatus  Fail Return Code:{2} Version:{3} Message:{4}",
                                                                             poBom.HPPO, avPartNo, status.retcode, status.version, status.message);
                    poBom.AstRangeList.Add(astRange);
                }
            }
            catch (Exception e)
            {
                logger.Error(methodName, e);
                throw e;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }
        }
Ejemplo n.º 12
0
        public static void ValidatePoStatus(BomStatus status, UPSPOBOM poBom, AppConfig config)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}()", methodName);
            try
            {
                logger.InfoFormat("Reply ValidatePoStatus retCode:{0} message:{1} datastring:{2}", status.retcode.ToString(), status.message, status.datastring);
                if (status.retcode == 0) //Holding process need waiting time
                {                    
                     poBom.State = SendBOMState.VerifyOK;                 
                }
                else if (status.retcode == 1) //need send OSI
                {
                    if (!string.IsNullOrEmpty(status.datastring))
                    {
                        poBom.State = SendBOMState.NeedSendOSI;


                        //產生OSI String ??????
                        //HP說目前OS只有CustomerPO欄位
                        //string osiString = "<CustomerPO>{0}</CustomerPO>";
                        //osiString = string.Format(osiString, poBom.CustPO);
                        string osiString = GenOSIString(poBom, status.datastring, config);

                        ValidateSendOSIStatus(RequestUPSSendOSI(poBom, osiString), poBom);
                        if (poBom.State == SendBOMState.SendOSIOK)
                        {
                            //6.UPSVerifyPO
                            BomStatus validatePoStatus = UPSWS.RequestUPSVerifyPOReady(poBom);
                            //7.UPSGetRange
                            UPSWS.ValidatePoStatus(validatePoStatus, poBom, config);
                        }
                    }
                    else
                    {
                        poBom.State = SendBOMState.VerifyFail;
                         poBom.ErrorText = string.Format("Return Code:{0} DataString:{1} Message:{2}", status.retcode, status.datastring, status.message);
                    }
                }
                else
                {
                    poBom.State = SendBOMState.VerifyFail;
                    poBom.ErrorText = string.Format("Return Code:{0} DataString:{1} Message:{2}", status.retcode, status.datastring, status.message);

                }
            }
            catch (Exception e)
            {
                logger.Error(methodName, e);
                throw e;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }
        }
Ejemplo n.º 13
0
 public static void ValidateSendOSIStatus(BomStatus status, UPSPOBOM poBom)
 {
     string methodName = MethodBase.GetCurrentMethod().Name;
     logger.DebugFormat("BEGIN: {0}()", methodName);
     try
     {
         logger.InfoFormat("Reply SendOSIStatus retCode:{0} message:{1} datastring:{2}", status.retcode.ToString(), status.message, status.datastring);
         if (status.retcode == 0) //Holding process need waiting time
         {
             
              poBom.State = SendBOMState.SendOSIOK;
           
         }               
         else
         {
            poBom.State = SendBOMState.SendOSIFail;
            poBom.ErrorText = string.Format("Return Code:{0} DataString:{1} Message:{2}", status.retcode, status.datastring, status.message);
          }
     }
     catch (Exception e)
     {
         logger.Error(methodName, e);
         throw e;
     }
     finally
     {
         logger.DebugFormat("END: {0}()", methodName);
     }
 }
Ejemplo n.º 14
0
        public static void ValidateSendBomStatus(BomStatus status, UPSPOBOM poBom, AppConfig config)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}()", methodName);
            try
            {
                logger.InfoFormat("Reply SendBomStatus PO:{0} retCode:{1} message:{2} datastring:{3}", poBom.HPPO, status.retcode.ToString(), status.message, status.datastring);
                if (status.retcode == 0) //Holding process need waiting time
                {
                    poBom.State = SendBOMState.SendBOMHolding;
                    
                }
                else if (status.retcode == 1) // Send OSI 
                {
                    
                    poBom.State = SendBOMState.NeedSendOSI;
                  

                    //產生OSI String ??????
                    //HP說目前OS只有CustomerPO欄位
                    //string osiString = "<CustomerPO>{0}</CustomerPO>";
                    //osiString = string.Format(osiString, poBom.CustPO);
                   string osiString = GenOSIString(poBom, status.datastring, config);

                    ValidateSendOSIStatus(RequestUPSSendOSI(poBom, osiString), poBom);
                }
                else if (status.retcode == 2)
                {                  
                   poBom.State = SendBOMState.SendBOMOK;                  
                }
                else if (status.retcode == 4)
                {                    
                    poBom.State = SendBOMState.SendBOMUnSupportedAV;
                    poBom.ErrorText = string.Format("Reply SendBomStatus  PO:{0} Code:{1} DataString:{2} Message:{3}", poBom.HPPO, status.retcode, status.datastring, status.message);
                }
                else if (status.retcode == 3)
                {
                    poBom.State = SendBOMState.AlreadySendBOM;
                    poBom.ErrorText = string.Format("Reply SendBomStatus PO:{0} Code:{1} DataString:{2} Message:{3}", poBom.HPPO, status.retcode, status.datastring, status.message);
                }
                else
                {
                    poBom.State = SendBOMState.SendBOMFail;
                    poBom.ErrorText = string.Format("Reply SendBomStatus  PO:{0} Code:{1} DataString:{2} Message:{3}", poBom.HPPO, status.retcode, status.datastring, status.message);
                }
            }
            catch (Exception e)
            {
                logger.Error(methodName, e);
                throw e;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }
        }
Ejemplo n.º 15
0
        public static BomStatus RequestUPSGetOSI(UPSPOBOM po)
        {
            string methodName = MethodBase.GetCurrentMethod().Name;
            logger.DebugFormat("BEGIN: {0}()", methodName);
            List<string> ret = new List<string>();
            try
            {

                UPSPrimaryServiceSoapClient soapClient = new UPSPrimaryServiceSoapClient("UPS");
                string txnId = DateTime.Now.ToString("yyyyMMddhhmmss.fff");
                logger.InfoFormat("UPSGetOSI HPPO:{0}", po.HPPO);
                return soapClient.UPSGetOSI(po.HPPO);


            }
            catch (Exception e)
            {
                logger.Error(methodName, e);
                throw e;
            }
            finally
            {
                logger.DebugFormat("END: {0}()", methodName);
            }
        }