示例#1
0
文件: DNNUtils.cs 项目: z3le/DNN.Wiki
        /// <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>
        /// 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);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Exports the module.
        /// </summary>
        /// <param name="moduleID">The module unique identifier.</param>
        /// <returns>XML String of the module data</returns>
        public string ExportModule(int moduleID)
        {
            using (UnitOfWork uow = new UnitOfWork())
            {
                TopicBO topicBo = new TopicBO(uow);
                var topics = topicBo.GetAllByModuleID(moduleID);

                ModuleController mc = new ModuleController();
                Hashtable settings = mc.GetModuleSettings(moduleID);

                StringWriter strXML = new StringWriter();
                XmlWriter writer = new XmlTextWriter(strXML);
                writer.WriteStartElement("Wiki");

                writer.WriteStartElement("Settings");
                foreach (DictionaryEntry item in settings)
                {
                    writer.WriteStartElement("Setting");
                    writer.WriteAttributeString("Name", Convert.ToString(item.Key));
                    writer.WriteAttributeString("Value", Convert.ToString(item.Value));
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();

                writer.WriteStartElement("Topics");
                foreach (var topic in topics)
                {
                    writer.WriteStartElement("Topic");
                    writer.WriteAttributeString("AllowDiscussions", topic.AllowDiscussions.ToString());
                    writer.WriteAttributeString("AllowRatings", topic.AllowRatings.ToString());
                    writer.WriteAttributeString("Content", topic.Content);
                    writer.WriteAttributeString("Description", topic.Description);
                    writer.WriteAttributeString("Keywords", topic.Keywords);
                    writer.WriteAttributeString("Name", topic.Name);
                    writer.WriteAttributeString("Title", topic.Title);
                    writer.WriteAttributeString("UpdateDate", topic.UpdateDate.ToString("g"));
                    writer.WriteAttributeString("UpdatedBy", topic.UpdatedBy);
                    writer.WriteAttributeString("UpdatedByUserID", topic.UpdatedByUserID.ToString("g"));
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();

                writer.WriteEndElement();
                writer.Close();

                return strXML.ToString();
            }
        }
示例#4
0
        /// <summary>
        /// Exports the module.
        /// </summary>
        /// <param name="moduleID">The module unique identifier.</param>
        /// <returns>XML String of the module data</returns>
        public string ExportModule(int moduleID)
        {
            using (UnitOfWork uow = new UnitOfWork())
            {
                TopicBO topicBo = new TopicBO(uow);
                var     topics  = topicBo.GetAllByModuleID(moduleID);

                ModuleController mc       = new ModuleController();
                Hashtable        settings = mc.GetModuleSettings(moduleID);

                StringWriter strXML = new StringWriter();
                XmlWriter    writer = new XmlTextWriter(strXML);
                writer.WriteStartElement("Wiki");

                writer.WriteStartElement("Settings");
                foreach (DictionaryEntry item in settings)
                {
                    writer.WriteStartElement("Setting");
                    writer.WriteAttributeString("Name", Convert.ToString(item.Key));
                    writer.WriteAttributeString("Value", Convert.ToString(item.Value));
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();

                writer.WriteStartElement("Topics");
                foreach (var topic in topics)
                {
                    writer.WriteStartElement("Topic");
                    writer.WriteAttributeString("AllowDiscussions", topic.AllowDiscussions.ToString());
                    writer.WriteAttributeString("AllowRatings", topic.AllowRatings.ToString());
                    writer.WriteAttributeString("Content", topic.Content);
                    writer.WriteAttributeString("Description", topic.Description);
                    writer.WriteAttributeString("Keywords", topic.Keywords);
                    writer.WriteAttributeString("Name", topic.Name);
                    writer.WriteAttributeString("Title", topic.Title);
                    writer.WriteAttributeString("UpdateDate", topic.UpdateDate.ToString("g"));
                    writer.WriteAttributeString("UpdatedBy", topic.UpdatedBy);
                    writer.WriteAttributeString("UpdatedByUserID", topic.UpdatedByUserID.ToString("g"));
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();

                writer.WriteEndElement();
                writer.Close();

                return(strXML.ToString());
            }
        }
示例#5
0
        /// <summary>
        /// Handles the Unload event of the Page control and gets rid of initiated objects on the
        /// page startup.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Unload(object sender, EventArgs e)
        {
            if (this.mUnitOfWorkObject != null)
            {
                this.mUnitOfWorkObject.Dispose();
                this.mUnitOfWorkObject = null;
            }

            if (this.mTopicBoObject != null)
            {
                this.mTopicBoObject = null;
            }

            if (this.mTopicHistoryBoObject != null)
            {
                this.mTopicHistoryBoObject = null;
            }
        }
示例#6
0
        /// <summary>
        /// Handles the Click event of the SubmitButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event
        /// data.</param>
        private void SubmitButton_Click(object sender, System.EventArgs e)
        {
            using (UnitOfWork uOw = new UnitOfWork())
            {
                var commentBo = new CommentBO(uOw);

                string commentText = this.txtComment.Text;
                DotNetNuke.Security.PortalSecurity objSec = new DotNetNuke.Security.PortalSecurity();

                if (commentText.Length > this.CommentsMaxLength)
                {
                    commentText = commentText.Substring(0, this.CommentsMaxLength);
                }
                ////4.8.3 has better control for NoMarkup
                var comment = new Comment
                {
                    ParentId    = this.ParentId,
                    Name        = objSec.InputFilter(this.txtName.Text, DotNetNuke.Security.PortalSecurity.FilterFlag.NoMarkup),
                    Email       = objSec.InputFilter(this.txtEmail.Text, DotNetNuke.Security.PortalSecurity.FilterFlag.NoMarkup),
                    CommentText = objSec.InputFilter(commentText, PortalSecurity.FilterFlag.NoMarkup),
                    Ip          = objSec.InputFilter(this.Context.Request.ServerVariables["REMOTE_ADDR"], DotNetNuke.Security.PortalSecurity.FilterFlag.NoMarkup),
                    EmailNotify = this.chkSubscribeToNotifications.Checked,
                    Datetime    = DateTime.Now
                };
                comment = commentBo.Add(comment);

                ////send the notification
                var topic = new TopicBO(uOw).Get(this.ParentId);
                DNNUtils.SendNotifications(uOw, topic, comment.Name, comment.Email, comment.CommentText, comment.Ip);
                this.mSuccessValue = comment.CommentId > 0;

                if (this.mSuccessValue)
                {
                    this.txtName.Text    = string.Empty;
                    this.txtEmail.Text   = string.Empty;
                    this.txtComment.Text = string.Empty;
                    this.Context.Cache.Remove("WikiComments" + this.ParentId.ToString());
                    if (this.PostSubmitted != null)
                    {
                        this.PostSubmitted(this);
                    }
                }
            }
        }
示例#7
0
        /// <summary>
        /// Activates the items.
        /// </summary>
        /// <param name="currentUnitOfWork">The UnitOfWork.</param>
        private void ActivateItems(UnitOfWork currentUnitOfWork)
        {
            if (this.ActivateComments.Checked | this.ActivateRatings.Checked)
            {
                TopicBO topicBo = new TopicBO(currentUnitOfWork);

                var alltopics = topicBo.GetAllByModuleID(this.ModuleId);

                foreach (var topic in alltopics)
                {
                    if (topic.AllowDiscussions == false & this.ActivateComments.Checked)
                    {
                        topic.AllowDiscussions = true;
                    }

                    if (topic.AllowRatings == false & this.ActivateRatings.Checked)
                    {
                        topic.AllowRatings = true;
                    }

                    topicBo.Update(topic);
                }
            }
        }
示例#8
0
        /// <summary>
        /// Handles the Unload event of the Page control and gets rid of initiated objects on the
        /// page startup.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_Unload(object sender, EventArgs e)
        {
            if (this.mUnitOfWorkObject != null)
            {
                this.mUnitOfWorkObject.Dispose();
                this.mUnitOfWorkObject = null;
            }

            if (this.mTopicBoObject != null)
            {
                this.mTopicBoObject = null;
            }

            if (this.mTopicHistoryBoObject != null)
            {
                this.mTopicHistoryBoObject = null;
            }
        }
示例#9
0
        /// <summary>
        /// Handles the Click event of the SubmitButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event
        /// data.</param>
        private void SubmitButton_Click(object sender, System.EventArgs e)
        {
            using (UnitOfWork uOw = new UnitOfWork())
            {
                var commentBo = new CommentBO(uOw);

                string commentText = this.txtComment.Text;
                DotNetNuke.Security.PortalSecurity objSec = new DotNetNuke.Security.PortalSecurity();

                if (commentText.Length > this.CommentsMaxLength)
                {
                    commentText = commentText.Substring(0, this.CommentsMaxLength);
                }
                ////4.8.3 has better control for NoMarkup
                var comment = new Comment
                {
                    ParentId = this.ParentId,
                    Name = objSec.InputFilter(this.txtName.Text, DotNetNuke.Security.PortalSecurity.FilterFlag.NoMarkup),
                    Email = objSec.InputFilter(this.txtEmail.Text, DotNetNuke.Security.PortalSecurity.FilterFlag.NoMarkup),
                    CommentText = objSec.InputFilter(commentText, PortalSecurity.FilterFlag.NoMarkup),
                    Ip = objSec.InputFilter(this.Context.Request.ServerVariables["REMOTE_ADDR"], DotNetNuke.Security.PortalSecurity.FilterFlag.NoMarkup),
                    EmailNotify = this.chkSubscribeToNotifications.Checked,
                    Datetime = DateTime.Now
                };
                comment = commentBo.Add(comment);

                ////send the notification
                var topic = new TopicBO(uOw).Get(this.ParentId);
                DNNUtils.SendNotifications(uOw, topic, comment.Name, comment.Email, comment.CommentText, comment.Ip);
                this.mSuccessValue = comment.CommentId > 0;

                if (this.mSuccessValue)
                {
                    this.txtName.Text = string.Empty;
                    this.txtEmail.Text = string.Empty;
                    this.txtComment.Text = string.Empty;
                    this.Context.Cache.Remove("WikiComments" + this.ParentId.ToString());
                    if (this.PostSubmitted != null)
                    {
                        this.PostSubmitted(this);
                    }
                }
            }
        }
示例#10
0
        /// <summary>
        /// Activates the items.
        /// </summary>
        /// <param name="currentUnitOfWork">The UnitOfWork.</param>
        private void ActivateItems(UnitOfWork currentUnitOfWork)
        {
            if (this.ActivateComments.Checked | this.ActivateRatings.Checked)
            {
                TopicBO topicBo = new TopicBO(currentUnitOfWork);

                var alltopics = topicBo.GetAllByModuleID(this.ModuleId);

                foreach (var topic in alltopics)
                {
                    if (topic.AllowDiscussions == false & this.ActivateComments.Checked)
                    {
                        topic.AllowDiscussions = true;
                    }

                    if (topic.AllowRatings == false & this.ActivateRatings.Checked)
                    {
                        topic.AllowRatings = true;
                    }

                    topicBo.Update(topic);
                }
            }
        }
示例#11
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);
                }
            }
        }
