Naanou.ResourceExchange
Class Database

Database. A little wrapper around the in-use database system. Should really be more extendable to support ADO.NET, pluggable DBMSes etc, but this works Right Now.

Field Summary
System.Data.OleDb.OleDbDataAdapter adapter
System.Data.OleDb.OleDbConnection connection
string connectUrl

Constructor Summary
Database()
        Initializes a new instance of the Database class.

Property Summary
bool IsOpen

Method Summary
bool Add(Naanou.ResourceExchange.Entry entry)
         Adds a new entry. Silently drops metadata entries that are empty
void Clear()
         Nuke database contents
void Close()
         Close database
string Escape(string str)
string GetAmount(double amount)
         Gets a formatted scaled string using the default formatter
string GetAmount(double amount, string format)
         Gets a formatted scaled string
double GetAmount(double amount, string unit)
         Gets an scaled amount number
Naanou.ResourceExchange.Entry GetEntry(string path)
         Gets an entry from its filename
Naanou.ResourceExchange.Entry GetEntry(Naanou.Common.Hash hash)
         Gets an entry from a hash
Naanou.ResourceExchange.Entry GetEntryFromQuery(string query)
Naanou.ResourceExchange.Entry GetEntryFromSerial(string serial)
         Looks up an entry based on its content hash
string GetRate(double amount)
         Gets a formatted scaled rate using default formatter
string GetRate(double amount, string format)
         Gets a formatted scaled rate
double GetRate(double amount, string unit)
         Gets a scaled rate
void ManipulateEntries(Naanou.ResourceExchange.Database.EntryOp op)
void Open()
         Open database
void Remove(string hashSerial)
         Remove resource (and any metadata it has) from database
System.Data.DataSet SelectQuery(string qry)
int UpdateQuery(string qry)

Methods inherited from class System.Object
Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ToString


Field Detail

adapter

private System.Data.OleDb.OleDbDataAdapter adapter


connection

private System.Data.OleDb.OleDbConnection connection


connectUrl

private string connectUrl

Constructor Detail

Database

private Database()

Initializes a new instance of the Database class.

Property Detail

IsOpen

private bool IsOpen

Method Detail

Add

public bool Add(Naanou.ResourceExchange.Entry entry)

Adds a new entry. Silently drops metadata entries that are empty

Parameters:
entry -

Clear

public void Clear()

Nuke database contents


Close

internal void Close()

Close database


Escape

private string Escape(string str)


GetAmount

public string GetAmount(double amount)

Gets a formatted scaled string using the default formatter

Parameters:
amount - Amount (bytes)
Returns:
Formatted scaled string using default formatter

GetAmount

public string GetAmount(double amount,
                        string format)

Gets a formatted scaled string

Parameters:
amount - Amount (bytes)
format - Format string to use
Returns:
Formatted, scaled amount with unit added

GetAmount

public double GetAmount(double amount,
                        string unit)

Gets an scaled amount number

Parameters:
amount - Amount (bytes)
unit - Unit for new amount
Returns:
Scaled amount

GetEntry

public Naanou.ResourceExchange.Entry GetEntry(string path)

Gets an entry from its filename

Parameters:
path -
Returns:

GetEntry

public Naanou.ResourceExchange.Entry GetEntry(Naanou.Common.Hash hash)

Gets an entry from a hash

Parameters:
hash -
Returns:

GetEntryFromQuery

private Naanou.ResourceExchange.Entry GetEntryFromQuery(string query)


GetEntryFromSerial

public Naanou.ResourceExchange.Entry GetEntryFromSerial(string serial)

Looks up an entry based on its content hash

Parameters:
serial -
Returns:

GetRate

public string GetRate(double amount)

Gets a formatted scaled rate using default formatter

Parameters:
amount - Amount (bytes/sec)
Returns:
Formatted scaled rate with unit added

GetRate

public string GetRate(double amount,
                      string format)

Gets a formatted scaled rate

Parameters:
amount - Amount (bytes/sec)
format - Format string to use
Returns:
Formatted scaled rate with unit added

GetRate

public double GetRate(double amount,
                      string unit)

Gets a scaled rate

Parameters:
amount - Amount (bytes/s)
unit - Unit
Returns:
Scaled rate

ManipulateEntries

internal void ManipulateEntries(Naanou.ResourceExchange.Database.EntryOp op)


Open

private void Open()

Open database


Remove

public void Remove(string hashSerial)

Remove resource (and any metadata it has) from database

Parameters:
hashSerial -

SelectQuery

private System.Data.DataSet SelectQuery(string qry)


UpdateQuery

private int UpdateQuery(string qry)