Inheritance: Engage.Dnn.Publish.Portability.TransportableElement
Esempio n. 1
0
        /// <summary>
        /// Creates an Article object that you can continue to modify or save back into the database.
        /// </summary>
        /// <param name="name">Name of the Category to be created.</param>
        /// <param name="description">The description/abstract of the category to be created.</param>
        /// <param name="articleText"></param>
        /// <param name="authorUserId">The ID of the author of this category.</param>
        /// <param name="parentCategoryId"></param>
        /// <param name="moduleId">The moduleid for where this category will most likely be displayed.</param>
        /// <param name="portalId">The Portal ID of the portal this category belongs to.</param>
        /// <returns>A <see cref="Article" /> with the assigned values.</returns>
        public static Article Create(string name, string description, string articleText, int authorUserId, int parentCategoryId, int moduleId, int portalId)
        {
            var a = new Article
            {
                Name         = name,
                Description  = description.Replace("<br>", "<br />"),
                _articleText = articleText.Replace("<br>", "<br />"),
                AuthorUserId = authorUserId
            };
            //should we strip <br> tags now?

            var irel = new ItemRelationship
            {
                RelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId(),
                ParentItemId       = parentCategoryId
            };

            a.Relationships.Add(irel);
            a.StartDate = a.LastUpdated = a.CreatedDate = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            a.PortalId  = portalId;
            a.ModuleId  = moduleId;
            Category c = Category.GetCategory(parentCategoryId, portalId);

            a.DisplayTabId     = c.ChildDisplayTabId;
            a.ApprovalStatusId = ApprovalStatus.Approved.GetId();
            a.NewWindow        = false;
            a.SetDefaultItemVersionSettings();
            return(a);
        }