示例#12
0
        /// <summary>
        /// Gets the search items.
        /// </summary>
        /// <param name="modInfo">The module information.</param>
        /// <returns>Topics that meet the search criteria.</returns>
        public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
        {
            using (UnitOfWork uOw = new UnitOfWork())
            {
                TopicBO topicBo = new TopicBO(uOw);

                SearchItemInfoCollection searchItemCollection = new SearchItemInfoCollection();
                var topics = topicBo.GetAllByModuleID(modInfo.ModuleID);
                UserController uc = new UserController();

                foreach (var topic in topics)
                {
                    SearchItemInfo searchItem = new SearchItemInfo();

                    string strContent = null;
                    string strDescription = null;
                    string strTitle = null;
                    if (!string.IsNullOrWhiteSpace(topic.Title))
                    {
                        strTitle = topic.Title;
                    }
                    else
                    {
                        strTitle = topic.Name;
                    }

                    if (topic.Cache != null)
                    {
                        strContent = topic.Cache;
                        strContent += " " + topic.Keywords;
                        strContent += " " + topic.Description;

                        strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Cache), false), 100,
                            Localization.GetString("Dots", this.mSharedResourceFile));
                    }
                    else
                    {
                        strContent = topic.Content;
                        strContent += " " + topic.Keywords;
                        strContent += " " + topic.Description;

                        strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Content), false), 100,
                            Localization.GetString("Dots", this.mSharedResourceFile));
                    }

                    int userID = 0;

                    userID = Null.NullInteger;
                    if (topic.UpdatedByUserID != -9999)
                    {
                        userID = topic.UpdatedByUserID;
                    }

                    searchItem = new SearchItemInfo(strTitle, strDescription, userID, topic.UpdateDate, modInfo.ModuleID, topic.Name, strContent, "topic=" + WikiMarkup.EncodeTitle(topic.Name));

                    //// New SearchItemInfo(ModInfo.ModuleTitle & "-" & strTitle, strDescription,
                    //// userID, topic.UpdateDate, ModInfo.ModuleID, topic.Name, strContent, _
                    //// "topic=" & WikiMarkup.EncodeTitle(topic.Name))

                    searchItemCollection.Add(searchItem);
                }

                return searchItemCollection;
            }
        }
