Exemple #1
0
        /// <summary>
        /// Send a document to the database server
        /// </summary>
        /// <param name="doc">The document you want to send</param>
        /// <param name="log">The log you want to send your document to</param>
        /// <param name="addedUuidDescription">The description that the automatically generated UuidObject in the Manager will get</param>
        /// <param name="method">Sending method</param>
        public void PostDocument(Document doc, UuidObject log, string addedUuidDescription, Method method = Method.Post)
        {
            string transaction = (CurrentTransaction == "NONE") ? "" : $"/transaction/{CurrentTransaction}";
            string json        = JsonConvert.SerializeObject(doc);
            string resp;

            if (method == Method.Post)
            {
                resp = NetworkHandler.Send(this.NodeLocation.HttpAddress(), $"document/{log.Id}{transaction}", json, "POST");
            }
            else
            {
                resp = NetworkHandler.Send(this.NodeLocation.HttpAddress(), $"document/{log.Id}{transaction}", json, "PUT");
            }
            UuidManager.Add(resp, addedUuidDescription, UuidObject.UuidType.Key);
        }
Exemple #2
0
 /// <summary>
 /// End an established session with the database server
 /// </summary>
 public void Logout()
 {
     NetworkHandler.Send(this.NodeLocation.HttpAddress(), $"auth/logout", "", "POST");
 }
Exemple #3
0
        /// <summary>
        /// Start a session with the database server
        /// </summary>
        /// <param name="auth">Authentication data wich is specified in the config file of your database</param>
        public void Login(Authentication auth)
        {
            string json = JsonConvert.SerializeObject(auth);

            NetworkHandler.Send(this.NodeLocation.HttpAddress(), $"auth/login", json, "POST");
        }
Exemple #4
0
 /// <summary>
 /// Delete a specified document from the database server
 /// </summary>
 /// <param name="log">The log that stores your document</param>
 /// <param name="file">The key of your document</param>
 /// <returns>The server response</returns>
 public string DeleteDocument(UuidObject log, UuidObject file)
 {
     return(NetworkHandler.Delete(this.NodeLocation.HttpAddress(), $"document/{log.Id}/{file.Id}"));
 }