public AkkaActorSystemMechanism(IActorRef storageActorRef, IStorageMechanism worker, DataBaseSettings DdtaBaseSettings, IPecanLogger logger) { this.Logger = logger; this._storageActorRef = storageActorRef; this._worker = worker; this.FileSystem = this._worker?.FileSystem; this.DataBaseSettings = DdtaBaseSettings; }
public StorageDatabase(IStorageMechanism storageMechanism, string documentName, DatabaseService dataBaseSettings, IPecanLogger logger) { this.Logger = logger; this.Logger?.Trace(this.GetType().Name, $"Initializing storage database ..."); this.DataBaseSettings = dataBaseSettings; this.storageMechanism = storageMechanism; string dname = PecanDatabaseUtilityObj.DetermineDatabaseName <TDocumentWithObject, TObjectOnly>(documentName); this.DocumentName = dname; CurrentCount = this.storageMechanism.Count <TDocumentWithObject>(this.DocumentName, true); this.Logger?.Trace(this.GetType().Name, $"Initialized storage. Document Name {this.DocumentName} and current count {CurrentCount}"); }
/// <summary> /// Adds the storage mechanism. /// </summary> /// <param name="storageMechanism">The storage mechanism.</param> public void AddStorageMechanism(IStorageMechanism storageMechanism) { storageMechanisms.Add(storageMechanism); }
public static void UpdateDocumentHistory <TDocumentWithObject, TObjectOnly>(TDocumentWithObject original, TDocumentWithObject dbObject, IStorageMechanism storageMechanism, string databaseName, DatabaseService DatabaseService) where TDocumentWithObject : IStandardDocument <TObjectOnly> { if (TypeOfWrapper.TypeOf(typeof(TDocumentWithObject)).Name == TypeOfWrapper.TypeOf(typeof(History <>)).Name || TypeOfWrapper.TypeOf(typeof(TDocumentWithObject)).Name == TypeOfWrapper.TypeOf(typeof(SystemDb <>)).Name || original?.Id == null) { return; } List <PropertyCompareResult> compares = Compare <TDocumentWithObject, TObjectOnly>(original, dbObject); using (StorageDatabase <History <object>, object> history = DatabaseService.DatabaseAccessRegardlessOfTransaction <History <object>, object>(storageMechanism, null)) { history.CreateAll( compares.Select( x => new History <object> { OldValue = x.OldValue, NewValue = x.NewValue, DocumentName = x.DocumentName, DateTime = x.DateTime, Name = x.Name }).ToList()); } }
public DirectDocumentManipulator(IStorageMechanism s, DatabaseService _DatabaseService, IPecanLogger logger) { this.Logger = logger; this.DatabaseService = _DatabaseService; this.sMech = s ?? throw new ArgumentNullException(nameof(s)); }
internal StorageDatabase <TDocumentWithObject, TObjectOnly> DatabaseAccessRegardlessOfTransaction <TDocumentWithObject, TObjectOnly>(IStorageMechanism storageMechanism, string directoryName) where TDocumentWithObject : IStandardDocument <TObjectOnly> { string key = TypeOfWrapper.TypeOf(typeof(StorageDatabase <TDocumentWithObject, TObjectOnly>)).FullName + "+" + directoryName; this.Logger?.Trace(this.GetType().Name, $"Accessing database storage outside the usual pipeline with key {key} for directory name {directoryName} with storage mechanism {storageMechanism?.GetType().Name}. Documment with object : {typeof(TDocumentWithObject).Name}, Object type only : {typeof(TObjectOnly).Name}"); if (!this.cacheForTransactionScenarios.ContainsKey(key)) { lock (this.padlock2) { if (!this.cacheForTransactionScenarios.ContainsKey(key)) { var val = new StorageDatabase <TDocumentWithObject, TObjectOnly>( storageMechanism, directoryName, this, this.Logger); this.cacheForTransactionScenarios[key] = val; } } } return(this.cacheForTransactionScenarios[key] as StorageDatabase <TDocumentWithObject, TObjectOnly>); }
public static void LogDocument <TDocumentWithObject, TObjectOnly>(string documentId, TDocumentWithObject oldDoc, TDocumentWithObject newDoc, string operation, IStorageMechanism storageMechanism, string databaseName, DatabaseService DatabaseService) where TDocumentWithObject : IStandardDocument <TObjectOnly> { if (documentId == null) { throw new ArgumentNullException(nameof(documentId)); } if (TypeOfWrapper.TypeOf(typeof(TDocumentWithObject)).Name != TypeOfWrapper.TypeOf(typeof(History <>)).Name) { HistoryService.UpdateDocumentHistory <TDocumentWithObject, TObjectOnly>(oldDoc, newDoc, storageMechanism, databaseName, DatabaseService); } if (TypeOfWrapper.TypeOf(typeof(TDocumentWithObject)).Name == TypeOfWrapper.TypeOf(typeof(SystemDb <>)).Name) { return; } }