protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = Speedy.Extensions.GetSerializerSettings(true, false); GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter); GlobalConfiguration.Configuration.EnsureInitialized(); Database.SetInitializer(new MigrateDatabaseToLatestVersion <ScribeSqlDatabase, Configuration>(true)); var appDataPath = HttpContext.Current.Server.MapPath("~/App_Data"); var client = new ScribeDataChannel(new ScribeDatabaseProvider(() => new ScribeSqlDatabase())); var provider = new KeyValueRepositoryProvider <Event>(appDataPath); Tracker = Tracker.Start(client, provider); using (var datacontext = new ScribeSqlDatabase()) { var siteSettings = SiteSettings.Load(datacontext); IsConfigured = datacontext.Users.Any(); PrintCss = siteSettings.PrintCss ?? string.Empty; ViewCss = siteSettings.ViewCss ?? string.Empty; } }
public void WriteExistingEvent() { var provider = TestHelper.GetDatabaseProvider(); var channel = new ScribeDataChannel(provider); var currentTime = DateTime.UtcNow; var id = Guid.NewGuid(); using (var database = provider.GetDatabase()) { database.Events.Add(new Data.Entities.Event { CreatedOn = currentTime, CompletedOn = currentTime, Name = "Event", ElapsedTicks = 0, SessionId = Guid.NewGuid(), StartedOn = currentTime, Type = EventType.Event, UniqueId = id, }); database.SaveChanges(); } channel.WriteEvents(new[] { new Event { CompletedOn = currentTime, CreatedOn = currentTime, Name = "Event2", SessionId = Guid.Empty, Type = EventType.Event, UniqueId = id, Values = new List <EventValue> { new EventValue("Test", "Value") } } }); using (var database = provider.GetDatabase()) { Assert.AreEqual(1, database.Events.Count()); var actual = database.Events.First(); Assert.AreEqual("Event2", actual.Name); Assert.AreEqual(1, actual.Values.Count); var actualValue = actual.Values.First(); Assert.AreEqual("Test", actualValue.Name); Assert.AreEqual("Value", actualValue.Value); } }
public void WriteSingleEvent() { var provider = TestHelper.GetDatabaseProvider(); var channel = new ScribeDataChannel(provider); var currentTime = DateTime.UtcNow; channel.WriteEvents(new[] { new Event { CompletedOn = currentTime, CreatedOn = currentTime, Name = "Event", SessionId = Guid.Empty, Type = EventType.Event, UniqueId = Guid.NewGuid() } }); }