コード例 #1
0
ファイル: SendPings.cs プロジェクト: doct15/blogengine
    /// <summary>
    /// Handles the Saved event of the Post control.
    /// Sends the pings in a new thread.
    ///     <remarks>
    /// It opens a new thread and executes the pings from there,
    ///         because it takes some time to complete.
    ///     </remarks>
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.</param>
    private static void PostSaved(object sender, SavedEventArgs e)
    {
        if (!ExtensionManager.ExtensionEnabled("SendPings"))
            return;

        if (e.Action == SaveAction.None || e.Action == SaveAction.Delete)
            return;

        var item = (IPublishable)sender;
        if (!item.IsVisibleToPublic)
            return;

        var url = item.AbsoluteLink;

        // Need blogSettings to pass to Ping since the current blog instance won't
        // be detectable once in a BG thread.
        Guid blogId = Blog.CurrentInstance.Id;
        ThreadPool.QueueUserWorkItem(state =>
            {
                // because HttpContext is not available within this BG thread
                // needed to determine the current blog instance,
                // set override value here.
                Blog.InstanceIdOverride = blogId;

                Ping(item, url);
            });
    }
コード例 #2
0
ファイル: MonthList.cs プロジェクト: rajgit31/RajBlog
 static void Post_Saved(object sender, SavedEventArgs e)
 {
     // invalidate cache whenever a post is modified
     lock (_SyncRoot)
     {
         HttpRuntime.Cache.Remove(CacheKey);
     }
 }
コード例 #3
0
ファイル: SendPings.cs プロジェクト: bpanjavan/Blog
    /// <summary>
    /// Sends the pings in a new thread.
    /// <remarks>
    /// It opens a new thread and executes the pings from there,
    /// because it takes some time to complete.
    /// </remarks>
    /// </summary>
    private static void Post_Saved(object sender, SavedEventArgs e)
    {
        if (e.Action == SaveAction.None || e.Action == SaveAction.Delete)
            return;

        IPublishable item = (IPublishable)sender;

        if ((HttpContext.Current == null || !HttpContext.Current.Request.IsLocal) && item.IsVisible)
        {
            Uri url = item.AbsoluteLink;
            ThreadPool.QueueUserWorkItem(delegate { Ping(item, url); });
        }
    }
コード例 #4
0
ファイル: SendPings.cs プロジェクト: rajgit31/RajBlog
    /// <summary>
    /// Sends the pings in a new thread.
    /// <remarks>
    /// It opens a new thread and executes the pings from there,
    /// because it takes some time to complete.
    /// </remarks>
    /// </summary>
    private static void Post_Saved(object sender, SavedEventArgs e)
    {
        if (e.Action == SaveAction.None || e.Action == SaveAction.Delete)
            return;

        IPublishable item = (IPublishable)sender;

        if (item.IsVisibleToPublic)
        {
            Uri url = item.AbsoluteLink;
            ThreadPool.QueueUserWorkItem(delegate { Ping(item, url); });
        }
    }
コード例 #5
0
 private static void Page_Saved(object sender, SavedEventArgs e)
 {
     lock (_SyncRoot)
     {
         if (e.Action == SaveAction.Insert)
         {
             AddItem(sender as Page);
         }
         else
         {
             BuildCatalog();
         }
     }
 }
コード例 #6
0
ファイル: Search.cs プロジェクト: waynejr2/dotnetmocks2demo
 /// <summary>
 /// Handles the Saved event of the Post control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.</param>
 private static void Post_Saved(object sender, SavedEventArgs e)
 {
     lock (_syncRoot)
     {
         if (e.Action == SaveAction.Insert)
         {
             AddItem(sender as Post);
         }
         else
         {
             BuildEntries();
         }
     }
 }
コード例 #7
0
    /// <summary>
    /// Handles the Saved event of the Post control.
    /// Sends the pings in a new thread.
    ///     <remarks>
    /// It opens a new thread and executes the pings from there,
    ///         because it takes some time to complete.
    ///     </remarks>
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.</param>
    private static void PostSaved(object sender, SavedEventArgs e)
    {
        if (e.Action == SaveAction.None || e.Action == SaveAction.Delete)
        {
            return;
        }

        var item = (IPublishable)sender;
        if (!item.IsVisibleToPublic)
        {
            return;
        }
        
        var url = item.AbsoluteLink;
        ThreadPool.QueueUserWorkItem(state => Ping(item, url));
    }
コード例 #8
0
        /// <summary>
        /// Handles the Saved event of the BlogRollItem control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.</param>
        private static void BlogRollItemSaved(object sender, SavedEventArgs e)
        {
            switch (e.Action)
            {
                case SaveAction.Insert:
                    AddBlog((BlogRollItem)sender);
                    break;
                case SaveAction.Delete:
                    var affected = items.FirstOrDefault(req => req.RollItem.Equals(sender));
                    items.Remove(affected);
                    break;
            }

            if (((e.Action == SaveAction.Insert || e.Action == SaveAction.Delete) || e.Action == SaveAction.Update) &&
                items.Count > 0)
            {
                // Re-sort _Items collection in case sorting of blogroll items was changed.
                items.Sort((br1, br2) => br1.RollItem.CompareTo(br2.RollItem));
            }
        }
