Exemplo n.º 1
0
        public void readWarnings(SpreadsheetFile sf, WarningFile wf)
        {
            //Get temperature at which a warning will be produced
            wf.temperature = wf.getTemp(wf.pathname);

            float tempFloat = float.Parse(wf.temperature);

            string timeOfError = "";
            //Console.Write(dataList);
            bool warning = false;

            foreach (var dataRow in sf.datalist)
            {
                try
                {
                    //check if temperatures are greater than the warning level
                    if (Convert.ToDouble(dataRow.reading) > tempFloat)
                    {
                        warning     = true;
                        timeOfError = dataRow.dateAndTime;
                        break;
                    }
                }
                catch (FormatException)
                {
                    continue;
                }
            }
            if (warning)
            {
                string output = Regex.Replace(wf.temperature, "[\r,\n]", "");
                Console.WriteLine($"A temperature of over {output}°C has been Recorded. It was Recorded at {timeOfError}");
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            string location            = System.Reflection.Assembly.GetEntryAssembly().Location;
            string executableDirectory = System.IO.Path.GetDirectoryName(location);

            Console.WriteLine(location);
            Console.WriteLine(executableDirectory);

            SpreadsheetFile sf = new SpreadsheetFile();

            sf.pathname = sf.checkFile("Please enter the filepath of the data: ");
            sf.datalist = sf.assembleData(sf);
            WarningFile wf = new WarningFile();

            wf.pathname = wf.checkFile("Please enter the file containing the warning temperature: ");
            wf.readWarnings(sf, wf);
            ConsoleWindow.consoleRequest(sf, wf.pathname);
        }