Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeroen de Visser 5 posts 25 karma points
    May 04, 2011 @ 10:19
    Jeroen de Visser
    0

    ShowSpeechBubble after publishing

    Hi,

    I've implemented an event handler which runs "AfterPublish". Because I want to send a few e-mails here, I want to notify the users.

    Document.AfterPublish += new Document.PublishEventHandler(Document_AfterPublish);

    ...

    void Document_AfterPublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e)
    {
    if (sender.ContentType != null && sender.ContentType.Alias == "AgendaItem")
    {
    BasePage.Current.ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.info, "One moment please", "Busy sending notification mails");
    ...
    }
    }

     

    When I publish an item, I only see the "Content Published" speech bubble. Other functionality in the event handler works fine.

    Please help me :-)

  • Jeroen de Visser 5 posts 25 karma points
    May 04, 2011 @ 10:30
    Jeroen de Visser
    0

    Forgot to mention that I am developing with Umbraco 4.5.2.

    I get an error when trying to edit my previous post...

  • Steven Newstead 62 posts 103 karma points
    Jul 04, 2011 @ 14:37
    Steven Newstead
    0

    Hi there, 

    Did you ever find a solution on this? I'm trying to do the exact same thing...

    Thanks,

    Steve

  • Rich Green 2246 posts 4008 karma points
    Jul 04, 2011 @ 14:40
    Rich Green
    0

    I've got a feeling that this just doesn't work, from looking at packages like this http://our.umbraco.org/projects/website-utilities/disable-delete

    Rich

  • Steven Newstead 62 posts 103 karma points
    Jul 04, 2011 @ 15:42
    Steven Newstead
    0

    Pah, pesky thing.

    The only way I've managed to get something display is by throwing an exception which then pops up (which is a horrid solution...)

  • Sherry Ann Hernandez 320 posts 344 karma points
    Jul 04, 2011 @ 16:13
    Sherry Ann Hernandez
    0

    I also have the same issue. I have this event handler that checks whether the media being deleted is use in the content. I wanted to throw a message that it is not possible to delete the media because it is currently being use.

    Here's my code.

     

    void Media_BeforeMoveToTrash(Media sender, MoveToTrashEventArgs

    e)

    {

    //This sql get's all the newest versions of the documents which store the DAMP xml and contain the id of the current media item.

    string sql = string.Format(

    @"

    SELECT TOP 1 A.[id] from cmsPropertyData AS A

    LEFT JOIN cmsPropertyType AS B ON A.propertytypeid = b.id

    where B.dataTypeId IN ('5697','5698','6397','6410','6411','6419','6420','6421')

    and A.[dataInt] = '%{0}%' order by A.[id]"

     

    , sender.Id );

    using (IRecordsReader

    dr = SqlHelper.ExecuteReader(sql))

    {

    try

    {

    if

    (dr.HasRecords)

    {

    e.Cancel =

    true

    ;

    }

    }

    catch (Exception

    ex)

    {

    //If the xml can't be converted log it and go to the next row.

    Log.Add(LogTypes.Custom, sender.Id, "Error selecting a media " + ex.Message + "-"

    + sender.Text);

    }

     

    }

     

    }

     

    @Steven - Can you how you solve it?

  • Steven Newstead 62 posts 103 karma points
    Jul 04, 2011 @ 16:23
    Steven Newstead
    0

    It's not really a nice solution but it works for now I am basically some like this:

      private void Document_BeforeMoveToTrash(Document sender, MoveToTrashEventArgs e)

    {

    if (sender.HasChildren)

    {

    e.Cancel = true;

    Log.Add(LogTypes.Save, sender.Id, "This item cannot be deleted because it has children under it");

    ShowErrorBubble("Error deleting item",

    }

        }

            private static void ShowErrorBubble(string title, string exception)

            {

                //todo temp solution as we cannot get the commented code to work (forums suggest it is not possible.)

                //we could throw an execption here

                throw new Exception("This item cannot be deleted because it has children under it");

     

    //unreachable code below

    try

    {

    umbraco.BasePages.BasePage.Current.ClientTools.ShowSpeechBubble(umbraco.BasePages.BasePage.speechBubbleIcon.info, title, exception);

     

    }

    catch (Exception ex)

    {

    //do nothing at the moment, forums suggest we cannot send an error message

    }

     

            }

     

    Alternatively you could just use this line:

     

    Log.Add(LogTypes.Save, sender.Id, "This item cannot be deleted because it has children under it");

     

    This will allow the user to right click on the item and see what happened in the audit history (but it won't display a message to the user)

  • Steven Newstead 62 posts 103 karma points
    Jul 04, 2011 @ 16:24
    Steven Newstead
    0

    p.s. Sorry about the formatting the RTE is not playing today

  • Sherry Ann Hernandez 320 posts 344 karma points
    Jul 04, 2011 @ 17:03
    Sherry Ann Hernandez
    0

    Not possible to use the Logs since i'll be using this on the media section which doesn't have any audit trail as I know. :)

    Will try this. Thanks.

  • Nuno Lourenço 4 posts 30 karma points
    Nov 15, 2011 @ 16:35
    Nuno Lourenço
    0

    I don't know if anyone still got this issue, but I've made some code that needed this "notificatoin" also, and just needed to refresh the content tree:

    var tools = BasePage.Current.ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.success, "ATENTION !!!", "WE NEED YOU!");
    tools.RefreshTree();

    And that was all that was needed.

    Cheers.

Please Sign in or register to post replies

Write your reply to:

Draft