public void SaveEventsFor <TAggregate>(Guid?aggregateId, int eventsLoaded, ArrayList newEvents)
        {
            var aggregate = this.Aggregates.Find(aggregateId.Value);

            if (aggregate == null)
            {
                aggregate = new CqrsModels.Aggregate
                {
                    Id             = aggregateId.Value,
                    AggregateType  = typeof(TAggregate).AssemblyQualifiedName,
                    CommitDateTime = DateTime.UtcNow
                };

                Aggregates.Add(aggregate);
            }

            for (int i = 0; i < newEvents.Count; i++)
            {
                var e = newEvents[i];
                eventsLoaded = eventsLoaded + i;
                Events.Add(new CqrsModels.Event
                {
                    Id             = Guid.NewGuid(),
                    AggregateId    = aggregate.Id,
                    SequenceNumber = eventsLoaded,
                    Type           = e.GetType().AssemblyQualifiedName,
                    Body           = SerializeEvent(e),
                    CommitDateTime = aggregate.CommitDateTime
                });
            }



            _context.Commit();
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Select"/> class.
 /// </summary>
 /// <param name="aggregates">The aggregates.</param>
 public Select(params Aggregate[] aggregates)
 {
     foreach (Aggregate agg in aggregates)
     {
         Aggregates.Add(agg);
     }
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Select"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="aggregates">The aggregates.</param>
 public Select(IDataProvider provider, params Aggregate[] aggregates)
 {
     SQLCommand = SqlFragment.SELECT;
     _provider  = provider;
     foreach (Aggregate agg in aggregates)
     {
         Aggregates.Add(agg);
     }
 }
Пример #4
0
        /// <summary>
        /// Deserializa os dados agregados.
        /// </summary>
        /// <param name="aggregate"></param>
        private void DeserializeAggregate(string aggregate)
        {
            Func <AggregateFunction> func;

            if (_aggregateFactories.TryGetValue(aggregate, out func))
            {
                Aggregates.Add(func());
            }
        }
Пример #5
0
        public CatalogSchema() : base("Catalog", "Telesophy.Alexandria.Model")
        {
            Entities.Add(mediaSetEntity);
            Entities.Add(mediaItemEntity);
            Entities.Add(artistEntity);

            Aggregates.Add(mediaSetWithAllChildren);
            Aggregates.Add(mediaItemSingleton);
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Select"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="aggregates">The aggregates.</param>
 public Select(DataProvider provider, params Aggregate[] aggregates)
 {
     Provider     = provider;
     ProviderName = provider.Name;
     foreach (Aggregate agg in aggregates)
     {
         Aggregates.Add(agg);
     }
 }
Пример #7
0
        private void DeserializeAggregate(string aggregate)
        {
            Func <AggregateFunction> factory;

            if (aggregateFactories.TryGetValue(aggregate, out factory))
            {
                Aggregates.Add(factory());
            }
        }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Select"/> class.
 /// </summary>
 /// <param name="aggregates">The aggregates.</param>
 public Select(params Aggregate[] aggregates)
 {
     _provider  = ProviderFactory.GetProvider();
     SQLCommand = SqlFragment.SELECT;
     foreach (Aggregate agg in aggregates)
     {
         Aggregates.Add(agg);
     }
 }
        private void EnsureAggregateExists <TAggregate>(Guid AggregateRootId) where TAggregate : IAggregateRoot
        {
            var aggregate = Aggregates.Where(x => x.Id == AggregateRootId).FirstOrDefault();

            if (aggregate == null)
            {
                var aggregateDocument = new AggregateDocument(id: AggregateRootId, type: typeof(TAggregate).AssemblyQualifiedName);
                Aggregates.Add(aggregateDocument);
            }
        }
Пример #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Select"/> class.
 /// </summary>
 /// <param name="provider">The provider.</param>
 /// <param name="aggregates">The aggregates.</param>
 public Select(IDataProvider provider, params Aggregate[] aggregates)
 {
     _provider        = provider;
     this.sqlFragment = _provider.SqlFragment;
     SQLCommand       = this.sqlFragment.SELECT;
     foreach (Aggregate agg in aggregates)
     {
         Aggregates.Add(agg);
     }
 }
Пример #11
0
 /// <summary>
 /// 构造nvl
 /// </summary>
 /// <param name="defaultValue"></param>
 /// <returns></returns>
 public Property nvl(object defaultValue)
 {
     if (defaultValue.GetType().IsValueType)
     {
         Aggregates.Add("nvl({0}, " + defaultValue + ")");
     }
     else
     {
         Aggregates.Add("nvl({0}, '" + defaultValue + "')");
     }
     return(this);
 }
Пример #12
0
        public void RaiseAggregate <TAggRequest, TAggResponse>(TAggRequest dto, params string[] queues)
            where TAggRequest : IApiRequestDto
        {
            var request = new ApiControllerRequestDto()
            {
                Request = dto, ResponseType = typeof(TAggResponse).FullName, Destination = queues.ToList()
            };

            var eventRequestDto = ApplicationContext.Container.Resolve <IEventRequestDto <ApiControllerRequestDto> >();

            eventRequestDto.Queues   = queues.ToList();
            eventRequestDto.MetaData = request;
            Events.Add(eventRequestDto);

            Aggregates.Add(eventRequestDto);
        }
Пример #13
0
 /// <summary>
 /// Links the child column with this datagrid.
 /// </summary>
 /// <param name="column">Column to link with this datagrid.</param>
 internal void Hook(DataGridAggregate <TItem> aggregate)
 {
     Aggregates.Add(aggregate);
 }
Пример #14
0
 /// <summary>
 /// 构造Substr
 /// </summary>
 /// <param name="start"></param>
 /// <param name="length"></param>
 /// <returns></returns>
 public Property Substr(int start, int length)
 {
     Aggregates.Add("substr({0}, " + start + ", " + length + ")");
     return(this);
 }
Пример #15
0
 /// <summary>
 /// 构造Mix
 /// </summary>
 /// <returns></returns>
 public Property Mix()
 {
     Aggregates.Add("Mix({0})");
     return(this);
 }
Пример #16
0
 /// <summary>
 /// 构造Count
 /// </summary>
 /// <returns></returns>
 public Property Count()
 {
     Aggregates.Add("Count({0})");
     return(this);
 }
Пример #17
0
 /// <summary>
 /// 构造Sum
 /// </summary>
 /// <returns></returns>
 public Property Sum()
 {
     Aggregates.Add("Sum({0})");
     return(this);
 }