Ejemplo n.º 1
0
        public async Task SendNotificationAsync(string method, YDeploymentStatePayloadState state, YEngine engine, string message, Guid?callerUserId = default, object resource = null, bool addMembers = false)
        {
            var groupUsers = GetNotifiersGroup(engine, callerUserId, addMembers);

            List <string> groups = null;

            if (groupUsers != null)
            {
                groups = groupUsers.Select(guid => $"{engine.Id}-{guid}").ToList();
            }

            if (groups == null || groups.Count <= 0)
            {
                return;
            }

            var hubContext = await serviceManager.CreateHubContextAsync("JobHub").ConfigureAwait(false);

            var deployState = new YDeploymentStatePayload(state)
            {
                Id      = engine.Id,
                Message = message
            };

            if (resource != null)
            {
                await hubContext.Clients.Groups(groups).SendAsync(method, deployState, resource, default).ConfigureAwait(false);
            }
            else
            {
                await hubContext.Clients.Groups(groups).SendAsync(method, deployState, default).ConfigureAwait(false);
            }
        }
Ejemplo n.º 2
0
 public YDeploymentStatePayload(YDeploymentStatePayloadState state)
 {
     this.state = state;
 }