Esempio n. 1
0
        /// <summary>
        /// Move a file to the default directory.
        /// This method does NOT delete the file!
        /// </summary>
        /// <param name="fileID"></param>
        /// <param name="directoryID"></param>
        /// <returns>true = ok, false if errors occur</returns>
        public bool removeFileFromDirectory(int fileID, int directoryID)
        {
            FilesUploaded f = getEntityByID <FilesUploaded>(fileID);

            f.directoryID = null;

            return(commit());
        }
Esempio n. 2
0
        /// <summary>
        /// Move a file to a new directory.
        /// </summary>
        /// <param name="fileID"></param>
        /// <param name="newDirectoryID"></param>
        /// <returns>true = ok, false if errors occur</returns>
        public bool moveFileToDirectory(int fileID, int newDirectoryID)
        {
            FilesUploaded f = getEntityByID <FilesUploaded>(fileID);

            f.directoryID = newDirectoryID;

            return(commit());
        }
        public async Task AddLocalFiles(Action <string>?setNotificationMessage = null)
        {
            var files = OpenFileDialog();

            await AddFilesToDatabase(files, setNotificationMessage);

            setNotificationMessage?.Invoke(string.Empty);
            FilesUploaded?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 4
0
        /// <summary>
        /// Generate a new instance of FilesUploaded; this is needed to store file's binary data.
        /// </summary>
        /// <param name="directoryID"></param>
        /// <param name="name"></param>
        /// <returns>FilesUploaded reference or null if errors occur</returns>
        public FilesUploaded uploadFile(int directoryID, string name)
        {
            FilesUploaded f = new FilesUploaded()
            {
                directoryID = directoryID,
                fileName    = name
            };

            return(AddEntity(f));
        }
        public async Task AddLocalFolder(Action <string>?setNotificationMessage = null)
        {
            var dialog = new FolderBrowserDialog();
            var result = dialog.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }
            var dirInfo = new DirectoryInfo(dialog.SelectedPath);
            var files   = dirInfo.GetFiles("*.*", SearchOption.AllDirectories)
                          .Select(file => file.FullName);

            await AddFilesToDatabase(files, setNotificationMessage);

            setNotificationMessage?.Invoke(string.Empty);
            FilesUploaded?.Invoke(this, EventArgs.Empty);
        }