private void Page_Load(object sender, EventArgs e) { var iDaysBefore = 0; var iDaysAfter = 0; var iMax = 0; var iOwnerID = 0; var iLocationID = 0; var iImportance = 0; var categoryIDs = new ArrayList(); var locationIDs = new ArrayList(); var iGroupId = -1; var iUserId = -1; var iCategoryName = ""; var iLocationName = ""; var iOwnerName = ""; var txtPriority = ""; if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["mid"])) { _moduleID = Convert.ToInt32(HttpContext.Current.Request.QueryString["mid"]); } else { Response.Redirect(Globals.NavigateURL(), true); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["tabid"])) { _tabID = Convert.ToInt32(HttpContext.Current.Request.QueryString["tabid"]); } else { Response.Redirect(Globals.NavigateURL(), true); } var localResourceFile = TemplateSourceDirectory + "/" + Localization.LocalResourceDirectory + "/EventRSS.aspx.resx"; if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["CategoryName"])) { iCategoryName = HttpContext.Current.Request.QueryString["CategoryName"]; var objSecurity = new PortalSecurity(); iCategoryName = objSecurity.InputFilter(iCategoryName, PortalSecurity.FilterFlag.NoSQL); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["CategoryID"])) { categoryIDs.Add(Convert.ToInt32(HttpContext.Current.Request.QueryString["CategoryID"])); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["LocationName"])) { iLocationName = HttpContext.Current.Request.QueryString["LocationName"]; var objSecurity = new PortalSecurity(); iLocationName = objSecurity.InputFilter(iLocationName, PortalSecurity.FilterFlag.NoSQL); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["LocationID"])) { locationIDs.Add(Convert.ToInt32(HttpContext.Current.Request.QueryString["LocationID"])); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["groupid"])) { iGroupId = Convert.ToInt32(HttpContext.Current.Request.QueryString["groupid"]); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["DaysBefore"])) { iDaysBefore = Convert.ToInt32(HttpContext.Current.Request.QueryString["DaysBefore"]); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["DaysAfter"])) { iDaysAfter = Convert.ToInt32(HttpContext.Current.Request.QueryString["DaysAfter"]); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["MaxNumber"])) { iMax = Convert.ToInt32(HttpContext.Current.Request.QueryString["MaxNumber"]); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["OwnerName"])) { iOwnerName = HttpContext.Current.Request.QueryString["OwnerName"]; } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["OwnerID"])) { iOwnerID = Convert.ToInt32(HttpContext.Current.Request.QueryString["OwnerID"]); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["LocationName"])) { iLocationName = HttpContext.Current.Request.QueryString["LocationName"]; } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["LocationID"])) { iLocationID = Convert.ToInt32(HttpContext.Current.Request.QueryString["LocationID"]); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["Priority"])) { var iPriority = ""; iPriority = HttpContext.Current.Request.QueryString["Priority"]; var lHigh = ""; var lMedium = ""; var lLow = ""; lHigh = Localization.GetString("High", localResourceFile); lMedium = Localization.GetString("Normal", localResourceFile); lLow = Localization.GetString("Low", localResourceFile); txtPriority = "Medium"; if (iPriority == lHigh) { txtPriority = "High"; } else if (iPriority == lMedium) { txtPriority = "Medium"; } else if (iPriority == lLow) { txtPriority = "Low"; } else if (iPriority == "High") { txtPriority = "High"; } else if (iPriority == "Normal") { txtPriority = "Medium"; } else if (iPriority == "Low") { txtPriority = "Low"; } } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["Importance"])) { iImportance = Convert.ToInt32(HttpContext.Current.Request.QueryString["Importance"]); } var portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; _portalID = portalSettings.PortalId; _userinfo = (UserInfo)HttpContext.Current.Items["UserInfo"]; if (!string.IsNullOrEmpty(portalSettings.DefaultLanguage)) { var userculture = new CultureInfo(portalSettings.DefaultLanguage, false); Thread.CurrentThread.CurrentCulture = userculture; } if (_userinfo.UserID > 0) { if (!string.IsNullOrEmpty(_userinfo.Profile.PreferredLocale)) { var userculture = new CultureInfo(_userinfo.Profile.PreferredLocale, false); Thread.CurrentThread.CurrentCulture = userculture; } } _settings = EventModuleSettings.GetEventModuleSettings(_moduleID, localResourceFile); if (_settings.Enablecategories == EventModuleSettings.DisplayCategories.DoNotDisplay) { categoryIDs = _settings.ModuleCategoryIDs; iCategoryName = ""; } if (!string.IsNullOrEmpty(iCategoryName)) { var oCntrlEventCategory = new EventCategoryController(); var oEventCategory = oCntrlEventCategory.EventCategoryGetByName(iCategoryName, _portalID); if (!ReferenceEquals(oEventCategory, null)) { categoryIDs.Add(oEventCategory.Category); } } if (_settings.Enablelocations == EventModuleSettings.DisplayLocations.DoNotDisplay) { locationIDs = _settings.ModuleLocationIDs; iLocationName = ""; } if (!string.IsNullOrEmpty(iLocationName)) { var oCntrlEventLocation = new EventLocationController(); var oEventLocation = oCntrlEventLocation.EventsLocationGetByName(iLocationName, _portalID); if (!ReferenceEquals(oEventLocation, null)) { locationIDs.Add(oEventLocation.Location); } } if (!_settings.RSSEnable) { Response.Redirect(Globals.NavigateURL(), true); } if (_settings.SocialGroupModule == EventModuleSettings.SocialModule.UserProfile) { iUserId = _userinfo.UserID; } var getSubEvents = _settings.MasterEvent; // Define the range of dates that we have to select var dtEndDate = default(DateTime); if (iDaysBefore == 0 && iDaysAfter == 0) { iDaysAfter = _settings.RSSDays; } var objEventTimeZoneUtilities = new EventTimeZoneUtilities(); var currDate = objEventTimeZoneUtilities.ConvertFromUTCToModuleTimeZone(DateTime.UtcNow, _settings.TimeZoneId); dtEndDate = DateAndTime.DateAdd(DateInterval.Day, iDaysAfter, currDate).Date; var dtStartDate = default(DateTime); dtStartDate = DateAndTime.DateAdd(DateInterval.Day, Convert.ToDouble(-iDaysBefore), currDate).Date; var txtFeedRootTitle = ""; var txtFeedRootDescription = ""; var txtRSSDateField = ""; txtFeedRootTitle = _settings.RSSTitle; txtFeedRootDescription = _settings.RSSDesc; txtRSSDateField = _settings.RSSDateField; // Get ready for the RSS feed Response.ContentType = "text/xml"; Response.ContentEncoding = Encoding.UTF8; using (var sw = new StringWriter()) { using (var writer = new XmlTextWriter(sw)) { // Dim writer As XmlTextWriter = New XmlTextWriter(sw) writer.Formatting = Formatting.Indented; writer.Indentation = 4; writer.WriteStartElement("rss"); writer.WriteAttributeString("version", "2.0"); writer.WriteAttributeString("xmlns:wfw", "http://wellformedweb.org/CommentAPI/"); writer.WriteAttributeString("xmlns:slash", "http://purl.org/rss/1.0/modules/slash/"); writer.WriteAttributeString("xmlns:dc", "http://purl.org/dc/elements/1.1/"); writer.WriteAttributeString("xmlns:trackback", "http://madskills.com/public/xml/rss/module/trackback/"); writer.WriteAttributeString("xmlns:atom", "http://www.w3.org/2005/Atom"); writer.WriteAttributeString("xmlns", NsPre, null, NsFull); writer.WriteStartElement("channel"); writer.WriteStartElement("atom:link"); writer.WriteAttributeString("href", HttpContext.Current.Request.Url.AbsoluteUri); writer.WriteAttributeString("rel", "self"); writer.WriteAttributeString("type", "application/rss+xml"); writer.WriteEndElement(); writer.WriteElementString("title", portalSettings.PortalName + " - " + txtFeedRootTitle); if (portalSettings.PortalAlias.HTTPAlias.IndexOf("http://", StringComparison.Ordinal) == -1 && portalSettings.PortalAlias.HTTPAlias.IndexOf("https://", StringComparison.Ordinal) == -1) { writer.WriteElementString("link", Globals.AddHTTP(portalSettings.PortalAlias.HTTPAlias)); } else { writer.WriteElementString("link", portalSettings.PortalAlias.HTTPAlias); } writer.WriteElementString("description", txtFeedRootDescription); writer.WriteElementString("ttl", "60"); var objEventInfoHelper = new EventInfoHelper(_moduleID, _tabID, _portalID, _settings); var lstEvents = default(ArrayList); var tcc = new TokenReplaceControllerClass(_moduleID, localResourceFile); var tmpTitle = _settings.Templates.txtRSSTitle; var tmpDescription = _settings.Templates.txtRSSDescription; if (categoryIDs.Count == 0) { categoryIDs.Add("-1"); } if (locationIDs.Count == 0) { locationIDs.Add("-1"); } lstEvents = objEventInfoHelper.GetEvents(dtStartDate, dtEndDate, getSubEvents, categoryIDs, locationIDs, iGroupId, iUserId); var objEventBase = new EventBase(); var displayTimeZoneId = objEventBase.GetDisplayTimeZoneId(_settings, _portalID); var rssCount = 0; foreach (EventInfo eventInfo in lstEvents) { var objEvent = eventInfo; if ((Convert.ToInt32(categoryIDs[0]) == 0) & (objEvent.Category != Convert.ToInt32(categoryIDs[0]))) { continue; } if ((Convert.ToInt32(locationIDs[0]) == 0) & (objEvent.Location != Convert.ToInt32(locationIDs[0]))) { continue; } if ((iOwnerID > 0) & (objEvent.OwnerID != iOwnerID)) { continue; } if (!string.IsNullOrEmpty(iOwnerName) && objEvent.OwnerName != iOwnerName) { continue; } if ((iLocationID > 0) & (objEvent.Location != iLocationID)) { continue; } if (!string.IsNullOrEmpty(iLocationName) && objEvent.LocationName != iLocationName) { continue; } if (iImportance > 0 && (int)objEvent.Importance != iImportance) { continue; } if (!string.IsNullOrEmpty(txtPriority) && objEvent.Importance.ToString() != txtPriority) { continue; } // If full enrollments should be hidden, ignore if (HideFullEvent(objEvent)) { continue; } var pubDate = default(DateTime); var pubTimeZoneId = ""; switch (txtRSSDateField) { case "UPDATEDDATE": pubDate = objEvent.LastUpdatedAt; pubTimeZoneId = objEvent.OtherTimeZoneId; break; case "CREATIONDATE": pubDate = objEvent.CreatedDate; pubTimeZoneId = objEvent.OtherTimeZoneId; break; case "EVENTDATE": pubDate = objEvent.EventTimeBegin; pubTimeZoneId = objEvent.EventTimeZoneId; break; } objEvent = objEventInfoHelper.ConvertEventToDisplayTimeZone(objEvent, displayTimeZoneId); writer.WriteStartElement("item"); var eventTitle = tcc.TokenReplaceEvent(objEvent, tmpTitle); writer.WriteElementString("title", eventTitle); var eventDescription = tcc.TokenReplaceEvent(objEvent, tmpDescription); var txtDescription = HttpUtility.HtmlDecode(eventDescription); writer.WriteElementString("description", txtDescription); var txtURL = objEventInfoHelper.DetailPageURL(objEvent); writer.WriteElementString("link", txtURL); writer.WriteElementString("guid", txtURL); writer.WriteElementString("pubDate", GetRFC822Date(pubDate, pubTimeZoneId)); writer.WriteElementString("dc:creator", objEvent.OwnerName); if (objEvent.Category > 0) { writer.WriteElementString("category", objEvent.CategoryName); } if (objEvent.Location > 0) { writer.WriteElementString("category", objEvent.LocationName); } if ((int)objEvent.Importance != 2) { var strImportance = Localization.GetString(objEvent.Importance + "Prio", localResourceFile); writer.WriteElementString("category", strImportance); } // specific event data writer.WriteElementString(NsPre, "AllDayEvent", null, objEvent.AllDayEvent.ToString()); writer.WriteElementString(NsPre, "Approved", null, objEvent.Approved.ToString()); writer.WriteElementString(NsPre, "Cancelled", null, objEvent.Cancelled.ToString()); writer.WriteElementString(NsPre, "Category", null, objEvent.CategoryName); //writer.WriteElementString(NsPre, "Location", Nothing, objEvent.LocationName) writer.WriteElementString(NsPre, "DetailURL", null, objEvent.DetailURL); writer.WriteElementString(NsPre, "EventTimeBegin", null, objEvent.EventTimeBegin.ToString("yyyy-MM-dd HH:mm:ss")); writer.WriteElementString(NsPre, "EventTimeZoneId", null, objEvent.EventTimeZoneId); writer.WriteElementString(NsPre, "Duration", null, objEvent.Duration.ToString()); writer.WriteElementString(NsPre, "ImageURL", null, objEvent.ImageURL); writer.WriteElementString(NsPre, "LocationName", null, objEvent.LocationName); writer.WriteElementString(NsPre, "OriginalDateBegin", null, objEvent.OriginalDateBegin.ToString("yyyy-MM-dd HH:mm:ss")); writer.WriteElementString(NsPre, "Signups", null, objEvent.Signups.ToString()); writer.WriteElementString(NsPre, "OtherTimeZoneId", null, objEvent.OtherTimeZoneId); writer.WriteEndElement(); rssCount++; if ((iMax > 0) & (rssCount == iMax)) { break; } } writer.WriteEndElement(); writer.WriteEndElement(); Response.Write(sw.ToString()); } } }
protected void cmdPurchase_Click(object sender, EventArgs e) { var objEvent = default(EventInfo); try { if (Page.IsValid) { objEvent = _objCtlEvent.EventsGet(_itemID, ModuleId); // User wants to purchase event, create Event Signup Record _objEventSignups = new EventSignupsInfo(); //Just in case the user has clicked back and has now clicked Purchase again!! var objEventSignupsChk = default(EventSignupsInfo); if (string.IsNullOrEmpty(_anonEmail)) { objEventSignupsChk = _objCtlEventSignups.EventsSignupsGetUser( objEvent.EventID, UserId, objEvent.ModuleID); } else { objEventSignupsChk = _objCtlEventSignups.EventsSignupsGetAnonUser( objEvent.EventID, _anonEmail, objEvent.ModuleID); } if (!ReferenceEquals(objEventSignupsChk, null)) { _objEventSignups.SignupID = objEventSignupsChk.SignupID; } _objEventSignups.EventID = objEvent.EventID; _objEventSignups.ModuleID = objEvent.ModuleID; if (string.IsNullOrEmpty(_anonEmail)) { _objEventSignups.UserID = UserId; _objEventSignups.AnonEmail = null; _objEventSignups.AnonName = null; _objEventSignups.AnonTelephone = null; _objEventSignups.AnonCulture = null; _objEventSignups.AnonTimeZoneId = null; } else { var objSecurity = new PortalSecurity(); _objEventSignups.UserID = -1; _objEventSignups.AnonEmail = objSecurity.InputFilter(_anonEmail, PortalSecurity.FilterFlag.NoScripting); _objEventSignups.AnonName = objSecurity.InputFilter(_anonName, PortalSecurity.FilterFlag.NoScripting); _objEventSignups.AnonTelephone = objSecurity.InputFilter(_anonTelephone, PortalSecurity.FilterFlag.NoScripting); _objEventSignups.AnonCulture = Thread.CurrentThread.CurrentCulture.Name; _objEventSignups.AnonTimeZoneId = GetDisplayTimeZoneId(); } _objEventSignups.PayPalStatus = "none"; _objEventSignups.PayPalReason = "PayPal call initiated..."; _objEventSignups.PayPalPaymentDate = DateTime.UtcNow; _objEventSignups.Approved = false; _objEventSignups.NoEnrolees = int.Parse(lblNoEnrolees.Text); _objEventSignups = CreateEnrollment(_objEventSignups, objEvent); if (!ReferenceEquals(objEventSignupsChk, null)) { _objEventSignups = _objCtlEventSignups.EventsSignupsGet(objEventSignupsChk.SignupID, objEventSignupsChk.ModuleID, false); } // Mail users if (Settings.SendEnrollMessagePaying) { var objEventEmailInfo = new EventEmailInfo(); var objEventEmail = new EventEmails(PortalId, ModuleId, LocalResourceFile, ((PageBase)Page).PageCulture.Name); objEventEmailInfo.TxtEmailSubject = Settings.Templates.txtEnrollMessageSubject; objEventEmailInfo.TxtEmailBody = Settings.Templates.txtEnrollMessagePaying; objEventEmailInfo.TxtEmailFrom = Settings.StandardEmail; if (string.IsNullOrEmpty(_anonEmail)) { objEventEmailInfo.UserEmails.Add(PortalSettings.UserInfo.Email); objEventEmailInfo.UserLocales.Add(PortalSettings.UserInfo.Profile.PreferredLocale); objEventEmailInfo.UserTimeZoneIds.Add(PortalSettings.UserInfo.Profile.PreferredTimeZone .Id); } else { objEventEmailInfo.UserEmails.Add(_objEventSignups.AnonEmail); objEventEmailInfo.UserLocales.Add(_objEventSignups.AnonCulture); objEventEmailInfo.UserTimeZoneIds.Add(_objEventSignups.AnonTimeZoneId); } objEventEmailInfo.UserIDs.Add(objEvent.OwnerID); objEventEmail.SendEmails(objEventEmailInfo, objEvent, _objEventSignups); } // build PayPal URL var ppurl = Settings.Paypalurl + "/cgi-bin/webscr?cmd=_xclick&business="; var socialGroupId = GetUrlGroupId(); var objEventInfoHelper = new EventInfoHelper(ModuleId, TabId, PortalId, Settings); var returnURL = ""; if (socialGroupId > 0) { returnURL = objEventInfoHelper.AddSkinContainerControls( Globals.NavigateURL(TabId, "PPEnroll", "Mid=" + Convert.ToString(ModuleId), "signupid=" + Convert.ToString(_objEventSignups.SignupID), "status=enrolled", "groupid=" + socialGroupId), "?"); } else { returnURL = objEventInfoHelper.AddSkinContainerControls( Globals.NavigateURL(TabId, "PPEnroll", "Mid=" + Convert.ToString(ModuleId), "signupid=" + Convert.ToString(_objEventSignups.SignupID), "status=enrolled"), "?"); } if (returnURL.IndexOf("://") + 1 == 0) { returnURL = Globals.AddHTTP(Globals.GetDomainName(Request)) + returnURL; } var cancelURL = ""; if (socialGroupId > 0) { cancelURL = objEventInfoHelper.AddSkinContainerControls( Globals.NavigateURL(TabId, "PPEnroll", "Mid=" + Convert.ToString(ModuleId), "signupid=" + Convert.ToString(_objEventSignups.SignupID), "status=cancelled", "groupid=" + socialGroupId), "?"); } else { cancelURL = objEventInfoHelper.AddSkinContainerControls( Globals.NavigateURL(TabId, "PPEnroll", "Mid=" + Convert.ToString(ModuleId), "signupid=" + Convert.ToString(_objEventSignups.SignupID), "status=cancelled"), "?"); } if (cancelURL.IndexOf("://") + 1 == 0) { cancelURL = Globals.AddHTTP(Globals.GetDomainName(Request)) + cancelURL; } var strPayPalURL = ""; strPayPalURL = ppurl + Globals.HTTPPOSTEncode(objEvent.PayPalAccount); strPayPalURL = strPayPalURL + "&item_name=" + Globals.HTTPPOSTEncode(objEvent.ModuleTitle + " - " + lblEventName.Text + " ( " + lblFee.Text + " " + lblFeeCurrency.Text + " )"); strPayPalURL = strPayPalURL + "&item_number=" + Globals.HTTPPOSTEncode(Convert.ToString(_objEventSignups.SignupID)); strPayPalURL = strPayPalURL + "&quantity=" + Globals.HTTPPOSTEncode(Convert.ToString(_objEventSignups.NoEnrolees)); strPayPalURL = strPayPalURL + "&custom=" + Globals.HTTPPOSTEncode( Convert.ToDateTime(lblStartDate.Text).ToShortDateString()); // Make sure currency is in correct format var dblFee = double.Parse(lblFee.Text); var uiculture = Thread.CurrentThread.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; strPayPalURL = strPayPalURL + "&amount=" + Globals.HTTPPOSTEncode(Strings.Format(dblFee, "#,##0.00")); Thread.CurrentThread.CurrentCulture = uiculture; strPayPalURL = strPayPalURL + "¤cy_code=" + Globals.HTTPPOSTEncode(lblTotalCurrency.Text); strPayPalURL = strPayPalURL + "&return=" + returnURL; strPayPalURL = strPayPalURL + "&cancel_return=" + cancelURL; strPayPalURL = strPayPalURL + "¬ify_url=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)) + "/DesktopModules/Events/EventIPN.aspx"); strPayPalURL = strPayPalURL + "&undefined_quantity=&no_note=1&no_shipping=1"; //strPayPalURL = strPayPalURL & "&undefined_quantity=&no_note=1&no_shipping=1&rm=2" // redirect to PayPal Response.Redirect(strPayPalURL, true); } } catch (Exception exc) //Module failed to load { Exceptions.ProcessModuleLoadException(this, exc); } }