private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; timer1.Stop(); picPollGreenLed.Enabled = true; picPollStopedLed.Enabled = false; picPollStopedLed.Hide(); picPollGreenLed.Show(); // Do Poll for (int x = 0; x < g_pollList.Count; x++) { if (g_pollList[x] != null) // is poll == true { String Gen_mobile = (String)g_pollList[x]; if (Gen_mobile.Contains("+") && Gen_mobile.Length >= GEN_ID_DIGITS) // { String message = "REPORT"; gprsPoll.sendSMSMsg(this.usbPollport, Gen_mobile, message); Thread.Sleep(300); } //Gen_mobile = "+923363111563"; //"+923332383079" A Hayee; } }//orgs // Thread.Sleep(1000); picPollGreenLed.Enabled = false; picPollStopedLed.Enabled = true; picPollStopedLed.Show(); picPollGreenLed.Hide(); Int32 Interval = Convert.ToInt32(ConfigurationManager.AppSettings["GenPollTime"]); timer1.Interval = Interval * 1000; // seconds timer1.Enabled = true; timer1.Start(); }
private void btnLocGenRemove_Click(object sender, EventArgs e) { // Remove poll gen set PollCust & PollGen Poll bit = 0' // String SqlPGenPoll0 = String.Format(@"UPDATE PollGenerators SET poll = 0 WHERE Cust_Id = {0}",g_cuidList[comboGenLoc.SelectedIndex]); // String SqlPGenSetPoll0 = String.Format(@"UPDATE PollGenerators SET poll = 0 WHERE Cust_Id ={0} AND Gen_Id='{1}'", g_cuidList[comboGenLoc.SelectedIndex], genidList[comboGenLoc.SelectedIndex]); String SqlPGenPoll0 = String.Format(@"UPDATE PollGenerators SET poll = 0 WHERE Cust_Id = {0}", g_cuidList[listGenLoc.SelectedIndex]); String SqlPGenSetPoll0 = String.Format(@"UPDATE PollGenerators SET poll = 0 WHERE Cust_Id ={0} AND Gen_Id='{1}'", g_cuidList[listGenLoc.SelectedIndex], genidList[listGenLoc.SelectedIndex]); try { if (conn.State != ConnectionState.Open) { conn.Open(); } if (checkBoxLocGen.Checked) { using (SqlCommand cmd = new SqlCommand(SqlPGenPoll0, conn)) { cmd.CommandTimeout = 60; cmd.ExecuteNonQuery(); } if (rbTimer.Checked) { // Send REPORT=0 to stop intensive monitoring for (int x = 0; x < genidList.Count; x++) { String Gen_mobile = genidList[x]; if (Gen_mobile.Contains("+") && Gen_mobile.Length >= GEN_ID_DIGITS) // { String message = "REPORT=0"; // Stop Intensive Monitoring gprsPoll.sendSMSMsg(this.usbPollport, Gen_mobile, message); Thread.Sleep(2000); } } } } else { using (SqlCommand cmd = new SqlCommand(SqlPGenSetPoll0, conn)) { cmd.CommandTimeout = 60; cmd.ExecuteNonQuery(); } // Send : REPORT=0 String Gen_mobile = genidList[listGenLoc.SelectedIndex]; // if (Gen_mobile.Contains("+") && Gen_mobile.Length >= GEN_ID_DIGITS) // { if (rbTimer.Checked) // only send report=0 in timed polling mode. { String message = "REPORT=0"; // Stop Intensive Monitoring try { gprsPoll.sendSMSMsg(this.usbPollport, Gen_mobile, message); } catch (Exception ex) { MessageBox.Show("Modem error"); } Thread.Sleep(1000); } } //Gen_mobile = "+923363111563"; //"+923332383079" A Hayee; // UpdatePollList(); // update Gen polls list } object sender2 = new object(); EventArgs e2 = new EventArgs(); listBoxOrgs_SelectedIndexChanged(sender2, e2); // refresh display } catch (Exception ex) { if (conn.State == ConnectionState.Open) { conn.Close(); } } { if (conn.State == ConnectionState.Open) { conn.Close(); } } }