Esempio n. 2
0
        protected override void ResolveIds(int currentModuleId)
        {
            base.ResolveIds(currentModuleId);

            // display tab
            using (IDataReader dr = DataProvider.Instance().GetPublishTabId(this.ChildDisplayTabName, this.PortalId))
            {
                if (dr.Read())
                {
                    this.childDisplayTabId = (int)dr["TabId"];
                }
                else
                {
                    // Default to setting for module
                    string settingName = Utility.PublishDefaultDisplayPage + this.PortalId.ToString(CultureInfo.InvariantCulture);
                    string setting     = HostController.Instance.GetString(settingName);
                    if (!int.TryParse(setting, NumberStyles.Integer, CultureInfo.InvariantCulture, out this.childDisplayTabId))
                    {
                        throw new InvalidOperationException("Default Display Page setting must be set in order to import items");
                    }
                }
            }

            // For situations where the user is importing content from another system (file not generated from Publish)
            // they have no way of knowing what the top level category GUIDS are nor to include the entries in the
            // relationships section of the file. Note, the stored procedure verifies the relationship doesn't exist
            // before inserting a new row.
            var relationship = new ItemRelationship
            {
                RelationshipTypeId = RelationshipType.CategoryToTopLevelCategory.GetId(),
                ParentItemId       = TopLevelCategoryItemType.Category.GetId()
            };

            this.Relationships.Add(relationship);
            bool save = false;

            // now the Unique Id's
            // Does this ItemVersion exist in my db?
            using (IDataReader dr = DataProvider.Instance().GetItemVersion(this.ItemVersionIdentifier, this.PortalId))
            {
                if (dr.Read())
                {
                    // this item already exists
                    // update some stuff???
                }
                else
                {
                    // this version does not exist.
                    this.ItemId        = -1;
                    this.ItemVersionId = -1;
                    this.ModuleId      = currentModuleId;
                    save = true;
                }
            }

            if (save)
            {
                this.Save(this.RevisingUserId);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a Category object that you can continue to modify or save back into the database.,
        /// </summary>
        /// <param name="name">Name of the Category to be created.</param>
        /// <param name="description">The description/abstract of the category to be created.</param>
        /// <param name="authorUserId">The ID of the author of this category.</param>
        /// <param name="moduleId">The moduleid for where this category will most likely be displayed.</param>
        /// <param name="portalId">The Portal ID of the portal this category belongs to.</param>
        /// <param name="displayTabId">The Tab ID of the page this Category should be displayed on.</param>
        /// <returns>A <see cref="Category" /> with the assigned values.</returns>
        public static Category Create(string name, string description, int authorUserId, int moduleId, int portalId, int displayTabId)
        {
            var c = new Category
            {
                Name         = name,
                Description  = description,
                AuthorUserId = authorUserId
            };

            // default to the top level item type of category
            var irel = new ItemRelationship
            {
                RelationshipTypeId = RelationshipType.ItemToParentCategory.GetId(),
                ParentItemId       = TopLevelCategoryItemType.Category.GetId()
            };

            c.Relationships.Add(irel);
            c.StartDate = c.LastUpdated = c.CreatedDate = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            c.PortalId  = portalId;
            c.ModuleId  = moduleId;

            c.ApprovalStatusId = ApprovalStatus.Approved.GetId();
            c.NewWindow        = false;

            return(c);
        }
Esempio n. 4
0
        protected override void ResolveIds(int currentModuleId)
        {
            base.ResolveIds(currentModuleId);

            // display tab
            using (IDataReader dr = DataProvider.Instance().GetPublishTabId(this.ChildDisplayTabName, this.PortalId))
            {
                if (dr.Read())
                {
                    this.childDisplayTabId = (int)dr["TabId"];
                }
                else
                {
                    // Default to setting for module
                    string settingName = Utility.PublishDefaultDisplayPage + this.PortalId.ToString(CultureInfo.InvariantCulture);
                    string setting = HostController.Instance.GetString(settingName);
                    if (!int.TryParse(setting, NumberStyles.Integer, CultureInfo.InvariantCulture, out this.childDisplayTabId))
                    {
                        throw new InvalidOperationException("Default Display Page setting must be set in order to import items");
                    }
                }
            }

            // For situations where the user is importing content from another system (file not generated from Publish)
            // they have no way of knowing what the top level category GUIDS are nor to include the entries in the
            // relationships section of the file. Note, the stored procedure verifies the relationship doesn't exist
            // before inserting a new row.
            var relationship = new ItemRelationship
                {
                    RelationshipTypeId = RelationshipType.CategoryToTopLevelCategory.GetId(),
                    ParentItemId = TopLevelCategoryItemType.Category.GetId()
                };

            this.Relationships.Add(relationship);
            bool save = false;

            // now the Unique Id's
            // Does this ItemVersion exist in my db?
            using (IDataReader dr = DataProvider.Instance().GetItemVersion(this.ItemVersionIdentifier, this.PortalId))
            {
                if (dr.Read())
                {
                    // this item already exists
                    // update some stuff???
                }
                else
                {
                    // this version does not exist.
                    this.ItemId = -1;
                    this.ItemVersionId = -1;
                    this.ModuleId = currentModuleId;
                    save = true;
                }
            }

            if (save)
            {
                this.Save(this.RevisingUserId);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a Category object that you can continue to modify or save back into the database., 
        /// </summary>
        /// <param name="name">Name of the Category to be created.</param>
        /// <param name="description">The description/abstract of the category to be created.</param>
        /// <param name="authorUserId">The ID of the author of this category.</param>
        /// <param name="moduleId">The moduleid for where this category will most likely be displayed.</param>
        /// <param name="portalId">The Portal ID of the portal this category belongs to.</param>
        /// <param name="displayTabId">The Tab ID of the page this Category should be displayed on.</param>
        /// <returns>A <see cref="Category" /> with the assigned values.</returns>
        public static Category Create(string name, string description, int authorUserId, int moduleId, int portalId, int displayTabId)
        {
            var c = new Category
                {
                    Name = name,
                    Description = description,
                    AuthorUserId = authorUserId
                };

            // default to the top level item type of category
            var irel = new ItemRelationship
                {
                    RelationshipTypeId = RelationshipType.ItemToParentCategory.GetId(),
                    ParentItemId = TopLevelCategoryItemType.Category.GetId()
                };

            c.Relationships.Add(irel);
            c.StartDate = c.LastUpdated = c.CreatedDate = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            c.PortalId = portalId;
            c.ModuleId = moduleId;

            c.ApprovalStatusId = ApprovalStatus.Approved.GetId();
            c.NewWindow = false;

            return c;
        }
Esempio n. 6
0
        /// <summary>
        /// Creates an Article object that you can continue to modify or save back into the database. 
        /// </summary>
        /// <param name="name">Name of the Category to be created.</param>
        /// <param name="description">The description/abstract of the category to be created.</param>
        /// <param name="articleText"></param>
        /// <param name="authorUserId">The ID of the author of this category.</param>
        /// <param name="parentCategoryId"></param>
        /// <param name="moduleId">The moduleid for where this category will most likely be displayed.</param>
        /// <param name="portalId">The Portal ID of the portal this category belongs to.</param>
        /// <returns>A <see cref="Article" /> with the assigned values.</returns>
        public static Article Create(string name, string description, string articleText, int authorUserId, int parentCategoryId, int moduleId, int portalId)
        {
            var a = new Article
                        {
                                Name = name,
                                Description = description.Replace("<br>", "<br />"),
                                _articleText = articleText.Replace("<br>", "<br />"),
                                AuthorUserId = authorUserId
                        };
            //should we strip <br> tags now?

            var irel = new ItemRelationship
                           {
                                   RelationshipTypeId = Util.RelationshipType.ItemToParentCategory.GetId(),
                                   ParentItemId = parentCategoryId
                           };
            a.Relationships.Add(irel);
            a.StartDate = a.LastUpdated = a.CreatedDate = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            a.PortalId = portalId;
            a.ModuleId = moduleId;
            Category c = Category.GetCategory(parentCategoryId, portalId);
            a.DisplayTabId = c.ChildDisplayTabId;
            a.ApprovalStatusId = ApprovalStatus.Approved.GetId();
            a.NewWindow = false;
            a.SetDefaultItemVersionSettings();
            return a;
        }
 public void Add(ItemRelationship r)
 {
     Debug.Assert(r != null, "r cannot be null");
     this.InnerList.Add(r);
 }
 public void Add(ItemRelationship r)
 {
     Debug.Assert(r != null, "r cannot be null");
     this.InnerList.Add(r);
 }