示例#1
0
        /// <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_Lock(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();

            Rows.ID             = ID;
            Rows.LOCK_NAME      = ItemName;
            Rows.LOCK_KEY       = "1";
            Rows.LOCK_TIME_LONG = 5;
            Rows.EDIT_EMP       = Emp_No;
            Rows.LOCK_TIME      = System.DateTime.Now;
            Rows.LOCK_IP        = IP;
            Rows.GetInsertString(DBType);
            string result = DB.ExecSQL(Rows.GetInsertString(DBType));

            try
            {
                int rows = int.Parse(result);
                if (rows > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// add by fgg 2018.03.14 Get Lock Object
        /// </summary>
        /// <param name="lockName"></param>
        /// <param name="db"></param>
        /// <param name="dbType"></param>
        /// <returns></returns>
        public R_SYNC_LOCK GetSYNCLockObject(string lockName, OleExec db, DB_TYPE_ENUM dbType)
        {
            string          StrSql   = $@"SELECT * From R_SYNC_LOCK where Lock_Name='{lockName}' ";
            DataTable       dt       = db.ExecSelect(StrSql).Tables[0];
            Row_R_SYNC_LOCK Row_SYNC = (Row_R_SYNC_LOCK)this.NewRow();

            if (dt.Rows.Count > 0)
            {
                Row_SYNC.loadData(dt.Rows[0]);
                return(Row_SYNC.GetDataObject());
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        /// <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);
            }
        }