private void processNectar_Click(object sender, RoutedEventArgs e)
        {
            NectarVat vat = new NectarVat();
            Bee       bee = new Bee(15);
            HiveLog   log = new HiveLog();


            ProcessNectar(vat, bee, log);
        }
 private void ProcessNectar(NectarVat vat, Bee bee, HiveLog log)
 {
     try
     {
         queen.ProcessNectar(vat, bee, log);
     }
     catch (HiveLogException)
     {
         MessageBox.Show("There was a problem in the hive log.");
     }
 }
        private void processNectarLogError_Click(object sender, RoutedEventArgs e)
        {
            NectarVat vat = new NectarVat();
            Bee       bee = new Bee(15);
            HiveLog   log = new HiveLog();

            bee.UnitsExpected         = 2;
            log.ThrowHiveLogException = true;

            ProcessNectar(vat, bee, log);
        }
        private void processNectarIOProblem_Click(object sender, RoutedEventArgs e)
        {
            NectarVat vat = new NectarVat();
            Bee       bee = new Bee(15);
            HiveLog   log = new HiveLog();

            bee.UnitsExpected       = 2;
            log.OpenNonExistingFile = true;

            ProcessNectar(vat, bee, log);
        }
Пример #5
0
 public void ProcessNectar(NectarVat vat, Bee worker, HiveLog log)
 {
     try
     {
         NectarUnit[] units = worker.EmptyVat(vat);
         for (int i = 0; i < worker.UnitsExpected; i++)
         {
             Stream hiveLogFile = log.OpenLogFile();
             worker.AddLogEntry(hiveLogFile);
             hiveLogFile.Close();
         }
     }
     catch (VatEmptyException)
     {
         MessageBox.Show("The vat is empty.");
         vat.Emptied = true;
     }
     catch (HiveLogException ex)
     {
         MessageBox.Show("Throwing a HiveLogException: " + ex.Message);
         throw;
     }
     // It's fine for two blocks to use the same 'ex' for the exception as long as they aren't nested.
     catch (IOException ex)
     {
         worker.AlertQueen("An unspecified file error happened: "
                           + "Message: " + ex.Message + "\r\n"
                           + "Stack Trace: " + ex.StackTrace + "\r\n"
                           + "Data: " + ex.Data + "\r\n");
     }
     finally
     {
         vat.Seal();
         worker.FinishedJob();
         MessageBox.Show("Vat is sealed and the worker is finished.");
     }
 }
 private void ProcessNectar(NectarVat vat, Bee bee, HiveLog log)
 {
     try
     {
         queen.ProcessNectar(vat, bee, log);
     }
     catch (HiveLogException)
     {
         MessageBox.Show("There was a problem in the hive log.");
     }
 }
        private void processNectar_Click(object sender, RoutedEventArgs e)
        {
            NectarVat vat = new NectarVat();
            Bee bee = new Bee(15);
            HiveLog log = new HiveLog();

            ProcessNectar(vat, bee, log);
        }
        private void processNectarLogError_Click(object sender, RoutedEventArgs e)
        {
            NectarVat vat = new NectarVat();
            Bee bee = new Bee(15);
            HiveLog log = new HiveLog();

            bee.UnitsExpected = 2;
            log.ThrowHiveLogException = true;

            ProcessNectar(vat, bee, log);
        }
        private void processNectarIOProblem_Click(object sender, RoutedEventArgs e)
        {
            NectarVat vat = new NectarVat();
            Bee bee = new Bee(15);
            HiveLog log = new HiveLog();

            bee.UnitsExpected = 2;
            log.OpenNonExistingFile = true;

            ProcessNectar(vat, bee, log);
        }