コード例 #1
0
        private async Task OnEntityChangedAsync(ExtendedEntityChanged entityChanged, CancellationToken cancellationToken = default(CancellationToken)) {
            if (entityChanged == null)
                return;

            if (entityChanged.Type == typeof(User).Name) {
                foreach (var connectionId in _userIdConnections.GetConnections(entityChanged.Id))
                    await Context.Connection.TypedSend(connectionId, entityChanged);

                return;
            }

            if (!String.IsNullOrEmpty(entityChanged.OrganizationId))
                await Context.Groups.TypedSend(entityChanged.OrganizationId, entityChanged);
        }
コード例 #2
0
        private async Task OnEntityChangedAsync(ExtendedEntityChanged entityChanged, CancellationToken cancellationToken = default(CancellationToken)) {
            if (entityChanged == null)
                return;

            if (entityChanged.Type == typeof(User).Name) {
                foreach (var connectionId in await _connectionMapping.GetConnectionsAsync(entityChanged.Id))
                    await GroupSendAsync(connectionId, entityChanged);

                return;
            }

            if (!String.IsNullOrEmpty(entityChanged.OrganizationId))
                await GroupSendAsync(entityChanged.OrganizationId, entityChanged);
        }
コード例 #3
0
        public static ExtendedEntityChanged Create(EntityChanged entityChanged, bool removeWhenSettingProperties = true)
        {
            var model = new ExtendedEntityChanged {
                Id         = entityChanged.Id,
                Type       = entityChanged.Type,
                ChangeType = entityChanged.ChangeType,
                Data       = entityChanged.Data
            };

            if (model.Data.TryGetValue(KnownKeys.OrganizationId, out object organizationId))
            {
                model.OrganizationId = organizationId.ToString();
                if (removeWhenSettingProperties)
                {
                    model.Data.Remove(KnownKeys.OrganizationId);
                }
            }

            if (model.Data.TryGetValue(KnownKeys.ProjectId, out object projectId))
            {
                model.ProjectId = projectId.ToString();
                if (removeWhenSettingProperties)
                {
                    model.Data.Remove(KnownKeys.ProjectId);
                }
            }

            if (model.Data.TryGetValue(KnownKeys.StackId, out object stackId))
            {
                model.StackId = stackId.ToString();
                if (removeWhenSettingProperties)
                {
                    model.Data.Remove(KnownKeys.StackId);
                }
            }

            return(model);
        }