예제 #1
0
        /// <summary>
        /// Test WCF service by sending info to it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSendItem_Click(object sender, EventArgs e)
        {
            if (AreSendErrorsDetected())
            {
                MessageBox.Show("Cannot send item until all errors fixed.");
                return;
            }

            Score item = new Score();

            item.Name   = txtName.Text;
            item.Points = int.Parse(txtScore.Text);

            if (picImage.Image != null)
            {
                using (MemoryStream memory = new MemoryStream())
                {
                    picImage.Image.Save(memory, ImageFormat.Jpeg);
                    item.Picture = memory.ToArray();
                }
            }

            try
            {
                using (ScoreServiceClient client = new ScoreServiceClient())
                {
                    client.Add(item);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Utilities.GetAllExceptions(ex), "Exception attempting to send info to server.");
            }
        }
예제 #2
0
        public static void Send(string character, string name, int points)
        {
            byte[] picture = GetGamerAvatar(character);

            using (var client = new ScoreServiceClient())
            {
                client.Add(new Score()
                {
                    Name    = name,
                    Points  = points,
                    Picture = picture,
                });
            }
        }
예제 #3
0
 /// <summary>
 /// Test WCF service by pinging it.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnTestConnection_Click(object sender, EventArgs e)
 {
     lblTime.Text = "(Testing for service response)";
     try
     {
         ScoreServiceClient item = new ScoreServiceClient();
         lblTime.Text = item.GetTime();
     }
     catch (Exception ex)
     {
         MessageBox.Show(Utilities.GetAllExceptions(ex), "Exception attempting to get time from server.");
         lblTime.Text = "*****  Exception  *****";
     }
 }
 private void OnDestroy()
 {
     if (isLocalPlayer)
     {
         ResetCamera();
         ScoreServiceClient client = new ScoreServiceClient(new NetTcpBinding(SecurityMode.None), new EndpointAddress("net.tcp://" + CurrentPlayer.IPDirection + ":8091/ScoreService"));
         Pacman_Sevices.IScoreServiceUser score = new Pacman_Sevices.IScoreServiceUser();
         score.Puntuación = kills;
         score.Nombre     = CurrentPlayer.Username;
         client.SetScore(score, kills);
         kills  = 0;
         deaths = 0;
     }
 }
예제 #5
0
        /// <summary>
        /// Send all info to scoring server.
        /// </summary>
        /// <param name="image"></param>
        /// <param name="score"></param>
        /// <param name="name"></param>
        private void SendToServer(Image image, int score, string name)
        {
            Score item = new Score();

            item.Name   = txtName.Text;
            item.Points = _mainForm.Score;

            if (image != null)
            {
                // Scale image to desired send size.
                Image scaledForServer = new Bitmap(image, _mainForm._settings.Size_HeadImageToScoringServer);

                using (MemoryStream memory = new MemoryStream())
                {
                    scaledForServer.Save(memory, ImageFormat.Jpeg);
                    item.Picture = memory.ToArray();
                }
            }

            try
            {
                if (_mainForm._settings.WriteToServerDuringSubmit)
                {
                    using (ScoreServiceClient client = new ScoreServiceClient())
                    {
                        client.Add(item);

                        // Wait brief time then exit application.
                        Thread.Sleep(500);
                    }
                }

                // Exit app.
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(Utilities.GetAllExceptions(ex), "Exception attempting to send info to server.");
            }
        }
예제 #6
0
        private void buttonSubmitScore_Click(object sender, RoutedEventArgs e)
        {
            ((Button) sender).IsEnabled = false;
            var score = new TbScore
                            {
                                ScoreValue = _highScore,
                                UserName = textUserName.Text,
                                ScoreDate = DateTime.Now
                            };
            if ((bool) checkBoxNotify.IsChecked)
                score.EmailAddress = textBoxEmail.Text;

            var ss = new ScoreServiceClient();
            //var ss = new ScoreServiceSoapClient();

            ss.SaveScoreCompleted += ss_SaveScoreCompleted;
            ss.SaveScoreAsync(score);
        }
예제 #7
0
        private void GetLatestHighScores()
        {
            lblHallOfFame.Text = "Loading Hall of Fame...";

            var ss = new ScoreServiceClient();
            //var ss = new ScoreServiceSoapClient();
            ss.GetLatestScoresCompleted += ss_GetLatestScoresCompleted;
            ss.GetLatestScoresAsync();
        }