示例#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;
 }
示例#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);
     }
 }
示例#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;
        }
示例#4
0
 public QueueWriter(AggregateBase aggregate, AggregateStore store, string Shard)
 {
     this.aggregate = aggregate;
     this.store = store;
     this.Shard = Shard;
 }
示例#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);
     }
 }
示例#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);
     }
 }
示例#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();
 }
示例#8
0
 private bool HasIndexes(AggregateBase aggregate)
 {
     return aggregate.HasIndexes();
 }
示例#9
0
 public void Submit(AggregateBase aggregate, string Shard)
 {
 }