Ejemplo n.º 1
0
        public static void InsertAssetRange(string strConnect, string hpPo, string iecPo, AstRange astRange)
        {
           if ( astRange.State== SendBOMState.GetAstRangeOK)
           {
               string zeroFormat = "D" + astRange.AstDigitCount;
               astRange.StartAst = astRange.AstPreFix + long.Parse(astRange.StartAst).ToString(zeroFormat);
               astRange.EndAst = astRange.AstPreFix + long.Parse(astRange.EndAst).ToString(zeroFormat);

               SQLStatement.InsertAssetRange(strConnect, astRange.avPartNo, astRange.StartAst, astRange.EndAst, "PO:" + hpPo + "~IECPO:" + iecPo+ "~PostFix:" + astRange.AstPostFix, "UPS");
               if (!string.IsNullOrEmpty(astRange.AstPostFix))
               {
                   SQLStatement.InsertAssetRangePostFixed(strConnect, astRange.avPartNo,astRange.AstPostFix, "PO:" + hpPo +"~IECPO:" + iecPo, "UPS");
               }
            }
        }
Ejemplo n.º 2
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.º 3
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);
            }
        }