Example #1
0
File: Client.cs Project: Gtach/ruh
        public static void Main(string[] args)
        {
            Console.WriteLine("Collecting updates from weather server…");

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

            var cities = repository.GetAll<City>();

            foreach (var city in cities)
            {
                Console.WriteLine(string.Format("Received: {0}, Weather: {1}", city.ToInfo(), city.Weather.ToInfo()));
            }
        }
Example #2
0
File: Server.cs Project: 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);
                }
            }
        }