private void AttachmentSetVirtualDelete(long idAttachment, Boolean delete) { litePerson person = Manager.GetLitePerson(UC.CurrentUserID); EventItemFile attachment = Manager.Get <EventItemFile>(idAttachment); if (person != null && attachment != null) { try { Manager.BeginTransaction(); attachment.UpdateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress); attachment.Deleted = delete ? BaseStatusDeleted.Manual : BaseStatusDeleted.None; CommunityEventItem item = EventItemGet(attachment.IdItemOwner); if (item != null) { item.ModifiedBy = attachment.ModifiedBy; item.ModifiedOn = attachment.ModifiedOn.Value; Manager.SaveOrUpdate(item); } Manager.SaveOrUpdate(attachment); Manager.Commit(); } catch (Exception ex) { Manager.RollBack(); } } }
public void AttachmentEditVisibility(CommunityEventItem item, EventItemFile attachment, Boolean visibleForModule, Boolean visibleForRepository) { Boolean updateRepositoryItems = false; litePerson person = Manager.GetLitePerson(UC.CurrentUserID); if (person != null && attachment != null) { try { Manager.BeginTransaction(); attachment.UpdateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress); attachment.isVisible = visibleForModule; if (attachment.Item != null & !attachment.Item.IsInternal && attachment.Item.IsVisible != visibleForRepository) { attachment.Item.UpdateMetaInfo(person.Id, UC.IpAddress, UC.ProxyIpAddress, attachment.ModifiedOn); attachment.Item.IsVisible = visibleForRepository; Manager.SaveOrUpdate(attachment.Item); updateRepositoryItems = true; } Manager.SaveOrUpdate(attachment); item.ModifiedBy = attachment.ModifiedBy; item.ModifiedOn = attachment.ModifiedOn.Value; Manager.SaveOrUpdate(item); Manager.Commit(); if (updateRepositoryItems) { Manager.Refresh(Manager.Get <lm.Comol.Core.FileRepository.Domain.RepositoryItem>(attachment.Item.Id)); lm.Comol.Core.DomainModel.Helpers.CacheHelper.PurgeCacheItems(lm.Comol.Core.FileRepository.Domain.CacheKeys.Repository(attachment.Item.Repository)); lm.Comol.Core.DomainModel.Helpers.CacheHelper.PurgeCacheItems(lm.Comol.Core.FileRepository.Domain.CacheKeys.UsersViewOfRepository(attachment.Item.Repository)); lm.Comol.Core.DomainModel.Helpers.CacheHelper.PurgeCacheItems(lm.Comol.Core.FileRepository.Domain.CacheKeys.UsersSizeViewOfRepository(attachment.Item.Repository)); } } catch (Exception ex) { Manager.RollBack(); } } }