public string CalculateVolume(string text) { try { var response = string.Empty; var spellChecker = new Spelling(); var result = ChecKProgress_Volume(text, ref response, Chemical, Weight, Concentration); if (result) { return(response); } var volume = Convert_Chemical_Volume (Weight, Concentration, Chemical); var cVolume = $"{volume:0.00}"; response = "Conversion complete. The Volume of " + Weight + " grams of " + Chemical + " at Concentration " + Concentration + " mols per liter is " + cVolume + " liters."; if (volume < 0) { response = "Conversion FAILED calculation did not return a valid result. please try again"; response += spellChecker.AnalyzeString(Chemical); } response += ". Data Saved"; ClearData(); _dialogTarget = 0; _multiDialougeTarget = 0; return(response); } catch (Exception ex) { ClearData(); _dialogTarget = 0; _multiDialougeTarget = 0; var response = "Error, there was an issue with the calculation attempt - " + ex.Message; return(response); } }
//continue setting this up for Operations run internal string ProcessMolarity(string text) { try { var response = string.Empty; var spellChecker = new Spelling(); var result = CheckProgress_Molarity(text, ref response, Chemical, Weight, Volume); if (result) { return(response); } var molarity = Calculate_Chemical_Mol_Concentration(Chemical, Weight, Volume); molarity = Math.Round(molarity, 2); var molesCount = Calculate_Moles(Chemical, Weight); response = "Conversion complete. The number of moles for " + Weight + " grams of " + Chemical + " at volume " + Volume + " liters is " + molesCount + " moles and the molar concentration c = " + molarity + " mol/L."; if (molarity > -1.1 && molarity < -0.9) { response = "Conversion FAILED calculation did not return a valid result. Please try again"; response += spellChecker.AnalyzeString(Chemical); } response += ". Data Saved"; ClearData(); _dialogTarget = 0; _multiDialougeTarget = 0; return(response); } catch (Exception ex) { ClearData(); _dialogTarget = 0; _multiDialougeTarget = 0; var response = "Error, there was an issue with the calculation attempt - " + ex.Message; return(response); } }
public string CalculateWeight(string text) { try { var response = string.Empty; var spellChecker = new Spelling(); var result = CheckProgress_Weight(text, ref response, Chemical, Concentration, Volume); if (result) { return(response); } var weight = Convert_Chemical_Weight(Volume, Concentration, Chemical); var cWeight = $"{weight:0.0000}"; response = "Calculation complete. In order to prepare " + Volume + " liters of " + Chemical + " solution at " + Concentration + " mol/L " + " you will need to measure " + cWeight + " grams of the chemical."; if (weight < 0) { response = "Conversion FAILED calculation did not return a valid result. Please try again."; response += spellChecker.AnalyzeString(Chemical); } response += " Data Saved."; ClearData(); _dialogTarget = 0; _multiDialougeTarget = 0; return(response); } catch { var response = "Conversion FAILED calculation did not return a valid result. please try again"; ClearData(); _dialogTarget = 0; _multiDialougeTarget = 0; return(response); } }
internal string ProcessChemical(string text) { var spellChecker = new Spelling(); var showMw = false; var showFormula = false; var showSynonyms = false; var showCid = false; var showKeys = false; var response = string.Empty; DataSpecified = false; var check = CheckProgress_ProcessChemical(text, ref response, ref showMw, ref showFormula, ref showSynonyms, ref showCid, ref showKeys, ref _dialogTarget); if (check) { return(response); } var dataMissing = false; ChemicalFormula = GetFormula(Chemical, ref dataMissing); if (dataMissing) { response = Chemical + " was not found in the PubChem database, please specify compound name, "; response += spellChecker.AnalyzeString(Chemical); Chemical = string.Empty; return(response); } response += "Chemical is " + Chemical + "\n"; _dialogTarget = 0; if (showMw) { MolecularWeight = GetMw(Chemical); response += " Molecular Weight is " + MolecularWeight + " g/mol \n"; } if (showFormula) { response += " Formula is " + ChemicalFormula + "\n"; } if (showCid) { CiDs = GetCiDs(Chemical); if (CiDs.Length > 9) { response += ". C.I.D. numbers are \n" + CiDs + "\n"; } else { response += ". C.I.D. number is " + CiDs + "\n"; } } if (showKeys) { InchiKeys = GetInChIKeys(Chemical); response += " InChi Keys = \n" + InchiKeys; } if (showSynonyms) { Synonyms = GetSynonyms(Chemical); response += " Synonyms are " + Synonyms; } return(response); }