Engage.Dnn.Publish.Category.ResolveIds C# (CSharp) Method

ResolveIds() protected method

protected ResolveIds ( int currentModuleId ) : void
currentModuleId int
return void
        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);
            }
        }