Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 public void Delete(AggregateBase aggregate, string Shard)
 {
     try
     {
         writeRepo.GetDeleteAggregate().Execute(aggregate.AggregateID, Shard);
     }
     catch (Exception e)
     {
         throw new Exception("Failed in 'Delete'", e);
     }
 }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
 public QueueWriter(AggregateBase aggregate, AggregateStore store, string Shard)
 {
     this.aggregate = aggregate;
     this.store = store;
     this.Shard = Shard;
 }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 6
0
 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);
     }
 }
Esempio n. 7
0
 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();
 }
Esempio n. 8
0
 private bool HasIndexes(AggregateBase aggregate)
 {
     return aggregate.HasIndexes();
 }
Esempio n. 9
0
 public void Submit(AggregateBase aggregate, string Shard)
 {
 }