Ejemplo n.º 1
0
        //        public override bool Connect()
        //        {

        //            SqlConnection Con;
        //            string adoCon;
        //            string adoConEncrypted;
        //            string sql;
        //            string site;


        //            try
        //            {
        //#if SAVE_AdoCon_In_AppSettings
        //                site = ConfigurationManager.AppSettings["Site"];
        //                //MessageBox.Show(site);
        //                adoConEncrypted = ConfigurationManager.AppSettings["AdoCon"]
        //#else
        //                site = CyBLE_MTK_Application.Properties.Settings.Default.Site;
        //                adoConEncrypted = CyBLE_MTK_Application.Properties.Settings.Default.AdoCon;
        //#endif
        //                adoCon = StrOperator.Decrypt(adoConEncrypted);
        //                //MessageBox.Show(adoCon);
        //                Con = new SqlConnection(adoCon);
        //                Con.Open();



        //                Con.Close();
        //                SqlConnected = true;
        //            }
        //            catch (Exception ex)
        //            {
        //                SqlConnected = false;
        //                LastError = "Failed to connect log server. (" + ex.Message + ")";
        //                MessageBox.Show(LastError, "Shopfloor error");
        //            }

        //            return SqlConnected;
        //        }

        public override bool Connect()
        {
            Fittec.MesInterface mesInterface = new Fittec.MesInterface();
            SqlConnected = false;
            int res = -1;

            try
            {
                res = mesInterface.MESProcessCheck("123456789");
                if (res == 404)
                {
                    MessageBox.Show(string.Format("{0}: Failed to connect log server (Err: {1}) Due to MES System Connection Loss. 请联系工程师检查MES数据库以及网络是否正常工作!", this.GetType().ToString().Substring(22), res), "MES系统连接异常");
                    Log.PrintLog(this, string.Format(string.Format("{0}: Failed to connect log server (Err: {1}) Due to MES System Connection Loss.", this.GetType().ToString().Substring(22), res)), LogDetailLevel.LogRelevant);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}: Failed to connect log server (Err: {1}) Due to {2}", this.GetType().ToString().Substring(22), res, ex.Message), "MES系统连接异常");
                Log.PrintLog(this, string.Format(string.Format("{0}: Failed to connect log server (Err: {1}) Due to {2}", this.GetType().ToString().Substring(22), res, ex.Message)), LogDetailLevel.LogRelevant);
                return(false);
            }

            Log.PrintLog(this, string.Format(string.Format("{0}: Success to connect log server.", this.GetType().ToString().Substring(22))), LogDetailLevel.LogRelevant);

            SqlConnected = true;
            return(true);
        }
Ejemplo n.º 2
0
        public override string PermissonCheck(string SerialNumber, string Model, string WorkerID, string Station)
        {
            string retMsg = "";

            Fittec.MesInterface mesInterface = new Fittec.MesInterface();
            int res = mesInterface.MESProcessCheck(SerialNumber);

            if (res == 0)
            {
                retMsg = string.Format("MESProcessCheck: {0} PASS ({1})", SerialNumber, res.ToString("D4"));
            }
            else if (res == 1)
            {
                retMsg = string.Format("MESProcessCheck: {0} IGNORE ({1})", SerialNumber, res.ToString("D4"));
            }
            else if (res == 404)
            {
                retMsg = string.Format("MESProcessCheck: {0} FAIL ({1}) DUE TO MES Connection Unreachable", SerialNumber, res.ToString("D4"));
            }
            else if (res == 9100)
            {
                retMsg = string.Format("MESProcessCheck: {0} FAIL ({1}) DUE TO Barcode is invalid", SerialNumber, res.ToString("D4"));
            }
            else if (res == 9101)
            {
                retMsg = string.Format("MESProcessCheck: {0} FAIL ({1}) DUE TO Process Station is incorrect", SerialNumber, res.ToString("D4"));
            }
            else if (res == 9102)
            {
                retMsg = string.Format("MESProcessCheck: {0} FAIL ({1}) DUE TO MES STOP", SerialNumber, res.ToString("D4"));
            }
            else if (res == 9103)
            {
                retMsg = string.Format("MESProcessCheck: {0} FAIL ({1}) DUE TO MES LOCK", SerialNumber, res.ToString("D4"));
            }
            else
            {
                retMsg = string.Format("MESProcessCheck: {0} FAIL ({1}) DUE TO MES Unknown Error Code", SerialNumber, res.ToString("D4"));
            }


            return(retMsg);
        }
