Example #1
0
 private static APKKeuringsregistratieEvent CreateEvent(string response, AutoKlaargemeldEvent autoKlaargemeldEvent)
 {
     try
     {
         var apkKeuringsregistratieEvent = new APKKeuringsregistratieEvent()
         {
             GUID = Guid.NewGuid().ToString(), RoutingKey = "Jomaya.Onderhoudsopdracht.Updated", TimeStamp = DateTime.UtcNow
         };
         apkKeuringsregistratieEvent.Kenteken = response.Substring(response.IndexOf("<kenteken>") + 10, response.IndexOf("</kenteken>") - (response.IndexOf("<kenteken>") + 10));
         var steekproef = !response.Contains("<apk:steekproef xsi:nil=\"true\"/>");
         if (steekproef)
         {
             var steekproefDatum = response.Substring(response.IndexOf("<apk:steekproef>") + 16, response.IndexOf("</apk:steekproef>") - (response.IndexOf("<apk:steekproef>") + 16));
             apkKeuringsregistratieEvent.SteekproefDatum = DateTime.Parse(steekproefDatum);
             apkKeuringsregistratieEvent.Status          = Common.OnderhoudStatus.InSteekproef;
         }
         else
         {
             apkKeuringsregistratieEvent.Status = Common.OnderhoudStatus.Afgemeld;
         }
         apkKeuringsregistratieEvent.AutoId          = autoKlaargemeldEvent.AutoId;
         apkKeuringsregistratieEvent.OnderhoudId     = autoKlaargemeldEvent.OnderhoudId;
         apkKeuringsregistratieEvent.Kilometerstand  = autoKlaargemeldEvent.KilometerStand;
         apkKeuringsregistratieEvent.Werkzaamheden   = autoKlaargemeldEvent.Werkzaamheden;
         apkKeuringsregistratieEvent.OnderhoudsDatum = autoKlaargemeldEvent.OnderhoudsDatum;
         return(apkKeuringsregistratieEvent);
     }
     catch (Exception e)
     {
         ExceptionEventPublisher.PublishException(e);
         return(null);
     }
 }
Example #2
0
        private string PostMessage(string url, string message)
        {
            try
            {
                byte[] bodyBytes = Encoding.UTF8.GetBytes(message);

                WebRequest request = HttpWebRequest.Create(url);

                request.Method = "POST";

                request.ContentType = "text/xml";

                Stream requestStream = request.GetRequestStreamAsync().Result;

                requestStream.Write(bodyBytes, 0, bodyBytes.Length);

                WebResponse response = request.GetResponseAsync().Result;

                StreamReader reader = new StreamReader(response.GetResponseStream());

                string returnMessage = reader.ReadToEnd();

                return(returnMessage);
            }
            catch (Exception e)
            {
                ExceptionEventPublisher.PublishException(e);
                return(null);
            }
        }
        public IActionResult OnderhoudBewerken(long id)
        {
            try
            {
                var onderhoudsopdracht = _onderhoudRepo.Find(id);
                onderhoudsopdracht.Auto       = _autoRepo.Find(onderhoudsopdracht.AutoId);
                onderhoudsopdracht.Auto.klant = _klantRepo.Find(onderhoudsopdracht.Auto.KlantId);
                switch (onderhoudsopdracht.Status)
                {
                case OnderhoudStatus.Aangemeld:
                    return(View("OnderhoudStarten", onderhoudsopdracht));

                case OnderhoudStatus.Opgepakt:
                    return(View("OnderhoudKlaarmelden", onderhoudsopdracht));

                case OnderhoudStatus.Klaargemeld:
                    return(View("WachtenOpRDW", onderhoudsopdracht));

                case OnderhoudStatus.InSteekproef:
                    return(View("OnderhoudAfmelden", onderhoudsopdracht));
                }
                return(View());
            }
            catch (Exception e)
            {
                ExceptionEventPublisher.PublishException(e);
                return(RedirectToAction("VierNulVier", "fout"));
            }
        }
Example #4
0
        public void Createmessage(AutoKlaargemeldEvent autoKlaargemeldEvent, Garage garage)
        {
            try
            {
                string message = @"<apkKeuringsverzoekRequestMessage xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
                                <keuringsverzoek xmlns='http://www.rdw.nl' xmlns:apk='http://www.rdw.nl/apk' correlatieId='51a33867-b5ec-4f10-9b31-b4e3ddcb58eb'>" +
                                 $"<voertuig type='personenauto'>" +
                                 $"<kenteken>{autoKlaargemeldEvent.Kenteken.Replace(" ", "")}</kenteken>" +
                                 $"<kilometerstand>{autoKlaargemeldEvent.KilometerStand}</kilometerstand>" +
                                 $"<naam>{autoKlaargemeldEvent.EigenaarNaam}</naam>" +
                                 $"</voertuig>" +
                                 $"<apk:keuringsdatum>{DateTime.Now.ToString("yyyy-MM-dd")}</apk:keuringsdatum>" +
                                 $"<apk:keuringsinstantie type='garage' kvk='3013 5370'>" +
                                 $"<apk:naam>{garage.GarageNaam}</apk:naam>" +
                                 $"<apk:plaats>{garage.PlaatsNaam}</apk:plaats>" +
                                 @"</apk:keuringsinstantie>
                                </keuringsverzoek>
                            </apkKeuringsverzoekRequestMessage>";
                string url = "http://rdwserver:18423/rdw/APKKeuringsverzoek";

                string response = PostMessage(url, message);
                APKKeuringsregistratieEvent apkKeuringsregistratieEvent = CreateEvent(response, autoKlaargemeldEvent);
                _publisher.Publish(apkKeuringsregistratieEvent);
            }
            catch (Exception e)
            {
                ExceptionEventPublisher.PublishException(e);
            }
        }
