像标题一样,我的代码确实在sitefinity文档中流动。 https://www.progress.com/documentation/sitefinity-cms/for-developers-edit-content部分通过版本ID修改项目。 它工作正常,但我尝试修改newsItem =>“ LastModified”,它会自动更新当前日期。
private void ModifyItemByLiveIDNativeAPI(Guid liveId)
{
NewsManager manager = NewsManager.GetManager();
NewsItem live = manager.GetNewsItems().Where(newsItem => newsItem.Id == liveId).FirstOrDefault();
if (live != null)
{
//Edit the item to get the master version.
NewsItem master = manager.Lifecycle.Edit(live) as NewsItem;
//Check out the master to get a temp version.
NewsItem temp = manager.Lifecycle.CheckOut(master) as NewsItem;
//Make the modifications to the temp version.
temp.Title = "New Title";
temp.LastModified = new DateTime(2011,1,1);
//Checkin the temp and get the updated master version.
//After the check in the temp version is deleted.
master = manager.Lifecycle.CheckIn(temp) as NewsItem;
manager.SaveChanges();
//Publish the news item.
var bag = new Dictionary<string,string>();
bag.Add("ContentType",typeof(NewsItem).FullName);
WorkflowManager.MessageWorkflow(master.Id,typeof(NewsItem),null,"Publish",false,bag);
}
}
标题=>更新。但是temp.LastModified =>自动更新为curentdate。 我不知道为什么,我在Google上搜索LastModified更改,但没有结果。谢谢