public void Index() { // Arrange EventsController controller = new EventsController(); var eventReq = new EventReq { From = "20130613154515", To = "20130614163022" }; // var eventReq = new EventReq {From = "20130618202500", To = "20130619182551"}; // TODO this test need better DTO that gives some data. Should SearchTerm be injected ? // var eventReq = new EventReq { }; // var eventService = new EventService { Repository = TestContainer.Resolve<IEventRepository>() }; // Act ViewResult result = controller.Index(eventReq) as ViewResult; // Assert Assert.AreEqual("Here is a list of all filtered events from all server nodes.", result.ViewBag.Message); Assert.IsNotNull(result, "Response from Eventservice is null"); Assert.IsInstanceOfType(result.Model, typeof(IEventRecListViewModel), "Returns the wrong ViewModel"); int evRlCount = ((IEventRecListViewModel)result.Model).EventList.Count; Assert.IsTrue(evRlCount > 0, "There should be more then 0 item in the event test list"); // Assert.IsTrue(evRlCount == 20, "There should be 20 item in the event test list"); }
public async Task <IEnumerable <string> > GetRegisterdEmailsForEvent(EventReq req) { List <string> emails = new List <string>(); await ctx.Events.Where(e => e.Name == req.EventName).ForEachAsync(e => emails.AddRange(e.RegisteredEmails)); return(emails); }
// public IAppConfig Config { get; set; } = //injected hopefully buy IOC // public JsonServiceClient ServiceClient = new JsonServiceClient("http://localhost:60176/api/"); // public JsonServiceClient ServiceClient = new JsonServiceClient(Config.AbsoluteBaseUri); //public IEventRepository EventRepository; //injected by Func IOC // // GET: /Events/ /// <summary> /// Gets an optional from and to show the repositories list of log events. The main get methods. Shows list of all events. /// EventReqModelBinder translates the parameters and httpcontext and make a good EventReq object /// </summary> /// <param name="eventReq">A class for parameters they are strings but represent from to dates for the log events</param> /// <seealso cref="EventReq"/> /// <seealso cref="EventReqModelBinder"/> public ActionResult Index([ModelBinder(typeof(EventReqModelBinder))] EventReq eventReq) { // Todo all this must be moved to the a config of IAppConfig and injected with Funq IOC instead var appSettings = new AppSettings(); string baseApiUrl = appSettings.Get("BaseApiUrl", "http://localhost:80/api/"); JsonServiceClient ServiceClient = new JsonServiceClient(baseApiUrl); //injected by Func IOC ViewBag.Message = "Here is a list of all filtered events from all server nodes."; var eventRecListViewModel = GetEventRecListViewModelEventRecListViewModel(eventReq, ServiceClient); return(View(eventRecListViewModel)); }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation("C# HTTP trigger function processed a request."); string name = req.Query["name"]; string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); EventReq data = JsonConvert.DeserializeObject <EventReq>(requestBody); var result = await _durableClient.StartNewAsync("A_Chaining", data); return(new OkObjectResult(result)); }
public ActionResult Lasthours(int hours) { // Todo all this must be moved to the a config of IAppConfig and injected with Funq IOC instead var appSettings = new AppSettings(); var dynamicEventReq = new EventReq() { To = DateTime.Now.ToString(Global_Const.DATE_FORMAT), From = DateTime.Now.AddHours(-1 * hours).ToString(Global_Const.DATE_FORMAT) }; string baseApiUrl = appSettings.Get("BaseApiUrl", "http://localhost:80/api/"); JsonServiceClient ServiceClient = new JsonServiceClient(baseApiUrl); //injected by Func IOC ViewBag.Message = "Here is a list of all filtered events from all server nodes."; var eventRecListViewModel = GetEventRecListViewModelEventRecListViewModel(dynamicEventReq, ServiceClient); return(View("Index", eventRecListViewModel)); }
private static EventRecListViewModel GetEventRecListViewModelEventRecListViewModel(EventReq dynamicEventReq, JsonServiceClient ServiceClient) { var eventRecListViewModel = new EventRecListViewModel(); var events = new Events { From = dynamicEventReq.From, To = dynamicEventReq.To }; try { var response = ServiceClient.Get(events); foreach (var ev in response.EventRecords) { var evViewR = new EventRec { Category = ev.Category, Server = ev.ComputerName, EventCode = ev.EventCode, EventType = ev.EventType, InsMessage = ev.InsertionStrings, Logfile = ev.Logfile, Msg = ev.Message, RecordNr = ev.RecordNumber, Source = ev.SourceName, Time = ev.TimeGenerated.ToString("O"), Type = ev.Type, SearchTermNr = ev.SearchTerm }; eventRecListViewModel.EventList.Add(evViewR); } } catch (WebServiceException exception) { throw; } return(eventRecListViewModel); }