public static void getsession()
        {
            try {
                using (WebClient client = new WebClient())
                {
                    byte[] response = client.UploadValues("https://" + Preference.serverip + "/getSession", new NameValueCollection()
                    {
                    });

                    Preference.sessionkey = Encoding.UTF8.GetString(response).Replace("\n", "");
                    Preference.auth       = SharedFunctions.EncryptStringToBytes_Aes(Preference.sessionkey, Encoding.ASCII.GetBytes(Preference.secretkey));
                }
            }
            catch (Exception)
            {
            }
        }
Example #2
0
 public WhichLab(Boolean reinstall)
 {
     InitializeComponent();
     if (SharedFunctions.getroomnames())
     {
         labdropdown.DataSource    = Preference.pilist;
         labdropdown.DisplayMember = "RoomName";
         if (!reinstall)
         {
             selectalabprompt.Text = "Select a lab:";
         }
         else
         {
             selectalabprompt.Text = "Select your existing lab:";
         }
     }
     else
     {
         MessageBox.Show("Please connect to the internet.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         Preference.closeform = true;
         Close();
     }
 }
Example #3
0
        private void okbutton_Click(object sender, EventArgs e)
        {
            if (frequency.Text != "")
            {
                Preference.backupfrequency = Int32.Parse(frequency.Text);
                Properties.Settings.Default.backupfrequency = Preference.backupfrequency;
            }

            if (backupdirectory.Text != "")
            {
                Preference.backupdirectory = backupdirectory.Text;
                Properties.Settings.Default.backupdirectory = Preference.backupdirectory;
            }

            if (directorysize.Text != "")
            {
                Preference.directorysize = Int32.Parse(directorysize.Text);
                Properties.Settings.Default.directorysize = Preference.directorysize;
            }

            //if (password.Text != "")
            //{
            //    passwordsaved = SharedFunctions.createuser();
            //    if (!passwordsaved)
            //    {
            //        MessageBox.Show("Please connect to the internet.");
            //    }
            //    else
            //    {
            //        Preference.password = password.Text;
            //        Properties.Settings.Default.password = Preference.password;
            //    }
            //}

            Properties.Settings.Default.processlist = string.Join(",", Preference.processlist);

            Preference.trustedprocesslist = trustedlist.CheckedItems.Cast <string>().ToList();
            Properties.Settings.Default.trustedprocesslist = string.Join(",", Preference.trustedprocesslist);
            Properties.Settings.Default.noofmonths         = noofmonths.Value;
            Properties.Settings.Default.runatstartup       = runatstartupcheckbox.Checked;
            Boolean updatesuccess = false;

            //wanted to provide support to change email but realised it is not possible as we need to update the directory name on pi and cloud
            if (Regex.IsMatch(email.Text, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase))
            {
                if (Preference.noofmonths != Properties.Settings.Default.noofmonths || Preference.email != email.Text)
                {
                    if (Preference.noofmonths != Properties.Settings.Default.noofmonths)
                    {
                        if (SharedFunctions.updatenoofmonths(noofmonths.Value))
                        {
                            updatesuccess         = true;
                            Preference.noofmonths = noofmonths.Value;
                            Properties.Settings.Default.Save();
                        }
                        else
                        {
                            MessageBox.Show("Please connect to the internet.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }

                    if (Preference.email != email.Text)
                    {
                        if (SharedFunctions.changeemail(Preference.email, email.Text))
                        {
                            updatesuccess    = true;
                            Preference.email = email.Text;
                            Properties.Settings.Default.email = Preference.email;
                            Properties.Settings.Default.Save();
                            Close();
                        }
                        else
                        {
                            MessageBox.Show("Please connect to the internet.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }

                    if (updatesuccess)
                    {
                        Close();
                    }
                }
                else
                {
                    Properties.Settings.Default.Save();
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Please enter a valid email.");
            }
        }