private void AttachmentsSetVirtualDelete(List <long> idAttachments, Boolean delete) { litePerson person = Manager.GetLitePerson(UC.CurrentUserID); List <EventItemFile> attachments = (from f in Manager.Linq <EventItemFile>() where idAttachments.Contains(f.Id) select f).ToList(); if (person != null && attachments.Count > 0) { List <CommunityEventItem> items = EventItemsGet(attachments.Select(f => f.IdCommunity).FirstOrDefault(), attachments.Select(f => f.IdItemOwner).Distinct().ToList()); try { Manager.BeginTransaction(); foreach (EventItemFile attachment in attachments) { attachment.UpdateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress); attachment.Deleted = delete ? BaseStatusDeleted.Manual : BaseStatusDeleted.None; CommunityEventItem item = items.Where(i => i.Id == attachment.IdItemOwner).FirstOrDefault(); 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(); } } }
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 List <dtoModuleUploadedItem> AddFiles(String istanceIdentifier, Int32 idUploaderUser, Boolean allowAnonymousUpload, Boolean alwaysLastVersion, RepositoryIdentifier identifier, long idFolder, List <dtoUploadedItem> files, Object obj, long idObject, Int32 idObjectType, String moduleCode, Int32 idModuleAjaxAction, Int32 idModuleAction = 0) { List <dtoModuleUploadedItem> items = new List <dtoModuleUploadedItem>(); if (!SessionTimeout() || allowAnonymousUpload && idUploaderUser > 0) { litePerson person = Service.GetValidPerson(idUploaderUser); liteRepositorySettings settings = Service.SettingsGetByRepositoryIdentifier(identifier); ModuleRepository module = Service.GetPermissions(identifier, idUploaderUser); ModuleRepository.ObjectType oType = ModuleRepository.ObjectType.File; ModuleRepository.ActionType uAction = ModuleRepository.ActionType.UnableToAddFile; liteRepositoryItem item = (idFolder > 0 ? Service.ItemGet(idFolder) : null); if (person == null || (item == null && idFolder > 0)) { View.DisplayError(ItemUploadError.UnableToAddFileToUnknownFolder); uAction = ModuleRepository.ActionType.UnknownItemFound; InitializeView(idFolder, identifier, module, settings, CurrentManager.GetLitePerson(idUploaderUser)); } else { Boolean allowAdd = module.Administration || module.ManageItems || module.UploadFile; dtoDisplayRepositoryItem dItem = Service.GetItemWithPermissions(idFolder, UserContext.CurrentUserID, identifier, View.GetUnknownUserName()); if (dItem != null) { oType = ModuleRepository.GetObjectType(dItem.Type); allowAdd = allowAdd || dItem.Permissions.GetActions().Contains(ItemAction.upload); } else if (idFolder == 0) { oType = ModuleRepository.ObjectType.Folder; } String folderName = (idFolder == 0 ? View.GetRootFolderName() : dItem.Name); if (!allowAdd) { View.DisplayError(ItemUploadError.MissingPermissionsToAddFile, folderName, "", ItemType.Folder); uAction = ModuleRepository.ActionType.UnavailableItem; } else { Boolean executed = false; items = Service.FileAddToRepository(settings, istanceIdentifier, identifier, person, alwaysLastVersion, module, View.GetRepositoryDiskPath(), idFolder, files, obj, idObject, idObjectType, moduleCode, idModuleAjaxAction, idModuleAction); executed = (items != null && items.Any(a => a.IsAdded)); uAction = (executed ? (items.Any(a => !a.IsAdded) ? ModuleRepository.ActionType.UnableToAddSomeFile : ModuleRepository.ActionType.AddFile) : ModuleRepository.ActionType.UnableToAddFile); if (executed) { View.NotifyAddedItems(Service.GetIdModule(), idFolder, folderName, RootObject.RepositoryItems(identifier.Type, identifier.IdCommunity, -1, (dItem == null ? 0 : dItem.Id)), items.Where(a => a.ItemAdded != null).Select(f => f.ItemAdded).ToList()); } else { View.DisplayError(ItemUploadError.UnableToAddFile, folderName, (items == null) ? null : items.Where(a => !a.IsAdded).Select(a => a.UploadedFile).ToList()); } } } View.SendUserAction(identifier.IdCommunity, Service.GetIdModule(), uAction, idFolder, oType); } return(items); }
//private Dictionary<Int32, ModuleTags> GetPermissions(Person person, Boolean forOrganization) //{ // Dictionary<Int32, ModuleTags> permissions = new Dictionary<Int32, ModuleTags>(); // List<Organization> organizations = ServiceCommunityManagement.GetAvailableOrganizations(person.Id, SearchCommunityFor.Subscribed); // permissions.Add(-3, ModuleTags.CreatePortalmodule(person.TypeID)); // if (organizations != null && organizations.Any()) // { // if (person.TypeID == (int)UserTypeStandard.SysAdmin || person.TypeID == (int)UserTypeStandard.Administrator) // organizations.ForEach(o => permissions.Add(o.Id, permissions[-3])); // else // { // List<Int32> communities = (from c in Manager.GetIQ<liteCommunityInfo>() // where c.IdFather == 0 // && organizations.Where(o => o.Id == c.IdOrganization).Any() // select c.Id).ToList(); // communities.ForEach(c => permissions.Add(c., GetPermission(c))); // } // } // return permissions; //} public TagItem SetStatus(long idTag, lm.Comol.Core.Dashboard.Domain.AvailableStatus status) { TagItem item = null; try { litePerson person = Manager.GetLitePerson(UC.CurrentUserID); if (person != null && person.TypeID != (int)UserTypeStandard.Guest && person.TypeID != (int)UserTypeStandard.PublicUser) { item = Manager.Get <TagItem>(idTag); item.UpdateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress); Manager.BeginTransaction(); item.Status = status; Manager.Commit(); if (item.Type == TagType.Community) { CacheHelper.PurgeCacheItems(CacheKeys.AllCommunityTags); CacheHelper.PurgeCacheItems(CacheKeys.AllUserCommunitiesTags); } CacheHelper.PurgeCacheItems(CacheKeys.Tags(item.Type)); if (item.MyTile.Status != Dashboard.Domain.AvailableStatus.Available && status != Dashboard.Domain.AvailableStatus.Draft) { ServiceDashboard.TileSetStatus(item.MyTile, status); } } } catch (Exception ex) { Manager.RollBack(); } return(item); }
public virtual CommunityTag Copy(TagItem tag, litePerson person, String ipAddress, String proxyIpAddress, DateTime?createdOn) { CommunityTag clone = new CommunityTag(); clone.Tag = tag; clone.IdCommunity = IdCommunity; clone.CreateMetaInfo(person, ipAddress, proxyIpAddress, createdOn); return(clone); }