added siaqodb

This commit is contained in:
kay.one 2013-02-16 17:52:40 -08:00
parent c55099ce5a
commit e44d262a1a
29 changed files with 761 additions and 553 deletions

View File

@ -0,0 +1,636 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>siaqodb</name>
</assembly>
<members>
<member name="T:Sqo.Attributes.IgnoreAttribute">
<summary>
Attribute to be used for a member of a storable class and that object will be ignored by siaqodb engine
</summary>
</member>
<member name="T:Sqo.Attributes.MaxLengthAttribute">
<summary>
Attribute to be used for a member of type String of a storable class to limit Length of a string object to be stored in database
</summary>
</member>
<member name="M:Sqo.Attributes.MaxLengthAttribute.#ctor(System.Int32)">
<summary>
Create an attribute instance of Type MaxLength
</summary>
<param name="maxLength">number of characters from string to be stored in database</param>
</member>
<member name="T:Sqo.Attributes.UseVariableAttribute">
<summary>
Use this attribute if you use a Property and inside that
property use some complex code and when Siaqodb engine is not able
to get what is backing field of that Property, variableName is used for Siaqodb engine when that property is used
</summary>
</member>
<member name="T:Sqo.Internal._bs">
<summary>
Do NOT use it!, it is used only internally
</summary>
</member>
<member name="M:Sqo.Internal._bs._b(System.String)">
<summary>
Do NOT use it!, it is used only internally
</summary>
<param name="p">
</param>
<returns>
</returns>
</member>
<member name="M:Sqo.Internal._bs._ofm(System.String,System.String)">
<summary>
Do NOT use it!, it is used only internally
</summary>
<param name="p">
</param>
<returns>
</returns>
</member>
<member name="M:Sqo.Internal._bs._uf(Sqo.Siaqodb,System.Int32,Sqo.MetaType,System.String,System.Object)">
<summary>
Do NOT use it!, it is used only internally
</summary>
</member>
<member name="M:Sqo.Internal._bs._gd(Sqo.Siaqodb,System.Type)">
<summary>
Do NOT use it!, it is used only internally
</summary>
</member>
<member name="M:Sqo.Internal._bs._do(Sqo.Siaqodb,System.Int32,Sqo.MetaType)">
<summary>
Do NOT use it!, it is used only internally
</summary>
</member>
<member name="M:Sqo.Internal._bs._io(Sqo.Siaqodb,Sqo.MetaType)">
<summary>
Do NOT use it!, it is used only internally
</summary>
</member>
<member name="M:Sqo.Internal._bs._sdbfn(Sqo.Siaqodb,Sqo.MetaType,System.String)">
<summary>
Do NOT use it!, it is used only internally
</summary>
</member>
<member name="M:Sqo.Internal._bs._loidtid(Sqo.Siaqodb,System.Int32,Sqo.MetaType,System.String,System.Collections.Generic.List{System.Int32}@,System.Int32@)">
<summary>
Do NOT use it!, it is used only internally
</summary>
</member>
<member name="M:Sqo.Internal._bs._ltid(Sqo.Siaqodb,System.Int32,Sqo.MetaType,System.String,System.Int32@,System.Boolean@)">
<summary>
Do NOT use it!, it is used only internally
</summary>
</member>
<member name="T:Sqo.IObjectList`1">
<summary>
Main interface to be used by implementers to retrieve objects from database
</summary>
<typeparam name="T">
</typeparam>
</member>
<!-- Badly formed XML comment ignored for member "M:Sqo.Evaluator.PartialEval(System.Linq.Expressions.Expression,System.Func{System.Linq.Expressions.Expression,System.Boolean})" -->
<!-- Badly formed XML comment ignored for member "T:Sqo.Evaluator.SubtreeEvaluator" -->
<!-- Badly formed XML comment ignored for member "T:Sqo.Evaluator.Nominator" -->
<member name="T:Sqo.MetaField">
<summary>
Class that describe a field of an object stored in database
</summary>
</member>
<member name="P:Sqo.MetaField.Name">
<summary>
Name of field stored in database
</summary>
</member>
<member name="P:Sqo.MetaField.FieldType">
<summary>
Type of field stored in database
</summary>
</member>
<member name="T:Sqo.MetaType">
<summary>
Class that describe Type of objects stored in database
</summary>
</member>
<member name="P:Sqo.MetaType.Name">
<summary>
Name of Type stored in database
</summary>
</member>
<member name="P:Sqo.MetaType.Fields">
<summary>
List of fields
</summary>
</member>
<member name="T:Sqo.ObjectList`1">
<summary>
List used to retrieve objects from database
</summary>
<typeparam name="T">Type of objects from list</typeparam>
</member>
<member name="M:Sqo.ObjectList`1.Add(`0)">
<summary>
Add obeject of Type T in the list
</summary>
<param name="item">object to be added</param>
</member>
<member name="M:Sqo.ObjectList`1.Clear">
<summary>
Remove all elements from list
</summary>
</member>
<member name="M:Sqo.ObjectList`1.Contains(`0)">
<summary>
Determines if an element is in list
</summary>
<param name="item">The object to locate in list</param>
<returns>bool value if object was found or not</returns>
</member>
<member name="M:Sqo.ObjectList`1.Remove(`0)">
<summary>
Remove object from list
</summary>
<param name="item">The object to remove</param>
<returns>bool value if object was removed or not</returns>
</member>
<member name="T:Sqo.Siaqodb">
<summary>
Main class of siaqodb database engine responsible for storing, retrieving ,deleting objects on database files
</summary>
</member>
<member name="M:Sqo.Siaqodb.#ctor">
<summary>
Create a new instance of Siaqodb, database is not opened yet
</summary>
</member>
<member name="M:Sqo.Siaqodb.#ctor(System.String)">
<summary>
Create a new instance of Siaqodb and open the database
</summary>
<param name="path">Physical folder name where objects are stored</param>
</member>
<member name="M:Sqo.Siaqodb.Open(System.String)">
<summary>
Open database folder
</summary>
<param name="path">path where objects are stored</param>
</member>
<member name="M:Sqo.Siaqodb.StoreObject(System.Object)">
<summary>
Insert or update object; if object is loaded from database and this method is called then update will occur, if object is new created then insert will occur
</summary>
<param name="obj">Object to be stored</param>
</member>
<member name="M:Sqo.Siaqodb.StoreObjectPartially(System.Object,System.String[])">
<summary>
Insert or update object partially, only provided properties are saved
</summary>
<param name="obj">object of which properties will be stored</param>
<param name="properties">properties to be stored</param>
</member>
<member name="M:Sqo.Siaqodb.StoreObjectPartially(System.Object,System.Boolean,System.String[])">
<summary>
Insert or update object partially, only provided properties are saved
</summary>
<param name="obj">object of which properties will be stored</param>
<param name="properties">properties to be stored</param>
<param name="onlyReferences">if true,it will store only references to complex objects</param>
</member>
<member name="M:Sqo.Siaqodb.StoreObject(System.Object,Sqo.Transactions.Transaction)">
<summary>
Insert or update object by a Transaction; if object is loaded from database and this method is called then update will occur, if object is new created then insert will occur
</summary>
<param name="obj">Object to be stored</param>
<param name="transaction">Transaction object</param>
</member>
<member name="M:Sqo.Siaqodb.LoadAll``1">
<summary>
Load all objects of Type provided
</summary>
<typeparam name="T">Type of objects to be loaded from database</typeparam>
<returns>List of objects retrieved from database</returns>
</member>
<member name="M:Sqo.Siaqodb.LoadObjectByOID``1(System.Int32)">
<summary>
Load object from database by OID provided
</summary>
<typeparam name="T">The Type of object to be loaded</typeparam>
<param name="oid">oid of object</param>
<returns>the object stored in database with oid provided</returns>
</member>
<member name="M:Sqo.Siaqodb.Close">
<summary>
Close database
</summary>
</member>
<member name="M:Sqo.Siaqodb.Cast``1">
<summary>
Cast method to be used in LINQ queries
</summary>
<typeparam name="T">Type over which LINQ will take action</typeparam>
<returns>
</returns>
</member>
<member name="M:Sqo.Siaqodb.Query``1">
<summary>
Query method to be used in LINQ queries
</summary>
<typeparam name="T">Type over which LINQ will take action</typeparam>
<returns>
</returns>
</member>
<member name="M:Sqo.Siaqodb.LoadOids``1(System.Linq.Expressions.Expression)">
<summary>
Load OIDs by expression
</summary>
<typeparam name="T">Type for which OIDs will be loaded</typeparam>
<param name="expression">filter expression</param>
<returns>List of OIDs</returns>
</member>
<member name="M:Sqo.Siaqodb.LoadAllOIDs(Sqo.MetaType)">
<summary>
Load all object OIDs of MetaType provided
</summary>
<param name="type">meta type Load by method GetAllTypes()</param>
<returns>
</returns>
</member>
<member name="M:Sqo.Siaqodb.LoadValue(System.Int32,System.String,Sqo.MetaType)">
<summary>
Load value of a field of an object identified by OID provided
</summary>
<param name="oid">OID of object</param>
<param name="fieldName">fieldName</param>
<param name="mt">MetaType</param>
<returns>
</returns>
</member>
<member name="M:Sqo.Siaqodb.Delete(System.Object)">
<summary>
Delete an object from database
</summary>
<param name="obj">Object to be deleted</param>
</member>
<member name="M:Sqo.Siaqodb.Delete(System.Object,Sqo.Transactions.Transaction)">
<summary>
Delete an object from database using a Transaction
</summary>
<param name="obj">Object to be deleted</param>
<param name="transaction">Transaction</param>
</member>
<member name="M:Sqo.Siaqodb.DeleteObjectBy(System.String,System.Object)">
<summary>
Delete an object from database by a certain field(ex:ID that come from server)
</summary>
<param name="obj">Object to be deleted</param>
<param name="fieldName">Names of field that this method will lookup for object to delete it</param>
</member>
<member name="M:Sqo.Siaqodb.DeleteObjectBy(System.Object,System.String[])">
<summary>
Delete an object from database by a certain field(ex:ID that come from server)
</summary>
<param name="obj">Object to be deleted</param>
<param name="fieldNames">Names of fields that this method will lookup for object to delete it</param>
</member>
<member name="M:Sqo.Siaqodb.DeleteObjectBy(System.Object,Sqo.Transactions.Transaction,System.String[])">
<summary>
Delete an object from database by a certain field(ex:ID that come from server)
</summary>
<param name="obj">Object to be deleted</param>
<param name="fieldNames">Names of fields that this method will lookup for object to delete it</param>
<param name="transaction">Transaction object</param>
</member>
<member name="M:Sqo.Siaqodb.DeleteObjectBy``1(System.Collections.Generic.Dictionary{System.String,System.Object})">
<summary>
Delete an object from database by a criteria
</summary>
<param name="criteria">Pairs of fields-values to lookup for object to delete it</param>
<returns>Number of objects deleted</returns>
</member>
<member name="M:Sqo.Siaqodb.DropType``1">
<summary>
Delete all objects of Type provided
</summary>
<typeparam name="T">Type of objects to be deleted</typeparam>
</member>
<member name="M:Sqo.Siaqodb.DropType(System.Type)">
<summary>
Delete all objects of Type provided
</summary>
<param name="type">Type of objects to be deleted</param>&gt;
</member>
<member name="M:Sqo.Siaqodb.DropType(System.Type,System.Boolean)">
<summary>
Delete all objects of Type provided
</summary>
<param name="type">Type of objects to be deleted</param>
<param name="claimFreespace">If this is TRUE all dynamic length data associated with objects will be marked as free and Shrink method is able to free the space</param>
</member>
<member name="M:Sqo.Siaqodb.GetAllTypes">
<summary>
Return all Types from database folder
</summary>
<returns>List of MetaType objects</returns>
</member>
<member name="M:Sqo.Siaqodb.Count``1">
<summary>
Return number of objects of Type provided
</summary>
<typeparam name="T">Type of objects</typeparam>
<returns>
</returns>
</member>
<member name="M:Sqo.Siaqodb.ExportToXML``1(System.Xml.XmlWriter)">
<summary>
Export to XML all objects of Type provided from database
</summary>
<typeparam name="T">Type of objects to be exported</typeparam>
<param name="writer">XmlWriter</param>
</member>
<member name="M:Sqo.Siaqodb.ExportToXML``1(System.Xml.XmlWriter,System.Collections.Generic.IList{``0})">
<summary>
Export to XML list of objects provided
</summary>
<typeparam name="T">Type of objects</typeparam>
<param name="writer">XmlWriter</param>
<param name="objects">list of objects to be exported</param>
</member>
<member name="M:Sqo.Siaqodb.ImportFromXML``1(System.Xml.XmlReader)">
<summary>
Import from XML objects and return a list of them
</summary>
<typeparam name="T">Type of objects to be imported</typeparam>
<param name="reader">XmlReader</param>
<returns>List of objects imported</returns>
</member>
<member name="M:Sqo.Siaqodb.ImportFromXML``1(System.Xml.XmlReader,System.Boolean)">
<summary>
Import from XML objects and return a list and save into database
</summary>
<typeparam name="T">Type of objects to be imported</typeparam>
<param name="reader">XmlReader</param>
<param name="importIntoDB">if TRUE objects are saved also in database</param>
<returns>List of objects imported</returns>
</member>
<member name="M:Sqo.Siaqodb.SetDatabaseFileName``1(System.String)">
<summary>
this method is obsolete Use SiaqodbConfigurator.SetDatabaseFileName() method
</summary>
<typeparam name="T">type</typeparam>
<param name="fileName">fielName</param>
</member>
<member name="M:Sqo.Siaqodb.UpdateObjectBy(System.String,System.Object)">
<summary>
Update an object in database by a certain Field(eq: ID that come from a server)
</summary>
<param name="fieldName">FieldName by which update is made(eq an ID)</param>
<param name="obj">object that has all values but not OID to update it in database</param>
<returns>true if object was updated and false if object was not found in database</returns>
</member>
<member name="M:Sqo.Siaqodb.UpdateObjectBy(System.Object,System.String[])">
<summary>
Update an object in database by certain Fields(eq: ID that come from a server)
</summary>
<param name="fieldNames">name of fields by which update is made(eq an ID)</param>
<param name="obj">object that has all values but not OID to update it in database</param>
<returns>true if object was updated and false if object was not found in database</returns>
</member>
<member name="M:Sqo.Siaqodb.UpdateObjectBy(System.Object,Sqo.Transactions.Transaction,System.String[])">
<summary>
Update an object in database by certain Fields(eq: ID that come from a server)
</summary>
<param name="fieldNames">name of fields by which update is made(eq an ID)</param>
<param name="obj">object that has all values but not OID to update it in database</param>
<param name="transaction">Transaction object</param>
<returns>true if object was updated and false if object was not found in database</returns>
</member>
<member name="M:Sqo.Siaqodb.GetDBPath">
<summary>
return current database path
</summary>
<returns>The database folder path</returns>
</member>
<member name="M:Sqo.Siaqodb.BeginTransaction">
<summary>
Start a database Transaction to be used on insert/update/delete objects
</summary>
<returns> Transaction object</returns>
</member>
<member name="M:Sqo.Siaqodb.LoadIndexValues``2(System.String)">
<summary>
Get a list of unique values for a field index
</summary>
<typeparam name="T">Type where index is defined</typeparam>
<typeparam name="TIndex">Type of field indexed</typeparam>
<param name="fieldName">Name of field or automatic property which is indexed</param>
<returns>
</returns>
</member>
<member name="M:Sqo.Siaqodb.LoadAllLazy``1">
<summary>
Load all objects in Lazy mode, objects are activated/read from db when it is accessed
by index or by enumerator
</summary>
<typeparam name="T">Type of objects to be loaded from database</typeparam>
<returns>LazyObjectList of objects</returns>
</member>
<member name="M:Sqo.Siaqodb.GetOID(System.Object)">
<summary>
Get OID of object, if the Type of object has not defined OID property then object and OID are weak cached during object load from database and this value is returned,
otherwise it is returned value of the OID property
</summary>
<param name="obj">The object for which OID is returned</param>
<returns>The OID associated with object that is stored in database</returns>
</member>
<member name="E:Sqo.Siaqodb.SavingObject">
<summary>
Raised before an object is saved in database
</summary>
</member>
<member name="E:Sqo.Siaqodb.SavedObject">
<summary>
Raised after an object is saved in database
</summary>
</member>
<member name="E:Sqo.Siaqodb.DeletingObject">
<summary>
Raised before an object is deleted from database
</summary>
</member>
<member name="E:Sqo.Siaqodb.DeletedObject">
<summary>
Raised after an object is deleted from database
</summary>
</member>
<member name="E:Sqo.Siaqodb.LoadingObject">
<summary>
Raised before an object is loaded from database
</summary>
</member>
<member name="E:Sqo.Siaqodb.LoadedObject">
<summary>
Raised after object is loaded from database
</summary>
</member>
<member name="T:Sqo.SiaqodbConfigurator">
<summary>
Class responsible for configurations of Siaqodb database engine
</summary>
</member>
<member name="M:Sqo.SiaqodbConfigurator.AddIndex(System.String,System.Type)">
<summary>
Add an index for a field or automatic property of a certain Type,an Index can be added also by using Attribute: Sqo.Attributes.Index;
both ways of adding index are similar
</summary>
<param name="field">Field name or automatic property name</param>
<param name="type">Type that declare the field</param>
</member>
<member name="M:Sqo.SiaqodbConfigurator.AddUniqueConstraint(System.String,System.Type)">
<summary>
Add an UniqueConstraint for a field of a certain Type,an UniqueConstraint can be added also by using Attribute: Sqo.Attributes.UniqueConstraint;
both ways of adding UniqueConstraint are similar
</summary>
<param name="field">Field name or automatic property name</param>
<param name="type">Type that declare the field</param>
</member>
<member name="M:Sqo.SiaqodbConfigurator.AddMaxLength(System.String,System.Int32,System.Type)">
<summary>
Put MaxLength for a string field or automatic property of a Type, MaxLength can be set also by using Attribute: Sqo.Attributes.MaxLength
</summary>
<param name="field">Field name or automatic property name</param>
<param name="maxLength">max length for a string</param>
<param name="type">Type that declare the field</param>
</member>
<member name="M:Sqo.SiaqodbConfigurator.AddIgnore(System.String,System.Type)">
<summary>
Ignore a field or automatic property to be stored
</summary>
<param name="field">Name of field or automatic property</param>
<param name="type">Type that declare the field</param>
</member>
<member name="M:Sqo.SiaqodbConfigurator.PropertyUseField(System.String,System.String,System.Type)">
<summary>
Set the name of backing field for a property in case engine cannto discover it, this also can be set by attribute: Sqo.Attributes.UseVariable
</summary>
<param name="propertyName">Name of property</param>
<param name="fieldName">Name of backing field of property</param>
<param name="type">
</param>
</member>
<member name="M:Sqo.SiaqodbConfigurator.SetEncryptionPassword(System.String)">
<summary>
Set the password for encryption algorithm used to encrypt database data
</summary>
<param name="pwd">The password</param>
</member>
<member name="M:Sqo.SiaqodbConfigurator.SetEncryptor(Sqo.Encryption.IEncryptor)">
<summary>
Set your custom encryption algorithm that implemets IEncryptor interface
</summary>
<param name="encryptor">The instance of custom encryption algorithm</param>
</member>
<member name="M:Sqo.SiaqodbConfigurator.SetEncryptor(Sqo.BuildInAlgorithm)">
<summary>
Set build-in encryption algorithm
</summary>
<param name="alg">Encryption algorithm</param>
</member>
<member name="M:Sqo.SiaqodbConfigurator.SetDatabaseFileName``1(System.String)">
<summary>
Set custom fileName on disk of database file for Type T
</summary>
<typeparam name="T">Type of objects</typeparam>
<param name="fileName">Name of database file on disk</param>
</member>
<member name="M:Sqo.SiaqodbConfigurator.LoadRelatedObjects``1(System.Boolean)">
<summary>
By default this is true for all types. Set this to false to not load childs entities of objects of Type provided
</summary>
<typeparam name="T">Type for objects</typeparam>
<param name="loadRelatedObjects">true if related object need to be loaded, false if you want to load by Include(...) method</param>
</member>
<member name="M:Sqo.SiaqodbConfigurator.SetRaiseLoadEvents(System.Boolean)">
<summary>
Set true to raise Loading/Loaded events
</summary>
<param name="raiseLoadEvents">
</param>
</member>
<member name="P:Sqo.SiaqodbConfigurator.EncryptedDatabase">
<summary>
Set if database will be encrypted or not
</summary>
</member>
<member name="T:Sqo.SiaqodbUtil">
<summary>
Database utilities
</summary>
</member>
<member name="M:Sqo.SiaqodbUtil.ReIndex(System.String)">
<summary>
Rebuild and defragment indexes
</summary>
<param name="siaqodb">
</param>
</member>
<member name="M:Sqo.SiaqodbUtil.Shrink(System.String,Sqo.ShrinkType)">
<summary>
Shrink database files including rawdata.sqr and indexes
</summary>
</member>
<member name="M:Sqo.SiaqodbUtil.Repair(System.String)">
<summary>
Repair database files by fixing corrupted objects bytes
</summary>
<param name="siaqodb">
</param>
</member>
<member name="M:Sqo.SiaqodbUtil.RepairType``1(System.String)">
<summary>
Repair database file of Type provided, the corrupted objects will be recuperated or deleted
</summary>
<param name="siaqodb">
</param>
</member>
<member name="F:Sqo.ShrinkType.Normal">
<summary>
Normal shrink, all blocks marked as free will be supressed
</summary>
</member>
<member name="F:Sqo.ShrinkType.ForceClaimSpace">
<summary>
All database files will be parsed and check if a block can be marked as free then supress free blocks;
This operation can be slow if your database is big.
</summary>
</member>
<member name="F:Sqo.ShrinkType.Total">
<summary>
This includes Normal + ForceClaimSpace but also shrink of every db file; after this operation OID values of the stored objects may change.
</summary>
</member>
<member name="T:Sqo.SqoDataObject">
<summary>
Basic class that any siaqodb storable class may inherits from
</summary>
</member>
<member name="P:Sqo.SqoDataObject.OID">
<summary>
Object Identifier(unique per Type)
</summary>
</member>
<member name="M:Sqo.Transactions.Transaction.Commit">
<summary>
Commit transaction to database
</summary>
</member>
<member name="M:Sqo.Transactions.Transaction.Rollback">
<summary>
Rollback changes
</summary>
</member>
</members>
</doc>