Example #5
0
 public void OnOnderhoudStatusChanged(OnderhoudStatusChangedEvent incomingEvent)
 {
     try
     {
         var opdracht = _onderhoudRepo.Find(incomingEvent.OnderhoudsopdrachtId);
         opdracht.Status = (OnderhoudStatus)incomingEvent.Status;
         _onderhoudRepo.Update(opdracht);
     }
     catch (Exception e)
     {
         ExceptionEventPublisher.PublishException(e);
     }
 }
 public IActionResult Invoeren(Auto auto)
 {
     try
     {
         return(View(new Onderhoudsopdracht()
         {
             AutoId = auto.Id
         }));
     }
     catch (Exception e)
     {
         ExceptionEventPublisher.PublishException(e);
         return(RedirectToAction("VierNulVier", "fout"));
     }
 }
Example #7
0
 public IActionResult GetKlant(long klantId)
 {
     try
     {
         var klant = _service.GetKlant(klantId);
         return(Ok(klant));
     }
     catch (Exception e)
     {
         ExceptionEventPublisher.PublishException(e);
         var error = new ErrorMessage(ErrorTypes.Unknown,
                                      $"Onbekende fout met volgende Command: Method:'GetEigenaarNaam' KlantID:{klantId}, TimeStamp:{DateTime.UtcNow} {e}");
         return(BadRequest(error));
     }
 }
Example #8
0
 public void OnAutoCreated(AutoCreatedEvent incomingEvent)
 {
     try
     {
         _autoRepo.Insert(new Auto()
         {
             Id       = incomingEvent.AutoId,
             Kenteken = incomingEvent.Kenteken,
             KlantId  = incomingEvent.KlantId,
             Type     = incomingEvent.Type,
         });
     }
     catch (Exception e)
     {
         ExceptionEventPublisher.PublishException(e);
     }
 }
Example #9
0
 public IActionResult Toevoegen(Auto auto)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(View("Invoeren", auto));
         }
         auto = _agent.AutoInvoeren(auto);
         return(RedirectToAction("Invoeren", "Onderhoud", auto));
     }
     catch (Exception e)
     {
         ExceptionEventPublisher.PublishException(e);
         return(RedirectToAction("VierNulVier", "fout"));
     }
 }
Example #10
0
 public void OnKlantCreated(KlantCreatedEvent incomingEvent)
 {
     try
     {
         _autoRepo.Insert(new Entities.Klant()
         {
             Id             = incomingEvent.KlantId,
             Voorletters    = incomingEvent.Voorletters,
             Tussenvoegsel  = incomingEvent.Tussenvoegsel,
             Achternaam     = incomingEvent.Achternaam,
             Telefoonnummer = incomingEvent.Telefoonnummer,
         });
     }
     catch (Exception e)
     {
         ExceptionEventPublisher.PublishException(e);
     }
 }
Example #11
0
        public IActionResult Insert(Klant klant)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View("Invoeren", klant));
                }

                klant = _agent.KlantInvoeren(klant);
                return(RedirectToAction("Invoeren", "Auto", new { klantId = klant.Id })); // ga naar Auto invoeren
            }
            catch (Exception e)
            {
                ExceptionEventPublisher.PublishException(e);
                return(RedirectToAction("VierNulVier", "fout"));
            }
        }
Example #12
0
        public IActionResult Toevoegen(Onderhoudsopdracht onderhoudsopdracht)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View("Invoeren", onderhoudsopdracht));
                }

                var result = _agent.OnderhoudsopdrachtInvoeren(onderhoudsopdracht);
                return(RedirectToAction("Index"));
            }
            catch (Exception e)
            {
                ExceptionEventPublisher.PublishException(e);
                return(RedirectToAction("VierNulVier", "fout"));
            }
        }
