public void UpdateAnnouncement(AnnouncementInfo announcement)
        {

            using (IDataContext context = DataContext.Instance())
            {
                var repository = context.GetRepository<AnnouncementInfo>();

                var objContentItem = new ContentItem
                {
                    ContentItemId = announcement.ContentItemID,
                    Content = announcement.Description,
                    ContentTitle = announcement.Title,
                    Indexed = false,
                    ModuleID = announcement.ModuleID,
                    TabID = Null.NullInteger,
                    ContentKey = null,
                    ContentTypeId = 4
                };

                if (objContentItem.ContentItemId == Null.NullInteger)
                {
                    announcement.ContentItemID = new ContentController().AddContentItem(objContentItem);
                }
                else
                {
                    new ContentController().UpdateContentItem(objContentItem);
                }

                repository.Update(announcement);

            }

        }
Пример #2
0
        public void UpdateAnnouncement(AnnouncementInfo announcement)
        {
            using (IDataContext context = DataContext.Instance())
            {
                var repository = context.GetRepository <AnnouncementInfo>();

                var objContentItem = new ContentItem
                {
                    ContentItemId = announcement.ContentItemID,
                    Content       = announcement.Description,
                    ContentTitle  = announcement.Title,
                    Indexed       = false,
                    ModuleID      = announcement.ModuleID,
                    TabID         = Null.NullInteger,
                    ContentKey    = null,
                    ContentTypeId = 4
                };

                if (objContentItem.ContentItemId == Null.NullInteger)
                {
                    announcement.ContentItemID = new ContentController().AddContentItem(objContentItem);
                }
                else
                {
                    new ContentController().UpdateContentItem(objContentItem);
                }

                repository.Update(announcement);
            }
        }
Пример #3
0
        public void AddAnnouncementToJournal(AnnouncementInfo announcement, String journalType, ModuleInfo moduleInfo)
        {
            var objJournalType = JournalController.Instance.GetJournalType(journalType);

            var journalItem = new JournalItem
            {
                PortalId      = announcement.PortalID,
                ProfileId     = announcement.LastModifiedByUserID,
                UserId        = announcement.LastModifiedByUserID,
                ContentItemId = announcement.ContentItemID,
                Title         = announcement.Title
            };
            var data = new ItemData
            {
                Url = announcement.Permalink()
            };

            journalItem.ItemData      = data;
            journalItem.Summary       = HtmlUtils.Shorten(HtmlUtils.Clean(System.Web.HttpUtility.HtmlDecode(announcement.Description), false), 250, "...");
            journalItem.Body          = announcement.Description;
            journalItem.JournalTypeId = objJournalType.JournalTypeId;
            journalItem.SecuritySet   = "E,";

            JournalController.Instance.SaveJournalItem(journalItem, moduleInfo);
        }
Пример #4
0
        public void SendNotifications(AnnouncementInfo announcement)
        {
            IEnumerable <AnnouncementsSubscriberInfo> subscribers = SubscriberController.GetSubscribers(announcement.ModuleID);

            foreach (var subscriber in subscribers)
            {
                var receiver = UserController.GetUserById(announcement.PortalID, subscriber.UserID);
                var sender   = UserController.GetUserById(announcement.PortalID, announcement.LastModifiedByUserID);
                AddAnnouncementNotification(announcement.Title, announcement.Description, receiver, sender, announcement.PortalID);
            }
        }
Пример #5
0
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface using an XmlReader
        /// and the IXmlSerializable Interface
        /// </summary>
        /// <param name="ModuleID">The Id of the module to be imported</param>
        public void ImportModule(int ModuleID, string Content, string Version, int UserId)
        {
            if (Version.StartsWith("03.04"))
            {
                // this is the legacy import function for version 03.04.00
                //INSTANT C# NOTE: Commented this declaration since looping variables in 'foreach' loops are declared in the 'foreach' header in C#:
                //				XmlNode xmlAnnouncement = null;
                XmlNode xmlAnnouncements = Globals.GetContent(Content, "Announcements");
                foreach (XmlNode xmlAnnouncement in xmlAnnouncements)
                {
                    AnnouncementInfo objAnnouncement = ImportAnnouncement(xmlAnnouncement);
                    if (objAnnouncement != null)
                    {
                        objAnnouncement.ModuleID        = ModuleID;
                        objAnnouncement.CreatedByUserID = UserId;
                        objAnnouncement.CreatedOnDate   = DateTime.Now;

                        AddAnnouncement(objAnnouncement);
                    }
                }
            }
            else if (Version.StartsWith("03"))
            {
                // this is the legacy import function for all versions prior to version 03.04
                XmlNode xmlAnnouncements = Globals.GetContent(Content, "announcements");
                foreach (XmlNode xmlAnnouncement in xmlAnnouncements)
                {
                    var objAnnouncement = new AnnouncementInfo
                    {
                        ModuleID      = ModuleID,
                        Title         = XmlUtils.GetNodeValue(xmlAnnouncement, "title"),
                        URL           = Globals.ImportUrl(ModuleID, XmlUtils.GetNodeValue(xmlAnnouncement, "url")),
                        Description   = XmlUtils.GetNodeValue(xmlAnnouncement, "description"),
                        ViewOrder     = XmlUtils.GetNodeValueInt(xmlAnnouncement, "vieworder"),
                        CreatedOnDate = XmlUtils.GetNodeValueDate(xmlAnnouncement, "createddate", DateTime.Now)
                    };
                    objAnnouncement.PublishDate     = objAnnouncement.CreatedOnDate;
                    objAnnouncement.CreatedByUserID = UserId;
                    AddAnnouncement(objAnnouncement);
                }
            }
            else
            {
                // this is the current import function
                using (XmlReader reader = XmlReader.Create(new StringReader(Content)))
                {
                    if (reader.Read())
                    {
                        reader.ReadStartElement("Announcements");
                        if (reader.ReadState != ReadState.EndOfFile & reader.NodeType != XmlNodeType.None & reader.LocalName != "")
                        {
                            do
                            {
                                reader.ReadStartElement("Announcement");
                                var announcement = new AnnouncementInfo();

                                //Deserialize announcement
                                announcement.ReadXml(reader);

                                //initialize values of the new announcement to this module and this user
                                announcement.ItemID          = Null.NullInteger;
                                announcement.ModuleID        = ModuleID;
                                announcement.CreatedByUserID = UserId;
                                announcement.CreatedOnDate   = DateTime.Now;

                                //Save announcement
                                AddAnnouncement(announcement);
                            } while (reader.ReadToNextSibling("Announcement"));
                        }
                    }

                    reader.Close();
                }
            }
        }
