// // Constructors // #region Constructors /// <summary> /// Initializes the members of this instance. /// </summary> static Globals() { _database = new SQLServerDatabase(@"Gamer-PC\SQLEXPRESS", "HCS"); _account = null; _kwh = 0; _microcontroller = null; /*bool flag = false; foreach (ConnectionStringSettings css in ConfigurationManager.ConnectionStrings) { try { _database = new SQLServerDatabase(css.ConnectionString); flag = true; break; } catch { } } if (!flag) throw new ArgumentException("No connection string was valid.");*/ }
public static bool LoadMicrocontroller(string portName = "") { if (portName == "") { if (System.IO.File.Exists("port.txt")) { _microcontroller = new Microcontroller(System.IO.File.ReadAllText("port.txt"), 9600); return true; } else return false; } else { _microcontroller = new Microcontroller(portName, 9600); System.IO.File.WriteAllText("port.txt", portName); return true; } }