public void FetchCurrentSeries(JObject requestValue, JToken Data, MESStationReturn StationReturn) { //BU,CustomerName,SeriesName string field = Data["Field"].ToString(); string value = Data["Value"].ToString(); OleExec sfcdb = null; DataTable dataTable = null; try { sfcdb = this.DBPools["SFCDB"].Borrow(); dataTable = new T_C_SERIES(sfcdb, DB_TYPE_ENUM.Oracle).GetQueryAll(field, value, sfcdb); StationReturn.Status = StationReturnStatusValue.Pass; //StationReturn.Message = "獲取成功"; StationReturn.MessageCode = "MES00000001"; StationReturn.Data = ConvertToJson.DataTableToJson(dataTable); if (sfcdb != null) { this.DBPools["SFCDB"].Return(sfcdb); } } catch (Exception ex) { if (sfcdb != null) { this.DBPools["SFCDB"].Return(sfcdb); } throw ex; } }
/// <summary> /// 從SKU加載Customer /// 若Series已裝載則從Series加載 /// </summary> /// <param name="Station"></param> /// <param name="Input"></param> /// <param name="Paras"></param> public static void CustFromSKUDataloader(MESStationBase Station, MESStationInput Input, List <R_Station_Action_Para> Paras) { OleExec sfcdb = Station.SFCDB; C_SERIES c_series = null; C_CUSTOMER c_customer = null; MESStationSession serieSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY); if (serieSession == null) { MESStationSession skuSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY); if (skuSession == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SKU" })); } SKU sku = (SKU)skuSession.Value; if (sku == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SKU" })); } c_series = new T_C_SERIES(sfcdb, DB_TYPE_ENUM.Oracle).GetDetailById(sfcdb, sku.CSeriesId);//sku.CSeriesId //是否加入StationSession... } else { c_series = (C_SERIES)serieSession.Value; } if (c_series == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SERIES" })); } //構建查詢CUSTOMER參數 Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("ID", c_series.CUSTOMER_ID); List <C_CUSTOMER> customers = new T_C_CUSTOMER(sfcdb, DB_TYPE_ENUM.Oracle).GetCustomerList(parameters, sfcdb); if (customers.Count == 0) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "CUSTOMER" })); } c_customer = customers[0]; MESStationSession custSession = Station.StationSession.Find(t => t.MESDataType == Paras[2].SESSION_TYPE && t.SessionKey == Paras[2].SESSION_KEY); if (custSession == null) { custSession = new MESStationSession() { MESDataType = Paras[2].SESSION_TYPE, SessionKey = Paras[2].SESSION_KEY }; Station.StationSession.Add(custSession); } custSession.Value = c_customer; Station.AddMessage("MES00000029", new string[] { "CUSTOMER", c_customer.CUSTOMER_NAME }, StationMessageState.Pass); }
public void GetSeriesByName(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { OleExec sfcdb = null; List <C_SERIES> SeriesList = new List <C_SERIES>(); T_C_SERIES table = null; string SeriesName = string.Empty; try { sfcdb = this.DBPools["SFCDB"].Borrow(); table = new T_C_SERIES(sfcdb, DBTYPE); SeriesName = Data["Series_Name"].ToString(); if (string.IsNullOrEmpty(SeriesName)) { GetAllSeries(requestValue, Data, StationReturn); } else { SeriesList = table.GetSeriesByName(SeriesName, sfcdb); if (SeriesList.Count() == 0) { //沒有獲取到數據 ConstructReturns( ref StationReturn, StationReturnStatusValue.Pass, MESReturnMessage.GetMESReturnMessage("QueryNoData"), new object()); } else { //獲取成功 ConstructReturns( ref StationReturn, StationReturnStatusValue.Pass, MESReturnMessage.GetMESReturnMessage("QueryOK", new string[] { SeriesList.Count().ToString() }), SeriesList); } } } catch (Exception e) { ConstructReturns( ref StationReturn, StationReturnStatusValue.Fail, MESReturnMessage.GetMESReturnMessage("Exception", new string[] { e.Message }), e.Message); } finally { this.DBPools["SFCDB"].Return(sfcdb); } }
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")); }
public void AddSeries(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { OleExec sfcdb = null; T_C_SERIES table = null; string SeriesObject = string.Empty; C_SERIES series = null; string result = string.Empty; try { sfcdb = this.DBPools["SFCDB"].Borrow(); table = new T_C_SERIES(sfcdb, DBTYPE); SeriesObject = Data["SeriesObject"].ToString(); series = (C_SERIES)JsonConvert.Deserialize(SeriesObject, typeof(C_SERIES)); series.EDIT_EMP = "A0225204";// LoginUser.EMP_NO; series.EDIT_TIME = DateTime.Now; result = table.UpdateSeries(BU, series, "ADD", sfcdb); if (Int32.Parse(result) > 0) { //添加成功 ConstructReturns( ref StationReturn, StationReturnStatusValue.Pass, MESReturnMessage.GetMESReturnMessage("UpdateOK", new string[] { result }), result); } else { //沒有添加任何數據 ConstructReturns( ref StationReturn, StationReturnStatusValue.Pass, MESReturnMessage.GetMESReturnMessage("UpdateNoData"), result); } } catch (Exception e) { ConstructReturns( ref StationReturn, StationReturnStatusValue.Fail, MESReturnMessage.GetMESReturnMessage("Exception", new string[] { e.Message }), e.Message); } finally { this.DBPools["SFCDB"].Return(sfcdb); } }
public void DeleteSeriesById(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { OleExec sfcdb = null; T_C_SERIES table = null; C_SERIES series = null; string result = string.Empty; string SeriesId = string.Empty; try { sfcdb = this.DBPools["SFCDB"].Borrow(); table = new T_C_SERIES(sfcdb, DBTYPE); SeriesId = Data["SeriesID"].ToString(); series = new C_SERIES(); series.ID = SeriesId; result = table.UpdateSeries(BU, series, "DELETE", sfcdb); if (Int32.Parse(result) > 0) { //刪除成功 ConstructReturns( ref StationReturn, StationReturnStatusValue.Pass, MESReturnMessage.GetMESReturnMessage("UpdateOK", new string[] { result }), result); } else { //沒有刪除任何數據 ConstructReturns( ref StationReturn, StationReturnStatusValue.Pass, MESReturnMessage.GetMESReturnMessage("UpdateNoData"), result); } } catch (Exception e) { ConstructReturns( ref StationReturn, StationReturnStatusValue.Fail, MESReturnMessage.GetMESReturnMessage("Exception", new string[] { e.Message }), e.Message); } finally { this.DBPools["SFCDB"].Return(sfcdb); } }
/// <summary> /// 從SKU加載Series /// </summary> /// <param name="Station"></param> /// <param name="Input"></param> /// <param name="Paras"></param> public static void SeriesFromSKUDataloader(MESStationBase Station, MESStationInput Input, List <R_Station_Action_Para> Paras) { //加載SeriesSavePoint MESStationSession SeriesSession = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY); if (SeriesSession == null) { SeriesSession = new MESStationSession() { MESDataType = Paras[0].SESSION_TYPE, SessionKey = Paras[0].SESSION_KEY }; Station.StationSession.Add(SeriesSession); } //SKULoadPoint MESStationSession SkuSession = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY); if (SkuSession == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SKU" })); } SKU sku = (SKU)SkuSession.Value; if (sku == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SKU" })); } OleExec sfcdb = Station.SFCDB; T_C_SERIES t_c_series = new T_C_SERIES(sfcdb, DB_TYPE_ENUM.Oracle); C_SERIES c_series = t_c_series.GetDetailById(sfcdb, sku.CSeriesId);//sku.CSeriesId if (c_series == null) { throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000045", new string[] { "SERIES" })); } SeriesSession.Value = c_series; Station.AddMessage("MES00000029", new string[] { "SERIES", c_series.SERIES_NAME }, StationMessageState.Pass); }
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")); }
public void DeleteSeriesById(JObject requestValue, JToken Data, MESStationReturn StationReturn) { OleExec sfcdb = null; string DeleteSql = ""; string strid = ""; T_C_SERIES DeleteInformation; Newtonsoft.Json.Linq.JArray seriesId = (Newtonsoft.Json.Linq.JArray)Data["ID"]; try { sfcdb = this.DBPools["SFCDB"].Borrow(); sfcdb.BeginTrain(); DeleteInformation = new T_C_SERIES(sfcdb, DBTYPE); for (int i = 0; i < seriesId.Count; i++) { strid = seriesId[i].ToString(); Row_C_SERIES row = (Row_C_SERIES)DeleteInformation.GetObjByID(strid, sfcdb); DeleteSql += row.GetDeleteString(DBTYPE) + ";\n"; } DeleteSql = "begin\n" + DeleteSql + "end;"; sfcdb.ExecSQL(DeleteSql); StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.MessageCode = "MES00000004"; sfcdb.CommitTrain(); this.DBPools["SFCDB"].Return(sfcdb); } catch (Exception e) { sfcdb.RollbackTrain(); this.DBPools["SFCDB"].Return(sfcdb); throw e; } //string seriesId = Data["SeriesId"].ToString(); //if (string.IsNullOrEmpty(seriesId)) //{ // StationReturn.Status = StationReturnStatusValue.Fail; // StationReturn.MessageCode = "MES00000006"; // StationReturn.MessagePara = new List<Object>() { "Series" }; // StationReturn.Data = null; // return; //} //OleExec sfcdb = DBPools["SFCDB"].Borrow(); //Row_C_SERIES c_series = (Row_C_SERIES) new T_C_SERIES(sfcdb, DB_TYPE_ENUM.Oracle).NewRow(); //string[] ids = seriesId.Split(','); //try //{ // sfcdb.BeginTrain(); // string deleteString = null; // foreach (string id in ids) // { // deleteString = c_series.GetDeleteString(DB_TYPE_ENUM.Oracle, id); // sfcdb.ExecuteNonQuery(deleteString, CommandType.Text, null); // } // sfcdb.CommitTrain(); //} //catch (Exception ex) //{ // sfcdb.RollbackTrain(); // if (sfcdb != null) this.DBPools["SFCDB"].Return(sfcdb); // throw ex; //} //StationReturn.Status = StationReturnStatusValue.Pass; //StationReturn.MessageCode = "MES00000004"; //StationReturn.Data = ""; //if (sfcdb != null) this.DBPools["SFCDB"].Return(sfcdb); }