コード例 #9
0
ファイル: widget.ascx.cs プロジェクト: aldrinmg/SadPanda-1
        /// <summary>
        /// Handles the Saving event of the Publishable.
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.
        /// </param>
        private static void PublishableSaving(object sender, SavedEventArgs e)
        {
            // Set SendNewsletterEmails to true whenever a publishable is changing from an unpublished
            // state to a published state.  To check the published state of this publishable before
            // it was changed, it's necessary to retrieve the publishable from the datastore since the
            // publishable in memory (via Post.GetPost() or Page.GetPage()) will already have the
            // updated values about to be saved.

            var publishable = (IPublishable)sender;

            SetSendNewsletterEmails(publishable.Id, false); // default to not sending

            if (publishable is Post && !SendEmailsForPosts)
                return;
            else if (publishable is BlogEngine.Core.Page && !SendEmailsForPages)
                return;

            if (e.Action == SaveAction.Insert && publishable.IsVisibleToPublic)
            {
                SetSendNewsletterEmails(publishable.Id, true);
            }
            else if (e.Action == SaveAction.Update && publishable.IsVisibleToPublic)
            {
                var preUpdatePublishable = (IPublishable)null;

                if (publishable is Post)
                    preUpdatePublishable = (IPublishable)BlogService.SelectPost(publishable.Id);
                else
                    preUpdatePublishable = (IPublishable)BlogService.SelectPage(publishable.Id);

                if (preUpdatePublishable != null && !preUpdatePublishable.IsVisibleToPublic)
                {
                    // Note, use publishable.Id below instead of preUpdatePublishable.Id because
                    // when directly calling BlogService.SelectPage or BlogService.SelectPost,
                    // the Guid ID is not set, and so will be a random, non-matching Guid ID.

                    SetSendNewsletterEmails(publishable.Id, true);
                }
            }
        }
コード例 #10
0
ファイル: widget.ascx.cs プロジェクト: aldrinmg/SadPanda-1
        /// <summary>
        /// Handles the Saved event of the Publishable.
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.
        /// </param>
        private static void PublishableSaved(object sender, SavedEventArgs e)
        {
            var publishable = (IPublishable)sender;

            if (!GetSendSendNewsletterEmails(publishable.Id))
            {
                return;
            }

            XmlNodeList emails = null;
            lock (syncRoot)
            {
                LoadEmails();

                emails = docs[Blog.CurrentInstance.Id].SelectNodes("emails/email");
            }

            if (emails == null) { return; }

            List<MailMessage> messages = new List<MailMessage>();
            foreach (XmlNode node in emails)
            {
                string address = node.InnerText.Trim();

                if (!Utils.StringIsNullOrWhitespace(address) && Utils.IsEmailValid(address))
                {
                    MailMessage message = CreateEmail(publishable);
                    message.To.Add(address);
                    messages.Add(message);
                }
            }
            if (messages.Count == 0) { return; }

            // retrieve the blogId before entering the BG thread.
            Guid blogId = Blog.CurrentInstance.Id;

            ThreadPool.QueueUserWorkItem(state =>
            {
                Thread.Sleep(3000);

                // because HttpContext is not available within this BG thread
                // needed to determine the current blog instance,
                // set override value here.
                Blog.InstanceIdOverride = blogId;

                foreach (MailMessage message in messages)
                {
                    Utils.SendMailMessage(message);
                }
            });
        }
コード例 #11
0
ファイル: RelatedPosts.cs プロジェクト: doct15/blogengine
        /// <summary>
        /// Handles the Saved event of the Post control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.</param>
        private static void PostSaved(object sender, SavedEventArgs e)
        {
            if (e.Action != SaveAction.Update)
            {
                return;
            }

            var post = (Post)sender;
            if (RelatedPostsCache.ContainsKey(post.Id))
            {
                RelatedPostsCache.Remove(post.Id);
            }
        }
コード例 #12
0
ファイル: RecentPosts.cs プロジェクト: bpanjavan/Blog
 static void Post_Saved(object sender, SavedEventArgs e)
 {
     if (e.Action != SaveAction.Update)
     BuildPostList();
 }
コード例 #13
0
        /// <summary>
        /// Handles the Saved event of the Post control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.</param>
        private static void PostSaved(object sender, SavedEventArgs e)
        {
            if (e.Action == SaveAction.Update)
            {
                return;
            }

            ClearCache(null, new EventArgs());
        }
