private async Task <List <Measurement> > FetchData() { var location = await GetLocation(); var installations = await GetInstallations(location, maxResults : 3); var data = await GetMeasurementsForInstallations(installations); var _items = new List <Measurement>(data); _dbHelper.Truncate(); _dbHelper.AddData(_items); return(_items); }
private void Bg2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (powerOn == false && meterConnected == true) { if (pass == true) { ID.Text = SerialNumber.Text; Test480.Text = "480V Test Passed"; DateTime aDate = DateTime.Now; //string time = aDate.ToString("dddd, dd MMMM yyyy HH:mm:ss"); string result = "Pass"; string result240 = "Pass"; string result480 = "Pass"; string barCode = SerialNumber.Text; string supplierCode = _stringHelper.RemoveLeadingChars(SerialNumber.Text, 1); string dateCode = _stringHelper.RemoveLeadingChars(SerialNumber.Text, 2); string serialNumber = _stringHelper.RemoveLeadingChars(SerialNumber.Text, 3); string partNumber = _stringHelper.RemoveLaggingChars(SerialNumber.Text); string leadsCover = "Yes"; DatabaseHelper.AddData(barCode, partNumber, supplierCode, dateCode, serialNumber, leadsCover, result240, dcVoltage1.ToString(), result480, dcVoltage2.ToString(), result, aDate); Fail.Text = ""; Pass.Text = "PASS"; Pass.Foreground = Brushes.Green; } if (fail == true) { ID.Text = SerialNumber.Text; Test480.Text = "480V Test Failed"; DateTime aDate = DateTime.Now; //string time = aDate.ToString("dddd, dd MMMM yyyy HH:mm:ss"); string result = "Fail"; string result240 = "Pass"; string result480 = "Fail"; string barCode = SerialNumber.Text; string supplierCode = _stringHelper.RemoveLeadingChars(SerialNumber.Text, 1); string dateCode = _stringHelper.RemoveLeadingChars(SerialNumber.Text, 2); string serialNumber = _stringHelper.RemoveLeadingChars(SerialNumber.Text, 3); string partNumber = _stringHelper.RemoveLaggingChars(SerialNumber.Text); string leadsCover = "Yes"; DatabaseHelper.AddData(barCode, partNumber, supplierCode, dateCode, serialNumber, leadsCover, result240, dcVoltage1.ToString(), result480, dcVoltage2.ToString(), result, aDate); Pass.Text = ""; Fail.Text = "FAIL"; Fail.Foreground = Brushes.Red; } if (fail240 == true) { ID.Text = SerialNumber.Text; Test240.Text = "240V Test Failed"; DateTime aDate = DateTime.Now; //string time = aDate.ToString("dddd, dd MMMM yyyy HH:mm:ss"); string result = "Fail"; string result240 = "Fail"; string result480 = ""; string barCode = SerialNumber.Text; string supplierCode = _stringHelper.RemoveLeadingChars(SerialNumber.Text, 1); string dateCode = _stringHelper.RemoveLeadingChars(SerialNumber.Text, 2); string serialNumber = _stringHelper.RemoveLeadingChars(SerialNumber.Text, 3); string partNumber = _stringHelper.RemoveLaggingChars(SerialNumber.Text); string leadsCover = "Yes"; DatabaseHelper.AddData(barCode, partNumber, supplierCode, dateCode, serialNumber, leadsCover, result240, dcVoltage1.ToString(), result480, dcVoltage2.ToString(), result, aDate); Pass.Text = ""; Fail.Text = "FAIL"; Fail.Foreground = Brushes.Red; } if (coverOpen == true) { MessageBox.Show("Check if Cover is closed. Check if leads are connected. Check if Base is assembled properly."); DateTime aDate = DateTime.Now; //string time = aDate.ToString("dddd, dd MMMM yyyy HH:mm:ss"); string result = ""; string result240 = ""; string result480 = ""; string barCode = SerialNumber.Text; string supplierCode = _stringHelper.RemoveLeadingChars(SerialNumber.Text, 1); string dateCode = _stringHelper.RemoveLeadingChars(SerialNumber.Text, 2); string serialNumber = _stringHelper.RemoveLeadingChars(SerialNumber.Text, 3); string partNumber = _stringHelper.RemoveLaggingChars(SerialNumber.Text); string leadsCover = "No"; dcVoltage1 = double.NaN; DatabaseHelper.AddData(barCode, partNumber, supplierCode, dateCode, serialNumber, leadsCover, result240, dcVoltage1.ToString(), result480, dcVoltage2.ToString(), result, aDate); } SerialNumber.Text = ""; IsOn.Foreground = new System.Windows.Media.SolidColorBrush((Color)ColorConverter.ConvertFromString("#C0C0C0")); IsOn.Text = "Power ON"; form = null; base_ = null; while (Math.Abs(myDmm.Measure()) > 5.0) { } Measage1.Foreground = new System.Windows.Media.SolidColorBrush((Color)ColorConverter.ConvertFromString("#C0C0C0")); Measage2.Foreground = new System.Windows.Media.SolidColorBrush((Color)ColorConverter.ConvertFromString("#C0C0C0")); } else if (powerOn == true) { Test240.Text = ""; Test480.Text = ""; Voltages.Clear(); Voltages2.Clear(); SerialNumber.Text = ""; form = null; base_ = null; while (Math.Abs(myDmm.Measure()) > 5.0) { } Measage1.Foreground = new System.Windows.Media.SolidColorBrush((Color)ColorConverter.ConvertFromString("#C0C0C0")); Measage2.Foreground = new System.Windows.Media.SolidColorBrush((Color)ColorConverter.ConvertFromString("#C0C0C0")); } else if (meterConnected == false) { IsOn.Foreground = new System.Windows.Media.SolidColorBrush((Color)ColorConverter.ConvertFromString("#C0C0C0")); IsOn.Text = "Power ON"; SerialNumber.Text = ""; Test240.Text = ""; Test480.Text = ""; Voltages.Clear(); Voltages2.Clear(); form = null; base_ = null; } else if (power480 == false) { SerialNumber.Text = ""; Voltages.Clear(); Voltages2.Clear(); IsOn.Foreground = new System.Windows.Media.SolidColorBrush((Color)ColorConverter.ConvertFromString("#C0C0C0")); IsOn.Text = "Power ON"; MessageBox.Show("480V POWER UP FAIL: " + power.fail); form = null; base_ = null; while (Math.Abs(myDmm.Measure()) > 5.0) { } Measage1.Foreground = new System.Windows.Media.SolidColorBrush((Color)ColorConverter.ConvertFromString("#C0C0C0")); Measage2.Foreground = new System.Windows.Media.SolidColorBrush((Color)ColorConverter.ConvertFromString("#C0C0C0")); } }