Exemplo n.º 1
0
        /// <summary>
        /// 1.檢查输入的Location位置是否是在数据库中存在,不存在则报错
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras">1個參數,WO保存的位置</param>
        public static void ReapirLocationDatachecker(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            OleExec       apdb         = null;
            List <string> LocationList = new List <string>();

            if (Paras.Count != 2)
            {
                throw new Exception("參數數量不正確!");
            }

            MESStationSession SNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (SNSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY }));
            }
            SN ObjSN = (SN)SNSession.Value;

            MESStationSession LocationSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (LocationSession == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            }
            string StrLocation = LocationSession.Value.ToString();

            //獲取ALLPART數據
            AP_DLL          APDLL = new AP_DLL();
            MESStationInput I     = Station.Inputs.Find(t => t.DisplayName == "Location");
            List <object>   ret   = I.DataForUse;

            ret.Clear();
            try
            {
                apdb         = Station.DBS["APDB"].Borrow();
                LocationList = APDLL.CheckLocationExist(ObjSN.SkuNo, StrLocation, apdb);
                if (LocationList.Count <= 0)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { StrLocation, ObjSN.SkuNo }));
                }
                else
                {
                    foreach (object item in LocationList)
                    {
                        ret.Add(item);
                    }
                }
                Station.DBS["APDB"].Return(apdb);
                Station.AddMessage("MES00000001", new string[] { }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Pass);
            }
            catch (Exception ex)
            {
                if (apdb != null)
                {
                    Station.DBS["APDB"].Return(apdb);
                }
                throw ex;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根據SN的SKUNO帶出維修LOCATION
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void LocationFromSNDataloader(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            List <string> LocationList = new List <string>();
            string        ErrMessage   = "";
            OleExec       apdb         = null;

            if (Paras.Count != 1)
            {
                string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000057");
                throw new MESReturnMessage(errMsg);
            }

            MESStationSession SNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (SNSession == null)
            {
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }
            SN ObjSn = (SN)SNSession.Value;

            //獲取ALLPART數據
            AP_DLL          APDLL = new AP_DLL();
            MESStationInput I     = Station.Inputs.Find(t => t.DisplayName == "Location");
            List <object>   ret   = I.DataForUse;

            ret.Clear();
            try
            {
                apdb = Station.APDB;

                LocationList = APDLL.GetLocationList(ObjSn.SkuNo, apdb);
                if (LocationList.Count <= 0)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { }));
                }
                else
                {
                    foreach (object item in LocationList)
                    {
                        ret.Add(item);
                    }
                }

                Station.AddMessage("MES00000001", new string[] { }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Pass);
            }
            catch (Exception ex)
            {
                if (apdb != null)
                {
                }
                throw ex;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 維修輸入加載TR_SN的DataRow對象,并把KP_NO,MFR_Name,Date_Code,Lot_Code到加載到對應輸入框的值
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void RepairTRSNObjDataLoader(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            if (Paras.Count != 1)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000057"));
            }
            string            inputValue  = Input.Value.ToString();
            MESStationSession sessionTRSN = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (sessionTRSN == null)
            {
                sessionTRSN = new MESStationSession()
                {
                    MESDataType = Paras[0].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[0].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(sessionTRSN);
            }
            try
            {
                AP_DLL         APDLL    = new AP_DLL();
                List <DataRow> TRSNlist = APDLL.R_TR_SN_GetBYTR_SN(inputValue, Station.APDB);
                if (TRSNlist.Count == 0)
                {
                    Station.Inputs.Find(input => input.DisplayName == "KP_NO").Value     = "";
                    Station.Inputs.Find(input => input.DisplayName == "MFR_Name").Value  = "";
                    Station.Inputs.Find(input => input.DisplayName == "Date_Code").Value = "";
                    Station.Inputs.Find(input => input.DisplayName == "Lot_Code").Value  = "";
                    Station.Inputs.Find(input => input.DisplayName == "TR_SN").Value     = "";
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { "TRSN:" + inputValue, "R_TR_SN" }));
                }
                else
                {
                    Station.Inputs.Find(input => input.DisplayName == "KP_NO").Value     = TRSNlist[0]["CUST_KP_NO"].ToString();
                    Station.Inputs.Find(input => input.DisplayName == "MFR_Name").Value  = TRSNlist[0]["MFR_KP_NO"].ToString();
                    Station.Inputs.Find(input => input.DisplayName == "Date_Code").Value = TRSNlist[0]["DATE_CODE"].ToString();
                    Station.Inputs.Find(input => input.DisplayName == "Lot_Code").Value  = TRSNlist[0]["Lot_Code"].ToString();
                    Dictionary <string, DataRow> TRSNInfo = new Dictionary <string, DataRow>();
                    TRSNInfo.Add("TR_SN", TRSNlist[0]);
                    sessionTRSN.Value      = TRSNlist[0];
                    sessionTRSN.InputValue = inputValue;
                    sessionTRSN.ResetInput = Input;
                    Station.NextInput      = Station.Inputs.Find(input => input.DisplayName == "Description");
                    Station.AddMessage("MES00000001", new string[] { inputValue }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Pass);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 加載SKU在Allpart的配置信息從Allpart系統加載mes1.c_product_config, mes4.r_pcba_link
        /// 將查詢到的結果存入Dictionary<string_Datarow> 中, key為表名如:" c_product_config "
        /// 2018/1/3 肖倫
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void SkuAPInfoDataloader(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            string  StrSku = "";
            string  StrVer = "";
            SKU     sku    = new SKU();
            OleExec apdb   = null;
            Dictionary <string, List <DataRow> > APInfo = new Dictionary <string, List <DataRow> >();

            if (Paras.Count != 2)
            {
                string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000057");
                throw new MESReturnMessage(errMsg);
            }
            MESStationSession APConfig_Session = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (APConfig_Session == null)
            {
                APConfig_Session = new MESStationSession()
                {
                    MESDataType = Paras[0].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[0].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(APConfig_Session);
            }

            MESStationSession Wo_Session = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (Wo_Session == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            }
            //Modify by LLF 2017-01-25 For 獲取工單對象,從工單對象中獲取料號,版本
            //MESStationSession Sku_Session = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);
            //if (Sku_Session == null)
            //{
            //    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            //}
            //else
            //{
            //    sku = (SKU)Sku_Session.Value;
            //    if (sku == null || sku.SkuNo == null || sku.SkuNo.Length <= 0)
            //    {
            //        throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY }));
            //    }
            //    if (sku.Version == null || sku.Version.Length <= 0)
            //    {
            //        throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY + " Version" }));
            //    }
            //}
            //獲取ALLPART數據
            try
            {
                StrSku = ((MESStation.LogicObject.WorkOrder)Wo_Session.Value).SkuNO;
                StrVer = ((MESStation.LogicObject.WorkOrder)Wo_Session.Value).SKU_VER;
                apdb   = Station.APDB;
                AP_DLL         APDLL      = new AP_DLL();
                List <DataRow> ConfigList = APDLL.C_Product_Config_GetBYSkuAndVerson(StrSku, StrVer, apdb);
                if (ConfigList.Count <= 0)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { "SKU:" + StrSku + ",VER:" + StrVer, "C_PRODUCT_CONFIG" }));
                }
                APInfo.Add("C_PRODUCT_CONFIG", ConfigList);
                List <DataRow> PCBALinkList = APDLL.R_PCBA_LINK_GetBYSku(StrSku, apdb);
                if (PCBALinkList.Count <= 0)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { "SKU:" + StrSku, "R_PCBA_LINK" }));
                }
                APInfo.Add("R_PCBA_LINK", PCBALinkList);
                APConfig_Session.Value = APInfo;

                Station.AddMessage("MES00000001", new string[] { StrSku }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Pass);
                //Modify By LLF 2018-01-25 For 料號&版本從工單對象中獲取,而不是從C_SKU 中獲取

                /* List<DataRow> ConfigList = APDLL.C_Product_Config_GetBYSkuAndVerson(sku.SkuNo, sku.Version, apdb);
                 * if (ConfigList.Count <= 0)
                 * {
                 * throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { "SKU:" + sku.SkuNo, "C_PRODUCT_CONFIG" }));
                 * }
                 * APInfo.Add("C_PRODUCT_CONFIG", ConfigList);
                 * List<DataRow> PCBALinkList = APDLL.R_PCBA_LINK_GetBYSku(sku.SkuNo, apdb);
                 * if (PCBALinkList.Count <= 0)
                 * {
                 *  throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { "SKU:" + sku.SkuNo, "R_PCBA_LINK" }));
                 * }
                 * APInfo.Add("R_PCBA_LINK", PCBALinkList);
                 * APConfig_Session.Value = APInfo;
                 * Station.DBS["APDB"].Return(apdb);
                 * Station.AddMessage("MES00000001", new string[] { sku.SkuNo }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Pass);
                 */
            }
            catch (Exception ex)
            {
                if (apdb != null)
                {
                }
                throw ex;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// TR_SN數據加載,查詢R_TR_SN,R_TR_SN_WIP的數據保存到Dictionary<string_Datarow>中,key為表名 "R_TR_SN","R_TR_SN_WIP"
        /// 2018/1/3 肖倫
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void TRSNDataloader(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            Dictionary <string, DataRow> APInfo = new Dictionary <string, DataRow>();
            string  strTRSN    = "";
            string  ErrMessage = "";
            OleExec apdb       = null;

            if (Paras.Count != 1)
            {
                string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000057");
                throw new MESReturnMessage(errMsg);
            }

            strTRSN = Input.Value.ToString();
            MESStationSession TRSN_Session = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (TRSN_Session == null)
            {
                TRSN_Session = new MESStationSession()
                {
                    MESDataType = Paras[0].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[0].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(TRSN_Session);
            }
            else
            {
                TRSN_Session.ResetInput = Input;
                TRSN_Session.InputValue = strTRSN;
            }

            //獲取ALLPART數據
            APInfo = new Dictionary <string, DataRow>();
            AP_DLL APDLL = new AP_DLL();

            try
            {
                apdb = Station.APDB;
                List <DataRow> TRSNlist = APDLL.R_TR_SN_GetBYTR_SN(strTRSN, apdb);
                if (TRSNlist.Count <= 0)
                {
                    //throw new Exception("TRSN:" + "不存在ALLPART系統R_TR_SN中");
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { "TRSN:" + strTRSN, "R_TR_SN" }));
                }
                else
                {
                    APInfo.Add("R_TR_SN", TRSNlist[0]);
                }
                List <DataRow> TRSNWIPlist = APDLL.R_TR_SN_WIP_GetBYTR_SN(strTRSN, apdb);
                if (TRSNWIPlist.Count <= 0)
                {
                    //throw new Exception("TRSN:" + "不存在ALLPART系統R_TR_SN_WIP中");
                    //throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000072", new string[] { "TRSN:" + strTRSN, "R_TR_SN_WIP" }));
                    APInfo.Add("R_TR_SN_WIP", null);
                }
                else
                {
                    APInfo.Add("R_TR_SN_WIP", TRSNWIPlist[0]);
                }
                TRSN_Session.Value = APInfo;

                Station.AddMessage("MES00000001", new string[] { TRSN_Session.Value.ToString() }, MESPubLab.MESStation.MESReturnView.Station.StationMessageState.Pass);
            }
            catch (Exception ex)
            {
                if (apdb != null)
                {
                }
                throw ex;
            }
        }
