public void SetWoReplaceKpWithSku(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { string Wo = Data["WO"].ToString().Trim(), PartNo = Data["PARTNO"].ToString().Trim(), ReplacePartno = Data["REPLACEPARTNO"].ToString().Trim(), Sku = Data["SKUNO"].ToString().Trim(); OleExec oleDB = null; T_R_WO_KP_Repalce rWoKpReplace = null; T_C_SKU cSku = null; T_R_WO_BASE rWoBase = null; try { oleDB = this.DBPools["SFCDB"].Borrow(); rWoKpReplace = new T_R_WO_KP_Repalce(oleDB, DBTYPE); cSku = new T_C_SKU(oleDB, DBTYPE); rWoBase = new T_R_WO_BASE(oleDB, DBTYPE); if (!cSku.SkuIsExist(Sku, oleDB)) { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000245"; StationReturn.MessagePara = new List <object>() { Sku }; } else if (rWoBase.CheckDataExist(Wo, Sku, oleDB)) { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000245"; StationReturn.Data = ""; } else if (rWoKpReplace.CheckDataExist(Wo, PartNo, ReplacePartno, oleDB)) { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000005"; StationReturn.Data = ""; } else { Row_R_WO_KP_Repalce rowRWoKpReplace = (Row_R_WO_KP_Repalce)rWoKpReplace.NewRow(); rowRWoKpReplace.ID = rWoKpReplace.GetNewID(this.BU, oleDB, DBTYPE); rowRWoKpReplace.WO = Wo; rowRWoKpReplace.PARTNO = PartNo; rowRWoKpReplace.REPALCEPARTNO = ReplacePartno; rowRWoKpReplace.EDIT_EMP = this.LoginUser.EMP_NO; rowRWoKpReplace.EDIT_TIME = GetDBDateTime();; oleDB.ThrowSqlExeception = true; oleDB.ExecSQL(rowRWoKpReplace.GetInsertString(DBTYPE)); StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.MessageCode = "MES00000002"; StationReturn.Data = ""; } } catch (Exception e) { throw e; } finally { this.DBPools["SFCDB"].Return(oleDB); } }
public void SubmitWoInfo(JObject requestValue, JObject Data, MESStationReturn StationReturn) { //wo string wo = Data["wo"].ToString(); if (string.IsNullOrEmpty(wo)) { //StationReturn.Status = StationReturnStatusValue.Fail; //StationReturn.MessageCode = "MES00000006"; //StationReturn.MessagePara = new List<object>() { "Skuno" }; //StationReturn.Data = ""; //return; throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000006", new string[] { "WO" })); } OleExec sfcdb = DBPools["SFCDB"].Borrow(); T_R_WO_BASE t_wo = new T_R_WO_BASE(sfcdb, DB_TYPE_ENUM.Oracle); if (!t_wo.CheckDataExist(wo, sfcdb)) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000008", new string[] { wo })); } R_WO_HEADER wo_header = new T_R_WO_HEADER(sfcdb, DB_TYPE_ENUM.Oracle).GetDetailByWo(sfcdb, wo); //sku info string skuno = Data["skuno"].ToString();//wo_header.MATNR if (string.IsNullOrEmpty(skuno)) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000006", new string[] { "SKUNO" })); } string skuver = Data["sku_ver"].ToString();//wo_header.REVLV C_SKU c_sku = new T_C_SKU(sfcdb, DB_TYPE_ENUM.Oracle).GetSku(skuno, sfcdb, DB_TYPE_ENUM.Oracle).GetDataObject(); if (c_sku == null) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000007", new string[] { skuno })); } //route exchange from name string route_name = Data["route_name"].ToString(); if (string.IsNullOrEmpty(route_name)) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000006", new string[] { "ROUTE" })); } C_ROUTE c_route = new T_C_ROUTE(sfcdb, DB_TYPE_ENUM.Oracle).GetByRouteName(route_name, sfcdb); if (c_route == null) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000007", new string[] { route_name })); } //station route check string station_name = Data["station"].ToString(); if (string.IsNullOrEmpty(station_name)) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000006", new string[] { "STATION" })); } List <C_ROUTE_DETAIL> c_route_detail = new T_C_ROUTE_DETAIL(sfcdb, DB_TYPE_ENUM.Oracle).GetByRouteIdOrderBySEQASC(c_route.ID, sfcdb); if (c_route_detail != null && c_route_detail.Count > 0) { C_ROUTE_DETAIL check = c_route_detail.Find(t => t.STATION_NAME == station_name); if (check == null) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000007", new string[] { station_name })); } } else { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000007", new string[] { route_name })); } //data record Row_R_WO_BASE row_wobase = (Row_R_WO_BASE)t_wo.NewRow(); row_wobase.ID = t_wo.GetNewID(this.BU, sfcdb); row_wobase.WORKORDERNO = wo; row_wobase.PLANT = Data["factory"].ToString(); row_wobase.RELEASE_DATE = DateTime.Now; row_wobase.DOWNLOAD_DATE = Convert.ToDateTime(Data["date"].ToString()); row_wobase.PRODUCTION_TYPE = "BTO"; row_wobase.WO_TYPE = Data["wo_type"].ToString(); row_wobase.SKUNO = skuno; row_wobase.SKU_VER = skuver; row_wobase.SKU_NAME = c_sku.SKU_NAME; //row_wobase.SKU_SERIES = null; //row_wobase.SKU_DESC = null; row_wobase.CUST_PN = c_sku.CUST_PARTNO; row_wobase.ROUTE_ID = c_route.ID; row_wobase.START_STATION = station_name; row_wobase.KP_LIST_ID = Data["kp_list_id"].ToString(); row_wobase.CLOSED_FLAG = "0"; row_wobase.WORKORDER_QTY = Convert.ToDouble(Data["qty"].ToString()); row_wobase.STOCK_LOCATION = wo_header.LGORT; row_wobase.CUST_ORDER_NO = wo_header.ABLAD; row_wobase.EDIT_EMP = this.LoginUser.EMP_NO; row_wobase.EDIT_TIME = DateTime.Now; string sql = row_wobase.GetInsertString(DB_TYPE_ENUM.Oracle); try { int res = sfcdb.ExecSqlNoReturn(sql, null); if (res == 0) { throw new Exception(MESReturnMessage.GetMESReturnMessage("MES00000021", new string[] { wo })); } if (sfcdb != null) { DBPools["SFCDB"].Return(sfcdb); } } catch (Exception ex) { if (sfcdb != null) { DBPools["SFCDB"].Return(sfcdb); } throw ex; } }
public void Download(string ItemName, string Date) { string StrSql = ""; OleExec sfcdb; DataTable RFC_Table = new DataTable(); T_C_TAB_COLUMN_MAP C_TAB_COLUMN_MAP; DataObjectBase Row; T_R_WO_HEADER R_WO_HEADER; T_R_WO_ITEM R_WO_ITEM; T_R_WO_TEXT R_WO_TEXT; T_R_WO_BASE R_WO_BASE; T_C_SKU C_SKU; T_C_PARAMETER C_PARAMETER; Row_C_PARAMETER Row_PARAMETER; Dictionary <string, string> DicPara = new Dictionary <string, string>(); string StrColumn = ""; string StrValue = ""; string[] StrColumn_Name; string[] StrColumn_Value; string StrWo = ""; bool Exist_WO_Flag = false; bool Exist_WO_Base_Flag = false; bool Exist_SKU_Flag = false; bool DownLoad_Auto = false; if (string.IsNullOrEmpty(StrWo)) { DownLoad_Auto = true; } sfcdb = this.DBPools["SFCDB"].Borrow(); C_PARAMETER = new T_C_PARAMETER(sfcdb, DB_TYPE_ENUM.Oracle); DicPara = C_PARAMETER.Get_Interface_Parameter_2(ItemName, sfcdb, DB_TYPE_ENUM.Oracle); this.DBPools["SFCDB"].Return(sfcdb); ZRFC_SFC_NSG_0001B Zrfc_SFC_NSG_001B = new ZRFC_SFC_NSG_0001B(StrWo); Zrfc_SFC_NSG_001B.SetValue("PLANT", DicPara["PLANT"]);//NHGZ,WDN1//WDN1,WSL3 Zrfc_SFC_NSG_001B.SetValue("SCHEDULED_DATE", Date); Zrfc_SFC_NSG_001B.SetValue("RLDATE", Date); Zrfc_SFC_NSG_001B.SetValue("COUNT", DicPara["COUNT"]); Zrfc_SFC_NSG_001B.SetValue("CUST", DicPara["CUST"]); Zrfc_SFC_NSG_001B.SetValue("IN_CNF", DicPara["IN_CNF"]); //IN_CNF=0,Download WO not Confirmed Zrfc_SFC_NSG_001B.CallRFC(); for (int i = 0; i < Zrfc_SFC_NSG_001B.ReturnDatatableByIndex.Count; i++) { string ErrorMessage = ""; switch (Zrfc_SFC_NSG_001B.ReturnDatatableByIndex[i].TableName.ToString().ToUpper()) { case "ITAB": if (Zrfc_SFC_NSG_001B.ReturnDatatableByIndex[0].Rows.Count > 0) { ErrorMessage = Zrfc_SFC_NSG_001B.ReturnDatatableByIndex[0].Rows[0][1].ToString(); throw new Exception(ErrorMessage); } break; case "WO_HEADER": sfcdb = this.DBPools["SFCDB"].Borrow(); C_TAB_COLUMN_MAP = new T_C_TAB_COLUMN_MAP(sfcdb, DB_TYPE_ENUM.Oracle); Row = C_TAB_COLUMN_MAP.GetTableColumnMap("R_WO_HEADER", sfcdb, DB_TYPE_ENUM.Oracle); StrColumn = Row["TAB_COLUMN"].ToString(); StrValue = ""; StrColumn_Name = StrColumn.Split(','); StrColumn_Value = new string[StrColumn_Name.Count()]; RFC_Table = (DataTable)Zrfc_SFC_NSG_001B.ReturnDatatableByIndex[i]; for (int m = 0; m < RFC_Table.Rows.Count; m++) { R_WO_BASE = new T_R_WO_BASE(sfcdb, DB_TYPE_ENUM.Oracle); Exist_WO_Base_Flag = R_WO_BASE.CheckDataExist(RFC_Table.Rows[m]["AUFNR"].ToString(), sfcdb); R_WO_HEADER = new T_R_WO_HEADER(sfcdb, DB_TYPE_ENUM.Oracle); Exist_WO_Flag = R_WO_HEADER.CheckWoHeadByWo(RFC_Table.Rows[m]["AUFNR"].ToString(), DownLoad_Auto, StrColumn, sfcdb, DB_TYPE_ENUM.Oracle); C_SKU = new T_C_SKU(sfcdb, DB_TYPE_ENUM.Oracle); Exist_SKU_Flag = C_SKU.CheckSku(RFC_Table.Rows[m][3].ToString(), sfcdb); if (!Exist_WO_Flag && Exist_SKU_Flag && !Exist_WO_Base_Flag) { string StrID = C_TAB_COLUMN_MAP.GetNewID(BU, sfcdb); for (int j = 0; j < StrColumn_Name.Count(); j++) { //StrColumn_Value[j] = ReplaceSpecialChar(RFC_Table.Rows[m][StrColumn_Name[j]].ToString()); StrColumn_Value[j] = RFC_Table.Rows[m][StrColumn_Name[j]].ToString(); if (j == 0) { StrValue = "'" + StrColumn_Value[j].ToString() + "'"; } else { StrValue = StrValue + ",'" + StrColumn_Value[j].ToString() + "'"; } } StrSql = " insert into R_WO_HEADER(" + StrColumn + ",ID " + ") values(" + StrValue + ",'" + StrID + "'" + ");"; R_WO_HEADER = new T_R_WO_HEADER(sfcdb, DB_TYPE_ENUM.Oracle); R_WO_HEADER.EditWoHead(StrSql, sfcdb, DB_TYPE_ENUM.Oracle); } } this.DBPools["SFCDB"].Return(sfcdb); break; case "WO_ITEM": StrSql = ""; sfcdb = this.DBPools["SFCDB"].Borrow(); C_TAB_COLUMN_MAP = new T_C_TAB_COLUMN_MAP(sfcdb, DB_TYPE_ENUM.Oracle); Row = C_TAB_COLUMN_MAP.GetTableColumnMap("R_WO_ITEM", sfcdb, DB_TYPE_ENUM.Oracle); StrColumn = Row["TAB_COLUMN"].ToString(); StrValue = ""; StrColumn_Name = StrColumn.Split(','); StrColumn_Value = new string[StrColumn_Name.Count()]; RFC_Table = (DataTable)Zrfc_SFC_NSG_001B.ReturnDatatableByIndex[i]; for (int m = 0; m < RFC_Table.Rows.Count; m++) { R_WO_BASE = new T_R_WO_BASE(sfcdb, DB_TYPE_ENUM.Oracle); Exist_WO_Base_Flag = R_WO_BASE.CheckDataExist(RFC_Table.Rows[m]["AUFNR"].ToString(), sfcdb); R_WO_ITEM = new T_R_WO_ITEM(sfcdb, DB_TYPE_ENUM.Oracle); Exist_WO_Flag = R_WO_ITEM.CheckWoItemByWo(RFC_Table.Rows[m]["AUFNR"].ToString(), RFC_Table.Rows[m]["MATNR"].ToString(), DownLoad_Auto, StrColumn, sfcdb, DB_TYPE_ENUM.Oracle); C_SKU = new T_C_SKU(sfcdb, DB_TYPE_ENUM.Oracle); Exist_SKU_Flag = C_SKU.CheckSku(RFC_Table.Rows[m][8].ToString(), sfcdb); if (!Exist_WO_Flag && Exist_SKU_Flag && !Exist_WO_Base_Flag) { string StrID = C_TAB_COLUMN_MAP.GetNewID(BU, sfcdb); for (int j = 0; j < StrColumn_Name.Count(); j++) { //StrColumn_Value[j] = ReplaceSpecialChar(RFC_Table.Rows[m][StrColumn_Name[j]].ToString()); StrColumn_Value[j] = RFC_Table.Rows[m][StrColumn_Name[j]].ToString(); if (j == 0) { StrValue = "'" + StrColumn_Value[j].ToString() + "'"; } else { StrValue = StrValue + ",'" + StrColumn_Value[j].ToString() + "'"; } } StrSql = "insert into R_WO_ITEM(" + StrColumn + ",ID " + ") values(" + StrValue + ",'" + StrID + "'" + ");\n"; R_WO_ITEM = new T_R_WO_ITEM(sfcdb, DB_TYPE_ENUM.Oracle); R_WO_ITEM.EditWoItem(StrSql, sfcdb, DB_TYPE_ENUM.Oracle); } } this.DBPools["SFCDB"].Return(sfcdb); break; case "WO_TEXT": StrSql = ""; sfcdb = this.DBPools["SFCDB"].Borrow(); C_TAB_COLUMN_MAP = new T_C_TAB_COLUMN_MAP(sfcdb, DB_TYPE_ENUM.Oracle); Row = C_TAB_COLUMN_MAP.GetTableColumnMap("R_WO_TEXT", sfcdb, DB_TYPE_ENUM.Oracle); StrColumn = Row["TAB_COLUMN"].ToString(); StrValue = ""; StrColumn_Name = StrColumn.Split(','); StrColumn_Value = new string[StrColumn_Name.Count()]; RFC_Table = (DataTable)Zrfc_SFC_NSG_001B.ReturnDatatableByIndex[i]; for (int m = 0; m < RFC_Table.Rows.Count; m++) { R_WO_BASE = new T_R_WO_BASE(sfcdb, DB_TYPE_ENUM.Oracle); Exist_WO_Base_Flag = R_WO_BASE.CheckDataExist(RFC_Table.Rows[m]["AUFNR"].ToString(), sfcdb); R_WO_TEXT = new T_R_WO_TEXT(sfcdb, DB_TYPE_ENUM.Oracle); Exist_WO_Flag = R_WO_TEXT.CheckWoTextByWo(RFC_Table.Rows[m]["AUFNR"].ToString(), DownLoad_Auto, StrColumn, sfcdb, DB_TYPE_ENUM.Oracle); R_WO_HEADER = new T_R_WO_HEADER(sfcdb, DB_TYPE_ENUM.Oracle); Exist_SKU_Flag = R_WO_HEADER.CheckWoHeadByWo(RFC_Table.Rows[m]["AUFNR"].ToString(), true, StrColumn, sfcdb, DB_TYPE_ENUM.Oracle); if (!Exist_WO_Flag && !Exist_WO_Base_Flag && Exist_SKU_Flag) { string StrID = C_TAB_COLUMN_MAP.GetNewID(BU, sfcdb); for (int j = 0; j < StrColumn_Name.Count(); j++) { StrColumn_Value[j] = RFC_Table.Rows[m][StrColumn_Name[j]].ToString(); if (j == 0) { StrValue = "'" + StrColumn_Value[j].ToString() + "'"; } else { StrValue = StrValue + ",'" + StrColumn_Value[j].ToString() + "'"; } } StrSql = "insert into R_WO_TEXT(" + StrColumn + ",ID " + ") values(" + StrValue + ",'" + StrID + "'" + ");"; R_WO_TEXT = new T_R_WO_TEXT(sfcdb, DB_TYPE_ENUM.Oracle); R_WO_TEXT.EditWoText(StrSql, sfcdb, DB_TYPE_ENUM.Oracle); } } this.DBPools["SFCDB"].Return(sfcdb); break; } } }