private void Page_Load(System.Object sender, System.EventArgs e) { try { if ((Request.Params["ItemId"] != null)) { ItemId = Int32.Parse(Request.Params["ItemId"]); } else { ItemId = Convert.ToInt32(System.DBNull.Value); } if (Page.IsPostBack == false) { cmdDelete.Attributes.Add("onClick", "javascript:return confirm('Are You Sure You Wish To Delete This Comment ?');"); if (!Null.IsNull(ItemId)) { RepositoryCommentController objRepositoryComments = new RepositoryCommentController(); RepositoryCommentInfo objComment = objRepositoryComments.GetSingleRepositoryComment(ItemId, ModuleId); if ((objComment != null)) { txtName.Text = objComment.CreatedByUser.ToString(); txtComment.Text = objComment.Comment.ToString(); } } else { Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(), true); } } else { cmdDelete.Visible = false; } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
private void cmdUpdate_Click(object sender, EventArgs e) { try { // Only Update if the Entered Data is Valid if (Page.IsValid == true) { RepositoryCommentController objRepositoryComments = new RepositoryCommentController(); RepositoryCommentInfo objComment = objRepositoryComments.GetSingleRepositoryComment(ItemId, ModuleId); DateTime dateNow = System.DateTime.Now; objComment.Comment = txtComment.Text + "<br>comment edited by admin -- " + dateNow.ToString("ddd, dd MMM yyyy hh:mm:ss tt G\\MT"); objComment.CreatedByUser = txtName.Text; objRepositoryComments.UpdateRepositoryComment(ItemId, ModuleId, objComment.CreatedByUser, objComment.Comment); // Redirect back to the portal home page Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(), true); } //Module failed to load } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
/// ----------------------------------------------------------------------------- /// <summary> /// ImportModule implements the IPortable ImportModule Interface /// </summary> /// <remarks> /// </remarks> /// <param name="ModuleID">The Id of the module to be imported</param> /// <history> /// [cnurse] 11/17/2004 documented /// </history> /// ----------------------------------------------------------------------------- public void ImportModule(int ModuleID, string Content, string Version, int UserId) { string catString = null; string[] aCategories = null; string thisCategory = null; int newCategoryID = 0; int newItemID = 0; System.Collections.Specialized.NameValueCollection categoryMapping = new System.Collections.Specialized.NameValueCollection(); System.Collections.Specialized.NameValueCollection objectMapping = new System.Collections.Specialized.NameValueCollection(); XmlNode xmlDocuments = DotNetNuke.Common.Globals.GetContent(Content, "repository"); RepositoryController RepositoryController = new RepositoryController(); RepositoryCategoryController CategoryController = new RepositoryCategoryController(); RepositoryObjectCategoriesController RepositoryCategoryController = new RepositoryObjectCategoriesController(); RepositoryCommentController RepositoryCommentController = new RepositoryCommentController(); RepositoryObjectCategoriesInfo RepositoryCategory = null; RepositoryCommentInfo RepositoryComment = null; // clear out any existing categories foreach (RepositoryCategoryInfo cat in CategoryController.GetRepositoryCategories(ModuleID, -1)) { CategoryController.DeleteRepositoryCategory(cat.ItemId); } // add the categories foreach (XmlNode xmlDocument in xmlDocuments.SelectNodes("category")) { RepositoryCategoryInfo objCategory = new RepositoryCategoryInfo(); objCategory.ItemId = 0; objCategory.ModuleId = ModuleID; objCategory.Category = xmlDocument["category"].InnerText; objCategory.Parent = int.Parse(xmlDocument["parent"].InnerText); objCategory.ViewOrder = int.Parse(xmlDocument["vieworder"].InnerText); objCategory.Count = int.Parse(xmlDocument["count"].InnerText); if (objCategory.Parent == -1) { newCategoryID = CategoryController.AddRepositoryCategory(0, objCategory.ModuleId, objCategory.Category, objCategory.Parent, objCategory.ViewOrder); } else { newCategoryID = CategoryController.AddRepositoryCategory(0, objCategory.ModuleId, objCategory.Category, int.Parse(categoryMapping[objCategory.Parent.ToString()]), objCategory.ViewOrder); } categoryMapping.Add(xmlDocument["itemid"].InnerText, newCategoryID.ToString()); } // add each item foreach (XmlNode xmlDocument in xmlDocuments.SelectNodes("item")) { RepositoryInfo objDocument = new RepositoryInfo(); objDocument.ItemId = 0; objDocument.ModuleId = ModuleID; objDocument.CreatedByUser = xmlDocument["createdbyuser"].InnerText; objDocument.CreatedDate = System.DateTime.Parse(xmlDocument["createddate"].InnerText); objDocument.UpdatedByUser = xmlDocument["updatedbyuser"].InnerText; objDocument.UpdatedDate = System.DateTime.Parse(xmlDocument["updateddate"].InnerText); objDocument.Name = xmlDocument["name"].InnerText; objDocument.Description = xmlDocument["description"].InnerText; objDocument.Author = xmlDocument["author"].InnerText; objDocument.AuthorEMail = xmlDocument["authoremail"].InnerText; objDocument.FileSize = xmlDocument["filesize"].InnerText; objDocument.Downloads = int.Parse(xmlDocument["downloads"].InnerText); objDocument.PreviewImage = xmlDocument["previewimage"].InnerText; objDocument.Image = xmlDocument["image"].InnerText; objDocument.FileName = xmlDocument["filename"].InnerText; objDocument.Clicks = int.Parse(xmlDocument["clicks"].InnerText); objDocument.RatingVotes = long.Parse(xmlDocument["ratingvotes"].InnerText); objDocument.RatingTotal = long.Parse(xmlDocument["ratingtotal"].InnerText); objDocument.RatingAverage = double.Parse(xmlDocument["ratingaverage"].InnerText); objDocument.CommentCount = int.Parse(xmlDocument["commentcount"].InnerText); objDocument.Approved = int.Parse(xmlDocument["approved"].InnerText); objDocument.ShowEMail = int.Parse(xmlDocument["showemail"].InnerText); objDocument.Summary = xmlDocument["summary"].InnerText; objDocument.SecurityRoles = xmlDocument["securityroles"].InnerText; newItemID = RepositoryController.AddRepositoryObject(objDocument.UpdatedByUser.ToString(), ModuleID, objDocument); objectMapping.Add(xmlDocument["itemid"].InnerText, newItemID.ToString()); } // add new items to new categories foreach (XmlNode xmlCatDocument in xmlDocuments.SelectNodes("item/categories/category")) { RepositoryCategory = new RepositoryObjectCategoriesInfo(); RepositoryCategory.ItemID = 0; RepositoryCategory.CategoryID = int.Parse(categoryMapping[xmlCatDocument["categoryid"].InnerText]); RepositoryCategory.ObjectID = int.Parse(objectMapping[xmlCatDocument["objectid"].InnerText]); RepositoryCategoryController.AddRepositoryObjectCategories(RepositoryCategory); } // add any comments foreach (XmlNode xmlComDocument in xmlDocuments.SelectNodes("item/comments/comment")) { RepositoryComment = new RepositoryCommentInfo(); RepositoryComment.ItemId = 0; RepositoryComment.ObjectId = int.Parse(objectMapping[xmlComDocument["objectid"].InnerText]); RepositoryComment.CreatedByUser = xmlComDocument["createdbyuser"].InnerText; RepositoryComment.CreatedDate = System.DateTime.Parse(xmlComDocument["createddate"].InnerText); RepositoryComment.Comment = xmlComDocument["comment"].InnerText; RepositoryCommentController.AddRepositoryComment(0, ModuleID, RepositoryComment.CreatedByUser, RepositoryComment.Comment); } }