Esempio n. 1
0
 protected void OnLogOutButtonClicked(object sender, EventArgs e)
 {
     db.logout();
     VotingMultiChain.LoginWindow win = new VotingMultiChain.LoginWindow(client, sshClient, db);
     win.Show();
     this.Destroy();
 }
        protected void OnLogOutButtonClicked(object sender, EventArgs e)
        {
            //If the user has not tried to vote yet have a message dialogue pop up when logging out
            if (!hasVoted)
            {
                var dialog = new MessageDialog(this,
                                               DialogFlags.Modal,
                                               MessageType.Info,
                                               ButtonsType.YesNo,
                                               "Are you sure you want to logout?");
                dialog.Response += (object o, ResponseArgs args) =>
                {
                    if (args.ResponseId == ResponseType.Yes)
                    {
                        db.logout();
                        VotingMultiChain.LoginWindow win = new VotingMultiChain.LoginWindow(client, sshClient, db);
                        win.Show();
                        this.Destroy();
                    }
                    else if (args.ResponseId == ResponseType.No)
                    {
                        //Do nothing user is still on the voting screen
                    }
                    else if (args.ResponseId == ResponseType.DeleteEvent)
                    {
                        //Do nothing user is still on the voting screen
                    }
                    dialog.Destroy();
                };

                dialog.Run();
            }
            //User has already voted logging out is fine no need for message
            else
            {
                db.logout();
                VotingMultiChain.LoginWindow win = new VotingMultiChain.LoginWindow(client, sshClient, db);
                win.Show();
                this.Destroy();
            }
        }
Esempio n. 3
0
        protected void OnClientConnectClicked(object sender, EventArgs e)
        {
            // Call task to connect to client blockchain
            try
            {
                isMainStation();                 //Check whether this machine is the main station
                if (!mainStation)                //Only Voting Stations require SSH connection to access database in Main Station
                {
                    connectToSsh();
                }
                connectToDB();

                var task = Task.Run(async() =>
                {
                    await connectToChain();
                });

                task.Wait();
            }
            catch (Exception ex)
            {
                Console.WriteLine("******************");
                Console.WriteLine(ex);

                MessageDialog md = new MessageDialog(this, DialogFlags.DestroyWithParent,
                                                     MessageType.Error, ButtonsType.Close,
                                                     "Could not connect to chain, please ensure you have entered the correct details.");
                md.Run();
                md.Destroy();
            }

            //Open login screen and close this if client connected successfully
            if (clientConnected)
            {
                VotingMultiChain.LoginWindow win = new VotingMultiChain.LoginWindow(client, sshClient, db);
                win.Show();
                this.Destroy();
            }
        }