Example #13
0
 public IActionResult OnderhoudAfmelden(Onderhoudsopdracht onderhoudsopdracht)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(View("Toevoegen", onderhoudsopdracht));
         }
         onderhoudsopdracht        = _onderhoudRepo.Find(onderhoudsopdracht.Id);
         onderhoudsopdracht.Status = OnderhoudStatus.Afgemeld;
         _agent.OnderhoudsOpdrachtUpdate(onderhoudsopdracht);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         ExceptionEventPublisher.PublishException(e);
         return(RedirectToAction("VierNulVier", "fout"));
     }
 }
Example #14
0
 public IActionResult UpdateOnderhoudsopdracht([FromBody] Onderhoudsopdracht onderhoudsopdracht)
 {
     if (!ModelState.IsValid)
     {
         var error = new ErrorMessage(ErrorTypes.BadRequest, "Modelstate Invalide");
         return(BadRequest(error));
     }
     try
     {
         Onderhoudsopdracht onderhoudsOpdracht = _service.UpdateOnderhoudsopdracht(onderhoudsopdracht);
         return(Ok(onderhoudsOpdracht));
     }
     catch (Exception e)
     {
         ExceptionEventPublisher.PublishException(e);
         var error = new ErrorMessage(ErrorTypes.Unknown,
                                      $"Onbekende fout met volgende Command: OnderhoudId:{onderhoudsopdracht.Id}, status:{onderhoudsopdracht.Status} {e}");
         return(BadRequest(error));
     }
 }
Example #15
0
 public IActionResult CreateKlant([FromBody] Klant klant)
 {
     if (!ModelState.IsValid)
     {
         var error = new ErrorMessage(ErrorTypes.BadRequest, "Modelstate Invalide");
         return(BadRequest(error));
     }
     try
     {
         _service.CreateKlant(klant);
         return(Ok(klant));
     }
     catch (Exception e)
     {
         ExceptionEventPublisher.PublishException(e);
         var error = new ErrorMessage(ErrorTypes.Unknown,
                                      $"Onbekende fout met volgende Command: RoomName:{klant.Voorletters}, TimeStamp:{DateTime.UtcNow} {e}");
         return(BadRequest(error));
     }
 }
Example #16
0
        public IActionResult Invoeren(long klantId)
        {
            try
            {
                if (klantId == 0)
                {
                    Response.Redirect(Request.Headers["Referer"].ToString());
                }

                return(View(new Auto()
                {
                    KlantId = klantId
                }));
            }
            catch (Exception e)
            {
                ExceptionEventPublisher.PublishException(e);
                return(RedirectToAction("VierNulVier", "fout"));
            }
        }
Example #17
0
 public IActionResult CreateAuto([FromBody]Auto auto)
 {
     if (!ModelState.IsValid)
     {
         var error = new ErrorMessage(ErrorTypes.BadRequest, $"Modelstate Invalide, {auto.ToString()}");
         return BadRequest(error);
     }
     try
     {
         auto = _service.CreateAuto(auto);
         return Ok(auto);
     }
     catch (Exception e)
     {
         ExceptionEventPublisher.PublishException(e);
         var error = new ErrorMessage(ErrorTypes.Unknown,
             $"Onbekende fout met volgende Command: Kenteken:{auto?.Kenteken}, KlantId:{auto?.KlantId}, TimeStamp:{DateTime.UtcNow} {e}");
         return BadRequest(error);
     }
 }        
Example #18
0
 public void OnOnderhoudCreated(OnderhoudsopdrachtCreatedEvent incomingEvent)
 {
     try
     {
         _onderhoudRepo.Insert(new Onderhoudsopdracht()
         {
             Id              = incomingEvent.OnderhoudsopdrachtId,
             AutoId          = incomingEvent.AutoId,
             Datum           = incomingEvent.OnderhoudsDatum,
             IsApk           = incomingEvent.IsApk,
             Kilometerstand  = incomingEvent.Kilometerstand,
             Status          = (OnderhoudStatus)incomingEvent.Status,
             SteekproefDatum = incomingEvent.SteekproefDatum,
             Werkzaamheden   = incomingEvent.Werkzaamheden,
         });
     }
     catch (Exception e)
     {
         ExceptionEventPublisher.PublishException(e);
     }
 }
Example #19
0
        public void TestCommonExceptionPublisher()
        {
            var errorMessage = "Dit is een TestException";

            var myException = new ArgumentException(errorMessage);

            using (FoutLoggingContext context = new FoutLoggingContext(_options))
                using (CustomExceptionRepository repo = new CustomExceptionRepository(context))
                    using (FoutLoggingDispatcher dispatcher = new FoutLoggingDispatcher(_config, repo))
                    {
                        ExceptionEventPublisher.PublishException(myException, false);

                        Thread.Sleep(10000);

                        Assert.IsTrue(context.Exceptions.Count(c => c.ExceptionType == typeof(ArgumentException).ToString()) > 0);

                        var result = context.Exceptions.First(c => c.ExceptionType == typeof(ArgumentException).ToString());

                        Assert.AreEqual("Dit is een TestException", result.Message);
                    }
        }