private void AddToSyndication(Guid userID, string rSSUri, SyndicationFeedFormatter feedFormatter)
        {
            try
            {
                ClimberProfile owner = new CFController().GetClimberProfile(userID);

                using (XmlReader reader = XmlReader.Create(rSSUri, new XmlReaderSettings {
                    CloseInput = true, IgnoreWhitespace = false
                }))
                {
                    feedFormatter.ReadFrom(reader);

                    var items = (from c in feedFormatter.Feed.Items where c.PublishDate > DateTime.Now.AddMonths(-1).AddDays(-10) select c); //.Take(NumberPerUser);

                    foreach (SyndicationItem item in items)
                    {
                        SyndicatedItems.Add(new CFUserSyndicationItem(item, owner));
                    }
                }
            }
            catch (Exception ex)
            {
                CFLogger.RecordException(ex, "Failed to load RSS from " + rSSUri);
            }
        }
Esempio n. 2
0
        protected new void Page_PreInit(object sender, EventArgs e)
        {
            ViewData["PageTitle"]  = "Error";
            ViewData["PageRobots"] = "noindex, follow";

            string relativeUrl = "/" + Page.Request.Url.ToString().Replace(CFSettings.WebAddress, "");

            if (!IsPostBack)
            {
                if (exception.ShouldRecord(relativeUrl))
                {
                    CFLogger.RecordException(exception);
                }
            }
            else
            {
                //-- This is important to log too because for some reason it means it is a web forms error.
                if (exception.ShouldRecord(relativeUrl))
                {
                    CFLogger.RecordException(exception);
                }
            }

            base.Page_PreInit(sender, e);
        }
        public ActionResult RenderFeed(byte channel, byte view, string area, string place, string tag)
        {
            try
            {
                int  temp;
                byte?tagID = null; if (int.TryParse(tag, out temp))
                {
                    tagID = (byte)temp;
                }
                int?areaID = null; if (int.TryParse(area, out temp))
                {
                    areaID = temp;
                }
                int?placeID = null; if (int.TryParse(place, out temp))
                {
                    placeID = temp;
                }

                FeedView    feedView    = (FeedView)view;
                FeedChannel feedChannel = (FeedChannel)channel;

                return(View("FeedItemList",
                            GetFeedItemsForViewSettings(feedChannel, feedView, areaID, placeID, tagID)));
            }
            catch (Exception ex)
            {
                CFLogger.RecordException(ex);
                SetPageMetaData();
                return(View("UrlGone"));
            }
        }
Esempio n. 4
0
        void Application_Error(Object sender, EventArgs e)
        {
            try
            {
                string    relativeUrl = HttpContext.Current.Request.RawUrl;
                Exception exception   = getBaseException(Server.GetLastError());

                if (exception.ShouldRecord(relativeUrl))
                {
                    CFLogger.RecordException(exception);
                }

                Server.ClearError();

                if (SpecialUrls.Instance.PermanentlyMoved.ContainsKey(relativeUrl))
                {
                    Response.Status = "301 Moved Permanently";
                    Response.AddHeader("Location", SpecialUrls.Instance.PermanentlyMoved[relativeUrl]);
                    Response.Flush();
                    Response.End();
                }
                else if (SpecialUrls.Instance.UrlsGone.Contains(relativeUrl))
                {
                    Response.Status = "410 Gone";
                    Response.WriteFile(Server.MapPath("~/410UrlGone.html"));
                }
                else if (exception.Message.Contains("The controller for path") || exception.Message.Contains("A public action method"))
                {
                    Response.Redirect("~/PageNotFound");
                }
                else
                {
                    Response.Redirect("~/Home/WebFormError");
                }
            }
            catch (Exception ex)
            {
                //TODO: write to text file

                Response.Write("<span class='note'>GLOBAL ENDPOINT: PLEASE EMAIL [email protected] IF YOU SEE THIS SCREEN!!!!!!!!!!!!</span>" + ex.ToString());

                /*string newFile = PPApp.AbsoluteAppDir + @"logs\GlobalEndPointExceptions" + " " + DateTime.Now.ToLongDateString() + ".txt";
                 *
                 * Response.Write("Writing to file " + newFile);
                 *
                 * StreamWriter tw = new StreamWriter(newFile);
                 * tw.WriteLine(ex.ToString());
                 * tw.Close();*/
            }
        }