During a recent content migration exercise I had need to bulk insert a lot of content that must be added in a checked-in state, i.e. the content must not have been published previously.
I was unable to find a solution using the Framework API or even the version 7 API (e.g. Ektron.CMS.API.Content.Content) so I had to delve deeper into the past!
The code below actually comes from the Workarea itself and uses the awful Visual Basic Collections (arrrrggghhh) :
using Microsoft.VisualBasic;
public partial class CheckIn : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Use a VB Collection to define the content item
Collection objCol = new Collection();
{
objCol.Add(1, "ContentType"); // 1 = HTML / SmartForm
objCol.Add("<root><MyField>Value goes here</MyField></root>", "ContentHtml"); // Content (XML)
objCol.Add("my comment", "Comment"); // Comment field
objCol.Add(0, "ContentID"); // Content ID (zero for new content)
objCol.Add(2057, "ContentLanguage"); // UK English
objCol.Add("my teaser", "ContentTeaser"); // Teaser / Summary field
objCol.Add(72, "FolderID"); // Folder where content should be added to
objCol.Add("my search text", "SearchText");
objCol.Add("", "GoLive");
objCol.Add("", "EndDate");
objCol.Add(2, "EndDateAction");
objCol.Add("my content title", "ContentTitle"); // Content title
objCol.Add(true, "AddToQlink");
objCol.Add(true, "IsSearchable");
objCol.Add("7", "MultiXmlID"); // Smartform Id
}
long intContentId = 0;
ContentAPI m_refContApi = new ContentAPI();
// The old API uses current use by default, so switch to Internal Admin
// in order to be able to add content.
// Remember the ID of the original user so we can switch back to that again afterwards.
long iOrig = m_refContApi.RequestInformationRef.CallerId;
m_refContApi.RequestInformationRef.CallerId =
(long)Ektron.Cms.Common.EkEnumeration.UserGroups.InternalAdmin;
m_refContApi.ContentLanguage = 2057;
// Adds content, then checks it in
intContentId = m_refContApi.EkContentRef.AddNewContentv2_0(objCol);
m_refContApi.EkContentRef.CheckContentInv2_0(intContentId);
// Set API back to original user ID
m_refContApi.RequestInformationRef.CallerId = iOrig;
}
}
Hopefully this code will save you having to dig through the old workarea code.