public static void UpdateRepositoryObjectCategories(RepositoryObjectCategoriesInfo RepositoryObjectCategoriesInfo)
 {
     DataProvider.Instance().UpdateRepositoryObjectCategories(RepositoryObjectCategoriesInfo.ItemID, RepositoryObjectCategoriesInfo.ObjectID, RepositoryObjectCategoriesInfo.CategoryID);
 }
Exemplo n.º 2
0
        /// -----------------------------------------------------------------------------
        /// <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);
            }
        }
 public int AddRepositoryObjectCategories(RepositoryObjectCategoriesInfo RepositoryObjectCategoriesInfo)
 {
     return(Convert.ToInt32(DataProvider.Instance().AddRepositoryObjectCategories(RepositoryObjectCategoriesInfo.ObjectID, RepositoryObjectCategoriesInfo.CategoryID)));
 }