string ResolveNameByNumber(string number) { IDbCommand cmd; IDataReader reader; try { cmd = DatabaseService.TryCreateCommand(); cmd.CommandText = String.Format("SELECT name FROM persons WHERE number='{0}'", number); reader = cmd.ExecuteReader(); } catch (Exception ex) { Log.AddException("SMS", ex); return(number); } Log.Add(LogLevel.Verbose, "SMS", cmd.CommandText); string ret; if (reader.Read()) { ret = (string)reader["name"]; } else { Log.Add(LogLevel.Warning, "SMS", String.Format("Number {0} not found in db.", number)); ret = number; } reader.Close(); return(ret); }
public override void Start() { try { Log.Add(LogLevel.Info, "SMS", "Opening device to port."); _gsm.Open(); StartReceiving(); } catch (Exception ex) { Log.AddException("SMS", ex); } }