Пример #1
0
        private void metroButton_redeem_Click(object sender, EventArgs e)
        {
            if (metroTextBox_accesscode.Text.Trim().Length == 4)
            {
                try
                {
                    if (MiscClass.CheckNetworkAvailablity(tw.adapter_public, tw.ip_public))
                    {
                        if (!MiscClass.GetConfigValue("ActiveSession").Equals(""))
                        {
                            string[] values = MiscClass.GetConfigValue("ActiveSession").Split(new string[] { "{{Session}}" }, StringSplitOptions.None);

                            if (Session.PauseSession_CloseUnexpectedly(values[0], values[1]))
                            {
                                MiscClass.SetConfigValue("ActiveSession", "");
                            }
                        }

                        metroTextBox_accesscode.Enabled = false;
                        metroButton_redeem.Enabled      = false;

                        var sessionobject = Session.GetNonClosedSession(mypc.Id, metroTextBox_accesscode.Text.Trim());

                        if (sessionobject.StartSession("Session Start By User", null))
                        {
                            CommandControl cc = new CommandControl(sessionobject, mypc, tw, gkh);
                            server.Stop();
                            backgroundWorker1.CancelAsync();
                            cc.Show();
                            this.Close();
                        }

                        else
                        {
                            MessageBox.Show("Some thing went wrong while starting your session !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                finally
                {
                    metroTextBox_accesscode.Enabled = true;
                    metroButton_redeem.Enabled      = true;
                }
            }
            else
            {
                MessageBox.Show("Access code should be 4 characters long.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void button_start_Click(object sender, EventArgs e)
        {
            try
            {
                if (pc != null)
                {
                    if (MiscClass.CheckNetworkAvailablity(adapter_public, ip_public))
                    {
                        if (checkBox_monitorprocess.Checked)
                        {
                            is_monitorable_public = "Yes";
                        }

                        else
                        {
                            is_monitorable_public = "No";
                        }

                        if (!GetConfigValue("LogPath").Equals(""))
                        {
                            if (Directory.Exists(GetConfigValue("LogPath")))
                            {
                                LockWindow lw = new LockWindow(pc, this);
                                lw.Show();
                                this.Visible       = false;
                                this.ShowInTaskbar = false;
                            }
                            else
                            {
                                MessageBox.Show("LogPath directory is not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }

                        else
                        {
                            MessageBox.Show("LogPath is not set.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }