示例#1
0
        private void change_password_button_Click(object sender, EventArgs e)
        {
            string password="";
            spacelocklinqDataContext data = new spacelocklinqDataContext();
            var query = from c in data.settings
                        where c.user == "admin"
                        select (c.Password);

            foreach (var item in query)
            {
                password = item.TrimEnd();
            }
            if (old_password_box.Text == password)
            {
                if (new_password_box.Text == confirm_new_password.Text && new_password_box.Text!="" && confirm_new_password.Text!="")
                {
                    spacelocklinqDataContext dat = new spacelocklinqDataContext();
                    var match = (from d in dat.GetTable<setting>()
                                 where d.user == "admin"
                                 select d).SingleOrDefault();
                    match.Password = confirm_new_password.Text;
                    match.Password.TrimEnd();
                    dat.SubmitChanges();
                    MessageBox.Show("Password Change Successful!");
                }
                else
                {
                    MessageBox.Show("Either the old password is wrong or the two passwords dont match");
                }
            }
            else
            {
                MessageBox.Show("Either the old password is wrong or the two passwords dont match");
            }
        }
示例#2
0
 private void change_number_button_Click(object sender, EventArgs e)
 {
     if (new_number_box.Text != "")
     {
         spacelocklinqDataContext data = new spacelocklinqDataContext();
         var match = (from d in data.GetTable<setting>()
                      where d.user == "admin"
                      select d).SingleOrDefault();
         match.Phone_Number = new_number_box.Text;
         match.Phone_Number.TrimEnd();
         data.SubmitChanges();
         displaynum();
     }
 }
示例#3
0
        /// <summary>
        /// This method constatly checks with the phone for any incomming message
        /// If a desired message is received from a particulaar number
        /// The application is either started or terminated
        /// </summary>
        private void read_sms()
        {
            SmsSubmitPdu pdu;
            string phone_number = "";
            int newPort = 10;
            spacelocklinqDataContext data = new spacelocklinqDataContext();
            var query = (from c in data.GetTable<setting>()
                         where c.user == "admin"
                         select c).SingleOrDefault();
            try
            {
                phone_number = query.Phone_Number.TrimEnd();
                newPort = query.Port_Number;
            }
            catch (Exception)
            {

            }
            send = "null";
            GsmCommMain comm = new GsmCommMain(newPort, 19200, 300);
            string storage = string.Empty;
            while (true)
            {
                try
                {
                    comm.Open();
                }
                catch (Exception)
                {
                    break;
                }

                storage = PhoneStorageType.Phone;
                SmsDeliverPdu del;
                DecodedShortMessage[] messages;
                try
                {
                    messages = comm.ReadMessages(PhoneMessageStatus.All, storage);
                }
                catch (Exception)
                {
                    break;
                }
                foreach (DecodedShortMessage message in messages)
                {
                    try
                    {
                        del = (SmsDeliverPdu)(message.Data);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                    if (del.UserDataText == "STOP" && del.OriginatingAddress == phone_number)
                    {
                        if (stop_check == false)
                        {
                            try
                            {
                                comm.DeleteMessage(message.Index, storage);
                            }
                            catch (Exception)
                            {
                                continue;
                            }
                            pdu = new SmsSubmitPdu("Space Lock has been deactivated", phone_number);
                            comm.SendMessage(pdu);
                            stop_check = true;
                            send = "stop";
                            //MessageBox.Show("STOP");  --ideamonk commented
                            try
                            {
                                comm.DeleteMessage(message.Index, storage);
                            }
                            catch (Exception)
                            {
                                continue;
                            }
                        }
                    }
                    if (del.UserDataText == "STOP" && del.OriginatingAddress == phone_number)
                    {
                        if (stop_check == true)
                        {
                            pdu = new SmsSubmitPdu("Wrong message! Space Lock has ALREADY been deactivated", phone_number);
                            comm.SendMessage(pdu);
                            try
                            {
                                comm.DeleteMessage(message.Index, storage);
                            }
                            catch (Exception)
                            {
                                continue;
                            }
                        }
                    }
                    if (del.UserDataText == "START" && del.OriginatingAddress == phone_number)
                    {
                        if (stop_check == true)
                        {
                            try
                            {
                                comm.DeleteMessage(message.Index, storage);
                            }
                            catch (Exception)
                            {
                                continue;
                            }
                            pdu = new SmsSubmitPdu("Space Lock has started", phone_number);
                            // the message is sent
                            comm.SendMessage(pdu);
                            stop_check = false;
                            send = "start";
                            try
                            {
                                comm.DeleteMessage(message.Index, storage);
                            }
                            catch (Exception)
                            {
                                continue;
                            }
                        }
                    }
                    if (del.UserDataText == "START" && del.OriginatingAddress == phone_number)
                    {
                        if (stop_check == false)
                        {
                            pdu = new SmsSubmitPdu("Space Lock is already running", phone_number);
                            // the message is sent
                            comm.SendMessage(pdu);
                            try
                            {
                                comm.DeleteMessage(message.Index, storage);
                            }
                            catch (Exception)
                            {
                                continue;
                            }
                        }
                    }
                }
                break;
            }
            try
            {
                comm.Close();

            }
            catch (Exception)
            {

            }
        }
示例#4
0
        public void start()
        {
            spacelocklinqDataContext data = new spacelocklinqDataContext();
            var match = (from d in data.GetTable<setting>()
                         where d.user == "admin"
                         select d).SingleOrDefault();
            sms_object.phone_number_change(match.Phone_Number.TrimEnd().ToString(), match.Port_Number);
            start_button.Enabled=false;
            close_button.Enabled=false;
            //settings_button.Enabled = false;
            settings_button.Hide();
            picWelcome.Visible = false;
            btnViewLog.Hide();
            btn_Browse.Hide();

            lock_button.Enabled=false;
            status_box.Show();
            password_box.Text = "";
            password_box.Show();
            password_label.Show();
            login_box.Show();
            stop_check = false;
            intrusion_check_variable = false;
            recording_check = false;
            rotation_check_variable = false;
            status_box.Items.Add("Login at: " + DateTime.Now);
            status_box.SelectedIndex = status_box.Items.Count - 1;
            status_box.SelectedIndex = -1;
            AppendLog();

            if (sms_object.check() == true)
            {
                status_box.Items.Add("Phone Connection Successful at " + DateTime.Now);
                status_box.SelectedIndex = status_box.Items.Count - 1;
                status_box.SelectedIndex = -1;
                AppendLog();
            }
            else
            {
                status_box.Items.Add("Phone Connection Unsuccessful at " + DateTime.Now);
                status_box.SelectedIndex = status_box.Items.Count - 1;
                status_box.SelectedIndex = -1;
                AppendLog();
            }
        }
示例#5
0
 private void test_phone_connection_button_Click(object sender, EventArgs e)
 {
     spacelocklinqDataContext dat = new spacelocklinqDataContext();
     var match = (from d in dat.GetTable<setting>()
                  where d.user == "admin"
                  select d).SingleOrDefault();
     try
     {
         match.Port_Number = int.Parse(com_port_box.Text.TrimEnd());
     }
     catch (Exception)
     {
         match.Port_Number = 10;
     }
     dat.SubmitChanges();
     GsmCommMain comm = new GsmCommMain(match.Port_Number, 19200, 300);
     try
     {
         comm.Open();
         comm.Close();
         MessageBox.Show("Phone Connection Successful");
     }
     catch (Exception)
     {
         MessageBox.Show("Phone Connection Unsuccessful");
     }
 }