/// <summary> /// Получить метрики. /// </summary> public ActionResult Metrics(int id, DataFilter filter) { DashboardMetrics metrics = this.metricsService.GetDashboardMetrics(id, DateRangeConverter.GetDateRange(filter)); var viewModel = new DashboardViewModel(metrics); return(this.MetricsView("_DashboardMetrics", viewModel)); }
private static void CreateManagmentJob() { DashboardRoutes.Routes.AddRazorPage(JobExtensionPage.PageRoute, x => new JobExtensionPage()); DashboardRoutes.Routes.AddRazorPage(JobsStoppedPage.PageRoute, x => new JobsStoppedPage()); DashboardRoutes.Routes.Add("/jobs/GetJobsStopped", new GetJobsStoppedDispatcher()); DashboardRoutes.Routes.Add("/JobConfiguration/GetJobs", new GetJobDispatcher()); DashboardRoutes.Routes.Add("/JobConfiguration/UpdateJobs", new ChangeJobDispatcher()); DashboardRoutes.Routes.Add("/JobConfiguration/GetJob", new GetJobForEdit()); DashboardRoutes.Routes.Add("/JobConfiguration/JobAgent", new JobAgentDispatcher()); DashboardRoutes.Routes.Add("/DataConfiguration/GetTimeZones", new GetTimeZonesDispatcher()); DashboardMetrics.AddMetric(TagDashboardMetrics.JobsStoppedCount); JobsSidebarMenu.Items.Add(page => new MenuItem("Jobs Stopped", page.Url.To("/jobs/stopped")) { Active = page.RequestPath.StartsWith("/jobs/stopped"), Metric = TagDashboardMetrics.JobsStoppedCount, }); NavigationMenu.Items.Add(page => new MenuItem(JobExtensionPage.Title, page.Url.To("/JobConfiguration")) { Active = page.RequestPath.StartsWith(JobExtensionPage.PageRoute), Metric = DashboardMetrics.RecurringJobCount }); AddDashboardRouteToEmbeddedResource("/JobConfiguration/js/page", "application/js", "Hangfire.RecurringJobAdmin.Dashboard.Content.js.jobextension.js"); AddDashboardRouteToEmbeddedResource("/JobConfiguration/js/vue", "application/js", "Hangfire.RecurringJobAdmin.Dashboard.Content.js.vue.js"); AddDashboardRouteToEmbeddedResource("/JobConfiguration/js/axio", "application/js", "Hangfire.RecurringJobAdmin.Dashboard.Content.js.axios.min.js"); AddDashboardRouteToEmbeddedResource("/JobConfiguration/js/daysjs", "application/js", "Hangfire.RecurringJobAdmin.Dashboard.Content.js.daysjs.min.js"); AddDashboardRouteToEmbeddedResource("/JobConfiguration/js/relativeTime", "application/js", "Hangfire.RecurringJobAdmin.Dashboard.Content.js.relativeTime.min.js"); AddDashboardRouteToEmbeddedResource("/JobConfiguration/js/vuejsPaginate", "application/js", "Hangfire.RecurringJobAdmin.Dashboard.Content.js.vuejs-paginate.js"); AddDashboardRouteToEmbeddedResource("/JobConfiguration/js/sweetalert", "application/js", "Hangfire.RecurringJobAdmin.Dashboard.Content.js.sweetalert.js"); AddDashboardRouteToEmbeddedResource("/JobConfiguration/css/jobExtension", "text/css", "Hangfire.RecurringJobAdmin.Dashboard.Content.css.JobExtension.css"); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { RegisterServices(services); services.AddSession(); var hangfireConnectionString = _configuration.GetConnectionString("HangfireConnection"); services.AddHangfire(config => { config.UseLogProvider(new HangfireLogProvider()); config.UseSqlServerStorage(hangfireConnectionString, new SqlServer.SqlServerStorageOptions { PrepareSchemaIfNecessary = true }); DashboardMetrics.GetMetrics().ToList().ForEach(m => config.UseDashboardMetric(m)); }); // services.AddManagementPages(_configuration,_hostingEnvironment, Path.Combine(_hostingEnvironment.ContentRootPath, "Jobs")); services.AddManagementPages(_configuration, _hostingEnvironment, typeof(Hangfire.TestJobs.TestJobs).Assembly); // Add framework services. services.AddMvc(); services.Configure <FormOptions>(x => { x.MultipartBodyLengthLimit = 10000000; }); }
public ConcurrentAnalysisModel GetConcurrentAnalysis(int projectId, IList <int> concurrentIds, DateRange dateRange) { IDictionary <int, IList <long> > usersIntersection; DashboardMetrics initialMetrics = this.metricsService.GetDashboardMetrics(projectId, dateRange); RankedModel initialRankedModel = RankedModel.Create(initialMetrics); IList <DashboardMetrics> concurrentsMetrics = new List <DashboardMetrics>(); IList <RankedModel> concurrentsRankedMetrics = new List <RankedModel>(); foreach (var concurrentId in concurrentIds) { var concurrentMetrics = this.metricsService.GetDashboardMetrics(concurrentId, dateRange); var rankedModel = RankedModel.Create(concurrentMetrics); concurrentsMetrics.Add(concurrentMetrics); concurrentsRankedMetrics.Add(rankedModel); } using (this.unitOfWorkProvider.CreateUnitOfWork()) { usersIntersection = this.usersCalculator.FindUsersIntersection(initialMetrics.AllUserIds, concurrentsMetrics.ToDictionary(c => c.Project.Id, v => v.AllUserIds)); } this.AssignUsersIntersection(concurrentsRankedMetrics, usersIntersection); this.RankModels(initialRankedModel, concurrentsRankedMetrics); var result = new ConcurrentAnalysisModel(initialRankedModel, concurrentsRankedMetrics); return(result); }
private async Task <DashboardMetrics> RefreshStaticMetrics() { var metrics = new DashboardMetrics(); try { metrics.DisposableIncome = await GetDisposableIncome(); metrics.TargetedNetWorth = GetTargetedNetWorth(); metrics.SavingsRate = await GetSavingsRate(); metrics.BudgetRuleExpense = GetBudgetRuleExpenses(); metrics.BudgetRuleSavings = GetBudgetRuleSavings(); metrics.BudgetRuleDiscretionary = GetBudgetRuleDiscretionary(); metrics.MinimumMonthlyExpenses = _minimumMonthlyExpenses = await GetMinimumMonthlyExpenses(); metrics.CashFlowByMonth = await GetCashFlowByMonth(); metrics.EmergencyFundRatio = await GetEmergencyFundRatio(); metrics.DueBeforeNextPayPeriod = await GetDueBeforeNextPayPeriod(); metrics.CashBalance = await GetCashBalance(); return(metrics); } catch (Exception e) { Logger.Instance.Error(e); return(null); } }
public DashboardViewModel(DashboardMetrics metrics) : base(metrics) { this.metrics = metrics; var dateTimeHelper = Factory.GetInstance <IDateTimeHelper>(); this.CustomDateRange = new CustomDateRange(dateTimeHelper.GetDateTimeNow().AddDays(-7), dateTimeHelper.GetDateTimeNow()); this.urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext); this.InitModels(); }
/// <summary> /// Configures Hangfire to use Tags. /// </summary> /// <param name="configuration">Global configuration</param> /// <param name="options">Options for tags</param> /// <param name="jobStorage">Job storage</param> /// <returns></returns> public static IGlobalConfiguration UseTags(this IGlobalConfiguration configuration, TagsOptions options = null, JobStorage jobStorage = null) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } TagsOptions.Options = options ?? new TagsOptions { Storage = JobStorage.Current as ITagsServiceStorage }; if (options != null && jobStorage != null) { TagsOptions.OptionsDictionary.Add(jobStorage.ToString(), options); } if (TagsOptions.Options.Storage == null) { throw new ApplicationException("The specified storage is not suitable for use with tags"); } if (DashboardRoutes.Routes.FindDispatcher("/tags/(.*)") != null) { throw new InvalidOperationException("Tags are already initialized"); } // Register server filter for jobs, to clean up after ourselves GlobalJobFilters.Filters.Add(new TagsCleanupStateFilter(), int.MaxValue); GlobalJobFilters.Filters.Add(new CreateJobFilter(), int.MaxValue); DashboardRoutes.Routes.AddRazorPage("/tags/search", x => new TagsSearchPage()); DashboardRoutes.Routes.AddRazorPage("/tags/search/.+", x => new TagsJobsPage()); DashboardRoutes.Routes.Add("/tags/all", new TagsDispatcher(TagsOptions.Options)); DashboardRoutes.Routes.Add("/tags/([0-9a-z\\-]+)", new JobTagsDispatcher(TagsOptions.Options)); DashboardMetrics.AddMetric(TagDashboardMetrics.TagsCount); if (!JobsSidebarMenu.Items.Contains(TagsMenuItemInitializer)) { JobsSidebarMenu.Items.Add(TagsMenuItemInitializer); } var assembly = typeof(GlobalConfigurationExtensions).Assembly; var jsPath = DashboardRoutes.Routes.Contains("/js[0-9]+") ? "/js[0-9]+" : "/js[0-9]{3}"; DashboardRoutes.Routes.Append(jsPath, new EmbeddedResourceDispatcher(assembly, "Hangfire.Tags.Resources.jquery.tagcloud.js")); DashboardRoutes.Routes.Append(jsPath, new EmbeddedResourceDispatcher(assembly, "Hangfire.Tags.Resources.script.js")); var cssPath = DashboardRoutes.Routes.Contains("/css[0-9]+") ? "/css[0-9]+" : "/css[0-9]{3}"; DashboardRoutes.Routes.Append(cssPath, new EmbeddedResourceDispatcher(assembly, "Hangfire.Tags.Resources.style.css")); DashboardRoutes.Routes.Append(cssPath, new DynamicCssDispatcher(TagsOptions.Options)); return(configuration); }
public static IGlobalConfiguration UseDashboardMetric( [NotNull] this IGlobalConfiguration configuration, [NotNull] DashboardMetric metric) { if (configuration == null) { throw new ArgumentNullException("configuration"); } if (metric == null) { throw new ArgumentNullException("metric"); } DashboardMetrics.AddMetric(metric); HomePage.Metrics.Add(metric); return(configuration); }
public static RankedModel Create(DashboardMetrics initialMetrics) { var model = new RankedModel(); model.ProjectId = initialMetrics.Project.Id; model.ProjectTitle = initialMetrics.Project.Title; model.AverageCommentsPerPost = new RankedValue <double>(initialMetrics.AverageCommentsPerPost); model.AverageLikesPerPost = new RankedValue <double>(initialMetrics.AverageLikesPerPost); model.InteractionRate = new RankedValue <double>(initialMetrics.InteractionRate); model.ResponseRate = new RankedValue <double>(initialMetrics.ResponseRate); model.ResponseTime = new RankedValue <string>(initialMetrics.ResponseTime); model.InvolmentRate = new RankedValue <double>(initialMetrics.InvolmentRate); model.UgcRate = new RankedValue <double>(initialMetrics.UgcRate); model.PhotosCount = new RankedValue <int>(initialMetrics.PhotosCount); model.VideosCount = new RankedValue <int>(initialMetrics.VideosCount); model.PostsCount = new RankedValue <int>(initialMetrics.PostsCount); model.TopicsCount = new RankedValue <int>(initialMetrics.TopicsCount); model.TopicCommentsCount = new RankedValue <int>(initialMetrics.TopicCommentsCount); model.SharePerPost = new RankedValue <double>(initialMetrics.SharePerPost); model.UsersPostCount = new RankedValue <int>(initialMetrics.UsersPostCount); model.AdminPostCount = new RankedValue <int>(initialMetrics.AdminPostCount); model.UsersPostsPerUser = new RankedValue <double>(initialMetrics.UsersPostsPerUser); model.AdminPostsPerAdmin = new RankedValue <double>(initialMetrics.AdminPostsPerAdmin); model.PostBiggestActivities = initialMetrics.PostBiggestActivities; model.UsersCount = new RankedValue <int>(initialMetrics.UsersCount); model.BadFans = new RankedValue <int>(initialMetrics.BadFans); model.BotsCount = new RankedValue <int>(initialMetrics.BotsCount); model.InactiveUsersCount = new RankedValue <int>(initialMetrics.InactiveUsersCount); model.ActiveUsersCount = new RankedValue <int>(initialMetrics.ActiveUsersCount); return(model); }
public DashboardViewModel() { Accounts = new List <Account>(); Metrics = new DashboardMetrics(); }