public MESServiceRes GetTestDataFromMES(string SN)
        {
            //DataCheck;
            //Sql注入;
            OleExec DB = new OleExec("VERTIVTESTDB", true);

            T_R_TEST_DETAIL_VERTIV rTestDetailVertivControl = new T_R_TEST_DETAIL_VERTIV(DB, DB_TYPE_ENUM.Oracle);
            DataTable dt = new DataTable();

            try
            {
                dt = rTestDetailVertivControl.GetDTRTestDetailVertivBySn(DB, SN);
                string resDtjson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, Newtonsoft.Json.Formatting.Indented, new Newtonsoft.Json.Converters.IsoDateTimeConverter {
                    DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
                });
                if (dt.Rows.Count > 0)
                {
                    resObj.Statusvalue = (int)StatusValue.success;
                    resObj.MessageCode = "";
                    resObj.Message     = resDtjson;
                }
                else
                {
                    resObj.Statusvalue = (int)StatusValue.fail;
                    resObj.MessageCode = "MES00005";
                    resObj.Message     = "No Data!";
                }
            }
            catch (Exception e)
            {
                resObj.Statusvalue = (int)StatusValue.fail;
                resObj.MessageCode = "MES00004";
                resObj.Message     = "查询错误:" + e.ToString();
            }
            return(resObj);
        }
        public MESServiceRes TestDataUploadMES(string SN, string MODEL, string TESTTIME, string STATE, string STATION,
                                               string CELL, string OPERATOR, string ERROR_CODE)
        {
            //Sql注入;
            TestRecordData testRecord = new TestRecordData();

            #region DataCheck;

            try
            {
                testRecord = TestDataUploadMES_CheckInputData(SN, MODEL, TESTTIME, STATE, STATION, CELL, OPERATOR,
                                                              ERROR_CODE);
            }
            catch (Exception e)
            {
                resObj.Statusvalue = (int)StatusValue.fail;
                resObj.MessageCode = "MES00001";
                resObj.Message     = "输入参数错误:" + e.ToString();
                return(resObj);
            }

            #endregion

            OleExec DB = new OleExec("VERTIVTESTDB", true);
            T_C_TEMES_STATION_MAPPING cTeMesStationMappingControl = new T_C_TEMES_STATION_MAPPING(DB,
                                                                                                  DB_TYPE_ENUM.Oracle);
            T_R_TEST_RECORD        rTestRecordControl       = new T_R_TEST_RECORD(DB, DB_TYPE_ENUM.Oracle);
            T_R_TEST_DETAIL_VERTIV rTestDetailVertivControl = new T_R_TEST_DETAIL_VERTIV(DB, DB_TYPE_ENUM.Oracle);
            T_R_SN rSnControl = new T_R_SN(DB, DB_TYPE_ENUM.Oracle);

            Row_R_TEST_RECORD        rowRTestRecord       = (Row_R_TEST_RECORD)rTestRecordControl.NewRow();
            Row_R_TEST_DETAIL_VERTIV rowRTestDetailVertiv = (Row_R_TEST_DETAIL_VERTIV)rTestDetailVertivControl.NewRow();
            try
            {
                C_TEMES_STATION_MAPPING cTeMesStationMapping = cTeMesStationMappingControl.GetTeMesStationMapping(DB,
                                                                                                                  STATION, "A");
                if (cTeMesStationMapping == null)
                {
                    resObj.Statusvalue = (int)StatusValue.fail;
                    resObj.MessageCode = "MES000017";
                    resObj.Message     = $@"上傳失敗:未在MES系統找到Te-Station:{STATION}對應的工站,請聯繫IT配置!";
                    return(resObj);
                }
                R_SN rSn = rSnControl.LoadSN(SN, DB);
                //RTestRecord
                rowRTestRecord.ID          = cTeMesStationMappingControl.GetNewID("VERTIV", DB);
                rowRTestRecord.R_SN_ID     = rSn?.ID;
                rowRTestRecord.SN          = testRecord.SN;
                rowRTestRecord.ENDTIME     = DateTime.Parse(testRecord.TESTTIME);
                rowRTestRecord.STARTTIME   = DateTime.Parse(testRecord.TESTTIME);
                rowRTestRecord.STATE       = testRecord.STATE;
                rowRTestRecord.TEGROUP     = "A";
                rowRTestRecord.TESTATION   = testRecord.STATION;
                rowRTestRecord.MESSTATION  = cTeMesStationMapping?.MES_STATION;
                rowRTestRecord.DETAILTABLE = "R_TEST_DETAIL_VERTIV";
                //RTestDetailVertiv
                rowRTestDetailVertiv.ID = rTestDetailVertivControl.GetNewID("VERTIV", DB);
                rowRTestDetailVertiv.R_TEST_RECORD_ID = rowRTestRecord.ID;
                rowRTestDetailVertiv.SN         = testRecord.SN;
                rowRTestDetailVertiv.SKUNO      = testRecord.MODEL;
                rowRTestDetailVertiv.CREATETIME = DateTime.Parse(testRecord.TESTTIME);
                rowRTestDetailVertiv.STATE      = testRecord.STATE;
                rowRTestDetailVertiv.STATION    = testRecord.STATION;
                rowRTestDetailVertiv.CELL       = testRecord.CELL;
                rowRTestDetailVertiv.OPERATOR   = testRecord.OPERATOR;
                rowRTestDetailVertiv.ERROR_CODE = testRecord.ERROR_CODE;
            }
            catch (Exception e)
            {
                resObj.Statusvalue = (int)StatusValue.fail;
                resObj.MessageCode = "MES00003";
                resObj.Message     = "MESDB异常:" + e.ToString();
                return(resObj);
            }
            try
            {
                DB.BeginTrain();
                DB.ExecSQL(rowRTestDetailVertiv.GetInsertString(DB_TYPE_ENUM.Oracle));
                DB.ExecSQL(rowRTestRecord.GetInsertString(DB_TYPE_ENUM.Oracle));
                DB.CommitTrain();
                resObj.Statusvalue = (int)StatusValue.success;
                resObj.MessageCode = "";
                resObj.Message     = "Upload Success!";
            }
            catch (Exception e)
            {
                DB.RollbackTrain();
                resObj.Statusvalue = (int)StatusValue.fail;
                resObj.MessageCode = "MES00002";
                resObj.Message     = "写入MESERR:" + e.ToString();
            }
            finally
            {
                DB.FreeMe();
            }
            return(resObj);
        }