コード例 #1
0
 public WorkflowProductService(
     IJobRepository <Product, Guid> productRepository,
     IJobRepository <UserTask> taskRepository,
     IJobRepository <User> userRepository,
     IJobRepository <ProductWorkflow, Guid> productWorkflowRepository,
     IJobRepository <WorkflowDefinition> workflowDefinitionRepository,
     IJobRepository <ProductTransition> productTransitionRepository,
     IBackgroundJobClient backgroundJobClient,
     SendNotificationService sendNotificationService,
     IServiceProvider serviceProvider,
     Bugsnag.IClient bugsnagClient,
     WorkflowRuntime runtime
     )
 {
     ProductRepository            = productRepository;
     TaskRepository               = taskRepository;
     UserRepository               = userRepository;
     ProductWorkflowRepository    = productWorkflowRepository;
     WorkflowDefinitionRepository = workflowDefinitionRepository;
     ProductTransitionRepository  = productTransitionRepository;
     BackgroundJobClient          = backgroundJobClient;
     SendNotificationService      = sendNotificationService;
     ServiceProvider              = serviceProvider;
     BugsnagClient = bugsnagClient;
     Runtime       = runtime;
 }
コード例 #2
0
 public BuildEngineProductService(
     IBuildEngineApi buildEngineApi,
     SendNotificationService sendNotificationService,
     IJobRepository <Product, Guid> productRepository,
     IJobRepository <SystemStatus> systemStatusRepository
     ) : base(buildEngineApi, sendNotificationService, systemStatusRepository)
 {
     this.sendNotificationService = sendNotificationService;
     ProductRepository            = productRepository;
 }
コード例 #3
0
 public BuildEngineServiceBase(
     IBuildEngineApi buildEngineApi,
     SendNotificationService sendNotificationService,
     IJobRepository <SystemStatus> systemStatusRepository
     )
 {
     BuildEngineApi          = buildEngineApi;
     SendNotificationService = sendNotificationService;
     SystemStatusRepository  = systemStatusRepository;
 }
コード例 #4
0
 public BuildEngineProjectService(
     IRecurringJobManager recurringJobManager,
     IBuildEngineApi buildEngineApi,
     SendNotificationService sendNotificationService,
     IJobRepository <Project> projectRepository,
     IJobRepository <SystemStatus> systemStatusRepository
     ) : base(buildEngineApi, systemStatusRepository)
 {
     RecurringJobManager     = recurringJobManager;
     SendNotificationService = sendNotificationService;
     ProjectRepository       = projectRepository;
 }
コード例 #5
0
 public BuildEngineReleaseService(
     IRecurringJobManager recurringJobManager,
     IBuildEngineApi buildEngineApi,
     SendNotificationService sendNotificationService,
     IJobRepository <Product, Guid> productRepository,
     IJobRepository <SystemStatus> systemStatusRepository
     ) : base(buildEngineApi, sendNotificationService, systemStatusRepository)
 {
     RecurringJobManager          = recurringJobManager;
     this.sendNotificationService = sendNotificationService;
     ProductRepository            = productRepository;
 }
コード例 #6
0
 protected async System.Threading.Tasks.Task SendNotificationOnFinalRetryAsync(PerformContext context,
                                                                               Organization organization,
                                                                               User user,
                                                                               string messageId,
                                                                               Dictionary <string, object> subs)
 {
     if (IsFinalRetry(context))
     {
         await SendNotificationService.SendNotificationToOrgAdminsAndOwnerAsync(organization, user,
                                                                                messageId, subs);
     }
 }
コード例 #7
0
 public BuildEngineSystemMonitor(
     IJobRepository <Organization> organizationRepository,
     IJobRepository <SystemStatus> systemStatusRepository,
     IJobRepository <UserRole> userRolesRepository,
     SendNotificationService sendNotificationService,
     IBuildEngineApi buildEngineApi
     )
 {
     OrganizationRepository  = organizationRepository;
     SystemStatusRepository  = systemStatusRepository;
     UserRolesRepository     = userRolesRepository;
     SendNotificationService = sendNotificationService;
     BuildEngineApi          = buildEngineApi;
 }
