private List <BenRecord> GetFileList() { List <BenRecord> downloadList = new List <BenRecord>(); string dirFile = m_tempDirectoryName + "bendir.txt"; try { //delete the existing dir file if one exists. if (FileSystem.FileExists(dirFile)) { FileSystem.DeleteFile(dirFile); } //build new dir files. BuildBenLinkDirINI(); ExecBenCommand(); // build list of records to download if (FileSystem.FileExists(dirFile)) { TextFieldParser dirReader = FileSystem.OpenTextFieldParser(dirFile, new string[] { "\t" }); while (!dirReader.EndOfData) { string[] curRow = dirReader.ReadFields(); if (Convert.ToInt32(curRow[2]) < BENMAXFILESIZE) { BenRecord curRecord = new BenRecord(Convert.ToInt32(curRow[0]), Convert.ToDateTime(curRow[1]), Convert.ToInt32(curRow[2])); if (curRecord.DateTime > DateTime.UtcNow.AddDays(-30) && curRecord.DateTime > m_lastFileDownloaded.DateTime) { downloadList.Add(curRecord); } } else { Program.Log("File too large Error: " + m_siteName + " - " + Convert.ToString(curRow[0]), m_tempDirectoryName); } } dirReader.Close(); } else { throw new Exception("GetFileList Error: " + m_siteName + " - dir file does not exist."); } } catch (Exception ex) { Program.Log("GetFileList Error: " + m_siteName + " - " + ex.ToString(), m_tempDirectoryName); throw new Exception("GetFileList Error: " + m_siteName + " - " + ex.ToString()); } return(downloadList); }
private List <BenRecord> GetFileList() { List <BenRecord> downloadList = new List <BenRecord>(); string dirFile = localPath + "\\bendir.txt"; try { //delete the existing dir file if one exists. //if (FileSystem.FileExists(dirFile)) // FileSystem.DeleteFile(dirFile); //build new dir files. BuildBenLinkDirINI(); ExecBenCommand(); // build list of records to download // todo: build an algroithm for rollover of record numbers if (FileSystem.FileExists(dirFile)) { TextFieldParser dirReader = FileSystem.OpenTextFieldParser(dirFile, new string[] { "\t" }); string[] curRow; while (!dirReader.EndOfData) { curRow = dirReader.ReadFields(); if (Convert.ToInt32(curRow[2]) < BENMAXFILESIZE) { //Program.Log("DateTime from GetFile List for "+Convert.ToInt32(curRow[0]).ToString() +": " + Convert.ToDateTime(curRow[1]).ToString()); BenRecord curRecord = new BenRecord(Convert.ToInt32(curRow[0]), Convert.ToDateTime(curRow[1]), Convert.ToInt32(curRow[2])); downloadList.Add(curRecord); } else { SendFileTooLargeEmailNotification("Record id: " + curRow[0]); } } dirReader.Close(); } else { throw new Exception("GetFileList Error: " + siteName + " - dir file does not exist."); } } catch (Exception ex) { Program.Log("GetFileList Error: " + siteName + " - " + ex.ToString()); throw new Exception("GetFileList Error: " + siteName + " - " + ex.ToString()); } return(downloadList); }