Beispiel #1
0
        protected void cmdUpgrade_Click(object sender, EventArgs e)
        {
            var emSettings = EventModuleSettings.GetEventModuleSettings(this.ModuleId, this.LocalResourceFile);

            var dummyRmid = emSettings.RecurDummy;

            this.divUpgrade.Visible = false;
            this.divRetry.Visible   = false;
            if (!string.IsNullOrEmpty(dummyRmid) &&
                dummyRmid != "99999")
            {
                var objEventController = new EventController();
                int dummyRmidInt       = int.TryParse(dummyRmid, out dummyRmidInt) ? dummyRmidInt : 0;
                var upgradeOk          =
                    objEventController.UpgradeRecurringEventModule(this.ModuleId, dummyRmidInt,
                                                                   emSettings.Maxrecurrences, this.LocalResourceFile);
                var objEventCtl = new EventController();
                objEventCtl.EventsUpgrade("04.01.00");
                if (!upgradeOk)
                {
                    this.divUpgrade.Visible = true;
                    this.divRetry.Visible   = true;
                }
            }
        }
Beispiel #2
0
        /// <summary>
        ///     Load current settings into the controls from the modulesettings
        /// </summary>
        /// <remarks></remarks>
        public override void LoadSettings()
        {
            // Force full PostBack since these pass off to aspx page
            if (AJAX.IsInstalled())
            {
                AJAX.RegisterPostBackControl(this.cmdUpgrade);
            }

            var emSettings = EventModuleSettings.GetEventModuleSettings(this.ModuleId, this.LocalResourceFile);

            var dummyRmid = emSettings.RecurDummy;

            this.divUpgrade.Visible = false;
            this.divRetry.Visible   = false;
            if (!string.IsNullOrEmpty(dummyRmid) &&
                dummyRmid != "99999")
            {
                this.divUpgrade.Visible = true;
            }
        }
        public override List <SitemapUrl> GetUrls(int portalID, PortalSettings ps, string version)
        {
            var sitemapUrls = new List <SitemapUrl>();

            var objDesktopModule = default(DesktopModuleInfo);

            objDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName("DNN_Events", portalID);

            var objModules          = new ModuleController();
            var objModule           = default(ModuleInfo);
            var lstModules          = objModules.GetModulesByDefinition(portalID, objDesktopModule.FriendlyName);
            var moduleIds           = new ArrayList();
            var visibleModuleIds    = new ArrayList();
            var visibleTabModuleIds = new ArrayList();

            foreach (ModuleInfo tempLoopVar_objModule in lstModules)
            {
                objModule = tempLoopVar_objModule;
                var objTabPermissions = TabPermissionController.GetTabPermissions(objModule.TabID, portalID);
                var objTabPermission  = default(TabPermissionInfo);

                foreach (TabPermissionInfo tempLoopVar_objTabPermission in objTabPermissions)
                {
                    objTabPermission = tempLoopVar_objTabPermission;

                    if (objTabPermission.PermissionKey == "VIEW" && objTabPermission.RoleName != "" &&
                        objTabPermission.AllowAccess && (objTabPermission.RoleID == -1) |
                        (objTabPermission.RoleID == -3))
                    {
                        if (objModule.InheritViewPermissions)
                        {
                            visibleTabModuleIds.Add("Tab" + objModule.TabID + "Mod" + objModule.ModuleID);
                            visibleModuleIds.Add(objModule.ModuleID);
                            break;
                        }

                        var objModulePermission = default(ModulePermissionInfo);
                        // ReSharper disable LoopCanBeConvertedToQuery
                        foreach (ModulePermissionInfo tempLoopVar_objModulePermission in objModule.ModulePermissions)
                        {
                            objModulePermission = tempLoopVar_objModulePermission;
                            // ReSharper restore LoopCanBeConvertedToQuery
                            if (objModulePermission.PermissionKey == "VIEW" && objModulePermission.RoleName != "" &&
                                objModulePermission.AllowAccess && (objModulePermission.RoleID == -1) |
                                (objModulePermission.RoleID == -3))
                            {
                                visibleTabModuleIds.Add("Tab" + objModule.TabID + "Mod" + objModule.ModuleID);
                                visibleModuleIds.Add(objModule.ModuleID);
                                break;
                            }
                        }
                    }
                }
            }
            foreach (ModuleInfo tempLoopVar_objModule in lstModules)
            {
                objModule = tempLoopVar_objModule;

                // This check for objModule = Nothing because of error in DNN 5.0.0 in GetModulesByDefinition
                if (ReferenceEquals(objModule, null))
                {
                    continue;
                }

                if (objModule.IsDeleted)
                {
                    continue;
                }

                if (moduleIds.Contains(objModule.ModuleID))
                {
                    continue;
                }

                if (!visibleTabModuleIds.Contains("Tab" + objModule.TabID + "Mod" + objModule.ModuleID))
                {
                    continue;
                }

                moduleIds.Add(objModule.ModuleID);
                var settings = EventModuleSettings.GetEventModuleSettings(objModule.ModuleID, null);
                if (!settings.EnableSitemap)
                {
                    continue;
                }

                if (settings.SocialGroupModule == EventModuleSettings.SocialModule.UserProfile)
                {
                    continue;
                }

                var iCategoryIDs = new ArrayList();
                if (settings.Enablecategories == EventModuleSettings.DisplayCategories.DoNotDisplay)
                {
                    iCategoryIDs = settings.ModuleCategoryIDs;
                }
                else
                {
                    iCategoryIDs.Add("-1");
                }

                var ilocationIDs = new ArrayList();
                if (settings.Enablelocations == EventModuleSettings.DisplayLocations.DoNotDisplay)
                {
                    ilocationIDs = settings.ModuleLocationIDs;
                }
                else
                {
                    ilocationIDs.Add("-1");
                }

                var objEventTimeZoneUtilities = new EventTimeZoneUtilities();
                var currDate    = objEventTimeZoneUtilities.ConvertFromUTCToModuleTimeZone(DateTime.UtcNow, settings.TimeZoneId);
                var dtStartDate = DateAndTime.DateAdd(DateInterval.Day, Convert.ToDouble(-settings.SiteMapDaysBefore), currDate);
                var dtEndDate   = DateAndTime.DateAdd(DateInterval.Day, settings.SiteMapDaysAfter, currDate);

                var objEventInfoHelper = new EventInfoHelper(objModule.ModuleID, objModule.TabID, portalID, settings);

                var lstevents = default(ArrayList);
                lstevents = objEventInfoHelper.GetEvents(dtStartDate, dtEndDate, settings.MasterEvent, iCategoryIDs, ilocationIDs, -1, -1);

                var objEvent = default(EventInfo);

                foreach (EventInfo tempLoopVar_objEvent in lstevents)
                {
                    objEvent = tempLoopVar_objEvent;
                    if (settings.Enforcesubcalperms && !visibleModuleIds.Contains(objEvent.ModuleID))
                    {
                        continue;
                    }
                    var pageUrl = new SitemapUrl();
                    pageUrl.Url             = objEventInfoHelper.DetailPageURL(objEvent, false);
                    pageUrl.Priority        = settings.SiteMapPriority;
                    pageUrl.LastModified    = objEvent.LastUpdatedAt;
                    pageUrl.ChangeFrequency = SitemapChangeFrequency.Daily;
                    sitemapUrls.Add(pageUrl);
                }
            }

            return(sitemapUrls);
        }