示例#13
0
        /// <summary>
        /// Gets the search items.
        /// </summary>
        /// <param name="modInfo">The module information.</param>
        /// <returns>Topics that meet the search criteria.</returns>
        public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
        {
            using (UnitOfWork uOw = new UnitOfWork())
            {
                TopicBO topicBo = new TopicBO(uOw);

                SearchItemInfoCollection searchItemCollection = new SearchItemInfoCollection();
                var            topics = topicBo.GetAllByModuleID(modInfo.ModuleID);
                UserController uc     = new UserController();

                foreach (var topic in topics)
                {
                    SearchItemInfo searchItem = new SearchItemInfo();

                    string strContent     = null;
                    string strDescription = null;
                    string strTitle       = null;
                    if (!string.IsNullOrWhiteSpace(topic.Title))
                    {
                        strTitle = topic.Title;
                    }
                    else
                    {
                        strTitle = topic.Name;
                    }

                    if (topic.Cache != null)
                    {
                        strContent  = topic.Cache;
                        strContent += " " + topic.Keywords;
                        strContent += " " + topic.Description;

                        strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Cache), false), 100,
                                                           Localization.GetString("Dots", this.mSharedResourceFile));
                    }
                    else
                    {
                        strContent  = topic.Content;
                        strContent += " " + topic.Keywords;
                        strContent += " " + topic.Description;

                        strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Content), false), 100,
                                                           Localization.GetString("Dots", this.mSharedResourceFile));
                    }

                    int userID = 0;

                    userID = Null.NullInteger;
                    if (topic.UpdatedByUserID != -9999)
                    {
                        userID = topic.UpdatedByUserID;
                    }

                    searchItem = new SearchItemInfo(strTitle, strDescription, userID, topic.UpdateDate, modInfo.ModuleID, topic.Name, strContent, "topic=" + WikiMarkup.EncodeTitle(topic.Name));

                    //// New SearchItemInfo(ModInfo.ModuleTitle & "-" & strTitle, strDescription,
                    //// userID, topic.UpdateDate, ModInfo.ModuleID, topic.Name, strContent, _
                    //// "topic=" & WikiMarkup.EncodeTitle(topic.Name))

                    searchItemCollection.Add(searchItem);
                }

                return(searchItemCollection);
            }
        }
示例#14
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);
                }
            }
        }