Ejemplo n.º 3
0
        //        public override bool UploadTestResult(string SerialNumber, string Model, string TesterID, UInt16 errorcode, string SocketId, string TestResult, string TestStation, string MFI_ID
        //)
        //        {
        //            SqlConnection Con;
        //            string adoCon;
        //            string adoConEncrypted;
        //            string sql;
        //            string site;
        //            int IntErrorCdoe = errorcode;

        //            SocketId = SocketId + "Socket#";

        //            if (!IsValidSerialNumber("UploadTestResult " + GetType().ToString(), SerialNumber))
        //            {
        //                return false;
        //            }

        //            try
        //            {
        //#if SAVE_AdoCon_In_AppSettings
        //                site = ConfigurationManager.AppSettings["Site"];
        //                //MessageBox.Show(site);
        //                adoConEncrypted = ConfigurationManager.AppSettings["AdoCon"]
        //#else
        //                site = CyBLE_MTK_Application.Properties.Settings.Default.Site;
        //                adoConEncrypted = CyBLE_MTK_Application.Properties.Settings.Default.AdoCon;
        //#endif
        //                adoCon = StrOperator.Decrypt(adoConEncrypted);
        //                //MessageBox.Show(adoCon);
        //                Con = new SqlConnection(adoCon);
        //                Con.Open();

        //                sql = "INSERT INTO if_check(if_site,if_barcode,if_result,if_mfi_id) VALUES (@Site,@BarCode,@Result,@MFiID)";

        //                SqlCommand sqlCmd = new SqlCommand(sql, Con);
        //                sqlCmd.Parameters.AddWithValue("@Site", site);
        //                sqlCmd.Parameters.AddWithValue("@BarCode", SerialNumber);
        //                sqlCmd.Parameters.AddWithValue("@Result", IntErrorCdoe);
        //                sqlCmd.Parameters.AddWithValue("@MFiID", MFI_ID);
        //                sqlCmd.ExecuteNonQuery();
        //                Con.Close();
        //                return true;
        //            }
        //            catch (Exception ex)
        //            {
        //                LastError = "Failed to connect log server. (" + ex.Message + ")";
        //                MessageBox.Show(LastError, "Shopfloor error");
        //            }

        //            return false;
        //        }

        public override bool UploadTestResult(string SerialNumber, string Model, string TesterID, UInt16 errorcode, string SocketId, string TestResult, string TestStation, string MFI_ID
                                              )
        {
            int res = -1;

            try
            {
                Fittec.InterfaceParam interfaceParam = new InterfaceParam();
                Fittec.MesInterface   mesInterface   = new Fittec.MesInterface();


                interfaceParam.BatchTestRunCycleTime = double.Parse(CyBLE_MTK.TestProgramRunCycleTimeForBatch);
                interfaceParam.SerialNumber          = SerialNumber;
                interfaceParam.ModelName             = Model;
                interfaceParam.MTK_App           = Assembly.GetExecutingAssembly().GetName().Name.ToString() + " v" + Assembly.GetExecutingAssembly().GetName().Version.ToString();
                interfaceParam.OverallTestResult = TestResult;
                interfaceParam.TestErrorCode     = errorcode.ToString("X4");
                interfaceParam.TestSocketNo      = int.Parse(SocketId);
                interfaceParam.TestXMLFileName   = CyBLE_MTK.CurrentTestXMLFile;
                interfaceParam.SFCS_Entity       = this.GetType().Name;
                interfaceParam.Remarks           = "";
                interfaceParam.MFi_ID            = "";

                //Log.PrintLog(this, String.Format(this.GetType().Name + " MES Interface {0}: UploadTestResult ==>DUT#({5}) SN: {1}   Model: {2}   OverallTestResult: {3}   ErrorCode: {4}",
                //    mesInterface.MyVersion(), interfaceParam.SerialNumber, interfaceParam.ModelName, interfaceParam.OverallTestResult, interfaceParam.TestErrorCode, interfaceParam.TestSocketNo
                //    ), LogDetailLevel.LogRelevant);

                try
                {
                    res = mesInterface.MESDataUpload(interfaceParam);
                }
                catch (Exception ex)
                {
                    Log.PrintLog(this, String.Format(this.GetType().Name + " MESDataUpload Error: UploadTestResult ==>DUT#({0}) SN: {1} Failure due to {2}",
                                                     SocketId.ToString(), SerialNumber, ex.Message
                                                     ), LogDetailLevel.LogRelevant);
                }


                if (res == 0)
                {
                    Log.PrintLog(this, String.Format("MES Interface (ver: {0}): UploadTestResult (Successful:{6}) ==>DUT#({5}) SN: {1}   Model: {2}   OverallTestResult: {3}   ErrorCode: {4}.",
                                                     mesInterface.MyVersion(), interfaceParam.SerialNumber, interfaceParam.ModelName, interfaceParam.OverallTestResult, interfaceParam.TestErrorCode, interfaceParam.TestSocketNo, res
                                                     ), LogDetailLevel.LogRelevant);
                }
                else if (res == 404)
                {
                    Log.PrintLog(this, String.Format("MES Interface (ver: {0}): UploadTestResult (Failure:{6}) ==>DUT#({5}) SN: {1}   Model: {2}   OverallTestResult: {3}   ErrorCode: {4}.",
                                                     mesInterface.MyVersion(), interfaceParam.SerialNumber, interfaceParam.ModelName, interfaceParam.OverallTestResult, interfaceParam.TestErrorCode, interfaceParam.TestSocketNo, res
                                                     ), LogDetailLevel.LogRelevant);

                    MessageBox.Show(String.Format("MES Interface (ver: {0}): UploadTestResult (Failure:{6}) ==>DUT#({5}) SN: {1}   Model: {2}   OverallTestResult: {3}   ErrorCode: {4}. 该条测试记录上传MES失败,请停止测试,联系工程师检查系统工作状态!",
                                                  mesInterface.MyVersion(), interfaceParam.SerialNumber, interfaceParam.ModelName, interfaceParam.OverallTestResult, interfaceParam.TestErrorCode, interfaceParam.TestSocketNo, res
                                                  ), "MESUploadResult Error");
                }
                else
                {
                    Log.PrintLog(this, String.Format("MES Interface (ver: {0}): UploadTestResult (Failure:{6}) ==>DUT#({5}) SN: {1}   Model: {2}   OverallTestResult: {3}   ErrorCode: {4}.",
                                                     mesInterface.MyVersion(), interfaceParam.SerialNumber, interfaceParam.ModelName, interfaceParam.OverallTestResult, interfaceParam.TestErrorCode, interfaceParam.TestSocketNo, res
                                                     ), LogDetailLevel.LogRelevant);
                }
            }
            catch (Exception ex)
            {
                Log.PrintLog(this, String.Format("MES Interface: UploadTestResult ==>DUT#({0}) SN: {1} Failure due to {2}",
                                                 SocketId.ToString(), SerialNumber, ex.Message
                                                 ), LogDetailLevel.LogRelevant);

                MessageBox.Show(String.Format("MES Interface: UploadTestResult ==>DUT#({0}) SN: {1} Failure due to {2} 该条测试记录上传MES失败,请停止测试,联系工程师检查系统工作状态!",
                                              SocketId.ToString(), SerialNumber, ex.Message), "MESUploadResult Error");
            }



            return(false);
        }