예제 #1
0
        public IActionResult ShowKeys(string newAppId, string expireKey)
        {
            string sessionId = this.cookie.Get("TelemetrySession");

            if (string.IsNullOrEmpty(sessionId))
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                GetUserByCookieResponse reportUserByCookie = this.authenticationService.GetUserByWebCookie(sessionId);
                if (reportUserByCookie.Success == true)
                {
                    if (reportUserByCookie.User.IsOrganizationAdmin)
                    {
                        if (!(string.IsNullOrEmpty(expireKey)))
                        {
                            this.customTelemetryService.ExpireTelemetryKey(Guid.Parse(expireKey));
                        }
                        if (!(string.IsNullOrEmpty(newAppId)))
                        {
                            this.customTelemetryService.AddTelemetryKey(newAppId, reportUserByCookie.User.Username);
                        }
                    }
                    var viewModel = new ShowKeysViewModel(telemetryRetrievalService);
                    return(View(viewModel));
                }
                else
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
        }
예제 #2
0
        public GetUserByCookieResponse GetUserByWebCookie(string cookie)
        {
            GetUserByCookieResponse result = new GetUserByCookieResponse();
            WebSession webSession          = _wrapper.WebSessionRepository.GetOne <WebSession>(f => f.SessionCookie == cookie);

            if (webSession != null && webSession.Expiry > DateTime.UtcNow)
            {
                result.User    = _wrapper.UserRepository.GetOne <CollectorUser>(f => f.Id == webSession.ReportUserId);
                result.Success = true;
            }
            else
            {
                result.User    = null;
                result.Success = false;
            }
            return(result);
        }
        /// <summary>
        /// Show all telemetry reported within the last day
        /// </summary>
        public IActionResult Today()
        {
            string sessionId = this.cookie.Get("TelemetrySession");
            if (string.IsNullOrEmpty(sessionId))
            {
                return RedirectToAction("Login", "Account");
            }
            else
            {
                GetUserByCookieResponse reportUserByCookie = this.authenticationService.GetUserByWebCookie(sessionId);
                if (reportUserByCookie.Success == true && reportUserByCookie.User.IsOrganizationAdmin)
                {
                    var viewModel = new LastDayFailuresViewModel(telemetryRetrievalService);
                    return View(viewModel);
                }
                else
                {
                    return RedirectToAction("Login", "Account");
                }
            }

        }
예제 #4
0
        /// <summary>
        /// Show telemetry reported within the week
        /// </summary>
        public IActionResult Weekly()
        {
            string sessionId = this.cookie.Get("TelemetrySession");

            if (string.IsNullOrEmpty(sessionId))
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                GetUserByCookieResponse reportUserByCookie = this.authenticationService.GetUserByWebCookie(sessionId);
                if (reportUserByCookie.Success == true)
                {
                    var viewModel = new WeeklyChartViewModel(telemetryRetrievalService);
                    return(View(viewModel));
                }
                else
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
        }
        public IActionResult Index()
        {
            var    viewModel = new AccountIndexViewModel();
            string sessionId = cookie.Get("TelemetrySession");

            if (string.IsNullOrEmpty(sessionId))
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                GetUserByCookieResponse reportUserByCookie = _authenticationService.GetUserByWebCookie(sessionId);
                if (reportUserByCookie.Success == true)
                {
                    viewModel.Message = "Welcome, " + reportUserByCookie.User.Username;
                }
                else
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
            return(View(viewModel));
        }