public Boolean CreatePanel(Hashtable temp, MESDBHelper.OleExec SFCDB, MESDataObject.DB_TYPE_ENUM _DBType) { try { T_R_PANEL_SN tPanel = new T_R_PANEL_SN(SFCDB, _DBType); Row_R_PANEL_SN rPanel = (Row_R_PANEL_SN)tPanel.NewRow(); rPanel.ID = tPanel.GetNewID(temp["BU"].ToString(), SFCDB); rPanel.PANEL = temp["Panel"].ToString(); rPanel.SN = rPanel.ID; rPanel.WORKORDERNO = temp["WO"].ToString(); rPanel.SEQ_NO = 0; rPanel.EDIT_EMP = temp["User"].ToString(); rPanel.EDIT_TIME = DateTime.Now; string strRet = SFCDB.ExecSQL(rPanel.GetInsertString(_DBType)); if (Convert.ToInt32(strRet) > 0) { return(true); } return(false); } catch (Exception e) { throw e; } }
public void DeleteEditPrivilege(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow(); string LoginUserEmp = Data["LoginUserEmp"].ToString().ToUpper(); string EditEmp = Data["EditEmp"].ToString().ToUpper(); string deleteSQL = ""; SFCDB.BeginTrain(); try { MESDataObject.Module.T_C_USER_PRIVILEGE tcp = new MESDataObject.Module.T_C_USER_PRIVILEGE(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_USER_PRIVILEGE rcp = (MESDataObject.Module.Row_C_USER_PRIVILEGE)tcp.NewRow(); foreach (string item in Data["PRS"]) { rcp = tcp.getC_PrivilegebyID(item, SFCDB); deleteSQL += rcp.GetDeleteString(this.DBTYPE) + ";\n"; } SFCDB.ExecSQL("Begin\n" + deleteSQL + "End;"); SFCDB.CommitTrain(); StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.Message = "刪除權限成功!!!"; this.DBPools["SFCDB"].Return(SFCDB); } catch (Exception ex) { SFCDB.RollbackTrain(); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "刪除權限失!"; StationReturn.Data = ex.Message.ToString(); this.DBPools["SFCDB"].Return(SFCDB); } }
public Boolean AddSnToPanel(Hashtable temp, MESDBHelper.OleExec SFCDB, MESDataObject.DB_TYPE_ENUM _DBType) { string strSn = temp["SN"].ToString(); SN sn = new SN(strSn, SFCDB, _DBType); string wo = sn.WorkorderNo; if (wo != this.PanelCollection[0].WORKORDERNO) { return(false); } T_R_PANEL_SN tPanel = new T_R_PANEL_SN(SFCDB, _DBType); Row_R_PANEL_SN rPanel = (Row_R_PANEL_SN)tPanel.NewRow(); rPanel.ID = tPanel.GetNewID(temp["BU"].ToString(), SFCDB); rPanel.SN = temp["SNID"].ToString(); rPanel.PANEL = this.PanelNo; rPanel.WORKORDERNO = wo; rPanel.SEQ_NO = this.PanelCollection.Count; rPanel.EDIT_EMP = temp["User"].ToString(); rPanel.EDIT_TIME = DateTime.Now; string strRet = SFCDB.ExecSQL(rPanel.GetInsertString(_DBType)); if (Convert.ToInt32(strRet) > 0) { this.PanelCollection.Add(rPanel.GetDataObject()); return(true); } return(false); }
public Boolean DeletePanelByID(string strID, MESDBHelper.OleExec SFCDB, MESDataObject.DB_TYPE_ENUM _DBType) { try { T_R_PANEL_SN tPanel = new T_R_PANEL_SN(SFCDB, _DBType); Row_R_PANEL_SN rPanel = (Row_R_PANEL_SN)tPanel.GetObjByID(strID, SFCDB, _DBType); string strRet = SFCDB.ExecSQL(rPanel.GetDeleteString(_DBType)); if (Convert.ToInt32(strRet) > 0) { return(true); } return(false); } catch (Exception e) { throw e; } }
/// <summary> /// 創建權限對應的ID /// </summary> public void CreatePrivilegeID(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow(); MESDataObject.Module.T_C_PRIVILEGE RolerPrivilege = new MESDataObject.Module.T_C_PRIVILEGE(SFCDB, DB_TYPE_ENUM.Oracle); MESDataObject.Module.Row_C_PRIVILEGE RolerPrivilegeRow = (MESDataObject.Module.Row_C_PRIVILEGE)RolerPrivilege.NewRow(); string PRIVILEGE_ID = Data["PRIVILEGE_ID"].ToString(); string PRIVILEGE_NAME = Data["PRIVILEGE_NAME"].ToString(); DataTable StrRes = new DataTable(); StrRes = RolerPrivilege.CheckPrivilegeID(PRIVILEGE_ID, PRIVILEGE_NAME, SFCDB, this.DBTYPE); if (StrRes.Rows.Count != 0) { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "創建權限ID失敗!"; } else { RolerPrivilegeRow.ID = RolerPrivilege.GetNewID(BU, SFCDB); RolerPrivilegeRow.MENU_ID = Data["MENU_ID"].ToString(); RolerPrivilegeRow.PRIVILEGE_NAME = Data["PRIVILEGE_NAME"].ToString(); RolerPrivilegeRow.PRIVILEGE_DESC = Data["PRIVILEGE_DESC"].ToString(); RolerPrivilegeRow.EDIT_TIME = DateTime.Now; RolerPrivilegeRow.EDIT_EMP = Data["EDIT_EMP"].ToString(); string STRRES = SFCDB.ExecSQL(RolerPrivilegeRow.GetInsertString(this.DBTYPE)); if (STRRES == "1") { StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.Message = "創建權限ID成功!"; } else { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "權限ID已存在!"; } } this.DBPools["SFCDB"].Return(SFCDB); }
/// <summary> /// 點擊新增權限保存按鈕時,為用戶添加ModelType權限 /// </summary> public void AddUserPrivilegeForModelType(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow(); string EditEmpID = Data["EditEmpID"].ToString().ToUpper(); string LoginUserEmp = Data["LoginUserEmp"].ToString().ToUpper(); string insql = ""; SFCDB.BeginTrain(); try { MESDataObject.Module.T_C_MODEL_USER tCModelUser = new MESDataObject.Module.T_C_MODEL_USER(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_MODEL_USER rCModelUser = (MESDataObject.Module.Row_C_MODEL_USER)tCModelUser.NewRow(); foreach (string item in Data["ID_ITEMS"]) { //去除C_Model_Type.ID的前后引號 string strTypeID = item.Trim('\'').Trim('\"'); rCModelUser.TYPE_ID = strTypeID; rCModelUser.USER_ID = EditEmpID; rCModelUser.EDIT_EMP = LoginUserEmp; rCModelUser.EDIT_TIME = DateTime.Now; rCModelUser.ID = tCModelUser.GetNewID(BU, SFCDB); insql += rCModelUser.GetInsertString(this.DBTYPE) + ";\n"; } SFCDB.ExecSQL("Begin\n" + insql + "End;"); StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.Message = "權限添加成功!!"; SFCDB.CommitTrain(); } catch (Exception ex) { SFCDB.RollbackTrain(); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "新增權限失敗!"; StationReturn.Data = ex.Message.ToString(); } finally { this.DBPools["SFCDB"].Return(SFCDB); } }
public void UpLoadKPList(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = this.DBPools["SFCDB"].Borrow(); SFCDB.BeginTrain(); try { string Skuno = Data["SkuNo"].ToString(); string ListName = Data["ListName"].ToString(); Newtonsoft.Json.Linq.JToken ListData = Data["ListData"]; T_C_KP_LIST T = new T_C_KP_LIST(SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle); string NewListID = T.GetNewID(this.BU, SFCDB); Row_C_KP_LIST R = (Row_C_KP_LIST)T.NewRow(); DateTime Now = DateTime.Now; T_C_KP_List_Item TItem = new T_C_KP_List_Item(SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle); Row_C_KP_List_Item RItem = (Row_C_KP_List_Item)TItem.NewRow(); T_C_KP_List_Item_Detail TDetail = new T_C_KP_List_Item_Detail(SFCDB, MESDataObject.DB_TYPE_ENUM.Oracle); Row_C_KP_List_Item_Detail RDetail = (Row_C_KP_List_Item_Detail)TDetail.NewRow(); KPListBase oldList = KPListBase.GetKPListByListName(ListName, SFCDB); if (oldList != null) { oldList.ReMoveFromDB(SFCDB); } R.ID = NewListID; R.SKUNO = Skuno.Trim(); R.LISTNAME = ListName; R.EDIT_EMP = this.LoginUser.EMP_NO; R.EDIT_TIME = Now; SFCDB.ExecSQL(R.GetInsertString(MESDataObject.DB_TYPE_ENUM.Oracle)); //Item PartNO KPName Station QTY ScanType DataTable dt = new DataTable(); dt.Columns.Add("Item"); dt.Columns.Add("PartNO"); dt.Columns.Add("KPName"); dt.Columns.Add("Station"); dt.Columns.Add("QTY"); dt.Columns.Add("ScanType"); List <DataRow> ListItem = new List <DataRow>(); for (int i = 0; i < ListData.Count(); i++) { DataRow dr = dt.NewRow(); dr["Item"] = ListData[i]["Item"].ToString(); dr["PartNO"] = ListData[i]["PartNO"].ToString(); dr["KPName"] = ListData[i]["KPName"].ToString(); dr["Station"] = ListData[i]["Station"].ToString(); dr["QTY"] = ListData[i]["QTY"].ToString(); dr["ScanType"] = ListData[i]["ScanType"].ToString(); dt.Rows.Add(dr); ListItem.Add(dr); } Dictionary <string, string> Item = new Dictionary <string, string>(); for (int i = 0; i < dt.Rows.Count; i++) { if (!Item.ContainsKey(dt.Rows[i]["Item"].ToString())) { Item.Add(dt.Rows[i]["Item"].ToString(), dt.Rows[i]["PartNO"].ToString()); } } string[] itemNo = new string[Item.Keys.Count]; Item.Keys.CopyTo(itemNo, 0); for (int i = 0; i < itemNo.Length; i++) { List <DataRow> Items = ListItem.FindAll(TT => TT["Item"].ToString() == itemNo[i]); for (int j = 0; j < Items.Count; j++) { if (j == 0) { RItem.ID = TItem.GetNewID(BU, SFCDB); RItem.LIST_ID = NewListID; RItem.KP_NAME = Items[j]["KPName"].ToString(); RItem.KP_PARTNO = Items[j]["PartNO"].ToString(); RItem.STATION = Items[j]["Station"].ToString(); RItem.QTY = double.Parse(Items[j]["QTY"].ToString()); RItem.SEQ = i; RItem.EDIT_EMP = this.LoginUser.EMP_NO; RItem.EDIT_TIME = Now; SFCDB.ExecSQL(RItem.GetInsertString(MESDataObject.DB_TYPE_ENUM.Oracle)); } RDetail.ID = TDetail.GetNewID(BU, SFCDB); RDetail.ITEM_ID = RItem.ID; RDetail.SCANTYPE = Items[j]["ScanType"].ToString(); RDetail.SEQ = j + 1; RDetail.EDIT_EMP = RItem.EDIT_EMP; RDetail.EDIT_TIME = Now; SFCDB.ExecSQL(RDetail.GetInsertString(MESDataObject.DB_TYPE_ENUM.Oracle)); } } StationReturn.Status = StationReturnStatusValue.Pass; } catch (Exception ee) { SFCDB.RollbackTrain(); this.DBPools["SFCDB"].Return(SFCDB); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000037"; StationReturn.MessagePara.Add(ee.Message); return; } SFCDB.CommitTrain(); this.DBPools["SFCDB"].Return(SFCDB); }
public void ScanKPItem(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = this.DBPools["SFCDB"].Borrow(); SFCDB.BeginTrain(); try { /* * new APIInputInfo() {InputName = "SN", InputType = "STRING", DefaultValue = ""}, * new APIInputInfo() {InputName = "STATION", InputType = "STRING", DefaultValue = ""}, * new APIInputInfo() {InputName = "KPITEM", InputType = "STRING", DefaultValue = ""} */ string strSN = Data["SN"].ToString(); string station = Data["STATION"].ToString(); JToken _ItemData = Data["KPITEM"]; T_R_SN_KP TRKP = new T_R_SN_KP(SFCDB, DB_TYPE_ENUM.Oracle); List <R_SN_KP> ItemData = new List <R_SN_KP>(); for (int i = 0; i < _ItemData.Count(); i++) { if (TRKP.CheckLinkByValue(_ItemData[i]["VALUE"].ToString(), SFCDB)) { throw new Exception(_ItemData[i]["VALUE"].ToString() + " has been link on other sn!"); } R_SN_KP I = new R_SN_KP(); I.ID = _ItemData[i]["ID"].ToString(); I.VALUE = _ItemData[i]["VALUE"].ToString(); I.MPN = _ItemData[i]["MPN"].ToString(); I.PARTNO = _ItemData[i]["PARTNO"].ToString(); I.SCANTYPE = _ItemData[i]["SCANTYPE"].ToString(); I.ITEMSEQ = double.Parse(_ItemData[i]["ITEMSEQ"].ToString()); I.SCANSEQ = double.Parse(_ItemData[i]["SCANSEQ"].ToString()); I.DETAILSEQ = double.Parse(_ItemData[i]["DETAILSEQ"].ToString()); ItemData.Add(I); } if (ItemData.Count == 0) { StationReturn.Status = StationReturnStatusValue.Pass; } LogicObject.SN SN = new LogicObject.SN(); SN.Load(strSN, SFCDB, DB_TYPE_ENUM.Oracle); MESDataObject.Module.T_R_WO_BASE TWO = new T_R_WO_BASE(SFCDB, DB_TYPE_ENUM.Oracle); Row_R_WO_BASE RWO = TWO.GetWo(SN.WorkorderNo, SFCDB); List <R_SN_KP> snkp = TRKP.GetKPRecordBySnIDStation(SN.ID, station, SFCDB); SN_KP KPCONFIG = new SN_KP(snkp, SN.WorkorderNo, SN.SkuNo, SFCDB); R_SN_KP kpItem = KPCONFIG.KPS.Find(T => T.ID == ItemData[0].ID); if (kpItem == null) { throw new Exception("Data Error!"); } List <R_SN_KP> ConfigItem = KPCONFIG.KPS.FindAll(T => T.PARTNO == kpItem.PARTNO && T.ITEMSEQ == kpItem.ITEMSEQ && T.SCANSEQ == kpItem.SCANSEQ ); if (ConfigItem.Count != ItemData.Count) { throw new Exception("Data Error! ConfigItem.Count != ItemData.Count"); } for (int i = 0; i < ItemData.Count; i++) { Row_R_SN_KP item = (Row_R_SN_KP)TRKP.GetObjByID(ItemData[i].ID, SFCDB); if (item.ITEMSEQ == ItemData[i].ITEMSEQ && item.SCANSEQ == ItemData[i].SCANSEQ && item.DETAILSEQ == ItemData[i].DETAILSEQ) { item.VALUE = ItemData[i].VALUE; item.MPN = ItemData[i].MPN; item.PARTNO = ItemData[i].PARTNO; item.EDIT_TIME = DateTime.Now; item.EDIT_EMP = LoginUser.EMP_NO; SFCDB.ExecSQL(item.GetUpdateString(DB_TYPE_ENUM.Oracle)); } else { throw new Exception("Data Error! 1"); } } StationReturn.Status = StationReturnStatusValue.Pass; SFCDB.CommitTrain(); } catch (Exception ee) { SFCDB.RollbackTrain(); //this.DBPools["SFCDB"].Return(SFCDB); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000037"; StationReturn.MessagePara.Add(ee.Message); } this.DBPools["SFCDB"].Return(SFCDB); }
public void ScanKPItem(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = this.DBPools["SFCDB"].Borrow(); SFCDB.BeginTrain(); try { /* * new APIInputInfo() {InputName = "SN", InputType = "STRING", DefaultValue = ""}, * new APIInputInfo() {InputName = "STATION", InputType = "STRING", DefaultValue = ""}, * new APIInputInfo() {InputName = "KPITEM", InputType = "STRING", DefaultValue = ""} */ string strSN = Data["SN"].ToString(); string station = Data["STATION"].ToString(); JToken _ItemData = Data["KPITEM"]; T_R_SN_KP TRKP = new T_R_SN_KP(SFCDB, DB_TYPE_ENUM.Oracle); T_R_SN t_r_sn = new T_R_SN(SFCDB, DB_TYPE_ENUM.Oracle); List <R_SN_KP> ItemData = new List <R_SN_KP>(); for (int i = 0; i < _ItemData.Count(); i++) { //已被綁定的就不能重複綁定 if (TRKP.CheckLinkByValue(_ItemData[i]["VALUE"].ToString(), SFCDB)) { throw new Exception(_ItemData[i]["VALUE"].ToString() + " has been link on other sn!"); } R_SN r_sn = new R_SN(); r_sn = t_r_sn.LoadSN(_ItemData[i]["VALUE"].ToString(), SFCDB); //如果KEYPART是本廠做的條碼則必須是完工狀態 if (r_sn != null && r_sn.COMPLETED_FLAG != "1") { throw new Exception(_ItemData[i]["VALUE"].ToString() + " is on " + r_sn.NEXT_STATION + ",can't completed!"); } R_SN_KP I = new R_SN_KP(); I.ID = _ItemData[i]["ID"].ToString(); I.VALUE = _ItemData[i]["VALUE"].ToString(); I.MPN = _ItemData[i]["MPN"].ToString(); I.PARTNO = _ItemData[i]["PARTNO"].ToString(); I.SCANTYPE = _ItemData[i]["SCANTYPE"].ToString(); I.ITEMSEQ = double.Parse(_ItemData[i]["ITEMSEQ"].ToString()); I.SCANSEQ = double.Parse(_ItemData[i]["SCANSEQ"].ToString()); I.DETAILSEQ = double.Parse(_ItemData[i]["DETAILSEQ"].ToString()); ItemData.Add(I); } if (ItemData.Count == 0) { StationReturn.Status = StationReturnStatusValue.Pass; } LogicObject.SN SN = new LogicObject.SN(); SN.Load(strSN, SFCDB, DB_TYPE_ENUM.Oracle); MESDataObject.Module.T_R_WO_BASE TWO = new T_R_WO_BASE(SFCDB, DB_TYPE_ENUM.Oracle); Row_R_WO_BASE RWO = TWO.GetWo(SN.WorkorderNo, SFCDB); List <R_SN_KP> snkp = TRKP.GetKPRecordBySnIDStation(SN.ID, station, SFCDB); SN_KP KPCONFIG = new SN_KP(snkp, SN.WorkorderNo, SN.SkuNo, SFCDB); R_SN_KP kpItem = KPCONFIG.KPS.Find(T => T.ID == ItemData[0].ID); if (kpItem == null) { throw new Exception("Data Error!"); } List <R_SN_KP> ConfigItem = KPCONFIG.KPS.FindAll(T => T.PARTNO == kpItem.PARTNO && T.ITEMSEQ == kpItem.ITEMSEQ && T.SCANSEQ == kpItem.SCANSEQ ); if (ConfigItem.Count != ItemData.Count) { throw new Exception("Data Error! ConfigItem.Count != ItemData.Count"); } List <Row_R_SN_KP> items = new List <Row_R_SN_KP>(); for (int i = 0; i < ItemData.Count; i++) { Row_R_SN_KP item = (Row_R_SN_KP)TRKP.GetObjByID(ItemData[i].ID, SFCDB); if (item.ITEMSEQ == ItemData[i].ITEMSEQ && item.SCANSEQ == ItemData[i].SCANSEQ && item.DETAILSEQ == ItemData[i].DETAILSEQ) { item.VALUE = ItemData[i].VALUE; item.MPN = ItemData[i].MPN; item.PARTNO = ItemData[i].PARTNO; item.EDIT_TIME = DateTime.Now; item.EDIT_EMP = LoginUser.EMP_NO; SFCDB.ExecSQL(item.GetUpdateString(DB_TYPE_ENUM.Oracle)); item.AcceptChange(); items.Add(item); } else { throw new Exception("Data Error! 1"); } } for (int i = 0; i < items.Count; i++) { var ScanTypes = SFCDB.ORM.Queryable <C_KP_Check>().Where(t => t.TYPENAME == items[i].SCANTYPE).ToList(); if (ScanTypes.Count > 0) { Assembly assembly = Assembly.LoadFile(AppDomain.CurrentDomain.BaseDirectory + ScanTypes[0].DLL); Type APIType = assembly.GetType(ScanTypes[0].CLASS); object API_CLASS = assembly.CreateInstance(ScanTypes[0].CLASS); var Methods = APIType.GetMethods(); var Funs = Methods.Where <MethodInfo>(t => t.Name == ScanTypes[0].FUNCTION); if (Funs.Count() > 0) { Funs.ElementAt(0).Invoke(API_CLASS, new object[] { KPCONFIG, SN, items[i], items, this, SFCDB }); } } } StationReturn.Status = StationReturnStatusValue.Pass; SFCDB.CommitTrain(); } catch (Exception ee) { SFCDB.RollbackTrain(); //this.DBPools["SFCDB"].Return(SFCDB); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000037"; if (ee.InnerException != null) { StationReturn.MessagePara.Add(ee.InnerException.Message); } else { StationReturn.MessagePara.Add(ee.Message); } } this.DBPools["SFCDB"].Return(SFCDB); }
public void UpLoadLabelFile(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { string LabelName = Data["LabelName"].ToString(); string PrintType = Data["PrintType"].ToString(); string ArryLength = Data["ArryLength"].ToString(); MESDBHelper.OleExec SFCDB = this.DBPools["SFCDB"].Borrow(); SFCDB.BeginTrain(); try { T_R_FILE TRF = new T_R_FILE(SFCDB, DB_TYPE_ENUM.Oracle); Row_R_FILE RRF = (Row_R_FILE)TRF.NewRow(); RRF.ID = TRF.GetNewID(BU, SFCDB); RRF.NAME = Data["Name"].ToString(); RRF.FILENAME = Data["FileName"].ToString(); RRF.MD5 = Data["MD5"].ToString(); RRF.USETYPE = Data["UseType"].ToString(); RRF.STATE = "1"; RRF.VALID = 1; //不使用CLOB字段 //RRF.CLOB_FILE = ":CLOB_FILE";// Data["Bas64File"].ToString(); RRF.BLOB_FILE = ":BLOB_FILE"; RRF.EDIT_EMP = LoginUser.EMP_NO; RRF.EDIT_TIME = DateTime.Now; SFCDB.ThrowSqlExeception = true; //將同類文件改為歷史版本 TRF.SetFileDisableByName(RRF.NAME, RRF.USETYPE, SFCDB); string strSql = RRF.GetInsertString(this.DBTYPE); strSql = strSql.Replace("':CLOB_FILE'", ":CLOB_FILE"); strSql = strSql.Replace("':BLOB_FILE'", ":BLOB_FILE"); System.Data.OleDb.OleDbParameter p = new System.Data.OleDb.OleDbParameter(":BLOB_FILE", System.Data.OleDb.OleDbType.Binary); string B64 = Data["Bas64File"].ToString(); string b64 = B64.Remove(0, B64.LastIndexOf(',') + 1); byte[] data = Convert.FromBase64String(b64); p.Value = data; //new System.Data.OleDb.OleDbParameter(":CLOB_FILE", Data["Bas64File"].ToString()), SFCDB.ExecSqlNoReturn(strSql, new System.Data.OleDb.OleDbParameter[] { p }); T_R_Label TRL = new T_R_Label(SFCDB, DB_TYPE_ENUM.Oracle); Row_R_Label RRL = TRL.GetLabelConfigByLabelName(LabelName, SFCDB); if (RRL == null) { RRL = (Row_R_Label)TRL.NewRow(); RRL.ID = TRL.GetNewID(BU, SFCDB); RRL.LABELNAME = LabelName; RRL.R_FILE_NAME = RRF.FILENAME; RRL.PRINTTYPE = PrintType; RRL.ARRYLENGTH = double.Parse(ArryLength); strSql = RRL.GetInsertString(DB_TYPE_ENUM.Oracle); } else { RRL.LABELNAME = LabelName; RRL.R_FILE_NAME = RRF.FILENAME; RRL.PRINTTYPE = PrintType; RRL.ARRYLENGTH = double.Parse(ArryLength); strSql = RRL.GetUpdateString(DB_TYPE_ENUM.Oracle); } string strRes = SFCDB.ExecSQL(strSql); //SFCDB.ExecSQL(RRF.GetInsertString(this.DBTYPE)); SFCDB.CommitTrain(); StationReturn.Status = StationReturnStatusValue.Pass; } catch (Exception ee) { SFCDB.RollbackTrain(); //this.DBPools["SFCDB"].Return(SFCDB); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.MessageCode = "MES00000037"; StationReturn.MessagePara.Add(ee.Message); } SFCDB.ThrowSqlExeception = false; this.DBPools["SFCDB"].Return(SFCDB); this.DBPools["SFCDB"].Return(SFCDB); }
public void CreatUserPrivilege(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow(); string GEMP_NO = Data["GEMP_NO"].ToString().ToUpper(); string SEMP_NO = Data["SEMP_NO"].ToString().ToUpper(); string EMP_ID = "", P_code = ""; SFCDB.BeginTrain(); try { MESDataObject.Module.T_c_user GetInformation = new MESDataObject.Module.T_c_user(SFCDB, this.DBTYPE); MESDataObject.Module.T_C_USER_PRIVILEGE tcup = new MESDataObject.Module.T_C_USER_PRIVILEGE(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_USER_PRIVILEGE rcup = (MESDataObject.Module.Row_C_USER_PRIVILEGE)tcup.NewRow(); MESDataObject.Module.T_C_MENU tcm = new MESDataObject.Module.T_C_MENU(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_MENU rcm = (MESDataObject.Module.Row_C_MENU)tcm.NewRow(); DataTable dt = GetInformation.SelectC_Userbyempno(SEMP_NO, SFCDB, this.DBTYPE); EMP_ID = dt.Rows[0]["ID"].ToString(); string insql = ""; if (dt.Rows.Count > 0) { foreach (string item in Data["ID_ITEMS"]) { string p_id = item.Trim('\'').Trim('\"'); rcup.ID = tcup.GetNewID(BU, SFCDB); rcup.SYSTEM_NAME = SystemName; rcup.USER_ID = EMP_ID; rcup.PRIVILEGE_ID = p_id; rcup.EDIT_EMP = GEMP_NO; rcup.EDIT_TIME = DateTime.Now; insql += rcup.GetInsertString(this.DBTYPE) + ";\n"; P_code += p_id + ","; do { rcm = tcm.getC_MenubyID(p_id, SFCDB); if (rcm.PARENT_CODE != "0") { p_id = rcm.PARENT_CODE; if (P_code.IndexOf(rcm.PARENT_CODE) < 0 && tcup.getC_PrivilegebyIDemp(rcm.PARENT_CODE, SEMP_NO, SFCDB) == null) { rcup.ID = tcup.GetNewID(BU, SFCDB); rcup.SYSTEM_NAME = SystemName; rcup.USER_ID = EMP_ID; rcup.PRIVILEGE_ID = rcm.PARENT_CODE; rcup.EDIT_EMP = GEMP_NO; rcup.EDIT_TIME = DateTime.Now; insql += rcup.GetInsertString(this.DBTYPE) + ";\n"; P_code += rcm.PARENT_CODE + ","; } } } while (rcm.PARENT_CODE != "0"); } SFCDB.ExecSQL("Begin\n" + insql + "End;"); SFCDB.CommitTrain(); StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.Message = "保存成功!!"; } else { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "找不到用戶信息!"; StationReturn.Data = ""; } this.DBPools["SFCDB"].Return(SFCDB); } catch (Exception ex) { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "刪權限失敗!!"; StationReturn.Data = ex.Message.ToString(); this.DBPools["SFCDB"].Return(SFCDB); } }