예제 #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();
        }
예제 #2
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);
			}
		}
예제 #3
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);
            }
        }