Esempio n. 1
0
        public async Task ProcessMessagesContinue(InputModels.Continue input, bool force = false)
        {
            input.ThrowIfNull(nameof(input));

            var messageQuery = from message in DbContext.Messages
                               where force || !message.Processed
                               orderby message.Id descending
                               select message;

            var take = SettingsRepository.MessagesPerPage(true);
            var skip = take * input.CurrentStep;

            var messages = messageQuery.Skip(skip).Take(take).ToList();

            foreach (var message in messages)
            {
                var serviceResponse = new ServiceModels.ServiceResponse();

                var processedMessage = await ProcessMessageInput(serviceResponse, message.OriginalBody);

                if (serviceResponse.Success)
                {
                    message.OriginalBody = processedMessage.OriginalBody;
                    message.DisplayBody  = processedMessage.DisplayBody;
                    message.ShortPreview = processedMessage.ShortPreview;
                    message.LongPreview  = processedMessage.LongPreview;
                    message.Cards        = processedMessage.Cards;
                    message.Processed    = true;

                    DbContext.Update(message);
                }
            }

            DbContext.SaveChanges();
        }
Esempio n. 2
0
        public IActionResult RebuildParticipants(InputModels.Continue input)
        {
            if (string.IsNullOrEmpty(input.Stage))
            {
                var totalSteps = MessageRepository.RebuildParticipants();

                input = new InputModels.Continue {
                    Stage       = nameof(MessageRepository.RebuildParticipants),
                    CurrentStep = -1,
                    TotalSteps  = totalSteps
                };
            }
            else
            {
                MessageRepository.RebuildParticipantsContinue(input);
            }

            var viewModel = new ViewModels.Delay {
                ActionName  = "Rebuilding participants",
                CurrentPage = input.CurrentStep,
                TotalPages  = input.TotalSteps,
                NextAction  = UrlHelper.Action(nameof(Messages.Admin), nameof(Messages))
            };

            if (input.CurrentStep < input.TotalSteps)
            {
                input.CurrentStep++;
                viewModel.NextAction = UrlHelper.Action(nameof(Messages.RebuildParticipants), nameof(Messages), input);
            }

            return(ForumViewResult.ViewResult(this, "Delay", viewModel));
        }
Esempio n. 3
0
        public async Task <IActionResult> ReprocessMessages(InputModels.Continue input)
        {
            if (string.IsNullOrEmpty(input.Stage))
            {
                var totalSteps = MessageRepository.ReprocessMessages();

                input = new InputModels.Continue {
                    Stage       = nameof(MessageRepository.ReprocessMessages),
                    CurrentStep = -1,
                    TotalSteps  = totalSteps
                };
            }
            else
            {
                await MessageRepository.ReprocessMessagesContinue(input);
            }

            var viewModel = new ViewModels.Delay {
                ActionName  = "Reprocessing Messages",
                ActionNote  = "Processing message text, loading external sites, replacing smiley codes.",
                CurrentPage = input.CurrentStep,
                TotalPages  = input.TotalSteps,
                NextAction  = UrlHelper.Action(nameof(Messages.Admin), nameof(Messages))
            };

            if (input.CurrentStep < input.TotalSteps)
            {
                input.CurrentStep++;
                viewModel.NextAction = UrlHelper.Action(nameof(Messages.ReprocessMessages), nameof(Messages), input);
            }

            return(ForumViewResult.ViewResult(this, "Delay", viewModel));
        }
Esempio n. 4
0
        public async Task <IActionResult> RecountReplies(InputModels.Continue input)
        {
            if (string.IsNullOrEmpty(input.Stage))
            {
                var totalSteps = await MessageRepository.RecountReplies();

                input = new InputModels.Continue {
                    Stage       = nameof(MessageRepository.RecountReplies),
                    CurrentStep = -1,
                    TotalSteps  = totalSteps
                };
            }
            else
            {
                await MessageRepository.RecountRepliesContinue(input);
            }

            var viewModel = new ViewModels.Delay {
                ActionName  = "Recounting Replies",
                CurrentPage = input.CurrentStep,
                TotalPages  = input.TotalSteps,
                NextAction  = UrlHelper.Action(nameof(Messages.Admin), nameof(Messages))
            };

            if (input.CurrentStep < input.TotalSteps)
            {
                input.CurrentStep++;
                viewModel.NextAction = UrlHelper.Action(nameof(Messages.RecountReplies), nameof(Messages), input);
            }

            return(await ForumViewResult.ViewResult(this, "Delay", viewModel));
        }
Esempio n. 5
0
        public async Task <IActionResult> Process(InputModels.Continue input)
        {
            CheckContext();

            var note = string.Empty;

            switch (input.CurrentStep)
            {
            case 1:
                note = "Roles have been setup.";
                await SetupService.SetupRoles();

                break;

            case 2:
                note = "Admins have been added.";
                await SetupService.SetupAdmins();

                break;

            case 3:
                note = "The first category has been added.";
                SetupService.SetupCategories();
                break;

            case 4:
                note = "The first board has been added.";
                SetupService.SetupBoards();
                break;
            }

            input.CurrentStep++;

            var viewModel = new ViewModels.Delay {
                ActionName  = "Processing",
                ActionNote  = note,
                CurrentPage = input.CurrentStep,
                TotalPages  = input.TotalSteps,
                NextAction  = UrlHelper.Action(nameof(Setup.Process), nameof(Setup), input)
            };

            if (input.CurrentStep > input.TotalSteps)
            {
                viewModel.NextAction = "/";
            }

            return(await ForumViewResult.ViewResult(this, "Delay", viewModel));
        }
Esempio n. 6
0
		public async Task RecountRepliesContinue(InputModels.Continue input) {
			input.ThrowIfNull(nameof(input));

			var parentMessageQuery = from message in DbContext.Messages
									 where message.ParentId == 0
									 orderby message.Id descending
									 select message;

			var take = 25;
			var skip = input.CurrentStep * take;

			var parents = parentMessageQuery.Skip(skip).Take(take).ToList();

			foreach (var parent in parents) {
				await RecountRepliesForTopic(parent);
			}
		}
Esempio n. 7
0
        public void RebuildParticipantsContinue(InputModels.Continue input)
        {
            input.ThrowIfNull(nameof(input));

            var parentMessageQuery = from message in DbContext.Messages
                                     where message.ParentId == 0
                                     orderby message.Id descending
                                     select message;

            var take = SettingsRepository.TopicsPerPage(true);
            var skip = input.CurrentStep * take;

            var parents = parentMessageQuery.Skip(skip).Take(take).ToList();

            foreach (var parent in parents)
            {
                RebuildParticipantsForTopic(parent.Id);
            }
        }
Esempio n. 8
0
 public async Task ReprocessMessagesContinue(InputModels.Continue input) => await ProcessMessagesContinue(input, true);
Esempio n. 9
0
 public IActionResult Admin(InputModels.Continue input = null) => View();
Esempio n. 10
0
 public async Task <IActionResult> Admin(InputModels.Continue input = null) => await ForumViewResult.ViewResult(this);