public IList <SystemStatistic> GetSystemStatistics() { var systemStatistics = this.context.SystemStatistics .OrderByDescending(s => s.Created) .Take(2) .ToList(); var systemSystemStatics = new List <SystemStatistic>(); if (systemStatistics != null) { foreach (var systemStatistic in systemStatistics) { var systemSystemStatistic = new SystemStatistic { WebSiteIsUp = systemStatistic.WebsiteIsUp, DatabaseIsUp = systemStatistic.DatabaseIsUp, AzureFunctionIsUp = systemStatistic.AzureFunctionIsUp, Created = systemStatistic.Created.ToString() }; systemSystemStatics.Add(systemSystemStatistic); } } return(systemSystemStatics); }
public void GetSystemStatistics_HappyPathTest(bool isValidToken) { var testToken = SetUpTokenForTesting(isValidToken); var systemStatisticToReturn = new SystemStatistic() { WebSiteIsUp = true, DatabaseIsUp = true, AzureFunctionIsUp = true, Created = DateTime.UtcNow.ToString() }; IList <SystemStatistic> systemStatisticsToReturn = new List <SystemStatistic>(); systemStatisticsToReturn.Add(systemStatisticToReturn); this.mockBucketListData.Setup(x => x.GetSystemStatistics()).Returns(systemStatisticsToReturn); var systemStatistics = this.service.GetSystemStatistics(testToken.EncodedUserName, testToken.EncodedToken); if (isValidToken) { Assert.IsNotNull(systemStatistics); Assert.AreEqual(systemStatisticToReturn.WebSiteIsUp, systemStatistics[0].WebSiteIsUp); Assert.AreEqual(systemStatisticToReturn.DatabaseIsUp, systemStatistics[0].DatabaseIsUp); Assert.AreEqual(systemStatisticToReturn.AzureFunctionIsUp, systemStatistics[0].AzureFunctionIsUp); Assert.AreEqual(systemStatisticToReturn.Created, systemStatistics[0].Created); this.mockBucketListData.Verify(x => x.GetSystemStatistics(), Times.Once); } else { Assert.IsNull(systemStatistics); } TestTokenVerifies(testToken); }
/// <summary> /// Creates a new instance /// </summary> public ParticleSystemManager(IManagerServiceProvider sceneInterface) { _sceneInterface = sceneInterface; ManagerProcessOrder = 100; Renderer = new QuadRenderer() { GraphicsDeviceService = GraphicsDeviceManager, }; Renderer.LoadContent(Application.ContentManager); _activeParticles = SystemConsole.GetStatistic("ParticleSystem_ActiveParticles", SystemStatisticCategory.Rendering); }
//GET: EmployeeManagement/PersonalData public ActionResult PersonalData(bool?returnUrl, bool?backUrl) { var restaurant = Session["restaurant"] as Restaurant; _employee = Session["Employee"] as Employee; ViewBag.State = new SelectList(_db.States, "StateId", "Name"); if (returnUrl != null && returnUrl.Value) { ViewBag.returnUrl = true; _employee = Session["Employee"] as Employee; if (_employee != null) { return(View(_employee.EmployeePersonalDatas.SingleOrDefault())); } } if (backUrl != null && backUrl.Value) { if (_employee != null) { return(View(_employee.EmployeePersonalDatas.SingleOrDefault())); } } var dataBase = new DataContext(); var statistics = new SystemStatistic(); if (restaurant != null) { statistics.RestaurantId = restaurant.RestaurantId; statistics.Action = StatisticsEnum.Registration.ToString(); statistics.DateOccured = DateTime.Now; } dataBase.SystemStatistics.Add(statistics); dataBase.SaveChanges(); return(View(_employee?.EmployeePersonalDatas.SingleOrDefault())); }
public virtual string GetStat(SystemStatistic stat) { throw new System.NotImplementedException(); }
public ActionResult Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } var appUser = new AuthenticationFactory().AuthenticateAppUserLogin(model.Email, model.Password); if (appUser != null) { var restaurant = _db.Restaurants.Find(appUser.RestaurantId); var userRole = _db.Roles.Find(appUser.RoleId); if (appUser.RestaurantId != null) { var restaurantStructure = _db.RestaurantStructures.SingleOrDefault(n => n.RestaurantId == restaurant.RestaurantId); Session["restaurantStructure"] = restaurantStructure; } //store objects in a session Session["odarmsloggedinuser"] = appUser; Session["restaurant"] = restaurant; Session["role"] = userRole; //create the authentication ticket var authTicket = new FormsAuthenticationTicket( 1, appUser.AppUserId.ToString(), //user id DateTime.Now, DateTime.Now.AddMinutes(40), //expiry true, //true to remember userRole.Name, //roles Url.Action("Dashboard", "Home") ); //encrypt the ticket and add it to a cookie HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(authTicket)); Response.Cookies.Add(cookie); var statistics = new SystemStatistic(); if (restaurant != null) { statistics.RestaurantId = restaurant.RestaurantId; statistics.Action = StatisticsEnum.Login.ToString(); statistics.DateOccured = DateTime.Now; statistics.LoggedInUserId = appUser.AppUserId; _db.SystemStatistics.Add(statistics); _db.SaveChanges(); if ((restaurant.SetUpStatus == SetUpStatus.Incomplete.ToString() && userRole.Name == "Restaurant Administrator")) { return(RedirectToAction("Create", "RestaurantStructures")); } } return(RedirectToAction("Dashboard", "Home")); } TempData["login"] = "******"; TempData["notificationType"] = NotificationType.Error.ToString(); return(View(model)); // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true //var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false); //switch (result) //{ // case SignInStatus.Success: // return RedirectToLocal(returnUrl); // case SignInStatus.LockedOut: // return View("Lockout"); // case SignInStatus.RequiresVerification: // return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }); // case SignInStatus.Failure: // default: // ModelState.AddModelError("", "Invalid login attempt."); // return View(model); //} }