コード例 #1
0
        /// <summary>
        ///     Invalidates the specified tenant.
        /// </summary>
        /// <param name="tenant">The tenant.</param>
        public static void Invalidate(IEntityRef tenant)
        {
            if (tenant == null)
            {
                return;
            }

            using (new SecurityBypassContext())
            {
                using (new EntityTypeContext( ))
                {
                    /////
                    // Invalidate all the caches that could possible hold this entity.
                    /////
                    var ids = GetEntityIdentifiers(tenant.Id);

                    using (new DeferredChannelMessageContext( ))
                    {
                        foreach (var id in ids)
                        {
                            /////
                            // EntityCache implicitly removes from the EntityFieldCache
                            // as well as the EntityRelationshipCache (in both directions).
                            /////
                            EntityCache.Instance.Remove(id);
                        }
                    }


                    InvalidateLocalProcessImpl(tenant.Id);

                    using (var channel = CreateMessageChannel( ))
                    {
                        if (channel != null)
                        {
                            var message = new TenantHelperMessage
                            {
                                MessageType = TenantHelperMessageType.InvalidateTenant,
                                TenantId    = tenant.Id
                            };

                            message.EntityIds.UnionWith(ids);

                            channel.Publish(message, PublishOptions.None, false, MergeMessages);
                        }
                    }
                }

                string tenantName;

                using (new TenantAdministratorContext(0))
                {
                    tenantName = Entity.GetName(tenant.Id);
                }

                UserAccountCache.Invalidate(tenantName);
            }
        }
コード例 #2
0
        /// <summary>
        /// Notify the system that a new tenant was created
        /// </summary>
        /// <param name="tenantId"></param>
        public static void NotifyTenantCreate(long tenantId)
        {
            using (new SecurityBypassContext())
            {
                using (var channel = CreateMessageChannel())
                {
                    if (channel != null)
                    {
                        var message = new TenantHelperMessage
                        {
                            MessageType = TenantHelperMessageType.NewTenant,
                            TenantId    = tenantId
                        };

                        channel.Publish(message, PublishOptions.None, true);
                    }
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Merges the messages.
 /// </summary>
 /// <param name="existingMessage">The existing message.</param>
 /// <param name="newMessage">The new message.</param>
 private static void MergeMessages(TenantHelperMessage existingMessage, TenantHelperMessage newMessage)
 {
     existingMessage.EntityIds.UnionWith(newMessage.EntityIds);
 }