예제 #1
0
        public static void RefreshCreators()
        {
            XDocument             doc      = XDocument.Load(CreatorsUrl);
            CreatorInfoCollection creators = new CreatorInfoCollection(doc.Element("creators").Elements("creatorInfo"));

            ZCache.InsertCache(CreatorsCacheKey, creators, CacheTime);
        }
예제 #2
0
        public static void RefreshCatalogs()
        {
            XDocument             doc      = XDocument.Load(CatalogsUrl);
            CatalogInfoCollection catalogs = new CatalogInfoCollection(doc.Element("catalogs").Elements("catalogInfo"));

            ZCache.InsertCache(CatalogsCacheKey, catalogs, CacheTime);
        }
예제 #3
0
        public void RefreshCategories()
        {
            XDocument doc = XDocument.Load(CategoryUrl);
            CategoryInfoCollection categories = new CategoryInfoCollection(this,
                                                                           doc.Element("categories").Elements("categoryInfo"));

            ZCache.InsertCache(CategoryCacheKey, categories, Marketplace.CacheTime);
        }
예제 #4
0
        protected object GetPostsByTag(string key, GraffitiContext graffitiContext)
        {
            PostCollection pc = ZCache.Get <PostCollection>("Tags-" + TagName);

            if (pc == null)
            {
                pc = Post.FetchPostsByTag(TagName);
                ZCache.InsertCache("Tags-" + TagName, pc, 60);
            }

            return(pc);
        }
예제 #5
0
        public void RefreshCreators()
        {
            CreatorInfoCollection creators = new CreatorInfoCollection();

            foreach (ItemInfo item in Items.Values)
            {
                if (!creators.ContainsKey(item.CreatorId))
                {
                    creators.Add(item.CreatorId, item.Creator);
                }
            }
            ZCache.InsertCache(CreatorCacheKey, creators, Marketplace.CacheTime);
        }
예제 #6
0
        /// <summary>
        /// Process the request for the feed.
        /// </summary>
        /// <param name="context">The HTTP context for the request.</param>
        public virtual void ProcessRequest(HttpContext context)
        {
            Context = context;

            string feed = ZCache.Get <string>(this.CacheKey);

            if (feed == null)
            {
                feed = BuildFeed();

                ZCache.InsertCache(this.CacheKey, feed, this.CacheTime);
            }

            WriteFeed(feed);
        }
예제 #7
0
        public void SendPings(object state)
        {
            if (pingServiceUrls == null || pingServiceUrls.Length == 0)
            {
                return;
            }

            foreach (string pingUrl in pingServiceUrls)
            {
                if (!string.IsNullOrEmpty(pingUrl))
                {
                    this.Url = pingUrl.Trim();
                    bool   result       = false;
                    string errorMessage = string.Empty;

                    // Try to remember if the last ping to this URL supported the ExtendedPing spec, so we don't send out unnecessary pings repeatdly
                    bool   isExtendedPing = true;
                    string lastPingResult = ZCache.Get <string>(CacheKey(pingUrl));
                    if (!string.IsNullOrEmpty(lastPingResult))
                    {
                        try { isExtendedPing = bool.Parse(lastPingResult); }
                        catch { }
                    }

                    if (isExtendedPing)
                    {
                        try
                        {
                            PingResult response = ExtendedPing(this.siteName, this.siteUrl, this.siteUrl, this.siteFeedUrl);
                            if (response.flerror != null && response.flerror == true)
                            {
                                if (string.IsNullOrEmpty(response.message))
                                {
                                    errorMessage = "Remote weblogUpdates.extendedPing service indicated an error but provided no error message.";
                                }
                                else
                                {
                                    errorMessage = response.message;
                                }
                            }
                            else
                            {
                                result = true;
                            }
                        }
                        catch (CookComputing.XmlRpc.XmlRpcException ex)
                        {
                            errorMessage = ex.Message;
                        }
                        catch (System.Exception ex)
                        {
                            errorMessage = ex.Message;
                        }

                        // If the ExtendedPing request failed, try a basic ping to this url
                        if (!result)
                        {
                            isExtendedPing = false;
                        }
                    }

                    if (!isExtendedPing)
                    {
                        try
                        {
                            PingResult response = BasicPing(this.siteName, this.siteUrl);
                            if (response.flerror != null && response.flerror == true)
                            {
                                if (string.IsNullOrEmpty(response.message))
                                {
                                    errorMessage = "Remote weblogUpdates.ping service indicated an error but provided no error message.";
                                }
                                else
                                {
                                    errorMessage = response.message;
                                }
                            }
                            else
                            {
                                result = true;
                            }
                        }
                        catch (CookComputing.XmlRpc.XmlRpcException ex)
                        {
                            errorMessage = ex.Message;
                        }
                        catch (System.Exception ex)
                        {
                            errorMessage = ex.Message;
                        }
                    }


                    // Log succcess or failure to EventLog
                    if (result)
                    {
                        // Remember whether extended or basic ping worked for this url in the future
                        ZCache.InsertCache(CacheKey(pingUrl), isExtendedPing.ToString(), 43200);

                        string message = String.Format("Blog Ping sent to {0}.", pingUrl);
                        Log.Info("Ping Sent", message);
                    }
                    else
                    {
                        string message = String.Format("Blog Ping attempt to the url {0} failed. Error message returned was: {1}.", pingUrl, errorMessage);
                        Log.Warn("Ping Error", message);
                    }
                }
            }
        }