public bool DeleteArchive(int archiveId) { var archive = GetArchiveById(archiveId); if (archive == null) { return(false); } if (FlagAnd(archive.Get().Flag, BuiltInArchiveFlags.IsSystem)) { throw new NotSupportedException("系统文档,不允许删除,请先取消系统设置后再进行删除!"); } var result = _archiveRep.DeleteArchive(SiteId, archive.GetAggregateRootId()); if (result) { //删除模板绑定 _tempRep.RemoveBind(archive.GetAggregateRootId(), TemplateBindType.ArchiveTemplate); } // //TODO:删除评论及点评 // //删除评论 // new CommentDAL().DeleteArchiveComments(archiveID); //删除点评 //new CommentBLL().DeleteArchiveReviews(archiveID); archive = null; return(result); }
public IDictionary <int, string> ClonePubArchive(int sourceSiteId, int targetSiteId, int toCid, int[] archiveIdArray, bool includeExtend, bool includeTempateBind, bool includeRelatedLink) { var totalFailed = 0; var totalSuccess = 0; IDictionary <int, string> errDict = new Dictionary <int, string>(); bool isFailed; bool shouldReSave; var srcContent = _contentRep.GetContent(sourceSiteId); var tarContent = _contentRep.GetContent(targetSiteId); foreach (var archiveId in archiveIdArray) { var srcArchive = srcContent.GetArchiveById(archiveId); var tarArchive = CopyArchive(targetSiteId, toCid, srcArchive); isFailed = false; shouldReSave = false; if (includeTempateBind && srcArchive.Template != null && srcArchive.Template.BindType == TemplateBindType.ArchiveTemplate && !string.IsNullOrEmpty(srcArchive.Template.TplPath)) { tarArchive.SetTemplatePath(srcArchive.Template.TplPath); shouldReSave = true; } //克隆扩展 if (includeExtend) { CloneArchiveExtendValue(srcArchive, tarArchive, errDict, ref isFailed, ref shouldReSave); } //包含关联链接 if (includeRelatedLink) { CloneArchiveRelatedLink(srcArchive, tarArchive); } if (isFailed) { _archiveRep.DeleteArchive(targetSiteId, tarArchive.GetAggregateRootId()); totalFailed += 1; } else if (shouldReSave) { tarArchive.Save(); totalSuccess += 1; } } return(errDict); }