public void AddStation(string DisplayName, string StationName, string FailStationID, double FailStationFlag, string StationID, OleExec sfcdb) { string InsertSql = ""; T_R_Station station; try { station = new T_R_Station(sfcdb, DBTYPE); DeleteStation(StationID, sfcdb); //先刪除這個ID的數據 CheckDataExistByStationName(DisplayName, sfcdb); Row_R_Station row = (Row_R_Station)station.NewRow(); row.ID = StationID; row.DISPLAY_STATION_NAME = DisplayName; row.STATION_NAME = StationName; row.FAIL_STATION_ID = FailStationID; row.FAIL_STATION_FLAG = FailStationFlag; row.EDIT_EMP = LoginUser.EMP_NO; row.EDIT_TIME = GetDBDateTime(); InsertSql = row.GetInsertString(DBTYPE); sfcdb.ExecSQL(InsertSql); } catch (Exception e) { // this.DBPools["SFCDB"].Return(sfcdb); throw e; } }
public void AddStation(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { OleExec sfcdb = null; string InsertSql = ""; T_R_Station station; string DisplayStationName = Data["DisplayStationName"].ToString().Trim(); string StationName = Data["StationName"].ToString().Trim(); string FailStationID = Data["FailStationID"].ToString().Trim(); double FailStationFlag = Convert.ToDouble(Data["FailStationFlag"]); try { sfcdb = this.DBPools["SFCDB"].Borrow(); station = new T_R_Station(sfcdb, DBTYPE); if (station.CheckDataExist(DisplayStationName, sfcdb)) { Row_R_Station row = (Row_R_Station)station.NewRow(); row.ID = station.GetNewID(BU, sfcdb); row.DISPLAY_STATION_NAME = DisplayStationName; row.STATION_NAME = StationName; row.FAIL_STATION_ID = FailStationID; row.FAIL_STATION_FLAG = FailStationFlag; row.EDIT_EMP = LoginUser.EMP_NO; row.EDIT_TIME = GetDBDateTime(); InsertSql = row.GetInsertString(DBTYPE); sfcdb.ExecSQL(InsertSql); StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.MessageCode = "MES00000002"; this.DBPools["SFCDB"].Return(sfcdb); } else { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000005"; } } catch (Exception e) { this.DBPools["SFCDB"].Return(sfcdb); throw e; } }
public void DeleteStation(String ID, OleExec sfcdb) { string DeleteSql = ""; T_R_Station stationaction; try { stationaction = new T_R_Station(sfcdb, DBTYPE); if (stationaction.CheckDataExistByID(ID, sfcdb)) { Row_R_Station row = (Row_R_Station)stationaction.GetObjByID(ID, sfcdb); DeleteSql = row.GetDeleteString(DBTYPE); sfcdb.ExecSQL(DeleteSql); // stationaction.DeleteDataByID(ID, sfcdb); } } catch (Exception e) { // this.DBPools["SFCDB"].Return(sfcdb); throw e; } }
/// <summary> /// 初始化方法 /// </summary> public virtual void Init(string _DisplayName, string _Line, string _BU, OleExec DB) { Inputs.Clear(); SFCDB = DB; Line = _Line; BU = _BU; //加載Station Input try { T_R_Station T = new T_R_Station(SFCDB, DBType); Row_R_Station R = T.GetRowByDisplayName(_DisplayName, SFCDB); _StationInfo = R.GetDataObject(); T_R_Station_Input T_I = new T_R_Station_Input(SFCDB, DBType); List <Row_R_Station_Input> R_Inputs = T_I.GetRowsByStationID(_StationInfo.ID, SFCDB); T_C_Input T_INPUT = new T_C_Input(SFCDB, DBType); for (int i = 0; i < R_Inputs.Count; i++) { Row_C_Input R_C_I = (Row_C_Input)T_INPUT.GetObjByID(R_Inputs[i].INPUT_ID, SFCDB); C_Input C_Input = R_C_I.GetDataObject(); MESStationInput Input = new MESStationInput(); Input.Station = this; Input.Init(C_Input, R_Inputs[i].GetDataObject()); Inputs.Add(Input); } //加載Station OutPut T_R_Station_Output TRSO = new T_R_Station_Output(SFCDB, DBType); List <Row_R_Station_Output> R_Outputs = TRSO.GetStationOutputByStationID(_StationInfo.ID, SFCDB); ROutputs = R_Outputs; for (int i = 0; i < R_Outputs.Count; i++) { R_Station_Output o = R_Outputs[i].GetDataObject(); DisplayOutPut o1 = new DisplayOutPut(); o1.DisplayType = o.DISPLAY_TYPE; o1.Value = ""; o1.Name = o.NAME; StationOutputs.Add(o); DisplayOutput.Add(o1); } } catch (Exception ex) { throw ex; } if (_StationInfo.FAIL_STATION_ID != null && _StationInfo.FAIL_STATION_ID.ToString().Trim() != "") { if (this.FailStation != null) { this.FailStation.StationMessages.Clear(); this.NextInput = null; } else { this.FailStation = new MESStationBase(); } this.FailStation.LoginUser = LoginUser; this.FailStation.Init(_StationInfo.FAIL_STATION_ID, _Line, _BU, DB); } }
public void Init(string DisplayName, OleExec SFCDB) { //生成R_STATION類 Dictionary <string, object> ret = new Dictionary <string, object>(); T_R_Station T = new T_R_Station(SFCDB, DBType); Row_R_Station R = T.GetRowByDisplayName(DisplayName, SFCDB); R_Station RStation = R.GetDataObject(); ret["ID"] = RStation.ID; ret["DISPLAY_STATION_NAME"] = RStation.DISPLAY_STATION_NAME; ret["STATION_NAME"] = RStation.STATION_NAME; ret["FAIL_STATION_ID"] = RStation.FAIL_STATION_ID; ret["FAIL_STATION_FLAG"] = RStation.FAIL_STATION_FLAG; ret["EDIT_TIME"] = RStation.EDIT_TIME; ret["EDIT_EMP"] = RStation.EDIT_EMP; List <object> inputlist = new List <object>(); ret["InputList"] = inputlist; //生成InputActionList類 List <R_Station_Input> RStationInputList = new List <R_Station_Input>(); T_R_Station_Input T_I = new T_R_Station_Input(SFCDB, DBType); RStationInputList = T_I.GetRowsByStationID(RStation.ID, SFCDB, true); T_R_Input_Action T_A = new T_R_Input_Action(SFCDB, DBType); T_R_Station_Action S_A = new T_R_Station_Action(SFCDB, DBType); for (int i = 0; i < RStationInputList.Count; i++) { Dictionary <string, object> input = new Dictionary <string, object>(); input = MakeInput(); input["ID"] = RStationInputList[i].ID; input["STATION_ID"] = RStationInputList[i].STATION_ID; input["INPUT_ID"] = RStationInputList[i].INPUT_ID; input["SEQ_NO"] = RStationInputList[i].SEQ_NO; input["REMEMBER_LAST_INPUT"] = RStationInputList[i].REMEMBER_LAST_INPUT; input["EDIT_TIME"] = RStationInputList[i].EDIT_TIME; input["EDIT_EMP"] = RStationInputList[i].EDIT_EMP; input["SCAN_FLAG"] = RStationInputList[i].SCAN_FLAG; input["DISPLAY_NAME"] = RStationInputList[i].DISPLAY_NAME; List <object> daction = new List <object>(); List <R_Input_Action> inputaction = new List <R_Input_Action>(); inputaction = T_A.GetActionByInputID(RStationInputList[i].INPUT_ID.ToString(), SFCDB); for (int j = 0; j < inputaction.Count; j++) //R_Input_Action表 { Dictionary <string, object> dinputaction = new Dictionary <string, object>(); dinputaction["ID"] = inputaction[j].ID; dinputaction["INPUT_ID"] = inputaction[j].INPUT_ID; dinputaction["C_STATION_ACTION_ID"] = inputaction[j].C_STATION_ACTION_ID; dinputaction["SEQ_NO"] = inputaction[j].SEQ_NO; dinputaction["CONFIG_TYPE"] = inputaction[j].CONFIG_TYPE; dinputaction["CONFIG_VALUE"] = inputaction[j].CONFIG_VALUE; dinputaction["ADD_FLAG"] = inputaction[j].ADD_FLAG; dinputaction["EDIT_TIME"] = inputaction[j].EDIT_TIME; dinputaction["EDIT_EMP"] = inputaction[j].EDIT_EMP; // ret["ParaIA"] =; T_R_Station_Action_Para T_P = new T_R_Station_Action_Para(SFCDB, DBType);//R_Station_Action_Para 表 List <R_Station_Action_Para> ParaList = T_P.GetActionParaByInputActionID(inputaction[j].ID, SFCDB); dinputaction["ParaSA"] = ParaList; T_C_ACTION_PARA A_P = new T_C_ACTION_PARA(SFCDB, DBType); //C_ACTION_PAR 表 List <C_ACTION_PARA> AParaList = A_P.QueryActionPara(RStationInputList[i].INPUT_ID, SFCDB); dinputaction["ParaSB"] = AParaList; T_c_station_action CS_A = new T_c_station_action(SFCDB, DBType);//R_Station_Action_Para 表 c_station_action ParaList3 = CS_A.GetActionByID(inputaction[j].C_STATION_ACTION_ID, SFCDB); dinputaction["C_STATION_ACTION"] = ParaList3; daction.Add(dinputaction); } List <object> dsaction = new List <object>(); List <R_Station_Action> stationaction = new List <R_Station_Action>();//R_Station_Action 表 stationaction = S_A.GetActionByInputID(RStationInputList[i].ID.ToString(), SFCDB); for (int j = 0; j < stationaction.Count; j++) //R_Station_Action 表 { Dictionary <string, object> dinputaction2 = new Dictionary <string, object>(); dinputaction2 = MakeStationAction(); dinputaction2["ID"] = stationaction[j].ID; dinputaction2["R_STATION_INPUT_ID"] = stationaction[j].R_STATION_INPUT_ID; dinputaction2["C_STATION_ACTION_ID"] = stationaction[j].C_STATION_ACTION_ID; dinputaction2["SEQ_NO"] = stationaction[j].SEQ_NO; dinputaction2["CONFIG_TYPE"] = stationaction[j].CONFIG_TYPE; dinputaction2["CONFIG_VALUE"] = stationaction[j].CONFIG_VALUE; dinputaction2["ADD_FLAG"] = stationaction[j].ADD_FLAG; dinputaction2["EDIT_TIME"] = stationaction[j].EDIT_TIME; dinputaction2["EDIT_EMP"] = stationaction[j].EDIT_EMP; T_R_Station_Action_Para T_P2 = new T_R_Station_Action_Para(SFCDB, DBType);//R_Station_Action_Para 表 List <R_Station_Action_Para> ParaList2 = T_P2.GetActionParaByStationActionID(stationaction[j].ID, SFCDB); dinputaction2["ParaSA"] = ParaList2; T_C_ACTION_PARA A_P = new T_C_ACTION_PARA(SFCDB, DBType);//C_ACTION_PARA 表 List <C_ACTION_PARA> AParaList = A_P.QueryActionParaByStation(stationaction[j].C_STATION_ACTION_ID, SFCDB); dinputaction2["ParaSB"] = AParaList; T_c_station_action CS_A = new T_c_station_action(SFCDB, DBType);//R_Station_Action_Para 表 c_station_action ParaList3 = CS_A.GetActionByID(stationaction[j].C_STATION_ACTION_ID, SFCDB); dinputaction2["C_STATION_ACTION"] = ParaList3; dsaction.Add(dinputaction2); } input["StationActionList"] = dsaction; inputlist.Add(input); } ret["InputList"] = inputlist; T_R_Station_Output R_O = new T_R_Station_Output(SFCDB, DBType);//R_Station_Output 表 List <R_Station_Output> StationOutput = R_O.GetStationOutputByStationID(RStation.ID, SFCDB, true); ret["OutputList"] = StationOutput; Station = ret; }