Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 private void FixCFGFiles(List <BenRecord> fileList)
 {
     try
     {
         string curFileName;
         string curFileContent;
         foreach (BenRecord curRec in fileList)
         {
             curFileName = localPath + "\\" + get232FN(curRec.rDateTime, serialNumber) + ".cfg";
             if (FileSystem.FileExists(curFileName))
             {
                 curFileContent = FileSystem.ReadAllText(curFileName);
                 FileSystem.WriteAllText(curFileName, siteName + curFileContent, false, System.Text.Encoding.ASCII);
             }
         }
     }
     catch (Exception ex)
     {
         Program.Log("fixcfgFiles error: " + siteName + " - " + ex.ToString());
         throw new System.Exception("fixcfgFiles error: " + siteName + " - " + ex.ToString());
     }
 }