public Submitter(AggregateBase aggregate, string Shard, Guid guid, long AggregateTypeID) { this.aggregate = aggregate; this.Shard = Shard; this.SubmissionID = guid.ToString(); this.ClassType = aggregate.GetType(); this.AggregateTypeID = AggregateTypeID; }
public void Delete(AggregateBase aggregate, string Shard) { try { writeRepo.GetDeleteAggregate().Execute(aggregate.AggregateID, Shard); } catch (Exception e) { throw new Exception("Failed in 'Delete'", e); } }
public long Save(AggregateBase aggregate, string Shard, long AggregateTypeID) { long ID = 0; try { aggregate.AggregateTypeID = AggregateTypeID; if (aggregate.AggregateID == 0) { aggregate.VersionNumber = 1; } AggregateStore store = aggregate.ToAggregateStore(); if (aggregate.AggregateID == 0) { ID = Add(store, Shard); aggregate.AggregateID = ID; store = aggregate.ToAggregateStore(); Update(aggregate, store, Shard); } else { Update(aggregate,store, Shard); ProcessCascadingUpdates(aggregate,store, Shard); } if (HasIndexes(aggregate)) { DeleteIndexes(store, Shard); RebuildIndexes(aggregate, store, Shard); } } catch (Exception e) { throw new Exception(string.Format( @"Save failed: {0} {1},", e.Message, e.InnerException.Message)); } return ID; }
public QueueWriter(AggregateBase aggregate, AggregateStore store, string Shard) { this.aggregate = aggregate; this.store = store; this.Shard = Shard; }
private void Update(AggregateBase aggregate, AggregateStore store, string Shard) { try { writeRepo.GetUpdateAggregate().Execute(store, aggregate.GetUniqueKey(), Shard); } catch (Exception e) { throw new Exception("Failed in 'Update'", e); } }
private void RebuildIndexes(AggregateBase aggregate, AggregateStore store, string Shard) { try { Dictionary<string, string> indexes = aggregate.GetIndexes(); foreach (string key in indexes.Keys) { writeRepo.GetInsertAggregateIndex().Execute(store, key, indexes[key], Shard); } } catch (Exception e) { throw new Exception("Failed in 'RebuildIndexes'", e); } }
private void ProcessCascadingUpdates(AggregateBase aggregate, AggregateStore store, string Shard) { // QueueWriter queueWriter = new QueueWriter(aggregate, store, Shard); queueWriter.Send(); Thread t = new Thread(queueWriter.Send); t.Start(); }
private bool HasIndexes(AggregateBase aggregate) { return aggregate.HasIndexes(); }
public void Submit(AggregateBase aggregate, string Shard) { }