Exemplo n.º 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);
            }
        }
Exemplo n.º 2
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);
            }
        }