示例#1
0
        public ActionResult CreateApplication()
        {
            var model = new AppCreateViewModel
            {
                IsEditMode = false,
                Enabled    = true,
                DefaultRetainPeriodDays = Util.GetRetentionDays(),
                MaxErrors      = 100,
                MaxFatalErrors = 100,
                MaxWarnings    = 100
            };

            return(View(model));
        }
示例#2
0
        public async Task <ActionResult> AppEvents(long appId, int pageNumber = 0, string keywords          = "",
                                                   DateTime?fromDate          = null, EventLevel?eventLevel = null,
                                                   bool returnPartial         = false)
        {
            try
            {
                fromDate = !fromDate.HasValue
                    ? DateTime.UtcNow.AddDays(-1 * Util.GetRetentionDays())
                    : fromDate.Value.ToUniversalTime();

                if (!eventLevel.HasValue)
                {
                    eventLevel = EventLevel.Fatal | EventLevel.Error | EventLevel.Warning | EventLevel.Information;
                }


                ApplicationEvents events =
                    await
                    ApplicationBusiness.GetApplicationEventsAsync(appId, pageNumber,
                                                                  Constants.SpecialValues.PageSize, keywords, fromDate, DateTime.UtcNow, eventLevel);

                if (returnPartial)
                {
                    return(PartialView("EventGrid", events.Events));
                }

                int pNumber = pageNumber + 1;

                NameValueCollection nameValues = HttpUtility.ParseQueryString(Request.QueryString.ToString());
                nameValues.Set("pageNumber", pNumber.ToString(CultureInfo.InvariantCulture));
                nameValues.Set("returnPartial", "true");
                nameValues.Set("fromDate", fromDate.Value.ToLocalTime().ToString(CultureInfo.InvariantCulture));
                nameValues.Set("eventLevel", ((int)eventLevel.Value).ToString(CultureInfo.InvariantCulture));
                nameValues.Set("keywords", keywords);

                string url = Request.Url.AbsolutePath;
                events.NewQueryString = string.Format("{0}?{1}", url, nameValues);
                return(View(events));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                return(new ContentResult {
                    Content = "An error occured."
                });
            }
        }
示例#3
0
        public async Task <ActionResult> Index()
        {
            try
            {
                List <Application> allApps = await ApplicationBusiness.FindAllAsync();

                User user = AccountBusiness.GetCurrentUser();
                if (user == null)
                {
                    return(RedirectToAction("Login", "Account"));
                }


                IEnumerable <long> appIds = (await ApplicationBusiness.GetAppsOfUserAsync(user.Id)).Select(p => p.Id);

                Util.Clear <GaugeData>(Code.Classes.Util.GetLayoutViewModel().Gauges);
                Code.Classes.Util.GetLayoutViewModel().Lines.Clear();
                var viewModel = new ApplicationViewModel();
                foreach (int appId in appIds)
                {
                    Application app = await ApplicationBusiness.GetByIdAsync(appId);

                    if (app.Id > 0)
                    {
                        ApplicationStatus appStatus = await ApplicationBusiness.GetAppStatusAsync(app.Id);

                        ApplicationTrends appTrend = await ApplicationBusiness.GetApplicationTrendAsync(app.Id);

                        app.Status = appStatus;
                        app.Trend  = appTrend;
                        viewModel.Applications.Add(app);
                    }
                }
                return(View("Index", viewModel));
            }
            catch (Exception exception)
            {
                Logger.LogError(exception);
                throw;
            }
        }