コード例 #8
0
 protected async Task SendNotificationOnFinalRetryAsync(PerformContext context,
                                                        Organization organization,
                                                        User user,
                                                        string ownerMessageId,
                                                        string adminMessageId,
                                                        Dictionary <string, object> subs,
                                                        string linkUrl)
 {
     if (IsFinalRetry(context))
     {
         await SendNotificationService.SendNotificationToOrgAdminsAndOwnerAsync(organization, user,
                                                                                ownerMessageId, adminMessageId, subs, linkUrl);
     }
 }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompanyCommunicatorSendFunction"/> class.
 /// </summary>
 /// <param name="companyCommunicatorSendFunctionOptions">The Company Communicator send function options.</param>
 /// <param name="precheckService">The service to precheck and determine if the queue message should be processed.</param>
 /// <param name="getSendNotificationParamsService">The service to get the parameters needed to send the notification.</param>
 /// <param name="sendNotificationService">The send notification service.</param>
 /// <param name="delaySendingNotificationService">The delay sending notification service.</param>
 /// <param name="manageResultDataService">The manage result data service.</param>
 public CompanyCommunicatorSendFunction(
     IOptions <CompanyCommunicatorSendFunctionOptions> companyCommunicatorSendFunctionOptions,
     PrecheckService precheckService,
     GetSendNotificationParamsService getSendNotificationParamsService,
     SendNotificationService sendNotificationService,
     DelaySendingNotificationService delaySendingNotificationService,
     ManageResultDataService manageResultDataService)
 {
     this.maxNumberOfAttempts           = companyCommunicatorSendFunctionOptions.Value.MaxNumberOfAttempts;
     this.sendRetryDelayNumberOfSeconds = companyCommunicatorSendFunctionOptions.Value.SendRetryDelayNumberOfSeconds;
     this.precheckService = precheckService;
     this.getSendNotificationParamsService = getSendNotificationParamsService;
     this.sendNotificationService          = sendNotificationService;
     this.delaySendingNotificationService  = delaySendingNotificationService;
     this.manageResultDataService          = manageResultDataService;
 }
コード例 #10
0
 public WorkflowProductService(
     IJobRepository <Product, Guid> productRepository,
     IJobRepository <UserTask> taskRepository,
     IJobRepository <User> userRepository,
     IJobRepository <ProductTransition> productTransitionRepository,
     SendNotificationService sendNotificationService,
     WorkflowRuntime runtime
     )
 {
     ProductRepository           = productRepository;
     TaskRepository              = taskRepository;
     UserRepository              = userRepository;
     ProductTransitionRepository = productTransitionRepository;
     SendNotificationService     = sendNotificationService;
     Runtime = runtime;
 }
コード例 #11
0
 public BuildEngineReleaseService(
     IRecurringJobManager recurringJobManager,
     IBuildEngineApi buildEngineApi,
     SendNotificationService sendNotificationService,
     IWebClient webClient,
     IJobRepository <Product, Guid> productRepository,
     IJobRepository <SystemStatus> systemStatusRepository,
     IJobRepository <ProductPublication> publicationRepository,
     IJobRepository <ProductBuild> buildRepository
     ) : base(buildEngineApi, sendNotificationService, systemStatusRepository)
 {
     RecurringJobManager          = recurringJobManager;
     this.sendNotificationService = sendNotificationService;
     WebClient             = webClient;
     ProductRepository     = productRepository;
     PublicationRepository = publicationRepository;
     BuildRepository       = buildRepository;
 }
コード例 #12
0
        protected async Task sendStatusUpdateNotificationAsync(SystemStatus systemEntry)
        {
            var organizations = OrganizationRepository.Get()
                                .Where(o => (o.BuildEngineUrl == systemEntry.BuildEngineUrl) &&
                                       (o.BuildEngineApiAccessToken == systemEntry.BuildEngineApiAccessToken));

            foreach (Organization organization in organizations)
            {
                var messageParms = new {
                    orgName = organization.Name,
                    url     = organization.BuildEngineUrl,
                    token   = organization.BuildEngineApiAccessToken
                };
                await SendNotificationService.SendNotificationToOrgAdminsAsync(organization,
                                                                               systemEntry.SystemAvailable? "notifications.buildengineConnected" : "notifications.buildengineDisconnected",
                                                                               messageParms);
            }
        }
コード例 #13
0
        protected async Task sendStatusUpdateNotificationAsync(SystemStatus systemEntry)
        {
            var organizations = OrganizationRepository.Get()
                                .Where(o => (o.BuildEngineUrl == systemEntry.BuildEngineUrl) &&
                                       (o.BuildEngineApiAccessToken == systemEntry.BuildEngineApiAccessToken));

            foreach (Organization organization in organizations)
            {
                var messageParms = new Dictionary <string, object>()
                {
                    { "orgName", organization.Name },
                    { "url", organization.BuildEngineUrl },
                    { "token", organization.BuildEngineApiAccessToken }
                };
                await SendNotificationService.SendNotificationToOrgAdminsAsync(organization,
                                                                               systemEntry.SystemAvailable? "buildengineConnected" : "buildengineDisconnected",
                                                                               messageParms);
            }
        }
