Ejemplo n.º 1
0
        public void Publish(object sender, RefreshObjectEventArgs e)
        {
            if (PublishInProgress)
            {
                throw new SubscriptionException("Refresh Publish Cascade error.  Subscriber " + sender + " just attempted a publish during an existing publish execution, cylic inception publishing is not allowed, you cannot respond to a refresh callback by issuing more refresh publishes");
            }

            lock (oPublishLock)
            {
                BeforePublish?.Invoke(sender, e);

                try
                {
                    PublishInProgress = true;
                    // Set cursor as hourglass
                    Cursor.Current = Cursors.WaitCursor;

                    //refresh it from the child provider
                    if (e.Exists)
                    {
                        e.Object.RevertToDatabaseState();
                    }
                    else
                    {
                        if (ChildProvider != null && e.DeletedObjectDescendancy == null)
                        {
                            e.DeletedObjectDescendancy = ChildProvider.GetDescendancyListIfAnyFor(e.Object);
                        }
                    }

                    RefreshObject?.Invoke(sender, e);
                }
                finally
                {
                    AfterPublish?.Invoke(this, e);
                    PublishInProgress = false;
                    Cursor.Current    = Cursors.Default;
                }
            }
        }