Exemplo n.º 6
0
        /// HWD PTH Allpart扣料,add by LLF 2018-02-19

        /// <summary>
        /// 更新TR_SN數據加載,查詢R_TR_SN,R_TR_SN_WIP的數據保存到Dictionary<string_Datarow>中,key為表名 "R_TR_SN","R_TR_SN_WIP"
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void TRSNDataSessionUpdateAction(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <MESDataObject.Module.R_Station_Action_Para> Paras)
        {
            Dictionary <string, DataRow> APInfo = new Dictionary <string, DataRow>();
            string  strTRSN    = "";
            string  ErrMessage = "";
            OleExec apdb       = null;
            int     LinkQty    = 0;
            int     TrSNExtQty = 0;

            if (Paras.Count < 0)
            {
                string errMsg = MESReturnMessage.GetMESReturnMessage("MES00000057");
                throw new MESReturnMessage(errMsg);
            }

            MESStationSession TRSN_Session = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (TRSN_Session == null)
            {
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }

            strTRSN = TRSN_Session.InputValue.ToString();

            MESStationSession TRSNExtQty_Session = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (TRSNExtQty_Session == null)
            {
                TRSNExtQty_Session = new MESStationSession()
                {
                    MESDataType = Paras[2].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[2].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(TRSNExtQty_Session);
                TRSNExtQty_Session.Value = 0;
            }

            MESStationSession TRSNPcbSku_Session = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (TRSNPcbSku_Session == null)
            {
                TRSNPcbSku_Session = new MESStationSession()
                {
                    MESDataType = Paras[1].SESSION_TYPE, InputValue = Input.Value.ToString(), SessionKey = Paras[1].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(TRSNPcbSku_Session);
                TRSNPcbSku_Session.Value = "";
            }

            MESStationSession LinkQty_Session = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);

            if (LinkQty_Session != null)
            {
                int.TryParse(LinkQty_Session.Value.ToString(), out LinkQty);
            }

            //獲取ALLPART數據
            AP_DLL APDLL = new AP_DLL();

            try
            {
                apdb = Station.APDB;

                List <DataRow> TRSNWIPlist = APDLL.R_TR_SN_WIP_GetBYTR_SN(strTRSN, apdb);
                if (TRSNWIPlist.Count > 0)
                {
                    TRSNExtQty_Session.Value = TRSNWIPlist[0]["EXT_QTY"];
                    TRSNPcbSku_Session.Value = TRSNWIPlist[0]["KP_NO"];
                }
                else
                {
                    TRSNExtQty_Session.Value = 0;
                }

                //Station.DBS["APDB"].Return(apdb);

                int.TryParse(TRSNExtQty_Session.Value.ToString(), out TrSNExtQty);
                if (TrSNExtQty < LinkQty)
                {
                    MESStationInput StationInput = Station.Inputs.Find(t => t.DisplayName == "TR_SN");
                    StationInput.Enable = true;
                    Station.NextInput   = StationInput;
                }
            }
            catch (Exception ex)
            {
                if (apdb != null)
                {
                    //Station.DBS["APDB"].Return(apdb);
                }
                throw ex;
            }
        }
Exemplo n.º 7
0
        public static void HWDBIPSNFailAction(MESStation.BaseClass.MESStationBase Station, MESStation.BaseClass.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            string     ErrMessage  = "";
            string     StrSn       = "";
            string     APVirtualSn = "";
            string     VirtualSn   = "";
            AP_DLL     APObj       = new AP_DLL();
            OleExec    APDB        = null;
            R_PANEL_SN PANELObj    = null;
            Int16      FailCount   = 0;
            List <Dictionary <string, string> > FailList = null;
            string        R_SN_STATION_DETAIL_ID         = "";
            StringBuilder ReturnMessage = new StringBuilder();
            string        RepairmainID  = "";//add by LLF 2018-04-12

            if (Paras.Count < 5)
            {
                throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000050"));
            }

            MESStationSession SNSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (SNSession == null)
            {
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE + Paras[0].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }

            MESStationSession FailCountSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (FailCountSession == null)
            {
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE + Paras[1].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }

            MESStationSession FailListSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY);

            if (FailListSession == null)
            {
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[2].SESSION_TYPE + Paras[2].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }

            MESStationSession PanelVitualSNSession = Station.StationSession.Find(t => t.MESDataType == Paras[3].SESSION_TYPE && t.SessionKey == Paras[3].SESSION_KEY);

            if (PanelVitualSNSession == null)
            {
                ErrMessage = MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[3].SESSION_TYPE + Paras[3].SESSION_KEY });
                throw new MESReturnMessage(ErrMessage);
            }

            MESStationSession StatusSession = Station.StationSession.Find(t => t.MESDataType == Paras[4].SESSION_TYPE && t.SessionKey == Paras[4].SESSION_KEY);

            if (StatusSession == null)
            {
                StatusSession = new MESStationSession()
                {
                    MESDataType = Paras[4].SESSION_TYPE, InputValue = Input.Value.ToString(), Value = Paras[4].VALUE, SessionKey = Paras[4].SESSION_KEY, ResetInput = Input
                };
                Station.StationSession.Add(StatusSession);
                if (StatusSession.Value.ToString() == "")
                {
                    StatusSession.Value = "FAIL";
                }
            }

            MESStationSession ClearInputSession = null;

            if (Paras.Count >= 6)
            {
                ClearInputSession = Station.StationSession.Find(t => t.MESDataType.Equals(Paras[5].SESSION_TYPE) && t.SessionKey.Equals(Paras[5].SESSION_KEY));
                if (ClearInputSession == null)
                {
                    ClearInputSession = new MESStationSession()
                    {
                        MESDataType = Paras[5].SESSION_TYPE, SessionKey = Paras[5].SESSION_KEY
                    };
                    Station.StationSession.Add(ClearInputSession);
                }
            }

            FailCount = Convert.ToInt16(FailCountSession.Value.ToString());
            FailList  = (List <Dictionary <string, string> >)FailListSession.Value;

            T_R_SN   rSn      = new T_R_SN(Station.SFCDB, DB_TYPE_ENUM.Oracle);
            DateTime FailTime = rSn.GetDBDateTime(Station.SFCDB);

            StrSn = SNSession.Value.ToString();
            if (FailList.Count >= FailCount && FailCount != 0) //允許掃描多個Fail
            {
                #region 業務邏輯

                OleExec oleDB = null;
                oleDB = Station.SFCDB;
                //oleDB = this.DBPools["SFCDB"].Borrow();
                //oleDB.BeginTrain();
                //OleExecPool APDBPool = Station.DBS["APDB"];
                //APDB = APDBPool.Borrow();
                //APDB.BeginTrain();
                APDB = Station.APDB;
                try
                {
                    Row_R_SN rrSn = (Row_R_SN)rSn.NewRow();
                    for (int i = 0; i < FailList.Count; i++)
                    {
                        //獲取頁面傳過來的數據
                        string failCode        = FailList[i]["FailCode"].ToString();
                        string failLocation    = FailList[i]["FailLocation"].ToString();
                        string failProcess     = FailList[i]["FailProcess"].ToString();
                        string failDescription = FailList[i]["FailDesc"].ToString();



                        //黃楊盛 2018年4月24日14:14:28 模擬自動做維修的動作,修正時間
                        //更新R_SN REPAIR_FAILED_FLAG=’1’
                        //modify by ZGJ 2018-03-22 BIP Fail 的產品自動清除待維修狀態,但是記錄不良

                        PANELObj = (R_PANEL_SN)PanelVitualSNSession.Value;
                        if (i == 0)
                        {
                            VirtualSn = PANELObj.SN.ToString();
                            R_SN r = rSn.GetDetailBySN(VirtualSn, Station.SFCDB);
                            rrSn = (Row_R_SN)rSn.GetObjByID(r.ID, Station.SFCDB);
                            //rrSn.REPAIR_FAILED_FLAG = "0";
                            rrSn.REPAIR_FAILED_FLAG = "1";
                            rrSn.SN        = StrSn;
                            rrSn.EDIT_EMP  = Station.LoginUser.EMP_NO; //add by LLF 2018-03-17
                            rrSn.EDIT_TIME = FailTime;                 //add by LLF 2018-03-17
                            string strRet = (Station.SFCDB).ExecSQL(rrSn.GetUpdateString(DB_TYPE_ENUM.Oracle));
                            if (!(Convert.ToInt32(strRet) > 0))
                            {
                                throw new MESReturnMessage("update repair failed flag error!");
                            }

                            // Update R_PANEL_SN
                            T_R_PANEL_SN   RPanelSN  = new T_R_PANEL_SN(Station.SFCDB, DB_TYPE_ENUM.Oracle);
                            Row_R_PANEL_SN Row_Panel = (Row_R_PANEL_SN)RPanelSN.NewRow();
                            Row_Panel    = (Row_R_PANEL_SN)RPanelSN.GetObjByID(PANELObj.ID, Station.SFCDB);
                            Row_Panel.SN = StrSn;
                            strRet       = (Station.SFCDB).ExecSQL(Row_Panel.GetUpdateString(DB_TYPE_ENUM.Oracle));
                            if (!(Convert.ToInt32(strRet) > 0))
                            {
                                throw new MESReturnMessage("update r_panel_sn error!");
                            }

                            //Update AP

                            //黄杨盛 2018年4月14日09:10:50 修正不能超过9连板的情况.同时加上不支持3位数连板的约束
                            //APVirtualSn = PANELObj.PANEL + "0" + PANELObj.SEQ_NO.ToString();
                            if (PANELObj.SEQ_NO > 99)
                            {
                                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000226",
                                                                                                new string[] { DB_TYPE_ENUM.Oracle.ToString() }));
                            }
                            APVirtualSn = PANELObj.PANEL + Convert.ToInt16(PANELObj.SEQ_NO).ToString("00");


                            string result = APObj.APUpdatePanlSN(APVirtualSn, StrSn, APDB);
                            //APDBPool.Return(APDB);
                            if (!result.Equals("OK"))
                            {
                                //2018年4月24日13:56:14 黃楊盛
                                //throw new MESReturnMessage("already be binded to other serial number");
                                throw new MESReturnMessage(result);
                            }


                            //新增一筆FAIL記錄到R_SN_STATION_DETAIL
                            T_R_SN_STATION_DETAIL rSnStationDetail =
                                new T_R_SN_STATION_DETAIL(Station.SFCDB, DB_TYPE_ENUM.Oracle);
                            //Add by LLF 2018-03-19
                            R_SN_STATION_DETAIL_ID = rSnStationDetail.GetNewID(Station.BU, Station.SFCDB);
                            //string detailResult = rSnStationDetail.AddDetailToRSnStationDetail(R_SN_STATION_DETAIL_ID,rrSn.GetDataObject(), Station.Line, Station.StationName, Station.StationName, Station.SFCDB);
                            string detailResult = rSnStationDetail.AddDetailToBipStationFailDetail(
                                R_SN_STATION_DETAIL_ID, rrSn.GetDataObject(), Station.Line, Station.StationName,
                                Station.StationName, Station.SFCDB, "1");
                            if (!(Convert.ToInt32(detailResult) > 0))
                            {
                                throw new MESReturnMessage("Insert sn station detail error!");
                            }

                            //update R_SN_STATION_DETAIL
                            rSnStationDetail.UpdateRSnStationDetailBySNID(StrSn, PANELObj.SN, Station.SFCDB);

                            //新增一筆到R_REPAIR_MAIN
                            T_R_REPAIR_MAIN   tRepairMain = new T_R_REPAIR_MAIN(Station.SFCDB, DB_TYPE_ENUM.Oracle);
                            Row_R_REPAIR_MAIN rRepairMain = (Row_R_REPAIR_MAIN)tRepairMain.NewRow();

                            RepairmainID = tRepairMain.GetNewID(Station.BU, Station.SFCDB);
                            //rRepairMain.ID = tRepairMain.GetNewID(Station.BU, Station.SFCDB);
                            rRepairMain.ID           = RepairmainID;
                            rRepairMain.SN           = StrSn;
                            rRepairMain.WORKORDERNO  = rrSn.WORKORDERNO;
                            rRepairMain.SKUNO        = rrSn.SKUNO;
                            rRepairMain.FAIL_LINE    = Station.Line;
                            rRepairMain.FAIL_STATION = Station.StationName;
                            rRepairMain.FAIL_EMP     = Station.LoginUser.EMP_NO;
                            //rRepairMain.FAIL_TIME = Station.GetDBDateTime();//Modify by LLF 2018-03-17
                            rRepairMain.FAIL_TIME   = FailTime; //Modify by LLF 2018-03-17
                            rRepairMain.EDIT_EMP    = Station.LoginUser.EMP_NO;
                            rRepairMain.EDIT_TIME   = Station.GetDBDateTime();
                            rRepairMain.CLOSED_FLAG = "1";
                            string insertResult =
                                (Station.SFCDB).ExecSQL(rRepairMain.GetInsertString(DB_TYPE_ENUM.Oracle));
                            if (!(Convert.ToInt32(insertResult) > 0))
                            {
                                throw new Exception("Insert repair main error!");
                            }
                        }

                        //新增一筆到R_REPAIR_FAILCODE
                        T_R_REPAIR_FAILCODE tRepairFailCode =
                            new T_R_REPAIR_FAILCODE(Station.SFCDB, DB_TYPE_ENUM.Oracle);
                        Row_R_REPAIR_FAILCODE rRepairFailCode = (Row_R_REPAIR_FAILCODE)tRepairFailCode.NewRow();
                        rRepairFailCode.ID = tRepairFailCode.GetNewID(Station.BU, Station.SFCDB);
                        //rRepairFailCode.REPAIR_MAIN_ID = rRepairMain.ID; //Modify by LLF 2018-04-11 多筆FAIL 取1一個RepairMainID
                        rRepairFailCode.REPAIR_MAIN_ID = RepairmainID;
                        rRepairFailCode.SN             = StrSn;
                        rRepairFailCode.FAIL_CODE      = failCode;
                        rRepairFailCode.FAIL_EMP       = Station.LoginUser.EMP_NO;
                        rRepairFailCode.FAIL_TIME      = FailTime;
                        rRepairFailCode.FAIL_CATEGORY  = "SYMPTOM";
                        rRepairFailCode.FAIL_LOCATION  = failLocation;
                        rRepairFailCode.FAIL_PROCESS   = failProcess;
                        rRepairFailCode.DESCRIPTION    = failDescription;
                        rRepairFailCode.REPAIR_FLAG    = "1";
                        rRepairFailCode.EDIT_EMP       = Station.LoginUser.EMP_NO;
                        rRepairFailCode.EDIT_TIME      = Station.GetDBDateTime();

                        string strResult =
                            (Station.SFCDB).ExecSQL(rRepairFailCode.GetInsertString(DB_TYPE_ENUM.Oracle));
                        if (!(Convert.ToInt32(strResult) > 0))
                        {
                            throw new MESReturnMessage("Insert repair failcode error!");
                        }


                        //oleDB.CommitTrain();

                        ReturnMessage.Append(failDescription).Append("|");
                    }


                    //黃楊盛 2018年4月24日14:11:42 做一筆出來的記錄
                    R_SN snOut = rSn.GetDetailBySN(StrSn, Station.SFCDB);
                    rrSn = (Row_R_SN)rSn.GetObjByID(snOut.ID, Station.SFCDB);
                    rrSn.CURRENT_STATION    = rrSn.NEXT_STATION;
                    rrSn.NEXT_STATION       = rSn.GetNextStation(snOut.ROUTE_ID, snOut.NEXT_STATION, oleDB);
                    rrSn.REPAIR_FAILED_FLAG = "0";
                    rrSn.SN        = StrSn;
                    rrSn.EDIT_EMP  = Station.LoginUser.EMP_NO;
                    rrSn.EDIT_TIME = FailTime;
                    var count = (Station.SFCDB).ExecSQL(rrSn.GetUpdateString(DB_TYPE_ENUM.Oracle));
                    if (!(Convert.ToInt32(count) > 0))
                    {
                        throw new MESReturnMessage("update rsn failed flag error!");
                    }

                    // 方國剛 2018.05.02 11:45:30
                    // 因拋賬計算過站數量時,不計算REPAIR_FAILED_FLAG=1的數量,故BIP Fail 的產品自動清除待維修狀態后再在過站記錄表記錄一筆REPAIR_FAILED_FLAG=0的記錄
                    T_R_SN_STATION_DETAIL rSnStationDetailRepaired = new T_R_SN_STATION_DETAIL(Station.SFCDB, DB_TYPE_ENUM.Oracle);
                    R_SN_STATION_DETAIL_ID = rSnStationDetailRepaired.GetNewID(Station.BU, Station.SFCDB);
                    string detailResultRepaired = rSnStationDetailRepaired.AddDetailToBipStationFailDetail(
                        R_SN_STATION_DETAIL_ID, rrSn.GetDataObject(), Station.Line, Station.StationName,
                        Station.StationName, Station.SFCDB, "0");
                    if (!(Convert.ToInt32(detailResultRepaired) > 0))
                    {
                        throw new MESReturnMessage("Insert sn station detail error!");
                    }
                }
                catch (Exception e)
                {
                    try
                    {
                        //APDB.RollbackTrain();
                        //oleDB.RollbackTrain();
                    }
                    catch (Exception x)
                    {
                        ;
                    }

                    throw new MESReturnMessage(e.Message + e.StackTrace);
                }
                finally
                {
                    //APDBPool.Return(APDB);
                }



                #endregion
                //add by zgj 2018-03-14
                //當記錄完當前 SN 不良後,清除保存在 session 中的不良信息
                //((List<Dictionary<string, string>>)FailListSession.Value).Clear();

                if (ClearInputSession != null)
                {
                    ClearInputSession.Value = "true";
                }

                ReturnMessage.Remove(ReturnMessage.Length - 1, 1);
                Station.NextInput = Station.FindInputByName("PanelSn");
                Station.AddMessage("MES00000158", new string[] { StrSn, ReturnMessage.ToString() }, MESReturnView.Station.StationMessageState.Pass);
            }
            else
            {
                Station.NextInput = Station.FindInputByName("Location");
                Station.AddMessage("MES00000162", new string[] { StrSn, FailCount.ToString(), FailList.Count.ToString() }, MESReturnView.Station.StationMessageState.Message);
            }
        }