Exemplo n.º 1
0
 public Task <bool> AddDependencyFlowEventAsync(
     int updateBuildId,
     DependencyFlowEventType flowEvent,
     DependencyFlowEventReason reason,
     MergePolicyCheckResult policy,
     string flowType,
     string url)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 2
0
        public async Task <bool> AddDependencyFlowEventAsync(
            int updateBuildId,
            DependencyFlowEventType flowEvent,
            DependencyFlowEventReason reason,
            MergePolicyCheckResult policy,
            string flowType,
            string url)
        {
            string updateReason = reason == DependencyFlowEventReason.New ||
                                  reason == DependencyFlowEventReason.AutomaticallyMerged ?
                                  reason.ToString() : $"{reason.ToString()}{policy.ToString()}";

            Logger.LogInformation($"Adding dependency flow event for {SubscriptionId} with {flowEvent} {updateReason} {flowType}");
            Subscription subscription = await Context.Subscriptions.FindAsync(SubscriptionId);

            if (subscription != null)
            {
                DependencyFlowEvent dfe = new DependencyFlowEvent {
                    SourceRepository = subscription.SourceRepository,
                    TargetRepository = subscription.TargetRepository,
                    ChannelId        = subscription.ChannelId,
                    BuildId          = updateBuildId,
                    Timestamp        = DateTimeOffset.UtcNow,
                    Event            = flowEvent.ToString(),
                    Reason           = updateReason,
                    FlowType         = flowType,
                    Url = url
                };
                Context.DependencyFlowEvents.Add(dfe);
                await Context.SaveChangesAsync();

                return(true);
            }
            else
            {
                Logger.LogInformation($"Could not find subscription with ID {SubscriptionId}. Skipping adding dependency flow event.");
                return(false);
            }
        }