Beispiel #4
0
        private string CleanupExpired()
        {
            var returnStr       = "Event Cleanup completed.";
            var noDeletedEvents = 0;

            Status = "Performing Event Cleanup";

            var objDesktopModule = default(DesktopModuleInfo);

            objDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName("DNN_Events", 0);

            if (ReferenceEquals(objDesktopModule, null))
            {
                return("Module Definition 'DNN_Events' not found. Cleanup cannot be performed.");
            }

            Status = "Performing Event Cleanup: Dummy";
            Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName;

            var objPortals = new PortalController();
            var objPortal  = default(PortalInfo);
            var objModules = new ModuleController();
            var objModule  = default(ModuleInfo);

            var lstportals = objPortals.GetPortals();

            foreach (PortalInfo tempLoopVar_objPortal in lstportals)
            {
                objPortal = tempLoopVar_objPortal;
                Status    = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID: Dummy";
                Status    = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" +
                            objPortal.PortalID;

                var lstModules = objModules.GetModulesByDefinition(objPortal.PortalID, objDesktopModule.FriendlyName);
                foreach (ModuleInfo tempLoopVar_objModule in lstModules)
                {
                    objModule = tempLoopVar_objModule;
                    // This check for objModule = Nothing because of error in DNN 5.0.0 in GetModulesByDefinition
                    if (ReferenceEquals(objModule, null))
                    {
                        continue;
                    }
                    Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" +
                             objPortal.PortalID + " ModuleID: Dummy";
                    Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" +
                             objPortal.PortalID + " ModuleID:" + objModule.ModuleID;

                    var settings = EventModuleSettings.GetEventModuleSettings(objModule.ModuleID, null);
                    if (settings.Expireevents != "")
                    {
                        Status = "Performing Event Cleanup:" + objDesktopModule.FriendlyName + " PortalID:" +
                                 objPortal.PortalID + " ModuleID:" + objModule.ModuleID + " IN PROGRESS";

                        var objEventCtl = new EventController();
                        var expireDate  =
                            DateAndTime.DateAdd(DateInterval.Day, -Convert.ToInt32(settings.Expireevents),
                                                DateTime.UtcNow);
                        var startdate          = expireDate.AddYears(-10);
                        var endDate            = expireDate.AddDays(1);
                        var objEventInfoHelper = new EventInfoHelper(objModule.ModuleID, settings);
                        var categoryIDs        = new ArrayList();
                        categoryIDs.Add("-1");
                        var locationIDs = new ArrayList();
                        locationIDs.Add("-1");
                        var lstEvents =
                            objEventInfoHelper.GetEvents(startdate, endDate, false, categoryIDs, locationIDs, -1, -1);

                        var objEventTimeZoneUtilities = new EventTimeZoneUtilities();
                        foreach (EventInfo objEvent in lstEvents)
                        {
                            var eventTime =
                                objEventTimeZoneUtilities.ConvertToUTCTimeZone(
                                    objEvent.EventTimeEnd, objEvent.EventTimeZoneId);
                            if (eventTime < expireDate)
                            {
                                objEvent.Cancelled = true;
                                objEventCtl.EventsSave(objEvent, true, 0, true);
                                noDeletedEvents++;
                                returnStr = "Event Cleanup completed. " + noDeletedEvents + " Events deleted.";
                            }
                        }
                        objEventCtl.EventsCleanupExpired(objModule.PortalID, objModule.ModuleID);
                    }
                }
            }
            Status = "Cleanup complete";
            return(returnStr);
        }