Binary file not shown.

View File

@ -1,69 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Repository;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.Datastore
{
[TestFixture]
public class IndexProviderFixture : ObjectDbTest<IndexProvider>
{
[SetUp]
public void Setup()
{
WithObjectDb();
}
[Test]
public void should_be_able_to_get_sequential_numbers()
{
var indexs = new List<int>();
for (var i = 0; i < 1000; i++)
{
indexs.Add(Subject.Next(GetType()));
}
indexs.Should().OnlyHaveUniqueItems();
}
[Test]
public void diffrentTypes_should_get_their_own_counter()
{
var seriesIndex = new List<int>();
var episodeIndex = new List<int>();
for (var i = 0; i < 200; i++)
{
seriesIndex.Add(Subject.Next(typeof(Series)));
}
for (var i = 0; i < 100; i++)
{
episodeIndex.Add(Subject.Next(typeof(Episode)));
}
seriesIndex.Should().OnlyHaveUniqueItems();
episodeIndex.Should().OnlyHaveUniqueItems();
seriesIndex.Min(c => c).Should().Be(1);
seriesIndex.Max(c => c).Should().Be(200);
episodeIndex.Min(c => c).Should().Be(1);
episodeIndex.Max(c => c).Should().Be(100);
}
}
}

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Eloquera.Client;
using FizzWare.NBuilder; using FizzWare.NBuilder;
using FluentAssertions; using FluentAssertions;
using NUnit.Framework; using NUnit.Framework;
@ -20,16 +19,16 @@ namespace NzbDrone.Core.Test.Datastore
[SetUp] [SetUp]
public void SetUp() public void SetUp()
{ {
WithObjectDb(false); WithObjectDb(memory:false);
testSeries = Builder<Series> testSeries = Builder<Series>
.CreateNew() .CreateNew()
.With(s => s.Id = 0) .With(s => s.OID = 0)
.Build(); .Build();
testEpisode = Builder<Episode> testEpisode = Builder<Episode>
.CreateNew() .CreateNew()
.With(e => e.Id = 0) .With(e => e.OID = 0)
.Build(); .Build();
@ -52,7 +51,7 @@ namespace NzbDrone.Core.Test.Datastore
[Test] [Test]
public void update_item_with_root_index_0_should_faile() public void update_item_with_root_index_0_should_faile()
{ {
testSeries.Id = 0; testSeries.OID = 0;
Assert.Throws<InvalidOperationException>(() => Db.Update(testSeries)); Assert.Throws<InvalidOperationException>(() => Db.Update(testSeries));
} }
@ -93,7 +92,7 @@ namespace NzbDrone.Core.Test.Datastore
{ {
testEpisode.Series = Builder<Series> testEpisode.Series = Builder<Series>
.CreateNew() .CreateNew()
.With(s => s.Id = 0) .With(s => s.OID = 0)
.Build(); .Build();
Db.Insert(testEpisode); Db.Insert(testEpisode);
@ -110,19 +109,19 @@ namespace NzbDrone.Core.Test.Datastore
[Test] [Test]
public void new_objects_should_get_id() public void new_objects_should_get_id()
{ {
testSeries.Id = 0; testSeries.OID = 0;
Db.Insert(testSeries); Db.Insert(testSeries);
testSeries.Id.Should().NotBe(0); testSeries.OID.Should().NotBe(0);
} }
[Test] [Test]
public void new_object_should_get_new_id() public void new_object_should_get_new_id()
{ {
testSeries.Id = 0; testSeries.OID = 0;
Db.Insert(testSeries); Db.Insert(testSeries);
Db.AsQueryable<Series>().Should().HaveCount(1); Db.AsQueryable<Series>().Should().HaveCount(1);
testSeries.Id.Should().Be(1); testSeries.OID.Should().Be(1);
} }
@ -135,31 +134,31 @@ namespace NzbDrone.Core.Test.Datastore
Db.Insert(nested); Db.Insert(nested);
nested.Id.Should().Be(1); nested.OID.Should().Be(1);
nested.List.Should().OnlyContain(c => c.Id > 0); nested.List.Should().OnlyContain(c => c.OID > 0);
} }
[Test] [Test]
public void should_have_id_when_returned_from_database() public void should_have_id_when_returned_from_database()
{ {
testSeries.Id = 0; testSeries.OID = 0;
Db.Insert(testSeries); Db.Insert(testSeries);
var item = Db.AsQueryable<Series>(); var item = Db.AsQueryable<Series>();
item.Should().HaveCount(1); item.Should().HaveCount(1);
item.First().Id.Should().NotBe(0); item.First().OID.Should().NotBe(0);
item.First().Id.Should().BeLessThan(100); item.First().OID.Should().BeLessThan(100);
item.First().Id.Should().Be(testSeries.Id); item.First().OID.Should().Be(testSeries.OID);
} }
[Test] [Test]
public void should_be_able_to_find_object_by_id() public void should_be_able_to_find_object_by_id()
{ {
Db.Insert(testSeries); Db.Insert(testSeries);
var item = Db.AsQueryable<Series>().Single(c => c.Id == testSeries.Id); var item = Db.AsQueryable<Series>().Single(c => c.OID == testSeries.OID);
item.Id.Should().NotBe(0); item.OID.Should().NotBe(0);
item.Id.Should().Be(testSeries.Id); item.OID.Should().Be(testSeries.OID);
} }
[Test] [Test]
@ -181,7 +180,7 @@ namespace NzbDrone.Core.Test.Datastore
List = new List<NestedModel> { this }; List = new List<NestedModel> { this };
} }
public IList<NestedModel> List { get; set; } public List<NestedModel> List { get; set; }
} }
} }

