public static void WriteToDB(Call c) { string commandString = String.Format( "insert into call([dateTime], [milliseconds], channel, radio, [group]) " + "values ('{0}', {1}, {2}, {3}, {4})", c.time, c.time.Millisecond, c.channel, c.radio, c.group); //Console.WriteLine(commandString); OdbcCommand command = new OdbcCommand(commandString, connection); command.ExecuteNonQuery(); }
public override void receivedFrequency(OSW osw) { int channel = osw.command; int radio = lastOSW.group; int group = osw.group & 0xfff0; if (calls.ContainsKey(group) == true) { if (calls[group].radio == radio) { if (calls[group].time < DateTime.Now.AddSeconds(-2)) { calls[group].time = DateTime.Now; calls[group].channel = channel; Program.WriteToDB(calls[group]); } else { currentState = stateNormal; return; } } else { calls[group].radio = radio; calls[group].channel = channel; calls[group].time = DateTime.Now; Program.WriteToDB(calls[group]); } } else { Call c = new Call(group, radio, channel); calls.Add(group, c); Program.WriteToDB(c); } Console.WriteLine("Call on channel: {0} radio: {1} --> group: {2}", osw.command, lastOSW.group, osw.group & 0xfff0); //Console.WriteLine("Received 308/Freq"); currentState = stateNormal; }