Ejemplo n.º 1
0
        /// <summary>
        /// Gets a player from the server.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The DoWorkEventArgs object that
        /// contains the event data.</param>
        private void GetPlayer(object sender, DoWorkEventArgs e)
        {
            // Set the language.
            if (m_forceEnglish)
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            }

            Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

            // Wait a couple of ticks to let the wait form display.
            Thread.Sleep(100);

            // Unbox the param.
            int playerId = (int)e.Argument;

            Player player = null;

            try
            {
                player = new Player(playerId, m_operatorId);
            }
            catch (ServerCommException)
            {
                throw; // Don't repackage the ServerCommException
            }
            catch (ServerException ex)
            {
                throw new ModuleException(string.Format(CultureInfo.CurrentCulture, (m_machineAccounts) ? Resources.GetMachineFailed : Resources.GetPlayerFailed, ServerExceptionTranslator.FormatExceptionMessage(ex)) + " " + string.Format(CultureInfo.CurrentCulture, Resources.MessageName, ex.Message), ex);
            }
            catch (Exception ex)
            {
                throw new ModuleException(string.Format(CultureInfo.CurrentCulture, (m_machineAccounts) ? Resources.GetMachineFailed : Resources.GetPlayerFailed, ServerExceptionTranslator.FormatExceptionMessage(ex)), ex);
            }

            e.Result = player;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a list of players from the server.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">The DoWorkEventArgs object that
        /// contains the event data.</param>
        private void SearchPlayers(object sender, DoWorkEventArgs e)
        {
            // Set the language.
            if (m_forceEnglish)
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            }

            Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

            // Wait a couple of ticks to let the wait form display.
            Thread.Sleep(100);

            // Unbox the search params.
            string[] parameters = (string[])e.Argument;

            if (!string.IsNullOrEmpty(parameters[0])) // Mag. Card
            {
                FindPlayerByCardMessage cardMsg = new FindPlayerByCardMessage();
                cardMsg.MagCardNumber = parameters[0];

                // Send the message.
                try
                {
                    cardMsg.Send();

                    if (cardMsg.SyncError != string.Empty)
                    {
                        throw new Exception(cardMsg.SyncError);
                    }
                }
                catch (ServerCommException ex)
                {
                    throw ex; // Don't repackage the ServerCommException
                }
                catch (Exception ex)
                {
                    throw new ModuleException(string.Format((m_machineAccounts) ? Resources.GetMachineFailed : Resources.GetPlayerFailed, ServerExceptionTranslator.FormatExceptionMessage(ex)), ex);
                }

                if (cardMsg.PlayerId > 0)
                {
                    PlayerListItem item = new PlayerListItem();
                    item.Id            = cardMsg.PlayerId;
                    item.LastName      = cardMsg.LastName;
                    item.FirstName     = cardMsg.FirstName;
                    item.MiddleInitial = cardMsg.MiddleInitial;

                    e.Result = new PlayerListItem[] { item };
                }
            }
            else // First and Last Name
            {
                GetPlayerListMessage listMsg = new GetPlayerListMessage();
                listMsg.LastName  = parameters[1];
                listMsg.FirstName = parameters[2];

                // Send the message.
                try
                {
                    listMsg.Send();
                }
                catch (ServerCommException ex)
                {
                    throw ex; // Don't repackage the ServerCommException
                }
                catch (Exception ex)
                {
                    throw new ModuleException(string.Format((m_machineAccounts)? Resources.GetMachineListFailed : Resources.GetPlayerListFailed, ServerExceptionTranslator.FormatExceptionMessage(ex)), ex);
                }

                e.Result = listMsg.Players;
            }
        }