View File

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<Eloquera xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Cache IndexCacheSize="10000"
WriteThru="false"
IndexCleanerPeriod="100"
IndexCleanerBatchSize="100"
CleanerPeriod="100"
CleanerBatchSize="2000"
CommitSequenceMaxLength="2000"
ShallowReadThreshold="1000"
ShallowReadAhead="1000"
ReadAhead="20"
SaturationThreshold="10000"
MemoryFootPrint="60"/>
<MemoryManager Mode="1" />
<Server ServerPort="43962"
Trace="true"
InMemoryAllowed="true"
Secure="false"
AllowUsers=""
AllowGroups="Everyone"
SNMPAddress="net.tcp://localhost:8523/SNMP"
AutoRecovery="false"
NotificationsEnabled="false"
VarSectorSize="40"
IndexNodeSize="512"/>
<SmartRuntime Smart="true"
TypeUpdateAllowed="true"/>
<UserLogin Enabled="false"
PasswordHash="l+on1aCwDrcZ5bGlv+fyyIlYkbuFIOxZFlFwIGKlms0CCwoGn9TZvM0E3Uksjwx64+/yv8nsaUajWLz1kyKG7A==" />
</Eloquera>

View File

@ -36,8 +36,8 @@ namespace NzbDrone.Core.Test.Framework
public abstract class ObjectDbTest : CoreTest public abstract class ObjectDbTest : CoreTest
{ {
private EloqueraDb _db; private IObjectDatabase _db;
protected EloqueraDb Db protected IObjectDatabase Db
{ {
get get
{ {
@ -52,15 +52,14 @@ namespace NzbDrone.Core.Test.Framework
{ {
if (memory) if (memory)
{ {
_db = new EloqueraDbFactory(new EnvironmentProvider()).CreateMemoryDb(); _db = new SiaqoDbFactory(new DiskProvider()).CreateMemoryDb();
} }
else else
{ {
_db = new EloqueraDbFactory(new EnvironmentProvider()).Create(Path.Combine(Environment.CurrentDirectory,Guid.NewGuid().ToString()+ ".elq")); _db = new SiaqoDbFactory(new DiskProvider()).Create(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Guid.NewGuid().ToString()));
} }
Mocker.SetConstant(Db); Mocker.SetConstant(Db);
Mocker.SetConstant(Db.Db);
} }
[TearDown] [TearDown]

View File

@ -90,18 +90,6 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\DeskMetrics\DeskMetrics.NET.dll</HintPath> <HintPath>..\Libraries\DeskMetrics\DeskMetrics.NET.dll</HintPath>
</Reference> </Reference>
<Reference Include="Eloquera.Client">
<HintPath>..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Eloquera.Common">
<HintPath>..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Common.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Eloquera.Server">
<HintPath>..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Server.exe</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FizzWare.NBuilder, Version=3.0.1.0, Culture=neutral, PublicKeyToken=5651b03e12e42c12, processorArchitecture=MSIL"> <Reference Include="FizzWare.NBuilder, Version=3.0.1.0, Culture=neutral, PublicKeyToken=5651b03e12e42c12, processorArchitecture=MSIL">
<HintPath>..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll</HintPath> <HintPath>..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll</HintPath>
</Reference> </Reference>
@ -163,7 +151,6 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Datastore\IndexProviderFixture.cs" />
<Compile Include="Datastore\ObjectDatabaseFixture.cs" /> <Compile Include="Datastore\ObjectDatabaseFixture.cs" />
<Compile Include="Framework\CoreTest.cs" /> <Compile Include="Framework\CoreTest.cs" />
<Compile Include="Framework\ObjectDbTest.cs" /> <Compile Include="Framework\ObjectDbTest.cs" />
@ -336,7 +323,6 @@
<Content Include="Files\JsonError.txt"> <Content Include="Files\JsonError.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<None Include="Eloquera.config" />
<None Include="Files\RSS\nzbx_search.json"> <None Include="Files\RSS\nzbx_search.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>

View File

@ -29,7 +29,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
{ {
Mocker.GetMock<IRootFolderRepository>() Mocker.GetMock<IRootFolderRepository>()
.Setup(s => s.All()) .Setup(s => s.All())
.Returns(new List<RootFolder> { new RootFolder { Id = 1, Path = @"C:\Test\TV" } }); .Returns(new List<RootFolder> { new RootFolder { OID = 1, Path = @"C:\Test\TV" } });
Mocker.GetMock<DiskProvider>() Mocker.GetMock<DiskProvider>()
.Setup(s => s.GetPathRoot(@"C:\Test\TV")) .Setup(s => s.GetPathRoot(@"C:\Test\TV"))
@ -49,8 +49,8 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
{ {
Mocker.GetMock<IRootFolderRepository>() Mocker.GetMock<IRootFolderRepository>()
.Setup(s => s.All()) .Setup(s => s.All())
.Returns(new List<RootFolder> { new RootFolder { Id = 1, Path = @"C:\Test\TV" }, .Returns(new List<RootFolder> { new RootFolder { OID = 1, Path = @"C:\Test\TV" },
new RootFolder { Id = 2, Path = @"C:\Test\TV2" }}); new RootFolder { OID = 2, Path = @"C:\Test\TV2" }});
Mocker.GetMock<DiskProvider>() Mocker.GetMock<DiskProvider>()
.Setup(s => s.GetPathRoot(It.IsAny<String>())) .Setup(s => s.GetPathRoot(It.IsAny<String>()))
@ -70,8 +70,8 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
{ {
Mocker.GetMock<IRootFolderRepository>() Mocker.GetMock<IRootFolderRepository>()
.Setup(s => s.All()) .Setup(s => s.All())
.Returns(new List<RootFolder> { new RootFolder { Id = 1, Path = @"C:\Test\TV" }, .Returns(new List<RootFolder> { new RootFolder { OID = 1, Path = @"C:\Test\TV" },
new RootFolder { Id = 2, Path = @"D:\Test\TV" }}); new RootFolder { OID = 2, Path = @"D:\Test\TV" }});
Mocker.GetMock<DiskProvider>() Mocker.GetMock<DiskProvider>()
.Setup(s => s.GetPathRoot(@"C:\Test\TV")) .Setup(s => s.GetPathRoot(@"C:\Test\TV"))
@ -95,7 +95,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RootDirProviderTests
{ {
Mocker.GetMock<IRootFolderRepository>() Mocker.GetMock<IRootFolderRepository>()
.Setup(s => s.All()) .Setup(s => s.All())
.Returns(new List<RootFolder> { new RootFolder { Id = 1, Path = @"C:\Test\TV" } }); .Returns(new List<RootFolder> { new RootFolder { OID = 1, Path = @"C:\Test\TV" } });
Mocker.GetMock<DiskProvider>() Mocker.GetMock<DiskProvider>()
.Setup(s => s.GetPathRoot(@"C:\Test\TV")) .Setup(s => s.GetPathRoot(@"C:\Test\TV"))

View File

@ -93,7 +93,7 @@ namespace NzbDrone.Core.Test.ProviderTests.RootFolderServiceTests
public void invalid_folder_path_throws_on_add(string path) public void invalid_folder_path_throws_on_add(string path)
{ {
Assert.Throws<ArgumentException>(() => Assert.Throws<ArgumentException>(() =>
Mocker.Resolve<RootFolderService>().Add(new RootFolder { Id = 0, Path = path }) Mocker.Resolve<RootFolderService>().Add(new RootFolder { OID = 0, Path = path })
); );
} }

View File

@ -3,7 +3,6 @@
<package id="Autofac" version="2.6.3.862" targetFramework="net40" /> <package id="Autofac" version="2.6.3.862" targetFramework="net40" />
<package id="AutoMoq" version="1.6.1" targetFramework="net40" /> <package id="AutoMoq" version="1.6.1" targetFramework="net40" />
<package id="CommonServiceLocator" version="1.0" targetFramework="net40" /> <package id="CommonServiceLocator" version="1.0" targetFramework="net40" />
<package id="EloqueraDB" version="5.0.0" targetFramework="net40" />
<package id="FluentAssertions" version="2.0.0.1" targetFramework="net40" /> <package id="FluentAssertions" version="2.0.0.1" targetFramework="net40" />
<package id="Moq" version="4.0.10827" /> <package id="Moq" version="4.0.10827" />
<package id="NBuilder" version="3.0.1.1" /> <package id="NBuilder" version="3.0.1.1" />

View File

@ -82,8 +82,8 @@ namespace NzbDrone.Core
container.Register(c => container.Register(c =>
{ {
return c.Resolve<EloqueraDbFactory>().Create(); return c.Resolve<IObjectDbFactory>().Create("");
}).As<EloqueraDb>().SingleInstance(); }).As<SiaqodbProxy>().SingleInstance();
container.RegisterType<DatabaseTarget>().WithParameter(ResolvedParameter.ForNamed<IDatabase>("DatabaseTarget")); container.RegisterType<DatabaseTarget>().WithParameter(ResolvedParameter.ForNamed<IDatabase>("DatabaseTarget"));
container.RegisterType<LogProvider>().WithParameter(ResolvedParameter.ForNamed<IDatabase>("LogProvider")); container.RegisterType<LogProvider>().WithParameter(ResolvedParameter.ForNamed<IDatabase>("LogProvider"));

View File

@ -1,14 +1,10 @@
using System.Linq; using System.Linq;
using Eloquera.Client;
namespace NzbDrone.Core.Datastore namespace NzbDrone.Core.Datastore
{ {
public abstract class BaseRepositoryModel public abstract class BaseRepositoryModel
{ {
[ID]
private long _eqId;
[PetaPoco.Ignore] [PetaPoco.Ignore]
public int Id { get; set; } public int OID { get; set; }
} }
} }

View File

@ -13,32 +13,32 @@ namespace NzbDrone.Core.Datastore
public class BasicRepository<TModel> : IBasicRepository<TModel> where TModel : BaseRepositoryModel, new() public class BasicRepository<TModel> : IBasicRepository<TModel> where TModel : BaseRepositoryModel, new()
{ {
public BasicRepository(EloqueraDb eloqueraDb) public BasicRepository(IObjectDatabase objectDatabase)
{ {
EloqueraDb = eloqueraDb; ObjectDatabase = objectDatabase;
} }
protected EloqueraDb EloqueraDb { get; private set; } protected IObjectDatabase ObjectDatabase { get; private set; }
public List<TModel> All() public List<TModel> All()
{ {
return EloqueraDb.AsQueryable<TModel>().ToList(); return ObjectDatabase.AsQueryable<TModel>().ToList();
} }
public TModel Get(int id) public TModel Get(int id)
{ {
return EloqueraDb.AsQueryable<TModel>().Single(c => c.Id == id); return ObjectDatabase.AsQueryable<TModel>().Single(c => c.OID == id);
} }
public TModel Add(TModel model) public TModel Add(TModel model)
{ {
return EloqueraDb.Insert(model); return ObjectDatabase.Insert(model);
} }
public void Delete(int id) public void Delete(int id)
{ {
var itemToDelete = Get(id); var itemToDelete = Get(id);
EloqueraDb.Delete(itemToDelete); ObjectDatabase.Delete(itemToDelete);
} }
} }
} }

View File

@ -1,83 +0,0 @@
using System;
using System.IO;
using System.Linq;
using Eloquera.Client;
using NzbDrone.Common;
using NzbDrone.Core.Repository;
using NzbDrone.Core.RootFolders;
namespace NzbDrone.Core.Datastore
{
public class EloqueraDbFactory
{
private readonly EnvironmentProvider _environmentProvider;
private readonly string dllPath;
public EloqueraDbFactory(EnvironmentProvider environmentProvider)
{
_environmentProvider = environmentProvider;
dllPath = _environmentProvider.GetWebBinPath();// this is the path where Eloquera dlls live.
}
public EloqueraDb CreateMemoryDb()
{
return InternalCreate("server=(local);password=;options=inmemory;uselocalpath=" + dllPath, Guid.NewGuid().ToString());
}
public EloqueraDb Create(string dbPath = null)
{
if (dbPath == null)
{
dbPath = _environmentProvider.GetElqMainDbPath();
}
var file = new FileInfo(dbPath);
return InternalCreate(string.Format("server=(local);password=;usedatapath={0};uselocalpath={1}", file.Directory.FullName, dllPath), file.Name);
}
private EloqueraDb InternalCreate(string connectionString, string databaseName)
{
var db = new DB(connectionString);
try
{
db.OpenDatabase(databaseName);
}
catch (FileNotFoundException)
{
db.CreateDatabase(databaseName);
db.OpenDatabase(databaseName);
}
//This seemse to cause Invalid Cast Exceptions... WTF
//db.RefreshMode = ObjectRefreshMode.AlwaysReturnUpdatedValues;
RegisterTypeRules();
RegisterTypes(db);
return new EloqueraDb(db, new IdService(new IndexProvider(db)));
}
private void RegisterTypeRules()
{
RootFolder rootFolder = null;
DB.TypeRules
//.SetIDField(() => rootFolder.Id)
.IgnoreProperty(() => rootFolder.FreeSpace)
.IgnoreProperty(() => rootFolder.UnmappedFolders);
//Series series = null;
//DB.TypeRules
// .SetIDField(() => series.Id);
}
private void RegisterTypes(DB db)
{
db.RegisterType(typeof(RootFolder));
db.RegisterType(typeof(Series));
db.RegisterType(typeof(Episode));
}
}
}

View File

@ -1,91 +0,0 @@
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace NzbDrone.Core.Datastore
{
public class IdService
{
private readonly IndexProvider _indexProvider;
private static readonly ConcurrentDictionary<string, IList<PropertyInfo>> propertyCache = new ConcurrentDictionary<string, IList<PropertyInfo>>();
public IdService(IndexProvider indexProvider)
{
_indexProvider = indexProvider;
}
public void EnsureIds<T>(T obj, HashSet<object> context)
{
//context is use to prevent infinite loop if objects are recursively looped.
if (obj == null || context.Contains(obj))
{
return;
}
context.Add(obj);
var modelBase = obj as BaseRepositoryModel;
if (modelBase != null && modelBase.Id == 0)
{
modelBase.Id = _indexProvider.Next(obj.GetType());
}
var list = obj as IEnumerable;
if (list != null)
{
foreach (var item in list)
{
EnsureIds(item, context);
}
return;
}
foreach (var propertyInfo in GetPotentialProperties(obj.GetType()))
{
var propValue = propertyInfo.GetValue(obj, null);
EnsureIds(propValue, context);
}
}
private IList<PropertyInfo> GetPotentialProperties(Type type)
{
IList<PropertyInfo> result;
if (!propertyCache.TryGetValue(type.FullName, out result))
{
result = type.GetProperties().Where(ShouldCrawl).ToList();
propertyCache.TryAdd(type.FullName, result);
}
return result;
}
private bool ShouldCrawl(PropertyInfo propertyInfo)
{
return propertyInfo.CanRead && ShouldCrawl(propertyInfo.PropertyType);
}
private bool ShouldCrawl(Type type)
{
if (type.IsGenericType)
{
var genericArg = type.GetGenericArguments()[0];
//skip if generic argument type isn't interesting
if (!ShouldCrawl(genericArg))
{
return false;
}
var listType = typeof(IList<>).MakeGenericType(genericArg);
return listType.IsAssignableFrom(type);
}
return type.IsClass && type.FullName.StartsWith("NzbDrone");
}
}
}

View File

@ -1,81 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Eloquera.Client;
namespace NzbDrone.Core.Datastore
{
public interface IProvideIndex
{
int Next(Type type);
}
public class IndexProvider : IProvideIndex
{
private readonly DB _db;
private static object _lock = new object();
public IndexProvider(DB db)
{
_db = db;
if (db.IsTypeRegistered(typeof(IndexList)))
{
db.RegisterType(typeof(IndexList));
}
lock (_lock)
{
try
{
_db.Query<IndexList>().Count();
}
catch (EloqueraException ex)
{
_db.Store(new IndexList());
}
}
}
public int Next(Type type)
{
if (type == null)
{
throw new ArgumentException();
}
var key = type.Name;
lock (_lock)
{
var indexList = _db.Query<IndexList>().Single();
var indexInfo = indexList.SingleOrDefault(c => c.Type == key);
if (indexInfo == null)
{
indexInfo = new IndexInfo { Type = key };
indexList.Add(indexInfo);
}
indexInfo.Index++;
_db.Store(indexList);
return indexInfo.Index;
}
}
public class IndexList : List<IndexInfo> { }
public class IndexInfo
{
public string Type { get; set; }
public int Index { get; set; }
}
}
}

View File

@ -35,12 +35,12 @@ namespace NzbDrone.Core.Datastore.Migrations
} }
} }
protected EloqueraDb GetObjectDb() protected IObjectDatabase GetObjectDb()
{ {
var sqlCeConnection = SqlCeProxy.EnsureDatabase(Database.ConnectionString); var sqlCeConnection = SqlCeProxy.EnsureDatabase(Database.ConnectionString);
var eqPath = sqlCeConnection.Database.Replace(".sdf", ".eq"); var eqPath = sqlCeConnection.Database.Replace(".sdf", ".eq");
return new EloqueraDbFactory(new EnvironmentProvider()).Create(eqPath); return new SiaqoDbFactory(new DiskProvider()).Create(eqPath);
} }
public override void Down() public override void Down()

View File

@ -0,0 +1,42 @@
using System;
using System.Linq;
using NzbDrone.Common;
using Sqo;
namespace NzbDrone.Core.Datastore
{
public interface IObjectDbFactory
{
IObjectDatabase CreateMemoryDb();
IObjectDatabase Create(string dbPath);
}
public class SiaqoDbFactory : IObjectDbFactory
{
private readonly DiskProvider _diskProvider;
public SiaqoDbFactory(DiskProvider diskProvider)
{
_diskProvider = diskProvider;
}
public IObjectDatabase CreateMemoryDb()
{
throw new NotImplementedException();
}
public IObjectDatabase Create(string dbPath)
{
if(!_diskProvider.FolderExists(dbPath))
{
_diskProvider.CreateDirectory(dbPath);
}
SiaqodbConfigurator.SetTrialLicense("uvhpW4hT5Rtq+Uoyq8MOm1Smon15foxV5iS5bAegIXU=");
var db = new Siaqodb(dbPath);
return new SiaqodbProxy(db);
}
}
}

View File

@ -1,80 +1,81 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using Sqo;
using Eloquera.Client;
namespace NzbDrone.Core.Datastore namespace NzbDrone.Core.Datastore
{ {
public class EloqueraDb : IDisposable public interface IObjectDatabase : IDisposable
{ {
private readonly IdService _idService; IEnumerable<T> AsQueryable<T>();
public DB Db { get; private set; } T Insert<T>(T obj) where T : BaseRepositoryModel;
T Update<T>(T obj) where T : BaseRepositoryModel;
IList<T> InsertMany<T>(IList<T> objects) where T : BaseRepositoryModel;
IList<T> UpdateMany<T>(IList<T> objects) where T : BaseRepositoryModel;
void Delete<T>(T obj) where T : BaseRepositoryModel;
void DeleteMany<T>(IEnumerable<T> objects) where T : BaseRepositoryModel;
}
public EloqueraDb(DB db, IdService idService) public class SiaqodbProxy : IObjectDatabase
{
private readonly Siaqodb _db;
public SiaqodbProxy(Siaqodb db)
{ {
_idService = idService; _db = db;
Db = db; }
public void Dispose()
{
} }
public IEnumerable<T> AsQueryable<T>() public IEnumerable<T> AsQueryable<T>()
{ {
return Db.Query<T>(); return _db.Cast<T>();
} }
public T Insert<T>(T obj) where T : BaseRepositoryModel public T Insert<T>(T obj) where T : BaseRepositoryModel
{ {
if (obj.Id != 0) if (obj.OID != 0)
{ {
throw new InvalidOperationException("Attempted to insert object with existing ID as new object"); throw new InvalidOperationException("Attempted to insert object with existing ID as new object");
} }
_idService.EnsureIds(obj, new HashSet<object>()); _db.StoreObject(obj);
Db.Store(obj);
return obj; return obj;
} }
public T Update<T>(T obj) where T : BaseRepositoryModel public T Update<T>(T obj) where T : BaseRepositoryModel
{ {
if (obj.Id == 0) if (obj.OID == 0)
{ {
throw new InvalidOperationException("Attempted to update object without ID"); throw new InvalidOperationException("Attempted to update object without an ID");
} }
_idService.EnsureIds(obj, new HashSet<object>()); _db.StoreObject(obj);
Db.Store(obj);
return obj; return obj;
} }
public IList<T> InsertMany<T>(IList<T> objects) where T : BaseRepositoryModel public IList<T> InsertMany<T>(IList<T> objects) where T : BaseRepositoryModel
{ {
_idService.EnsureIds(objects, new HashSet<object>()); return DoMany(objects,Insert);
return DoMany(objects, Insert);
} }
public IList<T> UpdateMany<T>(IList<T> objects) where T : BaseRepositoryModel public IList<T> UpdateMany<T>(IList<T> objects) where T : BaseRepositoryModel
{ {
_idService.EnsureIds(objects, new HashSet<object>());
return DoMany(objects, Update); return DoMany(objects, Update);
} }
public void Delete<T>(T obj) where T : BaseRepositoryModel public void Delete<T>(T obj) where T : BaseRepositoryModel
{ {
if (obj.Id == 0) throw new NotImplementedException();
{
throw new InvalidOperationException("Attempted to delete an object without an ID");
}
Db.Delete(obj);
} }
public void DeleteMany<T>(IEnumerable<T> objects) where T : BaseRepositoryModel public void DeleteMany<T>(IEnumerable<T> objects) where T : BaseRepositoryModel
{ {
foreach (var o in objects) throw new NotImplementedException();
{
Delete(o);
}
} }
private IList<T> DoMany<T>(IEnumerable<T> objects, Func<T, T> function) where T : BaseRepositoryModel private IList<T> DoMany<T>(IEnumerable<T> objects, Func<T, T> function) where T : BaseRepositoryModel
@ -82,10 +83,5 @@ namespace NzbDrone.Core.Datastore
return objects.Select(function).ToList(); return objects.Select(function).ToList();
} }
public void Dispose()
{
Db.Dispose();
}
} }
} }

View File

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<Eloquera xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Cache IndexCacheSize="10000"
WriteThru="false"
IndexCleanerPeriod="100"
IndexCleanerBatchSize="100"
CleanerPeriod="100"
CleanerBatchSize="2000"
CommitSequenceMaxLength="2000"
ShallowReadThreshold="1000"
ShallowReadAhead="1000"
ReadAhead="20"
SaturationThreshold="10000"
MemoryFootPrint="60"/>
<MemoryManager Mode="1" />
<Server ServerPort="43962"
Trace="true"
InMemoryAllowed="true"
Secure="false"
AllowUsers=""
AllowGroups="Everyone"
SNMPAddress="net.tcp://localhost:8523/SNMP"
AutoRecovery="false"
NotificationsEnabled="false"
VarSectorSize="40"
IndexNodeSize="512"/>
<SmartRuntime Smart="true"
TypeUpdateAllowed="true"/>
<UserLogin Enabled="false"
PasswordHash="l+on1aCwDrcZ5bGlv+fyyIlYkbuFIOxZFlFwIGKlms0CCwoGn9TZvM0E3Uksjwx64+/yv8nsaUajWLz1kyKG7A==" />
</Eloquera>

View File

@ -167,15 +167,6 @@
<Reference Include="DeskMetrics.NET"> <Reference Include="DeskMetrics.NET">
<HintPath>..\Libraries\DeskMetrics\DeskMetrics.NET.dll</HintPath> <HintPath>..\Libraries\DeskMetrics\DeskMetrics.NET.dll</HintPath>
</Reference> </Reference>
<Reference Include="Eloquera.Client">
<HintPath>..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Client.dll</HintPath>
</Reference>
<Reference Include="Eloquera.Common">
<HintPath>..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Common.dll</HintPath>
</Reference>
<Reference Include="Eloquera.Server">
<HintPath>..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Server.exe</HintPath>
</Reference>
<Reference Include="Growl.Connector"> <Reference Include="Growl.Connector">
<HintPath>..\packages\Growl.0.6\lib\Growl.Connector.dll</HintPath> <HintPath>..\packages\Growl.0.6\lib\Growl.Connector.dll</HintPath>
</Reference> </Reference>
@ -219,6 +210,9 @@
<Reference Include="RestSharp"> <Reference Include="RestSharp">
<HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath> <HintPath>..\packages\RestSharp.104.1\lib\net4\RestSharp.dll</HintPath>
</Reference> </Reference>
<Reference Include="siaqodb">
<HintPath>..\Libraries\Siaqodb\siaqodb.dll</HintPath>
</Reference>
<Reference Include="SignalR"> <Reference Include="SignalR">
<HintPath>..\packages\SignalR.Server.0.5.3\lib\net40\SignalR.dll</HintPath> <HintPath>..\packages\SignalR.Server.0.5.3\lib\net40\SignalR.dll</HintPath>
</Reference> </Reference>
@ -258,10 +252,8 @@
<Compile Include="Datastore\BaseRepositoryModel.cs" /> <Compile Include="Datastore\BaseRepositoryModel.cs" />
<Compile Include="Datastore\BasicRepository.cs" /> <Compile Include="Datastore\BasicRepository.cs" />
<Compile Include="Datastore\ConnectionFactory.cs" /> <Compile Include="Datastore\ConnectionFactory.cs" />
<Compile Include="Datastore\EloqueraDb.cs" /> <Compile Include="Datastore\ObjectDbFactory.cs" />
<Compile Include="Datastore\EloqueraDbFactory.cs" /> <Compile Include="Datastore\SiaqodbProxy.cs" />
<Compile Include="Datastore\IdService.cs" />
<Compile Include="Datastore\IndexProvider.cs" />
<Compile Include="Datastore\CustomeMapper.cs" /> <Compile Include="Datastore\CustomeMapper.cs" />
<Compile Include="Datastore\MigrationLogger.cs" /> <Compile Include="Datastore\MigrationLogger.cs" />
<Compile Include="Datastore\MigrationsHelper.cs" /> <Compile Include="Datastore\MigrationsHelper.cs" />
@ -670,7 +662,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
<None Include="Eloquera.config" />
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\AnalysisRules.ruleset" /> <None Include="Properties\AnalysisRules.ruleset" />
</ItemGroup> </ItemGroup>

View File

@ -1,5 +1,4 @@
using System; using System;
using Eloquera.Client;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using PetaPoco; using PetaPoco;

View File

@ -1,6 +1,5 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using Eloquera.Client;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;

View File

@ -1,7 +1,4 @@
using System.Collections.Generic; using NzbDrone.Core.Datastore;
using Eloquera.Client;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Repository;
using System.Linq; using System.Linq;
namespace NzbDrone.Core.RootFolders namespace NzbDrone.Core.RootFolders
@ -14,15 +11,15 @@ namespace NzbDrone.Core.RootFolders
//This way we only need to implement none_custom methods for repos, like custom queries etc... rest is done automagically. //This way we only need to implement none_custom methods for repos, like custom queries etc... rest is done automagically.
public class RootFolderRepository : BasicRepository<RootFolder>, IRootFolderRepository public class RootFolderRepository : BasicRepository<RootFolder>, IRootFolderRepository
{ {
public RootFolderRepository(EloqueraDb eloqueraDb) public RootFolderRepository(IObjectDatabase objectDatabase)
: base(eloqueraDb) : base(objectDatabase)
{ {
} }
public RootFolder Add(RootFolder rootFolder) public RootFolder Add(RootFolder rootFolder)
{ {
return EloqueraDb.Insert(rootFolder); return ObjectDatabase.Insert(rootFolder);
} }
} }
} }

View File

@ -3,7 +3,6 @@
<package id="Autofac" version="2.6.3.862" targetFramework="net40" /> <package id="Autofac" version="2.6.3.862" targetFramework="net40" />
<package id="DataTables.Mvc.Core" version="0.1.0.85" /> <package id="DataTables.Mvc.Core" version="0.1.0.85" />
<package id="DotNetZip" version="1.9.1.8" /> <package id="DotNetZip" version="1.9.1.8" />
<package id="EloqueraDB" version="5.0.0" targetFramework="net40" />
<package id="Growl" version="0.6" /> <package id="Growl" version="0.6" />
<package id="MediaInfoNet" version="0.3" targetFramework="net40" /> <package id="MediaInfoNet" version="0.3" targetFramework="net40" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" /> <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" />

View File

@ -1,31 +0,0 @@
<?xml version="1.0"?>
<Eloquera xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Cache IndexCacheSize="10000"
WriteThru="false"
IndexCleanerPeriod="100"
IndexCleanerBatchSize="100"
CleanerPeriod="100"
CleanerBatchSize="2000"
CommitSequenceMaxLength="2000"
ShallowReadThreshold="1000"
ShallowReadAhead="1000"
ReadAhead="20"
SaturationThreshold="10000"
MemoryFootPrint="60"/>
<MemoryManager Mode="1" />
<Server ServerPort="43962"
Trace="true"
InMemoryAllowed="true"
Secure="false"
AllowUsers=""
AllowGroups="Everyone"
SNMPAddress="net.tcp://localhost:8523/SNMP"
AutoRecovery="false"
NotificationsEnabled="false"
VarSectorSize="40"
IndexNodeSize="512"/>
<SmartRuntime Smart="true"
TypeUpdateAllowed="true"/>
<UserLogin Enabled="false"
PasswordHash="l+on1aCwDrcZ5bGlv+fyyIlYkbuFIOxZFlFwIGKlms0CCwoGn9TZvM0E3Uksjwx64+/yv8nsaUajWLz1kyKG7A==" />
</Eloquera>

View File

@ -92,17 +92,6 @@
<Reference Include="Dynamic"> <Reference Include="Dynamic">
<HintPath>..\packages\DynamicQuery.1.0\lib\35\Dynamic.dll</HintPath> <HintPath>..\packages\DynamicQuery.1.0\lib\35\Dynamic.dll</HintPath>
</Reference> </Reference>
<Reference Include="Eloquera.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=170cadcdba67be6c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Client.dll</HintPath>
</Reference>
<Reference Include="Eloquera.Common, Version=5.0.0.0, Culture=neutral, PublicKeyToken=170cadcdba67be6c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Common.dll</HintPath>
</Reference>
<Reference Include="Eloquera.Server">
<HintPath>..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Server.exe</HintPath>
</Reference>
<Reference Include="LowercaseRoutesMVC"> <Reference Include="LowercaseRoutesMVC">
<HintPath>..\packages\LowercaseRoutesMVC.1.0.3\lib\LowercaseRoutesMVC.dll</HintPath> <HintPath>..\packages\LowercaseRoutesMVC.1.0.3\lib\LowercaseRoutesMVC.dll</HintPath>
</Reference> </Reference>
@ -435,7 +424,6 @@
<Content Include="_backboneApp\Shared\NotificationView.js" /> <Content Include="_backboneApp\Shared\NotificationView.js" />
<Content Include="_backboneApp\Shared\SpinnerTemplate.html" /> <Content Include="_backboneApp\Shared\SpinnerTemplate.html" />
<Content Include="_backboneApp\Shared\SpinnerView.js" /> <Content Include="_backboneApp\Shared\SpinnerView.js" />
<Content Include="Eloquera.config" />
<Content Include="ClassDiagram1.cd" /> <Content Include="ClassDiagram1.cd" />
<Content Include="_backboneApp\JsLibraries\backbone.collectionbinder.js" /> <Content Include="_backboneApp\JsLibraries\backbone.collectionbinder.js" />
<Content Include="_backboneApp\JsLibraries\backbone.debug.js" /> <Content Include="_backboneApp\JsLibraries\backbone.debug.js" />

View File

@ -12,7 +12,6 @@
<package id="DataTables.Mvc.Core" version="0.1.0.85" /> <package id="DataTables.Mvc.Core" version="0.1.0.85" />
<package id="DotlessClientOnly" version="1.3.1.0" targetFramework="net40" /> <package id="DotlessClientOnly" version="1.3.1.0" targetFramework="net40" />
<package id="DynamicQuery" version="1.0" /> <package id="DynamicQuery" version="1.0" />
<package id="EloqueraDB" version="5.0.0" targetFramework="net40" />
<package id="FontAwesome" version="2.0.2" targetFramework="net40" /> <package id="FontAwesome" version="2.0.2" targetFramework="net40" />
<package id="jQuery" version="1.8.2" targetFramework="net40" /> <package id="jQuery" version="1.8.2" targetFramework="net40" />
<package id="jQuery.Ajax.Unobtrusive" version="2.0.20710.0" targetFramework="net40" /> <package id="jQuery.Ajax.Unobtrusive" version="2.0.20710.0" targetFramework="net40" />

Binary file not shown.