Esempio n. 1
0
        public static List <DocumentFile> GetFilesForTutorial(int tutorialId)
        {
            DocumentFileDSTableAdapters.FileInfoTableAdapter ta =
                new DocumentFileDSTableAdapters.FileInfoTableAdapter();

            DocumentFileDS.FileInfoDataTable table = ta.GetFilesByTutorial(tutorialId);

            List <DocumentFile> fileList = new List <DocumentFile>();

            if (table.Count > 0)
            {
                foreach (DocumentFileDS.FileInfoRow row in table)
                {
                    fileList.Add(DocumentFile.CreateNewTypedDocumentFileObject(
                                     row.fileID,
                                     row.uploadedOn,
                                     row.fileSize,
                                     row.fileName,
                                     row.extension,
                                     row.title,
                                     row.fileStoragePath));
                }
            }

            return(fileList);
        }
Esempio n. 2
0
        public List <DocumentFile> GetDocumentFilesByObject(int objectID, string objectTypeID)
        {
            if (objectID <= 0)
            {
                return(null);
            }

            if (string.IsNullOrEmpty(objectTypeID))
            {
                return(null);
            }
            DocumentFileDSTableAdapters.FileInfoTableAdapter ta =
                new DocumentFileDSTableAdapters.FileInfoTableAdapter();

            DocumentFileDS.FileInfoDataTable table = ta.GetDocumentFilesByObject(objectID, objectTypeID);

            List <DocumentFile> fileList = new List <DocumentFile>();

            if (table.Count > 0)
            {
                foreach (DocumentFileDS.FileInfoRow row in table)
                {
                    fileList.Add(DocumentFile.CreateNewTypedDocumentFileObject(
                                     row.fileID,
                                     row.uploadedOn,
                                     row.fileSize,
                                     row.fileName,
                                     row.extension,
                                     row.title,
                                     row.fileStoragePath));
                }
            }

            return(fileList);
        }
Esempio n. 3
0
        public static List <DocumentFile> GetFilesByStorageFolder(string folderName)
        {
            if (string.IsNullOrEmpty(folderName))
            {
                return(null);
            }

            folderName = folderName + "%";

            DocumentFileDSTableAdapters.FileInfoTableAdapter ta =
                new DocumentFileDSTableAdapters.FileInfoTableAdapter();

            DocumentFileDS.FileInfoDataTable table = ta.GetFilesByStoragePathName(folderName);

            List <DocumentFile> fileList = new List <DocumentFile>();

            if (table.Count > 0)
            {
                foreach (DocumentFileDS.FileInfoRow row in table)
                {
                    fileList.Add(DocumentFile.CreateNewTypedDocumentFileObject(
                                     row.fileID,
                                     row.uploadedOn,
                                     row.fileSize,
                                     row.fileName,
                                     row.extension,
                                     row.title,
                                     row.fileStoragePath));
                }
            }

            return(fileList);
        }
Esempio n. 4
0
        /// <summary>
        /// Get a specific document file form the database
        /// </summary>
        /// <param name="documentID">The ID of the document file</param>
        /// <returns>A data file object with the file data</returns>
        public static DocumentFile GetDocumentFile(int documentFileID)
        {
            if (documentFileID <= 0)
            {
                throw new ArgumentException("Invalid document file ID. Must be > 0");
            }

            DocumentFileDSTableAdapters.FileInfoTableAdapter theAdapter =
                new DocumentFileDSTableAdapters.FileInfoTableAdapter();

            DocumentFileDS.FileInfoDataTable theTable =
                theAdapter.GetBasicFileData(documentFileID);

            DocumentFile theResult = null;

            if (theTable.Count > 0)
            {
                theResult = DocumentFile.CreateNewTypedDocumentFileObject(
                    theTable[0].fileID,
                    theTable[0].uploadedOn,
                    theTable[0].fileSize,
                    theTable[0].fileName,
                    theTable[0].extension,
                    theTable[0].title,
                    theTable[0].fileStoragePath
                    );
            }
            else
            {
                log.Error("SQL Query resulted in zero rows for the file");
                return(null);
            }

            return(theResult);
        }