Пример #1
0
        /// <summary>
        /// Sends the notifications.
        /// </summary>
        /// <param name="uow">The Unit Of Work.</param>
        /// <param name="topic">The topic.</param>
        /// <param name="name">The name.</param>
        /// <param name="email">The email.</param>
        /// <param name="comment">The comment.</param>
        /// <param name="ipaddress">The IP Address.</param>
        public static void SendNotifications(
            UnitOfWork uow,
            Topic topic,
            string name,
            string email,
            string comment,
            string ipaddress)
        {
            if (topic != null)
            {
                List<string> lstEmailsAddresses = new TopicBO(uow).GetNotificationEmails(topic);

                if (lstEmailsAddresses.Count > 0)
                {
                    DotNetNuke.Entities.Portals.PortalSettings objPortalSettings = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings();
                    string strResourceFile = Globals.ApplicationPath + "/DesktopModules/Wiki/Views/" + Localization.LocalResourceDirectory + "/" + Localization.LocalSharedResourceFile;
                    string strSubject = Localization.GetString("NotificationSubject", strResourceFile);
                    string strBody = Localization.GetString("NotificationBody", strResourceFile);

                    string redirectUrl = DotNetNuke.Common.Globals.NavigateURL(objPortalSettings.ActiveTab.TabID, objPortalSettings, string.Empty, "topic=" + WikiMarkup.EncodeTitle(topic.Name));
                    strBody = strBody.Replace("[URL]", redirectUrl);

                    strBody = strBody.Replace("[NAME]", name);
                    strBody = strBody.Replace("[EMAIL]", email);
                    strBody = strBody.Replace("[COMMENT]", comment);
                    strBody = strBody.Replace("[IP]", string.Empty);

                    System.Text.StringBuilder usersToEmailSB = new System.Text.StringBuilder();
                    foreach (string userToEmail in lstEmailsAddresses)
                    {
                        usersToEmailSB.Append(userToEmail);
                        usersToEmailSB.Append(";");
                    }

                    // remove the last ;
                    usersToEmailSB.Remove(usersToEmailSB.Length - 1, 1);

                    // Services.Mail.Mail.SendMail(objPortalSettings.Email, objPortalSettings.Email,
                    //// sbUsersToEmail.ToString, strSubject, strBody, "", "", "", "", "", "")

                    Mail.SendMail(
                        objPortalSettings.Email,
                        usersToEmailSB.ToString(),
                        string.Empty,
                        string.Empty,
                        MailPriority.Normal,
                        strSubject,
                        MailFormat.Html,
                        Encoding.UTF8,
                        strBody,
                        string.Empty,
                        Host.SMTPServer,
                        Host.SMTPAuthentication,
                        Host.SMTPUsername,
                        Host.SMTPPassword,
                        Host.EnableSMTPSSL);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Saves the topic.
        /// </summary>
        /// <param name="content">The content.</param>
        /// <param name="allowDiscuss">if set to <c>true</c> [allow discuss].</param>
        /// <param name="allowRating">if set to <c>true</c> [allow rating].</param>
        /// <param name="title">The title.</param>
        /// <param name="description">The description.</param>
        /// <param name="keywords">The keywords.</param>
        /// <param name="out_crudOperation">The crud operation performed, only update or
        /// insert</param>
        protected void SaveTopic(
            string content,
            bool allowDiscuss,
            bool allowRating,
            string title,
            string description,
            string keywords,
            out SharedEnum.CrudOperation out_crudOperation)
        {
            TopicHistory topicHistory = new TopicHistory();
            topicHistory.TabID = this.TabId;
            topicHistory.PortalSettings = this.PortalSettings;
            if (this.mTopicObject.TopicID != 0)
            {
                if (!content.Equals(this.mTopicObject.Content) | !title.Equals(this.mTopicObject.Title) | !description.Equals(this.mTopicObject.Description) | !keywords.Equals(this.mTopicObject.Keywords))
                {
                    topicHistory.Name = this.mTopicObject.Name;
                    topicHistory.TopicId = this.mTopicObject.TopicID;
                    topicHistory.Content = this.mTopicObject.Content;
                    topicHistory.UpdatedBy = this.mTopicObject.UpdatedBy;
                    topicHistory.UpdateDate = DateTime.Now;
                    topicHistory.UpdatedByUserID = this.mTopicObject.UpdatedByUserID;
                    topicHistory.Title = this.mTopicObject.Title;
                    topicHistory.Description = this.mTopicObject.Description;
                    topicHistory.Keywords = this.mTopicObject.Keywords;

                    this.mTopicObject.UpdateDate = DateTime.Now;
                    if (UserInfo.UserID == -1)
                    {
                        this.mTopicObject.UpdatedBy = Localization.GetString("Anonymous", this.RouterResourceFile);
                    }
                    else
                    {
                        this.mTopicObject.UpdatedBy = UserInfo.Username;
                    }

                    this.mTopicObject.UpdatedByUserID = this.UserId;
                    this.mTopicObject.Content = content;
                    this.mTopicObject.Title = title;
                    this.mTopicObject.Description = description;
                    this.mTopicObject.Keywords = keywords;

                    this.TopicHistoryBo.Add(topicHistory);
                }

                this.mTopicObject.Name = this.mPageTopicValue;
                this.mTopicObject.Title = title;
                this.mTopicObject.Description = description;
                this.mTopicObject.Keywords = keywords;
                this.mTopicObject.AllowDiscussions = allowDiscuss;
                this.mTopicObject.AllowRatings = allowRating;
                this.mTopicObject.Content = content;

                this.TopicBo.Update(this.mTopicObject);
                out_crudOperation = SharedEnum.CrudOperation.Update;
            }
            else
            {
                this.mTopicObject = new Topic();
                this.mTopicObject.TabID = this.TabId;
                this.mTopicObject.PortalSettings = this.PortalSettings;
                this.mTopicObject.Content = content;
                this.mTopicObject.Name = this.mPageTopicValue;
                this.mTopicObject.ModuleId = this.ModuleId;
                if (UserInfo.UserID == -1)
                {
                    this.mTopicObject.UpdatedBy = Localization.GetString("Anonymous", this.RouterResourceFile);
                }
                else
                {
                    this.mTopicObject.UpdatedBy = UserInfo.Username;
                }

                this.mTopicObject.UpdatedByUserID = this.UserId;
                this.mTopicObject.UpdateDate = DateTime.Now;
                this.mTopicObject.AllowDiscussions = allowDiscuss;
                this.mTopicObject.AllowRatings = allowRating;
                this.mTopicObject.Title = title;
                this.mTopicObject.Description = description;
                this.mTopicObject.Keywords = keywords;

                this.mTopicObject = this.TopicBo.Add(this.mTopicObject);

                this.mTopicIdValue = this.mTopicObject.TopicID;
                out_crudOperation = SharedEnum.CrudOperation.Insert;
            }
        }
Пример #3
0
        /// <summary>
        /// Loads the topic.
        /// </summary>
        protected void LoadTopic()
        {
            this.mTopicObject = this.TopicBo.GetByNameForModule(this.ModuleId, this.mPageTopicValue);
            if (this.mTopicObject == null)
            {
                this.mTopicObject = new Topic();
                this.mTopicObject.TopicID = 0;
            }

            this.mTopicObject.TabID = this.TabId;
            this.mTopicObject.PortalSettings = this.PortalSettings;
            this.mTopicIdValue = this.mTopicObject.TopicID;
        }
Пример #4
0
        /// <summary>
        /// Creates the table.
        /// </summary>
        /// <param name="topicCollection">The topic collection.</param>
        /// <returns>html for the topics</returns>
        protected string CreateTable(List<Topic> topicCollection)
        {
            System.Text.StringBuilder tableHTML = new System.Text.StringBuilder("<table><tr><th>");
            tableHTML.Append(Localization.GetString("BaseCreateTableTopic", this.RouterResourceFile));
            tableHTML.Append("</th><th>");
            tableHTML.Append(Localization.GetString("BaseCreateTableModBy", this.RouterResourceFile));
            tableHTML.Append("</th><th>");
            tableHTML.Append(Localization.GetString("BaseCreateTableModDate", this.RouterResourceFile));
            tableHTML.Append("</th></tr>");
            //// Dim TopicTable As String
            Topic localTopic = new Topic();
            int i = 0;
            if (topicCollection != null && topicCollection.Any())
            {
                for (i = 0; i <= topicCollection.Count - 1; i++)
                {
                    localTopic = (Topic)topicCollection[i];
                    localTopic.TabID = this.TabId;
                    localTopic.PortalSettings = this.PortalSettings;

                    string nameToUse = string.Empty;
                    if (!string.IsNullOrWhiteSpace(localTopic.Title))
                    {
                        nameToUse = localTopic.Title.Replace(WikiModuleBase.WikiHomeName, "Home");
                    }
                    else
                    {
                        nameToUse = localTopic.Name.Replace(WikiHomeName, "Home");
                    }

                    tableHTML.Append("<tr>");
                    tableHTML.Append("<td><a class=\"CommandButton\" href=\"");
                    tableHTML.Append(DotNetNuke.Common.Globals.NavigateURL(this.TabId, this.PortalSettings, string.Empty, "topic=" + WikiMarkup.EncodeTitle(localTopic.Name)));
                    tableHTML.Append("\">");
                    tableHTML.Append(nameToUse);
                    tableHTML.Append("</a></td>");
                    tableHTML.Append("<td class=\"Normal\">");
                    tableHTML.Append(localTopic.UpdatedByUsername);
                    tableHTML.Append("</td>");
                    tableHTML.Append("<td class=\"Normal\">");
                    tableHTML.Append(localTopic.UpdateDate.ToString(CultureInfo.CurrentCulture));
                    tableHTML.Append("</td>");
                    tableHTML.Append("</tr>");
                }
            }
            else
            {
                tableHTML.Append("<tr><td colspan=3 class=\"Normal\">");
                tableHTML.Append(Localization.GetString("BaseCreateTableNoResults", this.RouterResourceFile));
                tableHTML.Append("</td></tr>");
            }

            tableHTML.Append("</table>");
            return tableHTML.ToString();
        }
Пример #5
0
        /// <summary>
        /// Imports the module.
        /// </summary>
        /// <param name="moduleID">The module unique identifier.</param>
        /// <param name="content">The content.</param>
        /// <param name="version">The version.</param>
        /// <param name="userID">The user unique identifier.</param>
        public void ImportModule(int moduleID, string content, string version, int userID)
        {
            using (UnitOfWork uow = new UnitOfWork())
            {
                XmlNode node = null;
                XmlNode nodes = Globals.GetContent(content, "Wiki");
                ModuleController objModules = new ModuleController();
                foreach (XmlNode node_loopVariable in nodes.SelectSingleNode("Settings"))
                {
                    node = node_loopVariable;
                    objModules.UpdateModuleSetting(moduleID, node.Attributes["Name"].Value, node.Attributes["Value"].Value);
                }

                TopicBO topicBo = new TopicBO(uow);

                // clean up
                var topics = topicBo.GetAllByModuleID(moduleID);
                foreach (var topic in topics)
                {
                    // TODO - On the old version topics where deleted via the SPROC
                    // [Wiki_TopicDelete], it should be dropped in this new version
                    topicBo.Delete(new Topic { TopicID = topic.TopicID });
                }

                try
                {
                    foreach (XmlNode node_loopVariable in nodes.SelectNodes("Topics/Topic"))
                    {
                        node = node_loopVariable;
                        var topic = new Topic();
                        topic.PortalSettings = PortalController.GetCurrentPortalSettings();
                        topic.AllowDiscussions = bool.Parse(node.Attributes["AllowDiscussions"].Value);
                        topic.AllowRatings = bool.Parse(node.Attributes["AllowRatings"].Value);
                        topic.Content = node.Attributes["Content"].Value;
                        topic.Description = node.Attributes["Description"].Value;
                        topic.Keywords = node.Attributes["Keywords"].Value;
                        topic.ModuleId = moduleID;
                        //// Here we need to define the TabID otherwise the import won't work until
                        //// the content is saved again.
                        ModuleController mc = new ModuleController();
                        ModuleInfo mi = mc.GetModule(moduleID, -1);
                        topic.TabID = mi.TabID;

                        topic.Name = node.Attributes["Name"].Value;
                        topic.RatingOneCount = 0;
                        topic.RatingTwoCount = 0;
                        topic.RatingThreeCount = 0;
                        topic.RatingFourCount = 0;
                        topic.RatingFiveCount = 0;
                        topic.RatingSixCount = 0;
                        topic.RatingSevenCount = 0;
                        topic.RatingEightCount = 0;
                        topic.RatingNineCount = 0;
                        topic.RatingTenCount = 0;
                        topic.Title = node.Attributes["Title"].Value;
                        topic.UpdateDate = DateTime.Parse(node.Attributes["UpdateDate"].Value);
                        topic.UpdatedBy = node.Attributes["UpdatedBy"].Value;
                        topic.UpdatedByUserID = int.Parse(node.Attributes["UpdatedByUserID"].Value);
                        topicBo.Add(topic);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                }
            }
        }