Esempio n. 1
0
        //runs everything.
        public MainWindow() {
            InitializeComponent();
            _writer = null;

            //state variables
            _logging = false;
            _email_logging = false;
            _log_path = GetDefaultDirectory();

            //create the page objects
            CreatePages();
            ContentFrame.Navigate(_student_id_page);

            //sets up timers to go at particular times
            //start of cougtech and end of cougtech working hours
            startDayTimer = new System.Windows.Threading.DispatcherTimer(); // Timer to automatically start logging at 8:00 am
            startDayTimer.Interval = TimeUntilNextTimer(startTime);
            startDayTimer.IsEnabled = true;
            startDayTimer.Tick += new EventHandler(AutoStartLog);

            endDayTimer = new System.Windows.Threading.DispatcherTimer(); // Timer to automatically end logging at 5:00 pm
            endDayTimer.Interval = TimeUntilNextTimer(endTime);
            endDayTimer.IsEnabled = true;
            endDayTimer.Tick += new EventHandler(AutoEndLog);

            ContentFrame.Navigated += ContentFrame_Navigated;
            ContentFrame.Navigating += ContentFrame_Navigating;

        }
Esempio n. 2
0
    public static void Main(string[] args)
    {
        CSVWriter cw;
        CSVReader cr;

        cw = new CSVWriter("test.csv");
        cw.Write("Sample text");
        cw.Write(23424);
        cw.Write("This is a string\"that contains a double quote character.");
        cw.Close();

        cr = new CSVReader("test.csv");
        object x;
        while ((x = cr.ReadNext()) != null)
        {
            Console.WriteLine(x);
        }
        cr.Close();
    }
Esempio n. 3
0
 /// <summary>
 /// Writes time log finished and deallocates the CSVWriter
 /// </summary>
 public void FinishLog()
 {
     _writer.addToCurrent("Log End Time: ");
     _writer.addToCurrent(DateTime.Now.ToShortTimeString());
     _writer.WriteLine();
     //close and dealocate the csv writer
     _writer = null;
 }
Esempio n. 4
0
        /// <summary>
        /// Creates a new CSVWriter object which will write to a new file
        /// This is performed weekly every monday or if a file does not exist for the week
        /// </summary>
        /// <param name="file_name">name of csv file</param>
        public void CreateLog(string file_name, FileMode mode) {
            //create a new writer
            try
            {
                if (mode == FileMode.Create)
                {
                    int i = 0;
                    string fname = _log_path + "\\" + file_name + "-" + i.ToString() + ".csv";
                    while (File.Exists(fname)) // this loop guarantees that it will not overwrite the file, but instead append a number to the end and create a new file
                    {
                        i += 1;
                        fname = _log_path + "\\" + file_name + "-" + i.ToString() + ".csv";
                    }
                    _writer = new CSVWriter(fname, mode);

                    //basic header stuff for the csv
                    //the name of the log, the time it started
                    _writer.addToCurrent("Log for: ");
                    _writer.addToCurrent(file_name);
                    _writer.addToCurrent(" ");
                    _writer.addToCurrent("Log Start Time: ");
                    _writer.addToCurrent(DateTime.Now.ToShortTimeString());
                    _writer.WriteLine();
                    //and then header for the collumns
                    _writer.addToCurrent("Time");
                    _writer.addToCurrent("ID Number");
                    _writer.addToCurrent("Problem");
                    _writer.addToCurrent("Description");
                    _writer.WriteLine();
                }
                else if (mode == FileMode.Append)
                {
                    _writer = new CSVWriter(file_name, mode);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error Creating Log");
                return;
            }
        }