public void Revert(string ID, bool RetainLatest) { var page = Get(ID); if (page.IsPublishedPage) { if (RetainLatest) {//保留当前编辑版本 Update(new PageEntity { IsPublish = false }, new DataFilter(new List <string> { "IsPublish" }).Where("ID", OperatorType.Equal, page.ReferencePageID)); page.PublishDate = DateTime.Now; Add(page); } else { Update(new PageEntity { PublishDate = null }, new DataFilter(new List <string> { "PublishDate" }).Where("ID", OperatorType.Equal, page.ReferencePageID)); Delete(page.ReferencePageID); //删除当前的编辑版本,加入旧的版本做为编辑版本,再发布 page.ID = page.ReferencePageID; page.ReferencePageID = null; page.IsPublish = false; page.IsPublishedPage = false; if (page.ExtendFields != null) { page.ExtendFields.Each(m => m.ActionType = ActionType.Create); } base.Add(page); } var widgets = WidgetService.GetByPageId(ID); widgets.Each(m => { var widgetService = m.CreateServiceInstance(); m = widgetService.GetWidget(m); if (m.ExtendFields != null) { m.ExtendFields.Each(f => f.ActionType = ActionType.Create); } m.PageID = page.ID; widgetService.Publish(m); }); if (!RetainLatest) { Publish(page); } else { StaticPageCache.Delete(page.ReferencePageID); } } }
public void Publish(PageEntity item) { Update(new PageEntity { IsPublish = true, PublishDate = DateTime.Now }, new DataFilter(new List <string> { "IsPublish", "PublishDate" }) .Where("ID", OperatorType.Equal, item.ID)); //Delete(m => m.ReferencePageID == item.ID && m.IsPublishedPage == true); if (StaticPageCache != null) { StaticPageCache.Delete(item.ID); } item.ReferencePageID = item.ID; item.IsPublishedPage = true; item.PublishDate = DateTime.Now; if (item.ExtendFields != null) { item.ExtendFields.Each(m => m.ActionType = ActionType.Create); } var widgets = WidgetService.GetByPageId(item.ID); Add(item); widgets.Each(m => { var widgetService = m.CreateServiceInstance(); m = widgetService.GetWidget(m); if (m.ExtendFields != null) { m.ExtendFields.Each(f => f.ActionType = ActionType.Create); } m.PageID = item.ID; widgetService.Publish(m); }); }