// 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); }
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); }