Exemplo n.º 1
0
        ///<summary>Returns the login attempts for the given user in the last X minutes.</summary>
        public static int CountForUser(string userName, UserWebFKeyType type, int lastXMinutes)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                return(Meth.GetObject <int>(MethodBase.GetCurrentMethod(), userName, type, lastXMinutes));
            }
            string command = $@"SELECT COUNT(*) FROM loginattempt WHERE UserName='******' AND LoginType={POut.Int((int)type)}
				AND DateTFail >= {DbHelper.DateAddMinute("NOW()",POut.Int(-lastXMinutes))}"                ;

            return(PIn.Int(Db.GetCount(command)));
        }
Exemplo n.º 2
0
        /// <summary>When starting up, in an attempt to be fast, it will not add a new computer to the list.</summary>
        public static void UpdateHeartBeat(string computerName, bool isStartup)
        {
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), computerName, isStartup);
                return;
            }
            string command;

            if (!isStartup)
            {
                if (_computerCache.ListIsNull())
                {
                    RefreshCache();                    //adds new computer to list
                }
                command = "SELECT LastHeartBeat<" + DbHelper.DateAddMinute(DbHelper.Now(), "-3") + " FROM computer WHERE CompName='" + POut.String(computerName) + "'";
                if (!PIn.Bool(Db.GetScalar(command))) //no need to update if LastHeartBeat is already within the last 3 mins
                {
                    return;                           //remote app servers with multiple connections would fight over the lock on a single row to update the heartbeat unnecessarily
                }
            }
            command = "UPDATE computer SET LastHeartBeat=" + DbHelper.Now() + " WHERE CompName = '" + POut.String(computerName) + "'";
            Db.NonQ(command);
        }