public Dictionary <File, bool> GetFolderFiles(Guid congressId, Guid folderId) { try { var getFolderFiles = new Dictionary <File, bool>(); var list = FileManagerComponent.Instance.FileFacade.Where(x => x.FolderId == folderId); var userFileBo = new UserFileBO(); var @select = userFileBo.Select(ConnectionHandler, x => x.FileId, x => x.CongressId == congressId); foreach (var file in list) { var foruser = @select.Any(x => x.Equals(file.Id)); getFolderFiles.Add(file, foruser); } return(getFolderFiles); } catch (KnownException ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public bool Update(Guid congressId, Guid fileId, bool foruser, File fileoptions) { try { this.ConnectionHandler.StartTransaction(IsolationLevel.ReadUncommitted); this.FileManagerConnection.StartTransaction(IsolationLevel.ReadUncommitted); var insert = FileManagerComponent.Instance.FileTransactionalFacade(this.FileManagerConnection) .Update(fileId, fileoptions); if (!insert) { return(false); } var userfile = new UserFileBO().Get(this.ConnectionHandler, congressId, fileId); if (userfile != null) { if (!foruser) { if (!new UserFileBO().Delete(this.ConnectionHandler, congressId, fileId)) { throw new Exception(); } } } else { if (foruser) { var userFile = new UserFile { CongressId = congressId, FileId = fileId }; if (!new UserFileBO().Insert(this.ConnectionHandler, userFile)) { throw new Exception(); } } } this.ConnectionHandler.CommitTransaction(); this.FileManagerConnection.CommitTransaction(); return(true); } catch (KnownException ex) { this.ConnectionHandler.RollBack(); this.FileManagerConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { this.ConnectionHandler.RollBack(); this.FileManagerConnection.RollBack(); Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }