Exemple #1
0
        void SaveDataToDatabase()
        {
            try
            {
                string batchName = null;
                foreach (int Socket in LifetimeTest.TestResults.Keys)
                {
                    string CurrentSerialNumber = listLifetimeInfo1.GetSerialNumber(Socket);
                    Dispatcher.BeginInvoke(new Action(delegate()
                    {
                        batchName = textBatchName.Text;
                    }));
                    if (numericTestHour.pinValue() == 0)
                    {
                        //this causing prob
                        int BaselineID = GCIDB.GetMostRecentLifetimeTestID_BaseLine(LoadedPartID, CurrentSerialNumber, batchName);
                        // Look at this later
                        //if (BaselineID != 0)
                        //{
                        //    if (MessageBox.Show("Baseline data already exists for:\nPart: " + SelectedPartName + "\nSerial Number: " + CurrentSerialNumber + "\n\nDo you want to change the baseline data to these measurements?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.Yes)
                        //    {
                        //        continue;
                        //    }
                        //    else
                        //        return;

                        //}
                    }

                    int LifetimeTestID = GCIDB.GetNextLifetimeTestID();

                    String Batch = null;
                    Dispatcher.BeginInvoke(new Action(delegate()
                    {
                        Batch = textBatchName.Text;
                    }));

                    DateTime Time        = DateTime.Now;
                    int      Hour        = (int)numericTestHour.pinValue();
                    double   Temperature = (double)numericTemperature.pinValue();

                    foreach (int TestedDUTPin in LifetimeTest.TestResults[Socket].Keys)
                    {
                        double AverageVoltage = LifetimeTest.TestResults[Socket][TestedDUTPin].GetVoltageAverage();
                        double StdDev         = LifetimeTest.TestResults[Socket][TestedDUTPin].GetStandardDeviation();

                        for (int j = 0; j < LifetimeTest.TestResults[Socket][TestedDUTPin].VoltageReadings.Count; j++)
                        {
                            Console.WriteLine(j - 1);
                            double MeasuredVoltage = LifetimeTest.TestResults[Socket][TestedDUTPin].VoltageReadings[j];
                            GCIDB.AddLifetimeTestData(LifetimeTestID, CurrentSerialNumber, Batch, LoadedPartID, Hour, LoadedLifetimeLimitID, Temperature, TestedDUTPin, j, MeasuredVoltage, AverageVoltage, StdDev, Time);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SaveDataToDatabase(): " + ex.ToString());
            }
        }