Esempio n. 1
0
        /// <summary>
        ///     Process an event asynchronously.
        /// </summary>
        /// <param name="e">event to process</param>
        /// <returns>
        ///     Task to wait on.
        /// </returns>
        public async Task HandleAsync(ReportAddedToIncident e)
        {
            if (e.Incident.ReportCount != 1)
            {
                var tags = await _repository.GetTagsAsync(e.Incident.Id);

                if (tags.Count > 0)
                {
                    return;
                }
            }

            _logger.Debug("Checking tags..");
            var ctx = new TagIdentifierContext(e.Report);
            var identifierProvider = new IdentifierProvider();
            var identifiers        = identifierProvider.GetIdentifiers(ctx);

            foreach (var identifier in identifiers)
            {
                identifier.Identify(ctx);
            }

            ExtractTagsFromCollections(e, ctx);

            _logger.Debug("done..");

            await _repository.AddAsync(e.Incident.Id, ctx.Tags.ToArray());
        }
        /// <inheritdoc />
        public async Task HandleAsync(IncidentReOpened e)
        {
            var tags = await _repository.GetTagsAsync(e.IncidentId);

            if (tags.Any(x => x.Name == "incident-reopened"))
            {
                return;
            }

            await _repository.AddAsync(e.IncidentId, new[] { new Tag("incident-reopened", 1) });
        }
Esempio n. 3
0
        /// <summary>
        ///     Process an event asynchronously.
        /// </summary>
        /// <param name="e">event to process</param>
        /// <returns>
        ///     Task to wait on.
        /// </returns>
        public async Task HandleAsync(ReportAddedToIncident e)
        {
            _logger.Debug("Checking tags..");
            var tags = await _repository.GetTagsAsync(e.Incident.Id);

            var ctx         = new TagIdentifierContext(e.Report, tags);
            var identifiers = _tagIdentifierProvider.GetIdentifiers(ctx);

            foreach (var identifier in identifiers)
            {
                identifier.Identify(ctx);
            }

            ExtractTagsFromCollections(e, ctx);

            _logger.DebugFormat("Done, identified {0} new tags", ctx.NewTags);

            if (ctx.NewTags.Count == 0)
            {
                return;
            }

            await _repository.AddAsync(e.Incident.Id, ctx.NewTags.ToArray());
        }
 public async Task <TagDTO[]> ExecuteAsync(GetTagsForIncident query)
 {
     return((await _repository.GetTagsAsync(query.IncidentId)).Select(ConvertTag).ToArray());
 }
 public async Task <TagDTO[]> HandleAsync(IMessageContext context, GetTags query)
 {
     return((await _repository.GetTagsAsync(query.ApplicationId, query.IncidentId)).Select(ConvertTag).ToArray());
 }
Esempio n. 6
0
        public async Task <ActionResult <IEnumerable <Tag> > > GetTags()
        {
            var tags = await _repo.GetTagsAsync();

            return(Ok(tags));
        }
Esempio n. 7
0
        public MITSQuery(IEventsRepository eventsRepo, IDaysRepository daysRepo, ISpeakersRepository speakerRepo, ITagsRepository tagRepo, IUserRepository userRepo, ISectionsRepository sectionsRepo)
        {
            Name = "query";

            #region Event

            Field <EventType>(
                "event",
                arguments: new QueryArguments(new QueryArgument <IntGraphType> {
                Name = "id"
            }),
                resolve: context => eventsRepo.GetEventByIdAsync(context.GetArgument <int>("id"))

                );

            //this.AuthorizeWith("AdminPolicy");
            Field <ListGraphType <EventType> >(
                "events",
                resolve: context => eventsRepo.GetEventsAsync()
                )
            //.AuthorizeWith("AdminPolicy")
            ;

            #endregion

            #region Day
            //Field<ListGraphType<DayType>>(
            //    "days",
            //    resolve: context => daysRepo.GetDays()
            //    );


            Field <ListGraphType <DayType>, List <Day> >()
            .Name("days")
            .ResolveAsync(context => daysRepo.GetDaysAsync());

            #endregion

            #region Section

            Field <ListGraphType <SectionType>, List <Section> >()
            .Name("sections")
            .ResolveAsync(context => sectionsRepo.GetSectionsAsync());


            #endregion

            #region Speaker

            Field <ListGraphType <SpeakerType>, List <Speaker> >()
            .Name("speakers")
            .ResolveAsync(context => speakerRepo.GetSpeakersAsync());

            Field <SpeakerType, Speaker>()
            .Name("speaker")
            .Argument <NonNullGraphType <IntGraphType> >("speakerId", "Id of speaker to get")
            .ResolveAsync(context => speakerRepo.GetSpeakerByIdAsync(context.GetArgument <int>("speakerId")));

            #endregion

            #region Tag

            Field <ListGraphType <TagType>, List <Tag> >()
            .Name("tags")
            .ResolveAsync(context => tagRepo.GetTagsAsync());

            #endregion

            #region User

            Field <ListGraphType <UserType>, List <User> >()
            .Name("users")
            .AuthorizeWith("AdminPolicy")
            .ResolveAsync(context => userRepo.GetUsersAsync());

            #endregion
        }
Esempio n. 8
0
        public async Task <ActionResult <IEnumerable <Tag> > > GetTags()
        {
            var tags = await _tagsRepo.GetTagsAsync();

            return(Ok(_mapper.Map <IEnumerable <TagDto> >(tags)));
        }