Beispiel #1
0
        public bool InsertURL(string url, string signature, string sha512, string sha256)
        {
            // Assign a UUID to the URL
            TimeUuid uuid = TimeUuid.NewId();

            // Insert the URL
            QueryInsertURL queryOne = new QueryInsertURL(this.session);

            queryOne.InsertURL(uuid, url, signature, sha512, sha256);

            // Hit the URL
            QueryHitURL queryTwo = new QueryHitURL(this.session);

            if (!queryTwo.HitURL(uuid, false))
            {
                return(false);
            }

            return(true);
        }
        public bool LookupSignature(string sha512, string sha256, out string signature, out long hits)
        {
            // See if the URL exists in database
            QueryUUIDBySHA queryOne = new QueryUUIDBySHA(session);

            if (!queryOne.GetUUIDBySHA(sha512, sha256, out TimeUuid uuid))
            {
                signature = string.Empty;
                hits      = -1;
                return(false);
            }

            // Get the signature of the existing URL
            QuerySignatureByUUID queryTwo = new QuerySignatureByUUID(session);

            if (!queryTwo.GetSignatureByUUID(uuid, out signature))
            {
                hits = -1;
                return(false);
            }

            // Hit the URL
            QueryHitURL queryThree = new QueryHitURL(this.session);

            if (!queryThree.HitURL(uuid))
            {
                hits = -1;
                return(false);
            }

            // Get URL's popularity
            QueryURLHitCount queryFour = new QueryURLHitCount(this.session);

            if (!queryFour.GetURLHitCount(uuid, out hits))
            {
                return(false);
            }

            return(true);
        }