Beispiel #5
0
        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());
                }
            }
        }
Beispiel #6
0
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                this._localResourceFile = this.TemplateSourceDirectory + "/" + Localization.LocalResourceDirectory +
                                          "/EventIPN.resx";

                var sPpnMessages = ""; //  Payment message
                // assign posted variables to local variables
                this._receiverEmail  = this.Request.Params["receiver_email"];
                this._itemName       = this.Request.Params["item_name"];
                this._itemNumber     = this.Request.Params["item_number"];
                this._quantity       = this.Request.Params["quantity"];
                this._invoice        = this.Request.Params["invoice"];
                this._custom         = this.Request.Params["custom"];
                this._paymentStatus  = this.Request.Params["payment_status"];
                this._currency       = this.Request.Params["mc_currency"];
                this._pendingReason  = this.Request.Params["pending_reason"];
                this._paymentDate    = this.Request.Params["payment_date"];
                this._paymentFee     = this.Request.Params["mc_fee"];
                this._paymentGross   = this.Request.Params["mc_gross"];
                this._txnID          = this.Request.Params["txn_id"];
                this._txnType        = this.Request.Params["txn_type"];
                this._firstName      = this.Request.Params["first_name"];
                this._lastName       = this.Request.Params["last_name"];
                this._addressStreet  = this.Request.Params["address_street"];
                this._addressCity    = this.Request.Params["address_city"];
                this._addressState   = this.Request.Params["address_state"];
                this._addressZip     = this.Request.Params["address_zip"];
                this._addressCountry = this.Request.Params["address_country"];
                this._addressStatus  = this.Request.Params["address_status"];
                this._payerEmail     = this.Request.Params["payer_email"];
                this._payerStatus    = this.Request.Params["payer_status"];
                this._paymentType    = this.Request.Params["payment_type"];
                this._notifyVersion  = this.Request.Params["notify_version"];
                this._verifySign     = this.Request.Params["verify_sign"];
                this._subscrDate     =
                    this.Request.Params
                    ["subscr_date"];     //Start date or cancellation date depending on whether transaction is "subscr_signup" or "subscr_cancel"
                this._period1 =
                    this.Request.Params
                    ["period1"];     //(optional) Trial subscription interval in days, weeks, months, years (example: a 4 day interval is "period1: 4 d")
                this._period2 =
                    this.Request.Params
                    ["period2"];                                  //(optional) Trial subscription interval in days, weeks, months, years
                this._period3 =
                    this.Request.Params["period3"];               //Regular subscription interval in days, weeks, months, years
                this._amount1   = this.Request.Params["amount1"]; //(optional) Amount of payment for trial period1
                this._amount2   = this.Request.Params["amount2"]; //(optional) Amount of payment for trial period2
                this._amount3   = this.Request.Params["amount3"]; //Amount of payment for regular period3
                this._recurring =
                    this.Request.Params["recurring"];             //Indicates whether regular rate recurs (1 is yes, 0 is no)
                this._reattempt =
                    this.Request.Params
                    ["reattempt"];                                  //Indicates whether reattempts should occur upon payment failures (1 is yes, 0 is no)
                this._retryAt    = this.Request.Params["retry_at"]; //Date we will retry failed subscription payment
                this._recurTimes =
                    this.Request.Params["recur_times"];             //How many payment installments will occur at the regular rate
                this._username =
                    this.Request.Params
                    ["username"];     //(optional) Username generated by PayPal and given to subscriber to access the subscription
                this._password =
                    this.Request.Params
                    ["password"];                     //(optional) Password generated by PayPal and given to subscriber to access the subscription (password will be hashed).
                this._subscrID =
                    this.Request.Params["subscr_id"]; //(optional) ID generated by PayPal for the subscriber
                this._strToSend = this.Request.Form.ToString();

                // Create the string to post back to PayPal system to validate
                this._strToSend += "&cmd=_notify-validate";

                // Get the Event Signup
                this._objEventSignups =
                    this._objCtlEventSignups.EventsSignupsGet(Convert.ToInt32(this._itemNumber), 0, true);

                // Get Module Settings
                this._moduleID = this._objEventSignups.ModuleID;
                this._settings = EventModuleSettings.GetEventModuleSettings(this._moduleID, this._localResourceFile);

                //Initialize the WebRequest.
                var webURL = "";
                webURL = this._settings.Paypalurl + "/cgi-bin/webscr";

                //Send PayPal Verification Response
                var myRequest = (HttpWebRequest)WebRequest.Create(webURL);
                myRequest.AllowAutoRedirect = false;
                myRequest.Method            = "POST";
                myRequest.ContentType       = "application/x-www-form-urlencoded";

                //Create post stream
                var requestStream = myRequest.GetRequestStream();
                var someBytes     = Encoding.UTF8.GetBytes(this._strToSend);
                requestStream.Write(someBytes, 0, someBytes.Length);
                requestStream.Close();

                //Send request and get response
                var myResponse = (HttpWebResponse)myRequest.GetResponse();
                if (myResponse.StatusCode == HttpStatusCode.OK)
                {
                    //Obtain a 'Stream' object associated with the response object.
                    var receiveStream = myResponse.GetResponseStream();
                    var encode        = Encoding.GetEncoding("utf-8");

                    //Pipe the stream to a higher level stream reader with the required encoding format.
                    var readStream = new StreamReader(receiveStream, encode);

                    //Read result
                    var result = readStream.ReadLine();
                    if (result == "INVALID")
                    {
                        this.MailUsTheOrder("PPIPN: Status came back as INVALID!", false);
                    }
                    else if (result == "VERIFIED")
                    {
                        switch (this._paymentStatus)
                        {
                        case "Completed"
                            : //The payment has been completed and the funds are successfully in your account balance
                            switch (this._txnType)
                            {
                            case "web_accept":
                            case "cart":
                                //"web_accept": The payment was sent by your customer via the Web Accept feature.
                                //"cart": This payment was sent by your customer via the Shopping Cart feature
                                sPpnMessages =
                                    sPpnMessages +
                                    "PPIPN: This payment was sent by your customer via the Shopping Cart feature" +
                                    Environment.NewLine;
                                break;

                            case "send_money"
                                :     //This payment was sent by your customer from the PayPal website, imports the "Send Money" tab
                                sPpnMessages =
                                    sPpnMessages +
                                    "PPIPN: This payment was sent by your customer from the PayPal website" +
                                    Environment.NewLine;
                                break;

                            case "subscr_signup":         //This IPN is for a subscription sign-up
                                sPpnMessages =
                                    sPpnMessages + "PPIPN: This IPN is for a subscription sign-up" +
                                    Environment.NewLine;
                                break;

                            case "subscr_cancel":         //This IPN is for a subscription cancellation
                                sPpnMessages =
                                    sPpnMessages + "PPIPN: Subscription cancellation." + Environment.NewLine;
                                break;

                            case "subscr_failed":         //This IPN is for a subscription payment failure
                                sPpnMessages =
                                    sPpnMessages + "PPIPN: Subscription failed." + Environment.NewLine;
                                break;

                            case "subscr_payment":         //This IPN is for a subscription payment
                                sPpnMessages =
                                    sPpnMessages + "PPIPN: This IPN is for a subscription payment" +
                                    Environment.NewLine;
                                break;

                            case "subscr_eot":         //This IPN is for a subscription's end of term
                                sPpnMessages =
                                    sPpnMessages + "PPIPN:  Subscription end of term." + Environment.NewLine;
                                break;
                            }
                            switch (this._addressStatus)
                            {
                            case "confirmed":         //Customer provided a Confirmed Address
                                break;

                            case "unconfirmed":         //Customer provided an Unconfirmed Address
                                break;
                            }
                            switch (this._payerStatus)
                            {
                            case "verified":         //Customer has a Verified U.S. PayPal account
                                break;

                            case "unverified":         //Customer has an Unverified U.S. PayPal account
                                break;

                            case "intl_verified":         //Customer has a Verified International PayPal account
                                break;

                            case "intl_unverified":         //Customer has an Unverified International PayPal account
                                break;
                            }
                            switch (this._paymentType)
                            {
                            case "echeck":         //This payment was funded with an eCheck
                                sPpnMessages =
                                    sPpnMessages + "PPIPN: Payment was funded with an eCheck." +
                                    Environment.NewLine;
                                break;

                            case "instant"
                                :     //This payment was funded with PayPal balance, credit card, or Instant Transfer
                                sPpnMessages =
                                    sPpnMessages +
                                    "PPIPN: This payment was funded with PayPal balance, credit card, or Instant Transfer" +
                                    Environment.NewLine;
                                break;
                            }
                            this.MailUsTheOrder(sPpnMessages, true);
                            break;

                        case "Pending"
                            : //The payment is pending - see the "pending reason" variable below for more information. Watch: You will receive another instant payment notification when the payment becomes "completed", "failed", or "denied"
                            switch (this._pendingReason)
                            {
                            case "echeck"
                                :     //The payment is pending because it was made by an eCheck, which has not yet cleared
                                break;

                            case "intl"
                                :     //The payment is pending because you, the merchant, hold an international account and do not have a withdrawal mechanism. You must manually accept or deny this payment from your Account Overview
                                break;

                            case "verify"
                                :     //The payment is pending because you, the merchant, are not yet verified. You must verify your account before you can accept this payment
                                break;

                            case "address"
                                :     //The payment is pending because your customer did not include a confirmed shipping address and you, the merchant, have your Payment Receiving Preferences set such that you want to manually accept or deny each of these payments. To change your preference, go to the "Preferences" section of your "Profile"
                                break;

                            case "upgrade"
                                :     //The payment is pending because it was made via credit card and you, the merchant, must upgrade your account to Business or Premier status in order to receive the funds
                                break;

                            case "unilateral"
                                :     //The payment is pending because it was made to an email address that is not yet registered or confirmed
                                break;

                            case "other"
                                :     //The payment is pending for an "other" reason. For more information, contact customer service
                                break;
                            }
                            this.MailUsTheOrder("PPIPN: Order is waiting to be processed.");
                            break;

                        case "Failed"
                            : //The payment has failed. This will only happen if the payment was made from your customer's bank account
                            this.MailUsTheOrder(
                                "PPIPN: This only happens if the payment was made from our customer's bank account.");
                            break;

                        case "Denied"
                            : //You, the merchant, denied the payment. This will only happen if the payment was previously pending due to one of the "pending reasons"
                            this.MailUsTheOrder("PPIPN: We denied this payment.");
                            break;
                        }
                    }
                }
                //Close the response to free resources.
                myResponse.Close(); //If it is "OK"
            }
            catch (Exception exc)
            {
                Exceptions.LogException(
                    new ModuleLoadException("EventIPN, Paypal Exception: " + exc.Message + " at: " + exc.Source));
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }