Ejemplo n.º 1
0
Archivo: Server.cs Proyecto: Gtach/ruh
        public static void Main(string[] args)
        {
            IDictionary <int, City> cities = new Dictionary <int, City>();

            var         domainMapper    = new DomainMapper();
            var         propertyManager = new PropertyManager();
            var         repository      = new ZmqRepository(domainMapper, propertyManager, @"C:\temp\data");
            IUnitOfWork unitOfWork      = new ChangeTrackUoW(propertyManager, repository);

            var randomizer = new Random(DateTime.Now.Millisecond);

            var weather = new Weather {
                Temperature = randomizer.Next(-80, 135), RelativeHumidity = randomizer.Next(10, 60)
            };

            for (var i = 0; i < 3; i++)
            {
                var city = new City
                {
                    CitySize = CitySize.Medium,
                    Name     = "Test",
                    ZipCode  = randomizer.Next(1, 100000),
                    Weather  = weather
                };

                unitOfWork.StartTransaction(city);

                try
                {
                    unitOfWork.Commit();
                }
                catch (System.Exception exception)
                {
                    unitOfWork.Rollback();
                    Console.WriteLine("Error: " + exception.Message);
                }
            }
        }
Ejemplo n.º 2
0
Archivo: Server.cs Proyecto: Gtach/ruh
        public static void Main(string[] args)
        {
            IDictionary<int, City> cities = new Dictionary<int, City>();

            var domainMapper = new DomainMapper();
            var propertyManager = new PropertyManager();
            var repository = new ZmqRepository(domainMapper, propertyManager, @"C:\temp\data");
            IUnitOfWork unitOfWork = new ChangeTrackUoW(propertyManager, repository);

            var randomizer = new Random(DateTime.Now.Millisecond);

            var weather = new Weather { Temperature = randomizer.Next(-80, 135), RelativeHumidity = randomizer.Next(10, 60) };

            for (var i = 0; i < 3; i++)
            {
                var city = new City
                               {
                                   CitySize = CitySize.Medium,
                                   Name = "Test",
                                   ZipCode = randomizer.Next(1, 100000),
                                   Weather = weather
                               };

                unitOfWork.StartTransaction(city);

                try
                {
                    unitOfWork.Commit();
                }
                catch (System.Exception exception)
                {
                    unitOfWork.Rollback();
                    Console.WriteLine("Error: " + exception.Message);
                }
            }
        }