public R_SYNC_LOCK GetDataObject() { R_SYNC_LOCK DataObject = new R_SYNC_LOCK(); DataObject.ID = this.ID; DataObject.LOCK_NAME = this.LOCK_NAME; DataObject.LOCK_KEY = this.LOCK_KEY; DataObject.LOCK_TIME_LONG = this.LOCK_TIME_LONG; DataObject.LOCK_TIME = this.LOCK_TIME; DataObject.EDIT_EMP = this.EDIT_EMP; DataObject.LOCK_IP = this.LOCK_IP; return(DataObject); }
public R_SYNC_LOCK GetSYNCLockID(string ItemName, OleExec DB, DB_TYPE_ENUM DBType) { string StrSql = $@"SELECT * From R_SYNC_LOCK where Lock_Name='{ItemName}' "; DataTable dt = DB.ExecSelect(StrSql).Tables[0]; R_SYNC_LOCK Row_SYNC = new R_SYNC_LOCK(); if (dt.Rows.Count > 0) { Row_SYNC.ID = dt.Rows[0]["ID"].ToString(); } return(Row_SYNC); }
/// <summary> /// add by fgg 2018.03.14 Check sync lock,if locked return lock ip /// </summary> /// <param name="lockName"></param> /// <param name="DB"></param> /// <param name="DBType"></param> /// <param name="ip"></param> /// <returns></returns> public bool IsLock(string lockName, OleExec DB, DB_TYPE_ENUM DBType, out string ip) { R_SYNC_LOCK lockObject = new R_SYNC_LOCK(); lockObject = GetSYNCLockObject(lockName, DB, DBType); if (lockObject == null) { ip = ""; return(false); } else { ip = lockObject.LOCK_IP; return(true); } }
/// <summary> /// 檢查運行項目是否被鎖 /// </summary> /// <param name="BU"></param> /// <param name="IP"></param> /// <param name="Program_Name"></param> /// <param name="ItemName"></param> /// <param name="Emp_No"></param> /// <param name="DB"></param> /// <param name="DBType"></param> /// <returns></returns> public bool Check_SYNC_Lock(string BU, string IP, string Program_Name, string ItemName, string Emp_No, OleExec DB, DB_TYPE_ENUM DBType) { string Message = ""; //string StrSql = $@"SELECT * From R_SYNC_LOCK where Lock_Name='{ItemName}' "; //DataTable dt = DB.ExecSelect(StrSql).Tables[0]; R_SYNC_LOCK SYNC_Lock = new R_SYNC_LOCK(); SYNC_Lock = GetSYNCLockID(ItemName, DB, DBType); if (SYNC_Lock == null) { return(true); } else { Message = ItemName + "正在被其他人使用!"; //WriteLog(BU, Program_Name, ItemName, Message, StrSql, Emp_No, DB, DBType); return(false); } }
/// <summary> /// 程式完,釋放鎖 /// </summary> /// <param name="BU"></param> /// <param name="IP"></param> /// <param name="Program_Name"></param> /// <param name="ItemName"></param> /// <param name="Emp_No"></param> /// <param name="DB"></param> /// <param name="DBType"></param> /// <returns></returns> public bool SYNC_UnLock(string BU, string IP, string Program_Name, string ItemName, string Emp_No, OleExec DB, DB_TYPE_ENUM DBType) { string ID = GetNewID(BU, DB); T_R_SYNC_LOCK R_SYNC_LOCK = new T_R_SYNC_LOCK(DB, DBType); Row_R_SYNC_LOCK Rows = (Row_R_SYNC_LOCK)R_SYNC_LOCK.NewRow(); R_SYNC_LOCK SYNC_Lock = new R_SYNC_LOCK(); SYNC_Lock = GetSYNCLockID(ItemName, DB, DBType); if (SYNC_Lock != null) { //Rows.ID = SYNC_Lock.ID; string result = DB.ExecSQL(Rows.GetDeleteString(DBType, SYNC_Lock.ID)); try { int rows = int.Parse(result); if (rows > 0) { return(true); } else { return(false); } } catch { return(false); } } else { return(true); } }