Exemplo n.º 1
0
        public ActionResult Clear()
        {
            var repository = new ReadRepository(new ConfigConnectionSettings("data"));

            foreach (var retreat in repository.All("SELECT * FROM [Retreats]", Enumerable.Empty<KeyValuePair<string, object>>()))
                bus.Send(new CurrentCancelRetreatCommand { AggregateRootId = retreat.Id });

            foreach (var participant in repository.All("SELECT * FROM [Participants]", Enumerable.Empty<KeyValuePair<string, object>>()))
                bus.Send(new CurrentUnregisterParticipantCommand { AggregateRootId = participant.Id });

            return this.RedirectToAction<ParticipantController>(c => c.List());
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var readRepository = new ReadRepository(new ConfigConnectionSettings("event"));
            var writeRepository = new WriteRepository(new ConfigConnectionSettings("event"));

            var binaryFormatter = new BinaryFormatter();

            var snapshots = readRepository.All("SELECT * FROM [Snapshots] ORDER BY [DateTime]", Enumerable.Empty<KeyValuePair<string, object>>());

            foreach (var snapshot in snapshots)
            {
                var actual = binaryFormatter.Deserialize(new MemoryStream((byte[])snapshot.Snapshot)) as Event;

                var stream = new MemoryStream();
                new XmlSerializer(actual.GetType()).Serialize(stream, actual);
                var content = stream.ToArray();

                var xmlpair = new KeyValuePair<string, object>("@Xml", content);
                var typepair = new KeyValuePair<string, object>("@Type", actual.ToString());
                var idpair = new KeyValuePair<string, object>("@Id", snapshot.Id);

                writeRepository.Do("UPDATE [Snapshots] SET [SnapshotXml] = @Xml, [Type] = @Type WHERE [Id] = @Id", new[] { xmlpair, typepair, idpair });
            }

            var events = readRepository.All("SELECT * FROM [Events] ORDER BY [DateTime]", Enumerable.Empty<KeyValuePair<string, object>>());

            foreach (var @event in events)
            {
                var actual = binaryFormatter.Deserialize(new MemoryStream((byte[])@event.Event)) as Event;

                var stream = new MemoryStream();
                new XmlSerializer(actual.GetType()).Serialize(stream, actual);
                var content = stream.ToArray();

                var xmlpair = new KeyValuePair<string, object>("@Xml", content);
                var typepair = new KeyValuePair<string, object>("@Type", actual.ToString());
                var idpair = new KeyValuePair<string, object>("@Id", @event.Id);
System.Threading.Thread.Sleep(10);
                writeRepository.Do("UPDATE [Events] SET [EventXml] = @Xml, [Type] = @Type WHERE [Id] = @Id", new[] { xmlpair, typepair, idpair });
            }
        }
Exemplo n.º 3
0
        public IEnumerable<Event> GetAll()
        {
            var repository = new ReadRepository(new ConfigConnectionSettings("event"));
            var events = repository.All("SELECT * FROM [Events] WHERE [AggregateRootId] != 'e20193e2-3fac-41ed-9bd1-0d6d61d65c97' ORDER BY [DateTime]", Enumerable.Empty<KeyValuePair<string, object>>());
            //var events = repository.All("SELECT * FROM [Events] ORDER BY [DateTime]", Enumerable.Empty<KeyValuePair<string, object>>());

            var formatter = new BinaryFormatter();

            foreach (var @event in events)
            {
                var stream = new MemoryStream((byte[])@event.Event);

                yield return formatter.Deserialize(stream) as Event;
            }
        }