예제 #1
0
        private bool GetMainAssySubAssyPCBInfo(string TRID, string MainAssyType, string SubAssy, out PCBAInfo tmpPCBAInfo, out string ErrorMessage)
        {
            bool   CheckFlag        = true;
            string ApolloEngineTRID = "";

            ErrorMessage = "";
            tmpPCBAInfo  = new PCBAInfo();


            if (GetEngineTRID(TRID, MainAssyType, out ApolloEngineTRID, out ErrorMessage) == false)
            {
                CheckFlag = false;
                return(CheckFlag);
            }

            if (GetMainAssyPCBAInfo(ApolloEngineTRID, SubAssy, out tmpPCBAInfo, out ErrorMessage) == false)
            {
                CheckFlag = false;
                return(CheckFlag);
            }

            return(CheckFlag);
        }
예제 #2
0
        private bool GetMainAssyPCBAInfo(string TRID, string MainAssyType, out PCBAInfo tmpPCBAInfo, out string ErrorMessage)
        {
            bool CheckFlag = true;

            ErrorMessage = "";
            tmpPCBAInfo  = new PCBAInfo();

            using (SqlConnection cn = new SqlConnection())
            {
                cn.ConnectionString = "server=" + dbHost + ";uid=" + dbUser + ";pwd=" + dbPass + ";database=" + dbName;
                try
                {
                    cn.Open();
                }
                catch (SqlException ex)
                {
                    ErrorMessage = ex.Message;
                    CheckFlag    = false;
                    return(CheckFlag);
                }

                if (cn.State == ConnectionState.Open)
                {
                    string SQL = "select top 1  M.RCARD TRID,M.EATTRIBUTE1 KeyPartType,M.MCARD KeyPartSn,U.Testitem TestItem,U.Measurevalue MeasureValue,U.datein Date,U.timein Time ";
                    SQL = SQL + "from  pics.dbo.HCS_UsbTestRecode U join pics.dbo.keymapping K on K.Mainkey = U.Testitem ";
                    SQL = SQL + "join(select * from openquery(qtymes,'";
                    SQL = SQL + "select * from (";
                    SQL = SQL + "select RCARD,MCARD,EATTRIBUTE1 from tblonwipitem ";
                    SQL = SQL + "where RCARD=''" + TRID + "'' and EATTRIBUTE1=''" + MainAssyType + "''";
                    SQL = SQL + "order by mdate desc,mtime desc) where rownum=''1''')";
                    SQL = SQL + ")M on K.Mappingkey = M.EATTRIBUTE1 ";
                    SQL = SQL + "where U.trid ='" + TRID + "' and M.EATTRIBUTE1 = '" + MainAssyType + "'";
                    SQL = SQL + "order by U.datein desc,U.timein desc";

                    SqlCommand cmd = new SqlCommand(SQL, cn);
                    //cmd.Parameters.AddWithValue("@TRID", TRID);
                    //cmd.Parameters.AddWithValue("@MainAssyType", MainAssyType);

                    Console.WriteLine(cmd.CommandText);

                    SqlDataReader dr = cmd.ExecuteReader();
                    try
                    {
                        if (dr.Read() == true)
                        {
                            if (!dr.Equals(DBNull.Value))
                            {
                                tmpPCBAInfo.KeypartType  = dr["KeyPartType"].ToString().Trim();
                                tmpPCBAInfo.KeypartSn    = dr["KeyPartSn"].ToString().Trim();
                                tmpPCBAInfo.TestItem     = dr["TestItem"].ToString().Trim();
                                tmpPCBAInfo.MeasureValue = dr["MeasureValue"].ToString().Trim();
                                CheckFlag = true;
                            }
                        }
                        else
                        {
                            tmpPCBAInfo.KeypartType = MainAssyType;


                            ErrorMessage = "查無此TRID : " + TRID + "資料!!!\n" + "KeyPartType : " + MainAssyType + "資料!!! \n 缺少對應資料(pics.dbo.keymapping)";
                            CheckFlag    = false;
                        }
                    }
                    catch
                    {
                        ErrorMessage = "資料庫查詢錯誤!!!! \n SQL : " + SQL;
                        CheckFlag    = false;
                    }
                    finally
                    {
                        dr.Close();
                    }
                }
                else
                {
                    ErrorMessage = "資料庫連接錯誤!!!!(GetMainAssyPCBAInfo)";
                    CheckFlag    = false;
                }
            }
            return(CheckFlag);
        }
예제 #3
0
        public bool GetPCBAIDandSN(string ApolloTRID, ref List <PCBAInfo> PCBAInfoList, string ApplicationPath, out string ErrorMessage)
        {
            bool CheckFlag = true;

            ErrorMessage = "";
            PCBAInfoList.Clear();
            FindInfoList.Clear();

            string SQL          = "";
            string ReadFindInfo = "";


            ProductInfo tmpParoduct = new ProductInfo(ApolloTRID);

            if (CheckTRID(ApolloTRID, ref tmpParoduct, out ErrorMessage) == false)
            {
                ErrorMessage = ErrorMessage + "\n 故無法取得PCBA資料!!!";
                return(false);
            }

            if (File.Exists(ApplicationPath) == false)
            {
                ErrorMessage = "外部檔不存在!!!\n路徑 : " + ApplicationPath;
                CheckFlag    = false;
                return(CheckFlag);
            }

            ReadFindInfo = Ini.IniReadValue("BoardIDGet", tmpParoduct.PartNo.ToUpper(), ApplicationPath);

            if (ReadFindInfo == "")
            {
                ErrorMessage = "外部檔 : " + ApplicationPath + "\n Section: [BoardIDGet]  \n Key : " + tmpParoduct.PartNo.ToUpper() + "\n 內容為空!!!";
                CheckFlag    = false;
                return(CheckFlag);
            }

            string[] tmpSplit = new string[] { "," };
            string[] tmp      = ReadFindInfo.Split(tmpSplit, StringSplitOptions.RemoveEmptyEntries);

            string[] SubtmpSplit = new string[] { "#" };

            //將外部檔設定解碼看物件需要搜索幾層
            for (int i = 0; i < tmp.Count(); i++)
            {
                string[] Subtmp = tmp[i].Split(SubtmpSplit, StringSplitOptions.RemoveEmptyEntries);

                FindPCBAInfo tmpFindInfo = new FindPCBAInfo();

                if (Subtmp.Count() == 2)
                {
                    tmpFindInfo.MainAssy = Subtmp[0];
                    tmpFindInfo.SubAssy  = Subtmp[1];

                    FindInfoList.Add(tmpFindInfo);

                    PCBAInfo tmpPCBAInfo = new PCBAInfo();

                    if (GetMainAssySubAssyPCBInfo(ApolloTRID, tmpFindInfo.MainAssy, tmpFindInfo.SubAssy, out tmpPCBAInfo, out ErrorMessage) == false)
                    {
                        CheckFlag = false;
                        return(CheckFlag);
                    }
                    PCBAInfoList.Add(tmpPCBAInfo);
                }
                else
                {
                    tmpFindInfo.MainAssy = Subtmp[0];
                    tmpFindInfo.SubAssy  = "";
                    FindInfoList.Add(tmpFindInfo);

                    PCBAInfo tmpPCBAInfo = new PCBAInfo();

                    if (GetMainAssyPCBAInfo(ApolloTRID, tmpFindInfo.MainAssy, out tmpPCBAInfo, out ErrorMessage) == false)
                    {
                        CheckFlag = false;
                        return(CheckFlag);
                    }

                    PCBAInfoList.Add(tmpPCBAInfo);
                }
            }

            GC.Collect();
            return(CheckFlag);
        }