コード例 #14
0
        private async Task SendNotificationForTask(UserTask task, User user, Product product)
        {
            var comment      = task.Comment ?? "";
            var messageParms = new Dictionary <string, object>()
            {
                { "activityName", task.ActivityName },
                { "project", product.Project.Name },
                { "productName", product.ProductDefinition.Name },
                { "status", task.Status },
                { "originator", product.Project.Owner.Name },
                { "to", user.Name },
                { "comment", task.Comment ?? "" }
            };

            await SendNotificationService.SendNotificationToUserAsync(user,
                                                                      "userTaskAdded",
                                                                      messageParms);

            Log.Information($"Notification: task={task.Id}, user={user.Name}, product={product.Id}, messageParms={messageParms}");
        }
コード例 #15
0
 public BuildEngineBuildService(
     IRecurringJobManager recurringJobManager,
     IBuildEngineApi buildEngineApi,
     WebRequestWrapper webRequestWrapper,
     IWebClient webClient,
     SendNotificationService sendNotificationService,
     IJobRepository <Product, Guid> productRepository,
     IJobRepository <ProductArtifact> productArtifactRepository,
     IJobRepository <ProductBuild> productBuildRepository,
     IJobRepository <StoreLanguage> languageRepository,
     IJobRepository <SystemStatus> systemStatusRepository
     ) : base(buildEngineApi, sendNotificationService, systemStatusRepository)
 {
     RecurringJobManager       = recurringJobManager;
     WebRequestWrapper         = webRequestWrapper;
     WebClient                 = webClient;
     SendNotificationSvc       = sendNotificationService;
     ProductRepository         = productRepository;
     ProductArtifactRepository = productArtifactRepository;
     ProductBuildRepository    = productBuildRepository;
     LanguageRepository        = languageRepository;
 }
コード例 #16
0
        public async Task ProductProcessChangedAsync(ProductProcessChangedArgs args)
        {
            // Clear PreExecute entries
            var emptyItems = ProductTransitionRepository.Get()
                             .Where(pt => pt.WorkflowUserId == null && pt.ProductId == args.ProcessId)
                             .Select(pt => pt.Id).ToList();

            foreach (var item in emptyItems)
            {
                await ProductTransitionRepository.DeleteAsync(item);
            }
            // Create PreExecute entries
            await Runtime.PreExecuteFromCurrentActivityAsync(args.ProcessId);

            // Find the Product assoicated with the ProcessId
            var product = await ProductRepository.Get()
                          .Where(p => p.Id == args.ProcessId)
                          .Include(p => p.ProductDefinition)
                          .Include(p => p.Project)
                          .ThenInclude(pr => pr.Owner)
                          .FirstOrDefaultAsync();

            if (product == null)
            {
                Log.Error($"Could find Product for ProcessId={args.ProcessId}");
                return;
            }

            await RemoveTasksByProductId(product.Id);

            // Find all users who could perform the current activity and create tasks for them
            var workflowUserIds = Runtime.GetAllActorsForDirectCommandTransitions(args.ProcessId, activityName: args.CurrentActivityName).ToList();
            var users           = UserRepository.Get().Where(u => workflowUserIds.Contains(u.WorkflowUserId.GetValueOrDefault().ToString())).ToList();
            var workflowComment = product.WorkflowComment;

            foreach (var user in users)
            {
                var task = new UserTask
                {
                    UserId       = user.Id,
                    ProductId    = product.Id,
                    ActivityName = args.CurrentActivityName,
                    Status       = args.CurrentState,
                    Comment      = workflowComment
                };
                task = await TaskRepository.CreateAsync(task);

                var messageParms = new Dictionary <string, object>()
                {
                    { "activityName", task.ActivityName },
                    { "project", product.Project.Name },
                    { "productName", product.ProductDefinition.Name },
                    { "fromActivity", args.PreviousActivityName ?? "" },
                    { "status", task.Status },
                    { "originator", user.Name },
                    { "to", product.Project.Owner.Name },
                    { "comment", task.Comment ?? "" }
                };
                await SendNotificationService.SendNotificationToUserAsync(user,
                                                                          "userTaskAdded",
                                                                          messageParms);

                Log.Information($"Notification: user={user.Name}, command={args.ExecutingCommand}, fromActivity:{args.PreviousActivityName}, toActivity:{args.CurrentState}, comment:{product.WorkflowComment}");
            }

            // Clear the WorkflowComment
            if (!String.IsNullOrWhiteSpace(workflowComment))
            {
                // Clear the comment
                product.WorkflowComment = "";
                await ProductRepository.UpdateAsync(product);
            }
        }