Пример #1
0
        public Dictionary<string, bool> GetAllPaths()
        {
            StringBuilder queryBuilder = new StringBuilder();

            queryBuilder.AppendFormat( "SELECT PATH, WEAK_PROTECTION FROM FILESYSTEM" );

            SqlCore sql = new SqlCore( DataUtils.GetConnectionString() );

            sql.Open();

            var reader = sql.DoQuery( queryBuilder.ToString() );

            var dictionary = new Dictionary<string, bool>();

            while ( reader.Read() )
            {
                string path = reader[ "PATH" ].ToString();
                bool weakProtection = Convert.ToInt32( reader[ "WEAK_PROTECTION" ].ToString() ) > 0;

                dictionary.Add( path, weakProtection );
            }

            sql.Close();

            return dictionary;
        }
Пример #2
0
        public bool HasPasswords()
        {
            StringBuilder queryBuilder = new StringBuilder();

            queryBuilder.AppendFormat( "SELECT COUNT(*) FROM ACCOUNT" );

            SqlCore sql = new SqlCore( DataUtils.GetConnectionString() );
            sql.Open();
            int num = Convert.ToInt32( sql.DoScalarQuery( queryBuilder.ToString() ) );
            sql.Close();

            return num > 0;
        }
Пример #3
0
        public bool DeletePassword(string password)
        {
            StringBuilder queryBuilder = new StringBuilder();

            string pswd = password.Replace( "'", "''" );

            queryBuilder.AppendFormat( "DELETE FROM ACCOUNT WHERE PASSWORD = '******'", pswd );

            SqlCore sql = new SqlCore( DataUtils.GetConnectionString() );
            sql.Open();
            int num = sql.DoNonQuery( queryBuilder.ToString() );
            sql.Close();

            return num > 0;
        }
Пример #4
0
        public bool CheckPassword( string password )
        {
            StringBuilder queryBuilder = new StringBuilder();

            string pswd = password.Replace( "'", "''" );

            queryBuilder.AppendFormat( "SELECT COUNT(*) FROM ACCOUNT WHERE PASSWORD = '******'", pswd );

            SqlCore sql = new SqlCore( DataUtils.GetConnectionString() );
            sql.Open();
            int num = Convert.ToInt32(sql.DoScalarQuery( queryBuilder.ToString() ));
            sql.Close();

            return num > 0;
        }
Пример #5
0
        public bool ExistsPath( string path )
        {
            StringBuilder queryBuilder = new StringBuilder();

            path = path.Replace( "'", "''" );

            queryBuilder.AppendFormat( "SELECT COUNT(*) FROM FILESYSTEM WHERE PATH = '{0}'", path );

            SqlCore sql = new SqlCore( DataUtils.GetConnectionString() );
            sql.Open();
            int num = Convert.ToInt32( sql.DoScalarQuery( queryBuilder.ToString() ) );
            sql.Close();

            return num > 0;
        }
Пример #6
0
        public bool DeletePath( string path )
        {
            StringBuilder queryBuilder = new StringBuilder();

            path = path.Replace( "'", "''" );

            queryBuilder.AppendFormat( "DELETE FROM FILESYSTEM WHERE PATH = '{0}'", path );

            SqlCore sql = new SqlCore( DataUtils.GetConnectionString() );
            sql.Open();
            int num = sql.DoNonQuery( queryBuilder.ToString() );
            sql.Close();

            return num > 0;
        }
Пример #7
0
        public bool ChangePassword(string oldPassword, string newPassword)
        {
            StringBuilder queryBuilder = new StringBuilder();

            string oldPswd = oldPassword.Replace( "'", "''" );
            string newPswd = newPassword.Replace( "'", "''" );

            queryBuilder.AppendFormat( "UPDATE ACCOUNT SET PASSWORD = '******' WHERE PASSWORD = '******'", oldPswd, newPswd );

            SqlCore sql = new SqlCore( DataUtils.GetConnectionString() );
            sql.Open();
            int num = sql.DoNonQuery( queryBuilder.ToString() );
            sql.Close();

            return num > 0;
        }
Пример #8
0
        public bool InsertPassword( string password )
        {
            StringBuilder queryBuilder = new StringBuilder();

            string pswd = password.Replace( "'", "''" );

            queryBuilder.AppendFormat( "INSERT INTO ACCOUNT (PASSWORD) VALUES ('{0}')", pswd );

            SqlCore sql = new SqlCore( DataUtils.GetConnectionString() );
            sql.Open();
            int num = sql.DoNonQuery( queryBuilder.ToString() );
            sql.Close();

            return num > 0;
        }
Пример #9
0
        public bool InsertPath( string path, bool weakProtection )
        {
            StringBuilder queryBuilder = new StringBuilder();

            path = path.Replace( "'", "''" );

            int weakProtectionValue = weakProtection ? 1 : 0;

            queryBuilder.AppendFormat( "INSERT INTO FILESYSTEM (PATH, WEAK_PROTECTION) VALUES ('{0}', {1})", path, weakProtectionValue );

            SqlCore sql = new SqlCore( DataUtils.GetConnectionString() );
            sql.Open();
            int num = sql.DoNonQuery( queryBuilder.ToString() );
            sql.Close();

            return num > 0;
        }