Ejemplo n.º 1
0
 void RefreshProgramSettings(SySal.OperaDb.OperaDbConnection conn)
 {
     SySal.OperaDb.OperaDbDataReader rd2 = null;
     try
     {
         lvProgramSettings.Items.Clear();
         string sql = "";
         if (chkFavorites.Checked)
         {
             sql = "select to_number(value), substr(name, length('PROGSET') + 2) as description from opera.lz_sitevars where name like 'PROGSET %' and exists (select * from tb_programsettings where id = to_number(value) and driverlevel = 2 and instr(upper(executable), 'TOTALSCAN') > 0) order by value";
         }
         else
         {
             sql = "select id, description from tb_programsettings where driverlevel = 2 and instr(upper(executable), 'TOTALSCAN') > 0 order by id";
         }
         rd2 = new SySal.OperaDb.OperaDbCommand(sql, conn).ExecuteReader();
         while (rd2.Read())
         {
             ListViewItem lvi = new ListViewItem(rd2.GetInt64(0).ToString());
             lvi.Tag = rd2.GetInt64(0);
             lvi.SubItems.Add(rd2.GetString(1));
             lvProgramSettings.Items.Add(lvi);
         }
     }
     catch (Exception x)
     {
         MessageBox.Show(x.ToString(), "Error Accessing DB", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         if (rd2 != null)
         {
             rd2.Close();
         }
     }
 }
Ejemplo n.º 2
0
 private void OnLoad(object sender, EventArgs e)
 {
     SySal.OperaDb.OperaDbConnection conn = null;
     SySal.OperaDb.OperaDbDataReader rd1  = null;
     SySal.OperaDb.OperaDbDataReader rd3  = null;
     SySal.OperaDb.OperaDbDataReader rd4  = null;
     try
     {
         conn = SySal.OperaDb.OperaDbCredentials.CreateFromRecord().Connect();
         conn.Open();
         rd1 = new SySal.OperaDb.OperaDbCommand("select id, name from tb_machines where id_site = (select value from opera.lz_sitevars where name = 'ID_SITE') and isscanningserver > 0 order by name", conn).ExecuteReader();
         while (rd1.Read())
         {
             ListViewItem lvi = new ListViewItem(rd1.GetInt64(0).ToString());
             lvi.Tag = rd1.GetString(1) /*rd1.GetInt64(0)*/;
             lvi.SubItems.Add(rd1.GetString(1));
             lvMachines.Items.Add(lvi);
         }
         rd1.Close();
         rd3 = new SySal.OperaDb.OperaDbCommand("select value from opera.lz_sitevars where name = 'BM_AutoStartFile'", conn).ExecuteReader();
         if (rd3.Read())
         {
             m_AutoStartPath = rd3.GetString(0);
         }
         else
         {
             MessageBox.Show("AutoStart file path not set in LZ_SITEVARS.\r\nCannot continue.", "Infrastructure Setup Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             Close();
             return;
         }
         System.Collections.ArrayList pa = new System.Collections.ArrayList();
         rd4 = new SySal.OperaDb.OperaDbCommand("select id, z from tb_plates where id_eventbrick = " + BrickId + " order by z desc", conn).ExecuteReader();
         while (rd4.Read())
         {
             pa.Add(new PlateRecord(rd4.GetInt32(0), rd4.GetDouble(1)));
         }
         if (pa.Count == 0)
         {
             throw new Exception("No plates registered in your DB for this brick.\r\nPlease check and retry.");
         }
         Plates = (PlateRecord[])pa.ToArray(typeof(PlateRecord));
         int i;
         for (i = 0; i < Plates.Length && Plates[i].Id != VolStart.Plate; i++)
         {
             ;
         }
         cmbPlates.Items.Add(i + "/0");
         cmbPlates.Items.Add("0/" + (Plates.Length - 1 - i));
         cmbSkew.Items.Add(VolStart.Slope.X.ToString("F4", System.Globalization.CultureInfo.InvariantCulture) + "/" + VolStart.Slope.Y.ToString("F4", System.Globalization.CultureInfo.InvariantCulture));
         rd4.Close();
         cmbNotes.Items.Add("TotalScan on brick " + BrickId);
         cmbNotes.Items.Add("TotalScan on brick " + BrickId + " around vertex point");
         cmbNotes.Items.Add("TotalScan on brick " + BrickId + " around stopping point");
         cmbNotes.SelectedIndex = VolumeStartsFromTrack ? 2 : 1;
         RefreshProgramSettings(conn);
         cmbWidthHeight.SelectedIndex = 0;
         cmbPlates.SelectedIndex      = 0;
         cmbSkew.SelectedIndex        = 0;
         OnWidthHeightLeave(this, null);
         OnPlatesLeave(this, null);
         OnSkewLeave(this, null);
     }
     catch (Exception x)
     {
         MessageBox.Show(x.ToString(), "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         Close();
     }
     finally
     {
         if (rd1 != null)
         {
             rd1.Close();
         }
         if (rd3 != null)
         {
             rd3.Close();
         }
         if (rd4 != null)
         {
             rd3.Close();
         }
         if (conn != null)
         {
             conn.Close();
         }
     }
 }