示例#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
        public Home()
        {
            InitializeComponent();

            //t.Start(stop_check);
            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(); ;
            }
            /*
            start_button.Enabled=false;
            status_box.Hide();
            stop_button.Enabled=false;
            lock_button.Enabled=false;
            settings_button.Hide();
            */
            // Changes -- ideamonk
                start_button.Enabled = false;
                status_box.Enabled = false;
                stop_button.Enabled = false;
                lock_button.Enabled = false;
                settings_button.Hide();
                picWelcome.Visible = false;
                btnViewLog.Hide();
                btn_Browse.Hide();
            // end Changes

            /* ---------------- Adding stats to a log fine ---------------  -- */
            // Truncate the log if too big
            // = File.ReadAllBytes(Application.StartupPath.ToString() + "\\SpaceLockLog.txt");
                MAX_LOG_SIZE = 102400;          // 100 KB
                try
                {
                    initialContent = File.ReadAllBytes(Application.StartupPath.ToString() + "\\SpaceLockLog.txt");
                    if (initialContent.Length > MAX_LOG_SIZE)
                    {
                        // Empty the log file
                        LogSW = File.CreateText(Application.StartupPath.ToString() + "\\SpaceLockLog.txt");
                        LogSW.WriteLine("SpaceLock Log truncated on " + System.DateTime.Today.ToString() + ", " + DateTime.Now.ToString());
                        LogSW.Close();
                    }
                }
                catch
                {
                    // Log file does not exist
                }

                // Open the log file in append mode
                LogSW = File.AppendText(Application.StartupPath.ToString() + "\\SpaceLockLog.txt");
            // Change Ends --------------- ]]

            // -------------------- Settings for Calling MotorController.exe --ideamonk
                proc = new System.Diagnostics.Process();
                proc.StartInfo.FileName = Application.StartupPath.ToString() + "\\MotorController.exe";
                proc.StartInfo.UseShellExecute = false;
                proc.StartInfo.RedirectStandardOutput = false;
            // Change ends ]]  19 Apr 2009

            // -------------------- Settings for Calling MotionDetect2.exe process --ideamonk
                procMotionDetect = new System.Diagnostics.Process();
                procMotionDetect.StartInfo.FileName = Application.StartupPath.ToString() + "\\MotionDetect2.exe";
                procMotionDetect.StartInfo.UseShellExecute = false;
                procMotionDetect.StartInfo.RedirectStandardOutput = false;
        }
示例#4
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)
            {

            }
        }
示例#5
0
        private void login()
        {
            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 (password_box.Text == password)
            {
                password_box.Hide();
                password_label.Hide();
                login_box.Hide();
                start_button.Enabled=true;
                settings_button.Show();
                picWelcome.Visible = true;
                btnViewLog.Show();
                btn_Browse.Show();
                close_button.Enabled=true;
                lock_button.Enabled=true;
                login_check = true;
            }
            else
                MessageBox.Show("Wrong Password!");
        }
示例#6
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();
            }
        }
示例#7
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");
     }
 }
示例#8
0
        private void displaynum()
        {
            spacelocklinqDataContext data = new spacelocklinqDataContext();
            var query = from c in data.settings
                        where c.user == "admin"
                        select (c.Phone_Number);

            foreach (var item in query)
            {
                current_phone_number_box.Text = item.TrimEnd();
            }
        }