Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // Create the database and tables if required
            try
            {
                if (!WowSQLController.CheckDatabaseExists())
                {
                    string errStr = WowSQLController.CreateDatabaseNTables();

                    if (!string.IsNullOrEmpty(errStr))
                    {
                        Console.WriteLine(errStr);
                    }
                }

                if (!WowSQLController.CheckTableExists())
                {
                    string errStr = WowSQLController.CreateTables();

                    if (!string.IsNullOrEmpty(errStr))
                    {
                        Console.WriteLine(errStr);
                    }
                }
            }
            catch (Exception)
            { /* Do some exception logging here */ }

            // Create the WowService URI base address and ServiceHost.
            Uri baseAddress = new Uri("http://localhost:8000/WowLoginServiceLib/");

            WSHttpBinding binding = new WSHttpBinding();

            binding.Security.Mode = SecurityMode.None;

            ServiceHost serviceHost = new ServiceHost(typeof(WowService), baseAddress);

            try
            {
                // Add a service endpoint.
                serviceHost.AddServiceEndpoint(typeof(IWowService), binding, "WowService");

                // Enable metadata exchange.
                ServiceMetadataBehavior metaDataBehaviour = new ServiceMetadataBehavior();
                metaDataBehaviour.HttpGetEnabled = true;
                serviceHost.Description.Behaviors.Add(metaDataBehaviour);

                // Start the WowService.
                serviceHost.Open();
                Console.WriteLine("The WowService is active.\nPress <ENTER> to terminate the service.");
                Console.ReadLine();

                serviceHost.Close();
            }
            catch (CommunicationException ex)
            {
                Console.WriteLine("An exception occurred: {0}", ex.Message);
                serviceHost.Abort();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Add a new character to the account.
 /// </summary>
 /// <param name="playerData">Account we are adding a character to.</param>
 /// <param name="character">The new character we are adding.</param>
 /// <returns>
 /// True:  The new character was successfully added to the player account.
 /// False: The new character could not be added to the player account.
 /// </returns>
 public bool AddCharacterToAccount(PlayerData playerData, Character character)
 {
     return(WowSQLController.AddCharacter(playerData, character));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Retrieve all of the characters in the database.
 /// </summary>
 /// <returns>
 /// List of all characters in the database.</returns>
 public List <Character> RetrieveAllCharacters()
 {
     return(WowSQLController.RetrieveAllCharacters());
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Create a new player account.
 /// </summary>
 /// <param name="accountName">Name of the player account.</param>
 /// <param name="password">Password for the account.</param>
 /// <param name="isAdmin">Account has administrator privileges.</param>
 /// <returns>
 /// True:  New account was successfully created.
 /// False: New account could not be created.
 /// </returns>
 public bool CreateAccount(string accountName, string password, bool isAdmin)
 {
     return(WowSQLController.CreateAccount(accountName, password, isAdmin));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Retrieve the characters for the account.
 /// </summary>
 /// <param name="accountName">Name of the players account.</param>
 /// <returns>
 /// The list of the accounts characters.
 /// </returns>
 public List <Character> RetrieveAccountCharacters(string accountName)
 {
     return(WowSQLController.RetrieveAccountCharacters(accountName));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Login a player account.
        /// </summary>
        /// <param name="accountName">Players account name.</param>
        /// <param name="password">Account password.</param>
        /// <param name="isAdmin">Returns whether the account has administrator privileges.</param>
        /// <returns>
        /// Accounts playerData and characters
        /// </returns>
        public PlayerData Login(string accountName, string password, out bool isAdmin)
        {
            PlayerData playerData = WowSQLController.LoginAccount(accountName, password, out isAdmin);

            return(playerData);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Delete a character from an account.
 /// </summary>
 /// <param name="playerData">Account we are deleting a character from.</param>
 /// <param name="character">Character to delete from the account.</param>
 public void DeleteCharacterFromAccount(PlayerData playerData, Character character)
 {
     WowSQLController.DeleteCharacter(playerData, character);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Update the levels of the characters passed in.
 /// </summary>
 /// <param name="characters">List of characters to update.</param>
 public void UpdateCharacterLevels(List <Character> characters)
 {
     WowSQLController.UpdateCharacterLevels(characters);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Update the accounts characters.
 /// </summary>
 /// <param name="playerData">The account whose characters are being updated.</param>
 public void UpdateCharactersForPlayer(PlayerData playerData)
 {
     WowSQLController.UpdateCharacters(playerData);
 }