public string ReadVacuum(StreamReader sr) { string line = sr.ReadLine(); if (string.IsNullOrEmpty(line)) { return(null); } int i = 10; while (line.Substring(0, 1) != "#") { var values = line.Split(';'); VacuumValue vacValue = new VacuumValue(); vacValue.Id = i.ToString(); string type = values[0] == "0" ? "Rampa" : "Patamar"; vacValue.Tipo = type; vacValue.SetPoint = String.IsNullOrEmpty(values[1]) ? null : Convert.ToDouble(values[1], System.Globalization.CultureInfo.InvariantCulture).ToString("0.00", System.Globalization.CultureInfo.InvariantCulture); vacValue.Taxa = String.IsNullOrEmpty(values[2]) ? null : Convert.ToDouble(values[2], System.Globalization.CultureInfo.InvariantCulture).ToString("0.00", System.Globalization.CultureInfo.InvariantCulture); vacValue.Tempo = values[3]; vacValue.Tolerancia = String.IsNullOrEmpty(values[4]) ? null : Convert.ToDouble(values[4], System.Globalization.CultureInfo.InvariantCulture).ToString("0.00", System.Globalization.CultureInfo.InvariantCulture); _vacauumRepository.addValue(vacValue); i += 10; line = sr.ReadLine(); if (string.IsNullOrEmpty(line)) { return(null); } } return(line); }
private void SetVacuumValue(VacuumValue vacValue) { (_controlList.Where(x => x.Name == "Id").FirstOrDefault() as TextBox).Text = vacValue.Id; (_controlList.Where(x => x.Name == "Tipo").FirstOrDefault() as ComboBox).SelectedIndex = (_controlList.Where(x => x.Name == "Tipo").FirstOrDefault() as ComboBox).Items.IndexOf(vacValue.Tipo); (_controlList.Where(x => x.Name == "SetPoint").FirstOrDefault() as TextBox).Text = vacValue.SetPoint; if ((_controlList.Where(x => x.Name == "Taxa").FirstOrDefault() as TextBox).IsEnabled) { (_controlList.Where(x => x.Name == "Taxa").FirstOrDefault() as TextBox).Text = vacValue.Taxa; } if ((_controlList.Where(x => x.Name == "Tempo").FirstOrDefault() as TextBox).IsEnabled) { (_controlList.Where(x => x.Name == "Tempo").FirstOrDefault() as TextBox).Text = vacValue.Tempo; } (_controlList.Where(x => x.Name == "Tolerancia").FirstOrDefault() as TextBox).Text = vacValue.Tolerancia; }
public bool isInputValid(VacuumValue tempValue) { if (!String.IsNullOrEmpty(tempValue.SetPoint)) { validateSetPoint(tempValue.SetPoint); } if (!String.IsNullOrEmpty(tempValue.Taxa)) { validateTaxa(tempValue.Taxa); } if (!String.IsNullOrEmpty(tempValue.Tempo)) { validateTempo(tempValue.Tempo); } if (!String.IsNullOrEmpty(tempValue.Tolerancia)) { validateTolerancia(tempValue.Tolerancia); } if (!String.IsNullOrEmpty(tempValue.Tipo)) { if (tempValue.Tipo == "Rampa") { if (!String.IsNullOrEmpty(tempValue.Taxa) && Convert.ToDouble(tempValue.Taxa, CultureInfo.InvariantCulture) != 0) { return(!String.IsNullOrEmpty(tempValue.SetPoint) && !String.IsNullOrEmpty(tempValue.Id) && !String.IsNullOrEmpty(tempValue.Taxa) && !String.IsNullOrEmpty(tempValue.Tolerancia)); } else { return(false); } } else { return(!String.IsNullOrEmpty(tempValue.SetPoint) && !String.IsNullOrEmpty(tempValue.Tempo) && (Convert.ToInt32(tempValue.Tempo, CultureInfo.InvariantCulture) != 0) && !String.IsNullOrEmpty(tempValue.Id) && !String.IsNullOrEmpty(tempValue.Tolerancia)); } } return(false); }
public void setValueFromControls(string type, object values) { switch (type) { case "Vacuum": VacuumValue vacValue = values as VacuumValue; SetVacuumValue(vacValue); break; case "Pressure": PressureValue presValue = values as PressureValue; SetPressureValue(presValue); break; case "Temperature": TemperatureValue TempValue = values as TemperatureValue; SetTemperatureValue(TempValue); break; default: throw new FormatException("Data Type Not Found"); } }
private VacuumValue GetVacuumValue() { VacuumValue newValue = new VacuumValue(); VacuumValidation vacuumValidation = new VacuumValidation(); newValue.Id = (_controlList.Where(x => x.Name == "Id").FirstOrDefault() as TextBox).Text; newValue.SetPoint = (_controlList.Where(x => x.Name == "SetPoint").FirstOrDefault() as TextBox).Text; newValue.Taxa = (_controlList.Where(x => x.Name == "Taxa").FirstOrDefault() as TextBox).Text; newValue.Tempo = (_controlList.Where(x => x.Name == "Tempo").FirstOrDefault() as TextBox).Text; newValue.Tolerancia = (_controlList.Where(x => x.Name == "Tolerancia").FirstOrDefault() as TextBox).Text; newValue.Tipo = (_controlList.Where(x => x.Name == "Tipo").FirstOrDefault() as ComboBox).SelectedValue as string; newValue.SetPoint = String.IsNullOrEmpty(newValue.SetPoint) ? null : Convert.ToDouble(newValue.SetPoint, CultureInfo.InvariantCulture).ToString("0.00", System.Globalization.CultureInfo.InvariantCulture); newValue.Taxa = String.IsNullOrEmpty(newValue.Taxa) ? null : Convert.ToDouble(newValue.Taxa, CultureInfo.InvariantCulture).ToString("0.00", System.Globalization.CultureInfo.InvariantCulture); newValue.Tolerancia = String.IsNullOrEmpty(newValue.Tolerancia) ? null : Convert.ToDouble(newValue.Tolerancia, CultureInfo.InvariantCulture).ToString("0.00", System.Globalization.CultureInfo.InvariantCulture); if (vacuumValidation.isInputValid(newValue)) { CleanVacuum(); return(newValue); } return(null); }