public static void Main(string[] args) { listener = new Listener(LISTENER_PORT); listener.SocketAccepted += new Listener.SocketAcceptedHandler(l_SocketAccepted); listener.Start(); // helper = new SQLServerHelper("tcp:dndo40zalb.database.windows.net,1433", "comp2014@dndo40zalb", "20041908kjH", "TestSQLDB"); helper = new SQLServerHelper("Data Source=DANS-PC; Database=OccupOS;Trusted_Connection=True;"); Console.WriteLine("Listening for connections on port {0}...", LISTENER_PORT); Console.Read(); }
private static void Main(string[] args) { SQLServerHelper helper; DateTime now = DateTime.Parse("2013-04-13 01:05:22.0000000"); int data; int count = 10; // helper = new SQLServerHelper("tcp:dndo40zalb.database.windows.net,1433", "comp2014@dndo40zalb", "20041908kjH", "TestSQLDB"); helper = new SQLServerHelper("Data Source=DANS-PC; Database=OccupOS;Trusted_Connection=True;"); while (true) { data = 40 + new Random().Next(5); // if (helper.InsertSensorData(1, 1, (data).ToString(), now.AddSeconds(count), 3) > 0) if (helper.InsertSensorData(1, 1, data.ToString(), DateTime.Now, DateTime.Now, 3) > 0) { // System.Diagnostics.Debug.WriteLine("Light Data is inserted"); Console.WriteLine("Light Data is inserted"); } else { // System.Diagnostics.Debug.WriteLine("There was a problem inserting Light Data"); Console.WriteLine("There was a problem inserting Light Data"); } // System.Diagnostics.Debug.WriteLine(data); Console.WriteLine(DateTime.Now); Console.WriteLine(data); data = 20 + new Random().Next(10); // if (helper.InsertSensorData(1, 1, (data).ToString(), now.AddSeconds(count), 9) > 0) if (helper.InsertSensorData(1, 1, data.ToString(), DateTime.Now, DateTime.Now, 9) > 0) { // System.Diagnostics.Debug.WriteLine("Temperature Data is inserted"); Console.WriteLine("Temperature Data is inserted"); } else { // System.Diagnostics.Debug.WriteLine("There was a problem inserting Temperature data"); Console.WriteLine("There was a problem inserting Temperature data"); } count += 10; // System.Diagnostics.Debug.WriteLine(data); Console.WriteLine(DateTime.Now); Console.WriteLine(data); System.Threading.Thread.Sleep(10000); } }