Пример #6
0
 private bool CheckIfAnnouncementIsActive(AnnouncementInfo announcement)
 {
     return(announcement.PublishDate < DateTime.Now && (announcement.ExpireDate == null || announcement.ExpireDate > DateTime.Now));
 }
		public void SetPropertySource(AnnouncementInfo announcement)
		{
			this.PropertySource[ObjectLessToken] = announcement;
		}
		public AnnouncementsTokenReplace(AnnouncementInfo announcement) : base(Scope.DefaultSettings)
		{
			this.UseObjectLessExpression = true;
			this.PropertySource[ObjectLessToken] = announcement;
		}
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface using an XmlReader
        /// and the IXmlSerializable Interface
        /// </summary>
        /// <param name="ModuleID">The Id of the module to be imported</param>
        public void ImportModule(int ModuleID, string Content, string Version, int UserId)
        {

            if (Version.StartsWith("03.04"))
            {
                // this is the legacy import function for version 03.04.00
                //INSTANT C# NOTE: Commented this declaration since looping variables in 'foreach' loops are declared in the 'foreach' header in C#:
                //				XmlNode xmlAnnouncement = null;
                XmlNode xmlAnnouncements = Globals.GetContent(Content, "Announcements");
                foreach (XmlNode xmlAnnouncement in xmlAnnouncements)
                {
                    AnnouncementInfo objAnnouncement = ImportAnnouncement(xmlAnnouncement);
                    if (objAnnouncement != null)
                    {
                        objAnnouncement.ModuleID = ModuleID;
                        objAnnouncement.CreatedByUserID = UserId;
                        objAnnouncement.CreatedOnDate = DateTime.Now;

                        AddAnnouncement(objAnnouncement);

                    }
                }
            }
            else if (Version.StartsWith("03"))
            {
                // this is the legacy import function for all versions prior to version 03.04
                XmlNode xmlAnnouncements = Globals.GetContent(Content, "announcements");
                foreach (XmlNode xmlAnnouncement in xmlAnnouncements)
                {
                    var objAnnouncement = new AnnouncementInfo
                        {
                            ModuleID = ModuleID,
                            Title = XmlUtils.GetNodeValue(xmlAnnouncement, "title"),
                            URL = Globals.ImportUrl(ModuleID, XmlUtils.GetNodeValue(xmlAnnouncement, "url")),
                            Description = XmlUtils.GetNodeValue(xmlAnnouncement, "description"),
                            ViewOrder = XmlUtils.GetNodeValueInt(xmlAnnouncement, "vieworder"),
                            CreatedOnDate = XmlUtils.GetNodeValueDate(xmlAnnouncement, "createddate", DateTime.Now)
                        };
                    objAnnouncement.PublishDate = objAnnouncement.CreatedOnDate;
                    objAnnouncement.CreatedByUserID = UserId;
                    AddAnnouncement(objAnnouncement);
                }
            }
            else
            {
                // this is the current import function
                using (XmlReader reader = XmlReader.Create(new StringReader(Content)))
                {
                    if (reader.Read())
                    {
                        reader.ReadStartElement("Announcements");
                        if (reader.ReadState != ReadState.EndOfFile & reader.NodeType != XmlNodeType.None & reader.LocalName != "")
                        {
                            do
                            {
                                reader.ReadStartElement("Announcement");
                                var announcement = new AnnouncementInfo();

                                //Deserialize announcement
                                announcement.ReadXml(reader);

                                //initialize values of the new announcement to this module and this user
                                announcement.ItemID = Null.NullInteger;
                                announcement.ModuleID = ModuleID;
                                announcement.CreatedByUserID = UserId;
                                announcement.CreatedOnDate = DateTime.Now;

                                //Save announcement
                                AddAnnouncement(announcement);
                            } while (reader.ReadToNextSibling("Announcement"));
                        }
                    }

                    reader.Close();
                }
            }
        }
 public void SendNotifications(AnnouncementInfo announcement)
 {
     IEnumerable<AnnouncementsSubscriberInfo> subscribers = SubscriberController.GetSubscribers(announcement.ModuleID);
     foreach (var subscriber in subscribers)
     {
         var receiver = UserController.GetUserById(announcement.PortalID, subscriber.UserID);
         var sender = UserController.GetUserById(announcement.PortalID, announcement.LastModifiedByUserID);
         AddAnnouncementNotification(announcement.Title, announcement.Description, receiver, sender, announcement.PortalID);
     }
 }
        public void AddAnnouncementToJournal(AnnouncementInfo announcement, int tabId, String journalType)
        {

            var objJournalType = JournalController.Instance.GetJournalType(journalType);

            var journalItem = new JournalItem
            {
                PortalId = announcement.PortalID,
                ProfileId = announcement.LastModifiedByUserID,
                UserId = announcement.LastModifiedByUserID,
                ContentItemId = announcement.ContentItemID,
                Title = announcement.Title
            };
            var data = new ItemData
            {
                Url = announcement.Permalink()
            };
            journalItem.ItemData = data;
            journalItem.Summary = HtmlUtils.Shorten(HtmlUtils.Clean(System.Web.HttpUtility.HtmlDecode(announcement.Description), false), 250, "...");
            journalItem.Body = announcement.Description;
            journalItem.JournalTypeId = objJournalType.JournalTypeId;
            journalItem.SecuritySet = "E,";

            JournalController.Instance.SaveJournalItem(journalItem, tabId);

        }