/// <summary> /// Helper methods for retreiving a queue of files names from the selected directory and adds it to the Cache object /// for sequential access i.e one by one /// </summary> private Queue <string> GetFileListQueue(int documentTypeId) { //Create cache for fileName queue for selected document type var documentType = _documentTypeBL.GetDocumentTypeById(documentTypeId); if (HttpRuntime.Cache.Get(documentType.Name) == null) { //Retreive queue //TODO: Potential return of no values Queue <string> fileQueue = _documentArchivingProcess.GetFileNamesInDirectory(documentTypeId); HttpRuntime.Cache.Insert(documentType.Name, fileQueue); } //retreive queue from Cache return((Queue <string>)HttpRuntime.Cache.Get(documentType.Name)); }
public void GetFileNamesInDirectory() { var documentArchiveProcess = new DocumentArchivingProcess(); //Use a docuemnt type that exists. The DocumentDirectory property for this document type will be used in the businessclass //to retreive file names for the specified directory const int documentTypeId = 1; //retrieve files in directory var fileQueue = documentArchiveProcess.GetFileNamesInDirectory(documentTypeId); //Check if there are files in the queue Assert.NotNull(fileQueue); for (int i = 1; i <= fileQueue.Count(); i++) { //Get first items in queue and write to debug window var fileName = (string)fileQueue.Dequeue(); System.Diagnostics.Debug.WriteLine(fileName); } }