public override void init() { try { //從Ini檔中獲取BU/Plant/DB/Cust/Count/ConvertWo/DownloadWO BU = ConfigGet("BU"); Plant = ConfigGet("PLANT"); DB = ConfigGet("DB");//與App.config中配置的匹配 CUST = ConfigGet("CUST"); COUNT = ConfigGet("COUNT"); //可以依工單前綴來確定哪種類型的工單需要自動轉,哪種需手動轉 arrayConvertWO = ConfigGet("CONVERTWO").Split(','); _downloadWO = ConfigGet("DOWNLOADWO"); List <System.Net.IPAddress> temp = HWDNNSFCBase.HostInfo.IP.Where(ipv4 => ipv4.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToList(); ip = temp[0].ToString(); //創建DownloadWO_UI,并附值給輸入對象Output.UI Output.UI = new DownLoadWO_UI(this); //依據Ini檔配置的DB從ConnectionManager中獲取數據庫連接 SFCDB = new OleExec(DB, false); //程序運行狀態表 synLock = new T_R_SYNC_LOCK(SFCDB, DB_TYPE_ENUM.Oracle); //工單欄位對照表 C_TAB_COLUMN_MAP = new T_C_TAB_COLUMN_MAP(SFCDB, DB_TYPE_ENUM.Oracle); //從SAP Download下來后分別存儲在以下三張表 R_WO_HEADER = new T_R_WO_HEADER(SFCDB, DB_TYPE_ENUM.Oracle); R_WO_ITEM = new T_R_WO_ITEM(SFCDB, DB_TYPE_ENUM.Oracle); R_WO_TEXT = new T_R_WO_TEXT(SFCDB, DB_TYPE_ENUM.Oracle); //獲取料號/Route C_SKU = new T_C_SKU(SFCDB, DB_TYPE_ENUM.Oracle); RouteDetail = new T_C_ROUTE_DETAIL(SFCDB, DB_TYPE_ENUM.Oracle); C_ROUTE = new T_C_ROUTE(SFCDB, DB_TYPE_ENUM.Oracle); T_Series = new T_C_SERIES(SFCDB, DB_TYPE_ENUM.Oracle); //工單類型及前綴信息 WOType = new T_R_WO_TYPE(SFCDB, DB_TYPE_ENUM.Oracle); Keypart = new T_C_KEYPART(SFCDB, DB_TYPE_ENUM.Oracle); R_WO_BASE = new T_R_WO_BASE(SFCDB, DB_TYPE_ENUM.Oracle); t_c_kp_list = new T_C_KP_LIST(SFCDB, DB_TYPE_ENUM.Oracle); //創建RFC類:建立SAP連接,建立RFC輸入輸出參數 ZRFC_SFC_NSG_0001B = new ZRFC_SFC_NSG_0001B(BU); } catch (Exception e) { throw new Exception("Init DownLoadWO Fail" + e.Message); } //取得RFC的輸出參數Table對象,并附值給Output.Tables Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("ITAB")); Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("WO_HEADER")); Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("WO_ITEM")); Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("WO_TEXT")); }
/// <summary> /// 外部調用時請賦值public屬性 /// </summary> private void CallRFC() { try { //將參數附值給RFCMDT ZRFC_SFC_NSG_0001B.SetValue("PLANT", this.Plant); ZRFC_SFC_NSG_0001B.SetValue("COUNT", COUNT); ZRFC_SFC_NSG_0001B.SetValue("CUST", CUST); ZRFC_SFC_NSG_0001B.SetValue("IN_CNF", ""); if (downLoadDate != "") { ZRFC_SFC_NSG_0001B.SetValue("SCHEDULED_DATE", downLoadDate); ZRFC_SFC_NSG_0001B.SetValue("RLDATE", downLoadDate); autoDownLoad = false; } else { ZRFC_SFC_NSG_0001B.SetValue("SCHEDULED_DATE", DateTime.Now.ToString("yyyy-MM-dd")); ZRFC_SFC_NSG_0001B.SetValue("RLDATE", DateTime.Now.ToString("yyyy-MM-dd")); } //調用RFC ZRFC_SFC_NSG_0001B.CallRFC(); //獲取RFC返回的結果 dtITAB = ZRFC_SFC_NSG_0001B.GetTableValue("ITAB"); dtWOHeader = ZRFC_SFC_NSG_0001B.GetTableValue("WO_HEADER"); dtWOItem = ZRFC_SFC_NSG_0001B.GetTableValue("WO_ITEM"); dtWOText = ZRFC_SFC_NSG_0001B.GetTableValue("WO_TEXT"); //????此處Tables是否已經存在 //異常返回表 Output.Tables.Add(dtITAB); Output.Tables.Add(dtWOHeader); Output.Tables.Add(dtWOItem); Output.Tables.Add(dtWOText); if (dtITAB.Rows.Count > 0) { throw new Exception(dtITAB.Rows[0][1].ToString()); } //寫入R_WO_Header&R_WO_Item表 SaveWOHeader(); //SaveWOItem(); //SaveWOText(); ConvertWO(); downLoadDate = ""; } catch (Exception ex) { //write log WriteLog.WriteIntoMESLog(SFCDB, BU, "MESInterface", "MESInterface.MBD.DownLoadWO", "CallRFC", ip + ";" + ex.Message.ToString(), "", "interface"); } }
public override void init() { try { BU = ConfigGet("BU"); Plant = ConfigGet("PLANT"); DB = ConfigGet("DB"); CUST = ConfigGet("CUST"); COUNT = ConfigGet("COUNT"); arrayConvertWO = ConfigGet("CONVERTWO").Split(','); _downloadWO = ConfigGet("DOWNLOADWO"); List <System.Net.IPAddress> temp = HWDNNSFCBase.HostInfo.IP.Where(ipv4 => ipv4.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToList(); ip = temp[0].ToString(); Output.UI = new DownLoadWO_UI(this); SFCDB = new OleExec(DB, false); synLock = new T_R_SYNC_LOCK(SFCDB, DB_TYPE_ENUM.Oracle); C_TAB_COLUMN_MAP = new T_C_TAB_COLUMN_MAP(SFCDB, DB_TYPE_ENUM.Oracle); C_SKU = new T_C_SKU(SFCDB, DB_TYPE_ENUM.Oracle); R_WO_HEADER = new T_R_WO_HEADER(SFCDB, DB_TYPE_ENUM.Oracle); R_WO_ITEM = new T_R_WO_ITEM(SFCDB, DB_TYPE_ENUM.Oracle); R_WO_TEXT = new T_R_WO_TEXT(SFCDB, DB_TYPE_ENUM.Oracle); RouteDetail = new T_C_ROUTE_DETAIL(SFCDB, DB_TYPE_ENUM.Oracle); WOType = new T_R_WO_TYPE(SFCDB, DB_TYPE_ENUM.Oracle); Keypart = new T_C_KEYPART(SFCDB, DB_TYPE_ENUM.Oracle); C_ROUTE = new T_C_ROUTE(SFCDB, DB_TYPE_ENUM.Oracle); R_WO_BASE = new T_R_WO_BASE(SFCDB, DB_TYPE_ENUM.Oracle); T_Series = new T_C_SERIES(SFCDB, DB_TYPE_ENUM.Oracle); t_c_kp_list = new T_C_KP_LIST(SFCDB, DB_TYPE_ENUM.Oracle); ZRFC_SFC_NSG_0001B = new ZRFC_SFC_NSG_0001B(BU); } catch (Exception e) { throw new Exception("Init DownLoadWO Fail" + e.Message); } Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("ITAB")); Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("WO_HEADER")); Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("WO_ITEM")); Output.Tables.Add(ZRFC_SFC_NSG_0001B.GetTableValue("WO_TEXT")); }