Esempio n. 1
0
        public IActionResult Index(
            [FromServices] IActivityManager activityManager
            )
        {
            var platforms = _platformManager.GetPlatforms();

            foreach (var platform in platforms)
            {
                platform.Tenant = $"{HttpContext.Request.Scheme}://{platform.Tenant}.{HttpContext.Request.Host}";
            }

            ViewBag.Platforms = platforms;

            var activities         = activityManager.GetActivityFeed();
            var activityViewModels = new List <ActivityViewModel>();

            foreach (var activity in activities.Reverse())
            {
                var vm = new ActivityViewModel(activity);
                activityViewModels.Add(vm);
            }

            ViewBag.Activities = activityViewModels;

            return(View());
        }
Esempio n. 2
0
        public async Task <ActionResult <PlatformUserConnectionStateViewModel> > GetUserPlatformConnectionState(
            CancellationToken cancellationToken)
        {
            var uniqueUserIdentifier = _httpContextAccessor.HttpContext.User.Identity.Name;

            using var session = _documentStore.OpenAsyncSession();
            var user = await _userManager.GetUserByUniqueIdentifier(uniqueUserIdentifier, session, cancellationToken);

            var platformIds = user.PlatformConnections.Select(pc => pc.PlatformId).ToList();
            var platforms   =
                (await _platformManager.GetPlatforms(platformIds, session, cancellationToken)).Values.ToList();
            var appIds = user.PlatformConnections.Select(pc => pc.ConnectionInfo)
                         .SelectMany(ci => ci.NotificationInfos).Select(ni => ni.AppId).Distinct().ToList();
            var apps = (await _appManager.GetAppsFromIds(appIds, session, cancellationToken)).ToList();

            return(new PlatformUserConnectionStateViewModel(user.PlatformConnections, platforms, apps));
        }
Esempio n. 3
0
        public IActionResult GetAllPlatforms([FromServices] IHostingEnvironment hostingEnvironment)
        {
            var platforms = _platformManager.GetPlatforms();

            platforms.ToList().ForEach((platform) =>
            {
                if (hostingEnvironment.EnvironmentName == "Production")
                {
                    platform.Tenant = $"{platform.Tenant}.{Constants.hostnames[3]}";
                }
                else
                {
                    platform.Tenant = $"{platform.Tenant}.{Constants.hostnames[1]}";
                }
            });

            return(Ok(platforms));
        }
Esempio n. 4
0
        // GET
        public IActionResult Dashboard(
            [FromServices] IPlatformManager platformManager,
            [FromServices] IProjectManager projectManager,
            [FromServices] IIdeationManager ideationManager,
            [FromServices] UserManager <User> userManager
            )
        {
            ViewBag.TotalPlatforms = platformManager.GetPlatforms().Count();
            ViewBag.TotalProjects  = projectManager.GetProjects().Count();
            ViewBag.TotalIdeations = ideationManager.GetIdeations().Count();

            ViewBag.TotalVotes         = ideationManager.GetTotalVoteCount();
            ViewBag.TotalUsers         = userManager.Users.Count();
            ViewBag.TotalOrganisations = userManager.GetUsersForClaimAsync(new Claim("Organisation", "Organisation")).Result.Count;

            return(View());
        }
Esempio n. 5
0
        public async Task Handle(PlatformDataFetcherTriggerMessage message)
        {
            using var _ = _logger.BeginNamedScopeWithMessage(nameof(DataFetchCompleteHandler),
                                                             _messageContext.Message.GetMessageId());

            _logger.LogInformation("Will check if any platform connection is up for data fetching.");

            var cancellationToken = _messageContext.GetCancellationToken();

            using var session = _documentStore.OpenAsyncSession();
            var platformConnectionsToFetchDataForPerUser =
                await GetPlatformConnectionsReadyForDataFetch(session, cancellationToken);

            var platforms = await _platformManager.GetPlatforms(
                platformConnectionsToFetchDataForPerUser.SelectMany(kvp => kvp.Value).Select(pc => pc.PlatformId).Distinct()
                .ToList(), session, cancellationToken);

            _logger.LogInformation(
                "Found {NoOfUsers} users that have at least one platform connection to trigger data fetch for.", platformConnectionsToFetchDataForPerUser.Count);

            foreach (var kvp in platformConnectionsToFetchDataForPerUser)
            {
                var userId = kvp.Key;
                using var __ = _logger.BeginPropertyScope((LoggerPropertyNames.UserId, userId));

                _logger.LogInformation("Will trigger data fetches for {NoOfPlatformConnections} distinct platforms for user.", kvp.Value.Count());

                foreach (var platformConnection in kvp.Value)
                {
                    using var ___ = _logger.BeginPropertyScope(
                              (LoggerPropertyNames.PlatformId, platformConnection.PlatformId),
                              (LoggerPropertyNames.PlatformName, platformConnection.PlatformName));

                    _logger.LogInformation(
                        "Will trigger data fetch for platform. LastSuccessfulDataFetch: {LastSuccessfulDataFetch}", platformConnection.LastSuccessfulDataFetch);

                    var platform = platforms[platformConnection.PlatformId];
                    await _platformManager.TriggerDataFetch(userId, platformConnection, platform.IntegrationType, _bus);
                }
            }

            await session.SaveChangesAsync(cancellationToken);
        }
Esempio n. 6
0
        public IActionResult List()
        {
            var platforms = _platformManager.GetPlatforms();

            return(View(platforms));
        }