コード例 #14
0
        /// <summary>
        /// Handles the Saving event of the Post control.
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.
        /// </param>
        private static void PostSaving(object sender, SavedEventArgs e)
        {
            // Set SendNewsletterEmails to true whenever a post is changing from an unpublished
            // state to a published state.  To check the published state of this Post before
            // it was changed, it's necessary to retrieve the post from the datastore since the
            // post in memory (via Post.GetPost()) will already have the updated values about
            // to be saved.
            var post = (Post)sender;

            SetSendNewsletterEmails(post.Id, false); // default to not sending

            if (e.Action == SaveAction.Insert && post.IsVisibleToPublic)
            {
                SetSendNewsletterEmails(post.Id, true);
            }
            else if (e.Action == SaveAction.Update && post.IsVisibleToPublic)
            {
                var preUpdatePost = BlogService.SelectPost(post.Id);
                if (preUpdatePost != null && !preUpdatePost.IsVisibleToPublic)
                {
                    SetSendNewsletterEmails(post.Id, true);
                }
            }
        }
コード例 #15
0
ファイル: Blogroll.cs プロジェクト: rajgit31/RajBlog
        private void BlogRollItem_Saved(object sender, SavedEventArgs e)
        {
            if (e.Action == SaveAction.Insert || e.Action == SaveAction.Update || e.Action == SaveAction.Delete)
            {
                if (e.Action == SaveAction.Insert)
                {
                    AddBlog((BlogRollItem)sender);
                }
                else if (e.Action == SaveAction.Delete)
                {
                    blogRequest affected = null;
                    foreach (blogRequest req in _Items)
                    {
                        if (req.RollItem.Equals(sender))
                        {
                            affected = req;
                            break;
                        }
                    }
                    _Items.Remove(affected);
                }

                if (_Items.Count > 0)
                {
                    // Re-sort _Items collection in case sorting of blogroll items was changed.
                    _Items.Sort(delegate(blogRequest br1, blogRequest br2) { return br1.RollItem.CompareTo(br2.RollItem); });
                }
            }
        }
コード例 #16
0
ファイル: RecentComments.cs プロジェクト: aldrinmg/SadPanda-1
        /// <summary>
        /// Handles the Saved event of the Post control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.</param>
        private static void PostSaved(object sender, SavedEventArgs e)
        {
            if (e.Action == SaveAction.Update)
            {
                return;
            }

            BindComments();
        }
コード例 #17
0
ファイル: RelatedPosts.cs プロジェクト: bpanjavan/Blog
 static void Post_Saved(object sender, SavedEventArgs e)
 {
     if (e.Action == SaveAction.Update)
     {
         Post post = (Post)sender;
         if (_Cache.ContainsKey(post.Id))
             _Cache.Remove(post.Id);
     }
 }
コード例 #18
0
ファイル: RecentPosts.cs プロジェクト: aldrinmg/SadPanda-1
        /// <summary>
        /// Handles the Saved event of the Post control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.</param>
        private static void PostSaved(object sender, SavedEventArgs e)
        {
            if (e.Action == SaveAction.Update)
            {
                return;
            }

            BuildPostList();
        }
コード例 #19
0
ファイル: RecentComments.cs プロジェクト: bpanjavan/Blog
 static void Post_Saved(object sender, SavedEventArgs e)
 {
     if (e.Action != SaveAction.Update)
         BindComments();
 }
コード例 #20
0
ファイル: widget.ascx.cs プロジェクト: bpanjavan/Blog
 static void Post_Saved(object sender, SavedEventArgs e)
 {
     Post post = (Post)sender;
     if (e.Action == SaveAction.Insert && post.IsPublished)
     {
         LoadEmails();
         foreach (XmlNode node in _Doc.SelectNodes("emails/email"))
         {
             MailMessage mail = CreateEmail(post);
             mail.To.Add(node.InnerText);
             Utils.SendMailMessageAsync(mail);
         }
     }
 }
コード例 #21
0
	private void Post_Saving(object sender, SavedEventArgs e)
	{
		//### executing here will only run the code once per post, but will modify the post itself
		//InsertCopyCodeLink(e);
	}
コード例 #22
0
        /// <summary>
        /// Handles the Saved event of the Post control.
        /// </summary>
        /// <param name="sender">
        /// The source of the event.
        /// </param>
        /// <param name="e">
        /// The <see cref="BlogEngine.Core.SavedEventArgs"/> instance containing the event data.
        /// </param>
        private static void PostSaved(object sender, SavedEventArgs e)
        {
            var post = (Post)sender;

            if (!GetSendSendNewsletterEmails(post.Id))
            {
                return;
            }

            LoadEmails();
            var emails = doc.SelectNodes("emails/email");
            if (emails == null)
            {
                return;
            }

            foreach (XmlNode node in emails)
            {
                var mail = CreateEmail(post);
                mail.To.Add(node.InnerText);
                Utils.SendMailMessageAsync(mail);
            }
        }