protected List <TransitAccountEvent> discoverRel(string url) { List <TransitAccountEvent> result = new List <TransitAccountEvent>(); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.UserAgent = SessionManager.GetCachedConfiguration("SnCore.Web.UserAgent", "SnCore/1.0"); request.Accept = "*/*"; WebResponse response = request.GetResponse(); string content; using (StreamReader sr = new StreamReader(response.GetResponseStream())) { content = sr.ReadToEnd(); sr.Close(); } List <HtmlLinkControl> links = HtmlLinkExtractor.Extract(content, new Uri(url)); foreach (HtmlLinkControl link in links) { try { switch (link.Type.ToLower()) { case "text/calendar": TransitAccountEventICALEmitter emitter = TransitAccountEventICALEmitter.Parse( link.Href, SessionManager.GetCachedConfiguration("SnCore.Web.UserAgent", "SnCore/1.0")); emitter.AccountEvent.Website = link.Href; AddUnique(result, emitter.AccountEvent); break; } } catch { } } List <Uri> webcallinks = HtmlUriExtractor.Extract(content, new Uri(url)); foreach (Uri link in webcallinks) { try { if (link.Scheme.ToLower() == "webcal" || link.GetLeftPart(UriPartial.Path).EndsWith(".ics")) { TransitAccountEventICALEmitter emitter = TransitAccountEventICALEmitter.Parse( link.ToString(), SessionManager.GetCachedConfiguration("SnCore.Web.UserAgent", "SnCore/1.0")); emitter.AccountEvent.Website = link.ToString(); AddUnique(result, emitter.AccountEvent); } } catch { } } return(result); }
public void Page_Load(object sender, EventArgs e) { place.Choose += new EventHandler(event_Changed); schedule.Confirm += new EventHandler(event_Changed); if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("Me Me", Request, "AccountManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("Events", Request, "AccountEventsManage.aspx")); DomainClass cs = SessionManager.GetDomainClass("AccountEvent"); inputName.MaxLength = cs["Name"].MaxLengthInChars; inputPhone.MaxLength = cs["Phone"].MaxLengthInChars; inputEmail.MaxLength = cs["Email"].MaxLengthInChars; inputWebsite.MaxLength = cs["Website"].MaxLengthInChars; inputCost.MaxLength = cs["Cost"].MaxLengthInChars; GetAccountEventTypes(sender, e); linkBack.NavigateUrl = ReturnUrl; linkDelete.Visible = linkSummarize.Visible = (RequestId > 0); if (RequestId > 0) { TransitAccountEvent tav = SessionManager.EventService.GetAccountEventById( SessionManager.Ticket, RequestId, SessionManager.UtcOffset.Ticks); inputName.Text = tav.Name; inputWebsite.Text = tav.Website; inputDescription.Text = tav.Description; inputPhone.Text = tav.Phone; inputEmail.Text = tav.Email; inputCost.Text = tav.Cost; inputPublish.Checked = tav.Publish; ListItemManager.TrySelect(selectType, tav.AccountEventType); schedule.Schedule = SessionManager.ObjectService.GetScheduleById(SessionManager.Ticket, tav.ScheduleId); place.Place = SessionManager.PlaceService.GetPlaceById(SessionManager.Ticket, tav.PlaceId); titleEvent.Text = Renderer.Render(tav.Name); sitemapdata.Add(new SiteMapDataAttributeNode(tav.Name, Request.Url)); } else if (!string.IsNullOrEmpty(Request["ical"])) { TransitAccountEventICALEmitter emitter = TransitAccountEventICALEmitter.Parse( Request["ical"], SessionManager.UtcOffset, SessionManager.GetCachedConfiguration("SnCore.Web.UserAgent", "SnCore/1.0")); inputName.Text = emitter.AccountEvent.Name; inputWebsite.Text = emitter.AccountEvent.Website; inputDescription.Text = emitter.AccountEvent.Description; inputPhone.Text = emitter.AccountEvent.Phone; inputEmail.Text = emitter.AccountEvent.Email; inputCost.Text = emitter.AccountEvent.Cost; inputPublish.Checked = emitter.AccountEvent.Publish; ListItemManager.TrySelect(selectType, emitter.AccountEvent.AccountEventType); schedule.Schedule = emitter.Schedule; place.Place = emitter.Place; titleEvent.Text = Renderer.Render(emitter.AccountEvent.Name); sitemapdata.Add(new SiteMapDataAttributeNode("New ICal Event", Request.Url)); } else { sitemapdata.Add(new SiteMapDataAttributeNode("New Event", Request.Url)); } StackSiteMap(sitemapdata); } SetDefaultButton(manageAdd); if (!SessionManager.HasVerified()) { ReportWarning("You don't have any verified e-mail addresses and/or profile photos.\n" + "You must add/confirm a valid e-mail address and upload a profile photo before posting."); manageAdd.Enabled = false; } }