protected void btnLogin_Click(object sender, EventArgs e) { ActivityTracker.Track("Logged In", (int)UserActionEnum.LoggedIn); //declare the collection of users UserStore <IdentityUser> userStore = new UserStore <IdentityUser>(); //declare the user manager UserManager <IdentityUser> manager = new UserManager <IdentityUser>(userStore); //try to find the user IdentityUser user = manager.Find(txtUsername.Text, txtPassword.Text); if (user == null) { lblMessage.Text = "Username or Password is incorrect"; } else { //authenticate user var authenticationManager = HttpContext.Current.GetOwinContext().Authentication; var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie); authenticationManager.SignIn(userIdentity); Session["UserId"] = user.Id; Response.Redirect("/Pages/Dashboard.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { ActivityTracker.Track("Contact Us", (int)UserActionEnum.Navigated); // Dynamically change contact and hours fields Contact data = db.Contacts.Where(u => u.Id == 1).SingleOrDefault(); // Mobile Hours hours3.InnerHtml = "<p><b>Monday: </b>" + data.Monday + "</p>" + "\n<p><b>Tuesday: </b>" + data.Tuesday + "</p>\n<p><b>Wednesday: </b>" + data.Wednesday + "</p>" + "\n<p><b>Thursday: </b>" + data.Thursday + "</p>\n<p><b>Friday: </b>" + data.Friday + "</p>" + "\n<p><b>Saturday: </b>" + data.Saturday + "</p>\n<p><b>Sunday: </b>" + data.Sunday + "</p>"; // Set tooltips tt1.Title = data.Sunday; tt2.Title = data.Monday; tt3.Title = data.Tuesday; tt4.Title = data.Wednesday; tt5.Title = data.Thursday; tt6.Title = data.Friday; tt7.Title = data.Saturday; // Contact info contact3.InnerHtml = "<h3 style='font-weight: 400;'>" + data.Company + "</h3>\n" + "<h5>" + data.Address + "</h5>\n<h5 class='call'><b>Telephone: </b>" + "<a href='tel:" + data.Telephone + "'>" + data.Telephone + "</a></h5>\n" + "<h5 class='callOff'><b>Telephone: </b>" + data.Telephone + "</h5>\n" + "<h5><b>Fax: </b>" + data.Fax + "</h5>\n" + "<h5><b>Email: </b><a href='mailto:" + data.Email + "' class='mail'>" + data.Email + "</a></h5>"; }
protected void Page_Load(object sender, EventArgs e) { ActivityTracker.Track("Dashboard", (int)UserActionEnum.Navigated); if (Page.User.Identity.IsAuthenticated && Session["UserId"] != null) { if (!Page.User.IsInRole("Administrator")) { pnlUserManager.Visible = false; pnlSlideShowManager.Visible = false; pnlFeedbackManager.Visible = false; pnlActivityTracker.Visible = false; pnlFitBitMonitor.Visible = false; pnlProgramsManager.Visible = false; } // Grab current user Id string userId = Session["UserId"].ToString(); // Query the db and grab the data using the Id HPSUser user = db.HPSUsers.Where(u => u.UserId == userId).SingleOrDefault(); // Display first name in the dashboard h1 tag welcome.InnerText = "Welcome " + user.FirstName + " " + user.LastName + "!"; } else { Response.Redirect("/Main.aspx"); } }
private static void CloseScope(HttpContextBase context) { var scope = context?.Items[ITEM_KEY] as ActivityScope; if (scope == null) { return; } if (string.IsNullOrEmpty(scope.ParentId)) { context.Response.AddHeader(CorrelationIdHttpHeader, scope.Id); scope.Dispose(); } var parentId = scope.ParentId; context.Response.AddHeader(CorrelationIdHttpHeader, scope.Id); scope.Dispose(); var parent = ActivityTracker.Find(parentId); if (parent == null) { return; } context.Response.AddHeader(CorrelationParentIdHttpHeader, scope.ParentId); parent?.Dispose(); }
public void TestAverage() { var clock = new MemoryClock(); var activityTracker = new ActivityTracker <MyCounters>(clock, TimeSpan.FromSeconds(10)); var collection = new CounterCollection <MyCounters>(); // Initial rates are (total: 0, ratePerSecond: 0) Dictionary <MyCounters, (long total, double ratePerSecond)> rates = activityTracker.GetRates(); rates[MyCounters.Value1].Should().Be((0, 0)); rates[MyCounters.Value2].Should().Be((0, 0)); clock.AddSeconds(1); collection.AddToCounter(MyCounters.Value1, 1); collection.AddToCounter(MyCounters.Value2, 2); activityTracker.ProcessSnapshot(collection); rates = activityTracker.GetRates(); // Totals should be changed, but the rates are still 0. We don't have enough data. rates[MyCounters.Value1].Should().Be((1, 0)); rates[MyCounters.Value2].Should().Be((2, 0)); clock.AddSeconds(1); collection.AddToCounter(MyCounters.Value1, 1); collection.AddToCounter(MyCounters.Value2, 2); activityTracker.ProcessSnapshot(collection); rates = activityTracker.GetRates(); rates[MyCounters.Value1].Should().Be((2, 1)); rates[MyCounters.Value2].Should().Be((4, 2)); // Moving the time to the end of the window clock.AddSeconds(9); collection.AddToCounter(MyCounters.Value1, 2); collection.AddToCounter(MyCounters.Value2, 4); activityTracker.ProcessSnapshot(collection); rates = activityTracker.GetRates(); rates[MyCounters.Value1].Should().Be((4, 0.3)); rates[MyCounters.Value2].Should().Be((8, 0.6)); // Move even further, should have only one record in the window. clock.AddSeconds(3); rates = activityTracker.GetRates(); rates[MyCounters.Value1].Should().Be((4, 0)); rates[MyCounters.Value2].Should().Be((8, 0)); clock.AddSeconds(2); // 5 seconds since the last snapshot collection.AddToCounter(MyCounters.Value1, 5); collection.AddToCounter(MyCounters.Value2, 10); activityTracker.ProcessSnapshot(collection); rates = activityTracker.GetRates(); rates[MyCounters.Value1].Should().Be((9, 1)); rates[MyCounters.Value2].Should().Be((18, 2)); }
public void Test_AreTitlesNearlyEqual_Email() { string common; string a = "Inbox - [email protected] (2* messages) - Postbox"; string b = "Inbox - [email protected] (** messages) - Postbox"; Assert.AreEqual(true, ActivityTracker.AreTitlesNearlyEqual(a, b, 3, out common)); Assert.AreEqual(b, common); }
// Update Contact & Hours Information protected void btnSaveAdminSettings_Click(object sender, EventArgs e) { ActivityTracker.Track("Administrator Settings Changed", (int)UserActionEnum.Updated); // Clear error label lblAdminSettingsErrors.Text = ""; // Load Administrator Settings Modal Data To Update it Contact info = db.Contacts.Find(1); // Contact Information info.Address = txtAddress.Text; info.Company = txtCompany.Text; info.Email = txtEmail.Text; info.Fax = txtFax.Text; info.Telephone = txtTelephone.Text; // Office Hours info.Monday = txtMonday.Text; info.Tuesday = txtTuesday.Text; info.Wednesday = txtWednesday.Text; info.Thursday = txtThursday.Text; info.Friday = txtFriday.Text; info.Saturday = txtSaturday.Text; info.Sunday = txtSunday.Text; // Banner Message info.BannerMessage = txtBanner.Text; info.BannerColor = colorPicker.Attributes["value"]; try { // Change the entry state db.Entry(info).State = System.Data.Entity.EntityState.Modified; // Save to DB db.SaveChanges(); // Create a notification for the database string[] role = { "Everyone" }; NotificationCreator.CreateNotification(role, "Information Updated", "Contact Info and Hours Changed", DateTime.Now, "Info", null, null); // To add new info to page Response.Redirect(Request.RawUrl); } catch (DataException dx) { // Display error to user and log it. lblAdminSettingsErrors.Text = "The changes you made failed to save, please try again.\nIf the problem persists contact the administrator."; LogFile.WriteToFile("HPFSMaster.Master.cs", "btnSaveAdminSettings_Click", dx, "Admin Settings Information change failed to save in db", "HPSErrorLog.txt"); } catch (Exception ex) { lblAdminSettingsErrors.Text = "The changes you made failed to save, please try again.\nIf the problem persists contact the administrator."; LogFile.WriteToFile("HPFSMaster.Master.cs", "btnSaveAdminSettings_Click", ex, "Admin Settings Information failed to update", "HPSErrorLog.txt"); } }
public MiBand(DeviceInformation Device) { activityTracker = new ActivityTracker(); Authenticated = false; ready = false; Debug.WriteLine("[miband] objeto creado"); this.device = Device; //bleDevice = await BluetoothLEDevice.FromIdAsync(device.Id); //bleDevice.ConnectionStatus == BluetoothConnectionStatus.Connected; }
public WebServiceActivity(WebServiceActivityConfig config, ActivityTracker tracker, IEnumerable<IWebServiceExtender> extenders) { _config = config; _tracker = tracker; _extenders = extenders; _config.BaseUrl = _config.BaseUrl.TrimEnd('/'); _config.BaseUrl += "/"; }
protected void Page_Load(object sender, EventArgs e) { ActivityTracker.Track("Home", (int)UserActionEnum.Navigated); if (Session["login"] != null) { // Open the login modal ScriptManager.RegisterStartupScript(this, this.GetType(), "loginModal", "$('#mdlLogin').modal('show');", true); Session["login"] = null; } }
protected void btnContactSend_Click(object sender, EventArgs e) { ActivityTracker.Track("Sent Contact Email", (int)UserActionEnum.Created); // Create an info object to dynamically set email address Contact info = db.Contacts.Find(1); using (MailMessage mm = new MailMessage(ConfigurationManager.AppSettings["Email"], info.Email)) { mm.Subject = txtContactSubject.Text; mm.Body = "Reply Address: " + txtContactEmail.Text + "\n\n" + tarContactMessage.InnerText; mm.IsBodyHtml = false; SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp-mail.outlook.com"; smtp.EnableSsl = true; NetworkCredential NetworkCred = new NetworkCredential(ConfigurationManager.AppSettings["Email"], ConfigurationManager.AppSettings["Password"]); smtp.UseDefaultCredentials = true; smtp.Credentials = NetworkCred; smtp.Port = 587; try { // Clear error label lblContactFormErrors.Text = ""; // try sending email smtp.Send(mm); // Create a notification for the database string[] role = { "Administrator" }; NotificationCreator.CreateNotification(role, "Contact Email Sent", "Subject: " + txtContactSubject.Text, DateTime.Now, "Info", null, null); // Alert user of success ScriptManager.RegisterStartupScript(this, GetType(), "alert", "alert('Your email has been successfully sent. We will get back to you as soon as possible.');", true); } catch (SmtpException se) { lblContactFormErrors.Text += "Email failed to send try again. You may have reached your daily limit. " + "If the problem persists contact your administrator."; LogFile.WriteToFile("HPFSMaster.Master.cs", "btnContactSend_Click", se, "Contact email failed to send.", "HPSErrorLog.txt"); } catch (Exception ex) { lblContactFormErrors.Text += " An error occured try again. If the problem persists contact your administrator.<br>"; LogFile.WriteToFile("HPFSMaster.Master.cs", "btnContactSend_Click", ex, "Error caused Contact email to fail.", "HPSErrorLog.txt"); } } }
public void Simple() { ServiceStack.Redis.RedisClient cli = new ServiceStack.Redis.RedisClient(); var c1 = cli.As <UserLight>(); var set1 = c1.Sets["set1"]; //set1.Add(new UserLight() { Id = DateTime.Now.Ticks, UserName = "******", LastSeen = DateTime.Now }); var s = "activity-" + DateTime.Now.ToString("dd-hh-mm-ss"); var users = ActivityTracker.GetActiveUsers(); }
// GET: Home public ActionResult Index() { if (User.Identity.IsAuthenticated) { var activeUsers = ActivityTracker.GetActiveUsers(); return(View(activeUsers)); } else { return(RedirectToAction("Login", "Account")); } }
protected void btnMinutes_Click(object sender, EventArgs e) { ActivityTracker.Track("Viewed the Minutes Fitbit Data", (int)UserActionEnum.Clicked); // Get button that was clicked HtmlButton edit = (HtmlButton)sender; // Get id from button int dayCount = Convert.ToInt32(edit.Attributes["data-id"]); // Morph graph to appropriate day count DrawChart(this.Page, dayCount, "Minutes"); }
public UiViewsModule(ActivityTracker tracker) : base(BaseUrl) { _tracker = tracker; Get["/"] = _ => View["views/status.sshtml"]; Get["/status"] = _ => View["views/status.sshtml"]; Get["/activity"] = _ => View["views/activity.sshtml"]; Get["/gallery"] = _ => View["views/gallery.sshtml"]; Get["/configure"] = _ => View["views/configure.sshtml"]; Get["/about"] = _ => View["views/about.sshtml"]; Get["/tools/diagnostics"] = _ => View["views/diagnostics.sshtml"]; Get["/tools/sendnotification"] = _ => { var siteInfo = _tracker.StartEvent; var config = Container.Resolve <WebServiceActivityConfig>(); var notification = new NotificationEvent { AgentId = siteInfo.AgentId, CheckId = "CheckId", CriticalFailure = false, CriticalFailureDetails = null, Data = "JSON Serialised copy of this...", MinuteBucket = AnalyticsBaseline.MinuteBucket, HourBucket = AnalyticsBaseline.HourBucket, DayBucket = AnalyticsBaseline.DayBucket, DisplayUnit = "", EventType = "", GeneratedOnUtc = DateTime.UtcNow, Id = Guid.NewGuid(), Latitude = "", Longitude = "", Message = "Message", Properties = new Properties { { "SomeProperty", "SomeValue" } }, Result = false, ResultCount = 0, SiteId = siteInfo.SiteId, State = MessageStateTypes.NotSet, Tags = new List <string> { "SomeTag" }, Version = Guid.Empty }; var keys = config.ApiKeys != null?config.ApiKeys.ToArray() : new string[0]; var model = new SendNotificationModel(notification, keys); return(View["views/sendnotification.sshtml", model]); }; }
public static void DownloadFile(int id) { ActivityTracker.Track("Downloaded a File", (int)UserActionEnum.Downloaded); // Get the file from the database var file = db.HPSFiles.Select(s => s) .Where(f => f.Id == id) .SingleOrDefault(); // Turn data into byte array fileToBeDownloaded = file.FileData; fileContentType = file.FileContentType; fileName = file.FileName; }
protected void btnUploadData_Click(object sender, EventArgs e) { ActivityTracker.Track("Added Their Fitbit Data to the DB", (int)UserActionEnum.Created); // Upload fitbit data UploadFitBitData(); // Repopulate goals GetStepGoals(); GetDistanceGoals(); GetMinuteGoals(); // Redraw the initial chart DrawChart(this.Page, 7, "Steps"); }
public void VerifyConsecutiveActivitiesAndSingleStatPerActivity() { var activityTracker = new ActivityTracker(); AddAction(activityTracker, "jump", 100); AddAction(activityTracker, "run", 75); AddAction(activityTracker, "jump", 200); var jsonStats = activityTracker.GetStats(); var stats = JsonSerializer.Deserialize <IEnumerable <ActivityStat> >(jsonStats, jsonOptions); //.Single will throw an exception if there is more than one var jumpStat = stats.Single(s => s.Action == "jump"); var runStat = stats.Single(s => s.Action == "run"); Assert.Equal(150, jumpStat.Avg); Assert.Equal(75, runStat.Avg); }
public UiViewsModule(ActivityTracker tracker) : base(BaseUrl) { _tracker = tracker; Get["/"] = _ => View["views/status.sshtml"]; Get["/status"] = _ => View["views/status.sshtml"]; Get["/activity"] = _ => View["views/activity.sshtml"]; Get["/gallery"] = _ => View["views/gallery.sshtml"]; Get["/configure"] = _ => View["views/configure.sshtml"]; Get["/about"] = _ => View["views/about.sshtml"]; Get["/tools/diagnostics"] = _ => View["views/diagnostics.sshtml"]; Get["/tools/sendnotification"] = _ => { var siteInfo = _tracker.StartEvent; var config = Container.Resolve<WebServiceActivityConfig>(); var notification = new NotificationEvent { AgentId = siteInfo.AgentId, CheckId = "CheckId", CriticalFailure = false, CriticalFailureDetails = null, Data = "JSON Serialised copy of this...", MinuteBucket = AnalyticsBaseline.MinuteBucket, HourBucket = AnalyticsBaseline.HourBucket, DayBucket = AnalyticsBaseline.DayBucket, DisplayUnit = "", EventType = "", GeneratedOnUtc = DateTime.UtcNow, Id = Guid.NewGuid(), Latitude = "", Longitude = "", Message = "Message", Properties = new Properties { {"SomeProperty", "SomeValue"} }, Result = false, ResultCount = 0, SiteId = siteInfo.SiteId, State = MessageStateTypes.NotSet, Tags = new List<string> {"SomeTag"}, Version = Guid.Empty }; var keys = config.ApiKeys != null ? config.ApiKeys.ToArray() : new string[0]; var model = new SendNotificationModel(notification, keys); return View["views/sendnotification.sshtml", model]; }; }
protected void btnUpload_Click(object sender, EventArgs e) { ActivityTracker.Track("Uploaded a File", (int)UserActionEnum.Created); UploadFile.Upload(NewFile, ddlUploadFileFolder, lblCRUDMessage); // Repopulate the notifications table Table table = (Table)Master.FindControl("tblNotifications"); string userId = HttpContext.Current.Session["UserId"].ToString(); TableBuilder.BuildNotificationTable(userId, table); // Rebuild folders BuildFolders(); // Rebuild modals to go with folders for CRUD BuildModals(); }
protected void Page_Load(object sender, EventArgs e) { ActivityTracker.Track("User Manager", (int)UserActionEnum.Navigated); if (Page.User.Identity.IsAuthenticated && Session["UserId"] != null && Page.User.IsInRole("Administrator")) { // Get the user id thats currently logged in userId = HttpContext.Current.Session["UserId"].ToString(); user = db.HPSUsers.Select(u => u) .Where(uid => uid.UserId == userId) .SingleOrDefault(); } else { Response.Redirect("/Main.aspx"); } }
public void VerifyAddActionReturnsErrorWithInvalidData() { var activityTracker = new ActivityTracker(); var nullResult = activityTracker.AddAction(null); var emptyResult = activityTracker.AddAction(""); var invalidJsonResult = activityTracker.AddAction("action is jump and time is 100"); var unexpectedJsonResult = activityTracker.AddAction(@"""action"": ""jump"", ""timeToComplete"": 100"); var negativeTimeJsonResult = activityTracker.AddAction(JsonSerializer.Serialize(new Activity() { Action = "jump", Time = -50 })); Assert.NotNull(nullResult); Assert.NotNull(emptyResult); Assert.NotNull(invalidJsonResult); Assert.NotNull(unexpectedJsonResult); Assert.NotNull(negativeTimeJsonResult); }
protected void btnRemoveAllGoals_Click(object sender, EventArgs e) { ActivityTracker.Track("Removed ALL Their Fitbit Goals", (int)UserActionEnum.Deleted); // Get userId from session string userId = Session["UserId"].ToString(); try { // Remove all related goal records db.MinuteGoals.RemoveRange(db.MinuteGoals.Where(c => c.UserId == userId)); db.DistanceGoals.RemoveRange(db.DistanceGoals.Where(c => c.UserId == userId)); db.StepGoals.RemoveRange(db.StepGoals.Where(c => c.UserId == userId)); db.SaveChanges(); // Show message to user lblCRUDMessage.Text = "All goals have been removed."; lblCRUDMessage.CssClass = "text-success"; } catch (DataException dx) { lblCRUDMessage.Text = "Unable to remove Goals at this time. Please try again later or inform an Administrator."; lblCRUDMessage.CssClass = "text-danger"; LogFile.WriteToFile("FitBitManager.aspx.cs", "btnRemoveAllGoals_Click", dx, User.Identity.Name + " tried to remove all of their Goals.", "HPSErrorLog.txt"); } catch (Exception ex) { lblCRUDMessage.Text = "Unable to remove Goals at this time. Please try again later or inform an Administrator."; lblCRUDMessage.CssClass = "text-danger"; LogFile.WriteToFile("FitBitManager.aspx.cs", "btnRemoveAllGoals_Click", ex, User.Identity.Name + " tried to remove all of their Goals.", "HPSErrorLog.txt"); } // Reload step, minutes, and distance data GetStepGoals(); GetDistanceGoals(); GetMinuteGoals(); // Redraw the initial graph DrawChart(this.Page, 7, "Steps"); // Build tables for viewing all goals TableBuilder.BuildStepGoalsTable(tblStepGoals, userId); TableBuilder.BuildDistanceGoalsTable(tblDistanceGoals, userId); TableBuilder.BuildMinuteGoalsTable(tblMinuteGoals, userId); }
public static void DeleteMinuteGoal(int id) { ActivityTracker.Track("Deleted a Minutes Goal", (int)UserActionEnum.Deleted); // Get the user id thats currently logged in string userId = HttpContext.Current.Session["UserId"].ToString(); var user = db.HPSUsers.Select(u => u) .Where(uid => uid.UserId == userId) .SingleOrDefault(); try { // Get the distance goal to be deleted MinuteGoal minuteGoal = db.MinuteGoals.Find(id); db.MinuteGoals.Remove(minuteGoal); // Save changes db.SaveChanges(); // Set the notification notificationMessage = "Minute Goal was successfully deleted."; notificationStyle = "text-success"; notification = true; } catch (DataException dx) { // Set the notification notificationMessage = "Minute Goal could not be deleted at this time. Please try again later or inform an Administrator."; notificationStyle = "text-danger"; notification = true; // Write error to log file Log File Writer LogFile.WriteToFile("FitBitManager.aspx.cs", "DeleteMinuteGoal", dx, user.AspNetUser.UserName + " tried to delete a Minute Goal.", "HPSErrorLog.txt"); } catch (Exception ex) { // Set the notification notificationMessage = "Minute Goal could not be deleted at this time. Please try again later or inform an Administrator."; notificationStyle = "text-danger"; notification = true; // Write error to log file Log File Writer LogFile.WriteToFile("FitBitManager.aspx.cs", "DeleteMinuteGoal", ex, user.AspNetUser.UserName + " tried to delete a Minute Goal.", "HPSErrorLog.txt"); } }
public void Test_AreTitlesNearlyEqual() { string common; Assert.AreEqual(true, ActivityTracker.AreTitlesNearlyEqual("Inbox (58) out", "Inbox (58) out", 3, out common)); Assert.AreEqual("Inbox (58) out", common); Assert.AreEqual(true, ActivityTracker.AreTitlesNearlyEqual("aaaaa", "aaa", 3, out common)); Assert.AreEqual("aaa**", common); Assert.AreEqual(true, ActivityTracker.AreTitlesNearlyEqual("Inbox (58) out", "Inbox (89) out", 3, out common)); Assert.AreEqual("Inbox (**) out", common); Assert.AreEqual(true, ActivityTracker.AreTitlesNearlyEqual("Inbox (58) out", "Inbox (893) out", 3, out common)); Assert.AreEqual("Inbox (***) out", common); Assert.AreEqual(true, ActivityTracker.AreTitlesNearlyEqual("Inbox (583) out", "Inbox (89) out", 3, out common)); Assert.AreEqual("Inbox (***) out", common); Assert.AreEqual(false, ActivityTracker.AreTitlesNearlyEqual("Inbox (5832) out", "Inbox (89) out", 3, out common)); Assert.AreEqual("", common); Assert.AreEqual(true, ActivityTracker.AreTitlesNearlyEqual("Inbox (*) out", "Inbox (89) out", 3, out common)); Assert.AreEqual("Inbox (**) out", common); }
public void VerifyParallelActivitiesAndSingleStatPerActivity() { var activityTracker = new ActivityTracker(); var actions = new List <Activity>() { new Activity() { Action = "jump", Time = 100 }, new Activity() { Action = "run", Time = 75 }, new Activity() { Action = "jump", Time = 200 } }; var tasks = new List <Task>(); //adapted from https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.run?view=net-5.0 foreach (var action in actions) { Task t = Task.Run(() => { //serializes to camelCase by default activityTracker.AddAction(JsonSerializer.Serialize(action)); }); tasks.Add(t); } Task.WaitAll(tasks.ToArray()); var jsonStats = activityTracker.GetStats(); var stats = JsonSerializer.Deserialize <IEnumerable <ActivityStat> >(jsonStats, jsonOptions); //.Single will throw exception if there is more than one var jumpStat = stats.Single(s => s.Action == "jump"); var runStat = stats.Single(s => s.Action == "run"); Assert.Equal(150, jumpStat.Avg); Assert.Equal(75, runStat.Avg); }
protected void btnSearch_Click(object sender, EventArgs e) { ActivityTracker.Track("Searched For User", (int)UserActionEnum.Clicked); db = new HPSDB(); // Get the creation dates DateTime startDate = (txtSearchStartDate.Text != String.Empty) ? Convert.ToDateTime(txtSearchStartDate.Text) : DateTime.MinValue; DateTime endDate = (txtSearchStartDate.Text != String.Empty) ? Convert.ToDateTime(txtSearchEndDate.Text) : DateTime.MaxValue; // Get the normal textboxes string firstName = (txtSearchFirstName.Text != String.Empty) ? txtSearchFirstName.Text : String.Empty; string lastName = (txtSearchLastName.Text != String.Empty) ? txtSearchLastName.Text : String.Empty; string email = (txtSearchEmail.Text != String.Empty) ? txtSearchEmail.Text : String.Empty; string username = (txtSearchUserName.Text != String.Empty) ? txtSearchUserName.Text : String.Empty; string role = (ddlSearchUserRole.SelectedValue != "-1") ? ddlSearchUserRole.SelectedValue : String.Empty; // Search based on criteria var users = db.HPSUsers .Where(f => f.FirstName.Contains(firstName)) .Where(l => l.LastName.Contains(lastName)) .Where(em => em.AspNetUser.Email.Contains(email)) .Where(u => u.AspNetUser.UserName.Contains(username)) .Where(s => s.CreatedOn >= startDate && s.CreatedOn <= endDate) .Where(a => a.RoleName.Contains(role)) .ToList(); if (users.Any()) { // Build the results table TableBuilder.BuildUsersTable(tblUsers, users, false); } else { lblNoResults.Visible = true; lblNoResults.Text = "No results found."; } // Show the panel pnlSearchResults.Visible = true; }
public NotificationModule(IWebServiceReceiverStrategy receiverStrategy, ActivityTracker tracker) : base(BaseUrl) { _tracker = tracker; _receiverStrategy = receiverStrategy; Post["/notify"] = request => { var message = this.Bind <NotificationEvent>(); message.GeneratedOnUtc = message.GeneratedOnUtc.ToUniversalTime(); message.State = MessageStateTypes.Delivered; message.ReceivedOnUtc = DateTime.UtcNow; Logger.Info("Received Notification ({0}) {1}", message.EventType, message.Id); _receiverStrategy.Execute(message); return(Response.AsJson(new { Message = "Success" }, HttpStatusCode.Accepted)); }; Get["/artifact/{NotificationId}"] = _ => { var restRequest = this.Bind <HealthCheckArtifact>(); var artifact = ArtifactManager.Get(restRequest.Name, restRequest.NotificationId); var response = Response.FromStream(artifact, restRequest.ContentType); response.Headers.Add("Content-Disposition", string.Format("attachment; filename=wolfpack-{0}.txt", restRequest.NotificationId)); return(response); }; Get["/start"] = _ => Response.AsJson(new StatusResponse { Info = _tracker.StartEvent, Status = "Running" }); Get["/list"] = _ => Response.AsJson(_tracker.Notifications.ToList()); }
protected void Page_Load(object sender, EventArgs e) { ActivityTracker.Track("Programs", (int)UserActionEnum.Navigated); // Build the first visible carousel if (!IsPostBack) { CarouselBuilder.BuildCarousel(plCollectiveKitchen, (int)SlideShowEnums.CollectiveKitchen, "CollectiveKitchenCarousel"); FillCollectiveKitchenTags(); FillComputerTutoringTags(); FillCottageStudioTags(); FillWednesdayLeisureGroupTags(); FillWalkingGroupTags(); FillSummerSportsTags(); FillTravellingCupTags(); FillSweetDonationsGroupTags(); FillMovieGroupTags(); FillGamingGroupTags(); FillFridaySocialGroupTags(); FillOverview(); } }
public NotificationModule(IWebServiceReceiverStrategy receiverStrategy, ActivityTracker tracker) : base(BaseUrl) { _tracker = tracker; _receiverStrategy = receiverStrategy; Post["/notify"] = request => { var message = this.Bind<NotificationEvent>(); message.GeneratedOnUtc = message.GeneratedOnUtc.ToUniversalTime(); message.State = MessageStateTypes.Delivered; message.ReceivedOnUtc = DateTime.UtcNow; Logger.Info("Received Notification ({0}) {1}", message.EventType, message.Id); _receiverStrategy.Execute(message); return Response.AsJson(new { Message = "Success" }, HttpStatusCode.Accepted); }; Get["/artifact/{NotificationId}"] = _ => { var restRequest = this.Bind<HealthCheckArtifact>(); var artifact = ArtifactManager.Get(restRequest.Name, restRequest.NotificationId); var response = Response.FromStream(artifact, restRequest.ContentType); response.Headers.Add("Content-Disposition", string.Format("attachment; filename=wolfpack-{0}.txt", restRequest.NotificationId)); return response; }; Get["/start"] = _ => Response.AsJson(new StatusResponse { Info = _tracker.StartEvent, Status = "Running" }); Get["/list"] = _ => Response.AsJson(_tracker.Notifications.ToList()); }
static ActivityTrackerError AddAction(ActivityTracker tracker, string action, int timeInSeconds) { return(tracker.AddAction($@"{{""action"": ""{action}"", ""time"": {timeInSeconds} }}")); }
protected void Page_Load(object sender, EventArgs e) { ActivityTracker.Track("About Us", (int)UserActionEnum.Navigated); }
protected void Page_Load(object sender, EventArgs e) { ActivityTracker.Track("Education And Research", (int)UserActionEnum.Navigated); }