public static Switch SwitchByNameOnly(String name) { ODatabase database = InitDB(); string query = String.Format("SELECT * FROM Switch WHERE name=\"" + name + "\""); List <ODocument> resultset = database.Query(query).ToList(); JavaScriptSerializer converter = new JavaScriptSerializer(); List <Switch> AllSwitches = new List <Switch>(); foreach (ODocument doc in resultset) { var json = converter.Serialize(doc); String a = json.ToString(); Switch d = converter.Deserialize <Switch>(a); AllSwitches.Add(d); } Switch router = null; if (AllSwitches != null) { router = AllSwitches[0]; } database.Close(); return(router); }
public void ShouldReturnDatabaseToPoolAfterCloseAndDisposeCall() { using (TestDatabaseContext testContext = new TestDatabaseContext()) { Assert.AreEqual( TestConnection.GlobalTestDatabasePoolSize, OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias) ); ODatabase database = new ODatabase(TestConnection.GlobalTestDatabaseAlias); Assert.AreEqual( TestConnection.GlobalTestDatabasePoolSize - 1, OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias) ); database.Close(); Assert.AreEqual( TestConnection.GlobalTestDatabasePoolSize, OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias) ); database.Dispose(); Assert.AreEqual( TestConnection.GlobalTestDatabasePoolSize, OClient.DatabasePoolCurrentSize(TestConnection.GlobalTestDatabaseAlias) ); } }
public static Router RouterByName(String name, String SerialNumber) { ODatabase database = InitDB(); string query = String.Format("SELECT * FROM Router WHERE name=\"" + name + "\" AND SerialNumber=\"" + SerialNumber + "\""); List <ODocument> resultset = database.Query(query).ToList(); JavaScriptSerializer converter = new JavaScriptSerializer(); List <Router> AllRouters = new List <Router>(); foreach (ODocument doc in resultset) { var json = converter.Serialize(doc); String a = json.ToString(); Router d = converter.Deserialize <Router>(a); AllRouters.Add(d); } Router router = null; if (AllRouters != null) { router = AllRouters[0]; } database.Close(); return(router); }
public static Server ServerByName(String name, String LanMacAddress) { ODatabase database = InitDB(); string query = String.Format("SELECT * FROM Server WHERE name=\"" + name + "\" AND LanMacAddress=\"" + LanMacAddress + "\""); List <ODocument> resultset = database.Query(query).ToList(); JavaScriptSerializer converter = new JavaScriptSerializer(); List <Server> AllServerss = new List <Server>(); foreach (ODocument doc in resultset) { var json = converter.Serialize(doc); String a = json.ToString(); Server d = converter.Deserialize <Server>(a); AllServerss.Add(d); } Server server = null; if (AllServerss != null) { server = AllServerss[0]; } database.Close(); return(server); }
public static void Disconnect() { if (db != null) { db.Close(); } }
public static Laptop LaptopByName(String name, String LanMacAddress, String WiFiMacAddress) { ODatabase database = InitDB(); string query = String.Format("SELECT * FROM Laptop WHERE name=\"" + name + "\" AND LanMacAddress=\"" + LanMacAddress + "\" AND WiFiMacAddress=\"" + WiFiMacAddress + "\""); List <ODocument> resultset = database.Query(query).ToList(); JavaScriptSerializer converter = new JavaScriptSerializer(); List <Laptop> AllLaptops = new List <Laptop>(); foreach (ODocument doc in resultset) { var json = converter.Serialize(doc); String a = json.ToString(); Laptop d = converter.Deserialize <Laptop>(a); AllLaptops.Add(d); } Laptop laptop = null; if (AllLaptops != null) { laptop = AllLaptops[0]; } database.Close(); return(laptop); }
public static Desktop DesktopByNameOnly(String name) { ODatabase database = InitDB(); string query = String.Format("SELECT * FROM Desktop WHERE name=\"" + name + "\""); List <ODocument> resultset = database.Query(query).ToList(); JavaScriptSerializer converter = new JavaScriptSerializer(); List <Desktop> AllDesktops = new List <Desktop>(); foreach (ODocument doc in resultset) { var json = converter.Serialize(doc); String a = json.ToString(); Desktop d = converter.Deserialize <Desktop>(a); AllDesktops.Add(d); } Desktop desktop = null; if (AllDesktops != null) { desktop = AllDesktops[0]; } database.Close(); return(desktop); }
public static void AddDesktop(String name, String OS, String LanMacAddress) { ODatabase database = InitDB(); database.Insert().Into("Desktop").Set("name", name) .Set("OS", OS).Set("LanMacAddress", LanMacAddress).Run(); database.Close(); }
public void TestDatabaseCloseConnection() { using (ODatabase database = new ODatabase(_hostname, _port, _databaseName, ODatabaseType.Document, _username, _password)) { database.Close(); Assert.IsTrue(database.SessionID == -1); } }
public static void AddServer(String name, String OS, String LanMacAddress, String Type, String Description) { ODatabase database = InitDB(); database.Insert().Into("Server").Set("name", name) .Set("OS", OS).Set("LanMacAddress", LanMacAddress) .Set("Type", Type).Set("Description", Description).Run(); database.Close(); }
public static void AddLaptop(String name, String OS, String LanMacAddress, String WiFiMacAddress, String WiFiNetworkName) { ODatabase database = InitDB(); database.Insert().Into("Laptop").Set("name", name) .Set("OS", OS).Set("LanMacAddress", LanMacAddress) .Set("WiFiMacAddress", WiFiMacAddress).Set("WiFiNetworkName", WiFiNetworkName).Run(); database.Close(); }
public static void AddSwitch(String name, String SerialNumber, String Manufacturer, int NumberOfPorts, int NumberOfTakenPorts) { List <String> MacAddressList = new List <string>(); ODatabase database = InitDB(); database.Insert().Into("Switch").Set("name", name) .Set("SerialNumber", SerialNumber) .Set("Manufacturer", Manufacturer) .Set("NumberOfPorts", NumberOfPorts).Set("NumberOfTakenPorts", NumberOfTakenPorts) .Set("MacAddressList", MacAddressList).Run(); database.Close(); }
public static void AddRouter(String name, String OS, String SerialNumber, String Manufacturer, String WiFiNetworkName, int NumberOfPorts, int NumberOfTakenPorts) { List <String> MacAddressList = new List <string>(); ODatabase database = InitDB(); database.Insert().Into("Router").Set("name", name) .Set("OS", OS).Set("SerialNumber", SerialNumber) .Set("Manufacturer", Manufacturer).Set("WiFiNetworkName", WiFiNetworkName) .Set("NumberOfPorts", NumberOfPorts).Set("NumberOfTakenPorts", NumberOfTakenPorts) .Set("MacAddressList", MacAddressList).Run(); database.Close(); }
public static List <ODocument> FindServerConnections(String name, String LanMacAddress) { ODatabase database = InitDB(); string query = String.Format("SELECT * FROM Server WHERE name=\"" + name + "\" AND LanMacAddress=\"" + LanMacAddress + "\""); List <ODocument> result = database.Query(query).ToList(); ODocument o = result[0]; ORID z = o.GetField <ORID>("@ORID"); String querry = "TRAVERSE * FROM " + z + " WHILE $depth<=2"; List <ODocument> resultset = database.Query(querry).ToList <ODocument>(); database.Close(); return(resultset); }
public void TestGetDatabase() { using (ODatabase database = new ODatabase(_poolAlias)) { Assert.IsTrue(database.SessionID > 0); DatabasePool pool = EasternClient.GetDatabasePool(_poolAlias); Assert.IsTrue(pool.CurrentPoolSize == (pool.PoolSize - 1)); Assert.IsFalse(pool.ContainsDatabaseSession(database.SessionID)); database.Close(); Assert.IsTrue(pool.CurrentPoolSize == pool.PoolSize); Assert.IsTrue(pool.ContainsDatabaseSession(database.SessionID)); } }
public static List <Switch> GetAllSwitches() { ODatabase database = InitDB(); List <ODocument> resultset = database.Select().From("Switch").ToList(); JavaScriptSerializer converter = new JavaScriptSerializer(); List <Switch> AllSwitches = new List <Switch>(); foreach (ODocument doc in resultset) { var json = converter.Serialize(doc); String a = json.ToString(); Switch d = converter.Deserialize <Switch>(a); AllSwitches.Add(d); } database.Close(); return(AllSwitches); }
public static List <Desktop> GetAllDesktops() { ODatabase database = InitDB(); string query = String.Format("SELECT * FROM Desktop"); List <ODocument> resultset = database.Select().From("Desktop").ToList(); JavaScriptSerializer converter = new JavaScriptSerializer(); List <Desktop> AllDesktops = new List <Desktop>(); foreach (ODocument doc in resultset) { var json = converter.Serialize(doc); String a = json.ToString(); Desktop d = converter.Deserialize <Desktop>(a); AllDesktops.Add(d); } database.Close(); return(AllDesktops); }
public static ODocument ComputerByName(String name) { ODatabase database = InitDB(); string query = String.Format("SELECT * FROM Computer WHERE name=\"" + name + "\""); List <ODocument> resultset = database.Query(query).ToList(); List <ODocument> AllComputers = new List <ODocument>(); foreach (ODocument doc in resultset) { AllComputers.Add(doc); } ODocument computer = null; if (AllComputers != null) { computer = AllComputers[0]; } database.Close(); return(computer); }
public static ODocument NodeByName(String name) { ODatabase database = InitDB(); string query = String.Format("SELECT * FROM Node WHERE name=\"" + name + "\""); List <ODocument> resultset = database.Query(query).ToList(); List <ODocument> AllNodes = new List <ODocument>(); foreach (ODocument doc in resultset) { AllNodes.Add(doc); } ODocument node = null; if (AllNodes != null) { node = AllNodes[0]; } database.Close(); return(node); }
public static void closeDB(ODatabase db) { db.Close(); db.Dispose(); }
static long Do() { DateTime start = DateTime.Now; bool running = true; long tps = 0; do { ODatabase database = new ODatabase(_alias); //List<ORecord> result = database.Query("select name from OGraphVertex where in[0].label = 'followed_by' and in[0].out.name = 'JAM'"); //List<ORecord> result = database.Query("select from OGraphVertex limit 20"); List<ORecord> result = database.Query("select from OGraphEdge limit 20"); database.Close(); tps++; TimeSpan dif = DateTime.Now - start; if (dif.TotalMilliseconds > 1000) { running = false; } } while (running); return tps; }