Ejemplo n.º 1
0
 public long Add(WeatherReport report)
 {
     lock (_lock)
     {
         report.Id = _reports.Count + 1;
         _reports.Add(report);
         return(report.Id);
     }
 }
Ejemplo n.º 2
0
        public virtual long SendReport(WeatherReport report)
        {
            Console.WriteLine("SendReport for " + report.Location + ": request");

            long id = _reportRepository.Add(report);

            Thread.Sleep(TimeSpan.FromMilliseconds(_random.Next(100, 1000)));

            Console.WriteLine("SendReport for " + report.Location + ": returning Report ID = " + id);
            return(id);
        }
Ejemplo n.º 3
0
        public long Add(WeatherReport report)
        {
            lock (_lock)
            {
                report.Id = _reports.Count + 1;
                _reports.Add(report);

                if (report.Id % 5 == 0)
                {
                    Console.WriteLine("Throwing exception for Report ID = " + report.Id);
                    throw new InvalidOperationException($"Oops! Report with ID '{report.Id}' produced an error on server. Look for its Fault_Response.xml in log folder.");
                }

                return(report.Id);
            }
        }