public async Task <Account> GetAsync(long id)
 {
     using (var database = new AccountDatabase())
     {
         return(await database.GetAccountAsync(id));
     }
 }
Example #2
0
        static async void LoadDatabase()
        {
            while (guild == null)
            {
                guild = Program.GetGuild();
            }

            await guild.DownloadUsersAsync();

            supporterRole    = guild.GetRole(547202953505800233);
            supporterChannel = guild.GetTextChannel(547204432144891907);
            generalChannel   = guild.GetChannel(334933825383563266) as SocketTextChannel;

            try
            {
                database = FileDatabase.Read <AccountDatabase>("Accounts/accounts");

                Console.WriteLine("Loaded database!");

                foreach (AccountInfo account in database.accounts.Values)
                {
                    await UpdateAsync(account, null);
                }

                Console.WriteLine(database.accounts.Count);
                Console.WriteLine(database.expiryAccounts.Count);
            }
            catch (Exception e)
            {
                Console.WriteLine("Account database not found! " + e.Message);

                database = new AccountDatabase();
            }
        }
    public DataHandler(Queue <DataPacket> receiveQueue, Queue <DataPacket> sendQueue, object newReceiveLock, object newSendLock)
    {
        instance = this;

        receiveMsgs = receiveQueue;
        sendMsgs    = sendQueue;
        receiveLock = newReceiveLock;
        sendLock    = newSendLock;
        loginUser   = new Dictionary <Socket, string>();
        userState   = new Dictionary <string, UserState>();

        SetNotifier();

        database = AccountDatabase.Instance;
        database.InitailizeDatabase();
        monsterDatabase = MonsterDatabase.Instance;
        monsterDatabase.InitializeMonsterDatabase();
        dungeonDatabase = DungeonDatabase.Instance;
        dungeonDatabase.InitializeDungeonDatabase();
        monsterDatabase = MonsterDatabase.Instance;
        monsterDatabase.InitializeMonsterDatabase();
        characterDatabase = CharacterDatabase.Instance;
        characterDatabase.InitializeCharacterDatabase();
        roomManager = new RoomManager();

        Thread handleThread = new Thread(new ThreadStart(DataHandle));

        handleThread.Start();
        //Thread logoutCheckThread = new Thread(new ThreadStart(CheckLogoutUser));
        //logoutCheckThread.Start();
    }
Example #4
0
    public void SetupWithSenderAndText(string sender, string text)
    {
        Sprite badgeIconSprite;

        AccountDatabase.GetAccountImageBasedOnUserName(ref sender, out badgeIconSprite);
        badgeIconImage.sprite = badgeIconSprite;

        messageText.text = text;

        //Rebuild the layout immediately to get the layout groups and content size fitters
        //to apply to this dynamically UI added element
        LayoutRebuilder.ForceRebuildLayoutImmediate(this.transform.parent as RectTransform);
    }
        public bool ValidateUsername()
        {
            // Check account database for existing username
            AccountDatabase database = new AccountDatabase();

            database.OpenConnection();
            // If there is an existing account, update the validation message
            if (database.LookUpAccountRecord(Username, Password).ErrorString != "no record found")
            {
                usernameValidationMessage = "\u2022 Username already exists. \n";
            }
            else if (Username == null || Username.Trim().Length == 0)
            {
                UsernameValidationMessage = "\u2022 Username cannot be empty. \n";
            }
            else
            {
                UsernameValidationMessage = null;
                if (Username.Trim().Length < 7)
                {
                    UsernameValidationMessage += "\u2022 Username must be at least 7 characters long. \n";
                }
                if (Username.Trim().Length > 20)
                {
                    UsernameValidationMessage += "\u2022 Username cannot be more than 20 characters long. \n";
                }
                if ((Username.Any(char.IsWhiteSpace)))
                {
                    UsernameValidationMessage += "\u2022 Username cannot contain spaces. \n";
                }
            }
            // Close connection to Account Database
            database.CloseConnection();
            // If username has not been disqualified, send an "acceptable" message
            if (UsernameValidationMessage == null)
            {
                UsernameValidationMessage = "\u2022 Username is acceptable. \n";
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void CreateAccount()
        {
            // Open a connection to the Account Database
            AccountDatabase database = new AccountDatabase();

            database.OpenConnection();
            // Send the request to generate a new account and store result in accountCreated property
            AccountRecord newlyCreatedAccount = new AccountRecord();

            newlyCreatedAccount.Username = Username;
            AccountCreated = database.AddAccountRecord(newlyCreatedAccount, Password);
            // Close connection to the Account Database
            database.CloseConnection();
            AccountCreated = true;
            if (AccountCheck && AccountCreated)
            {
                AccountValidationMessage = "\u2022 Account created.  Log in to play!";
            }
        }
Example #7
0
        public void ValidateAccountAndLogin()
        {
            // Open connection to the Account Database
            AccountDatabase database = new AccountDatabase();

            database.OpenConnection();
            // Check whether the username/password combination is valid or not
            AccountRecord loginAccount = database.LookUpAccountRecord(Username, Password);

            if (loginAccount.ErrorString == "valid record")
            {
                AccountValidationMessage = "Successful login";
                LoginCompleted           = true;
            }
            else
            {
                AccountValidationMessage = "Failed login. Check username and password and try again.";
                LoginCompleted           = false;
            }
        }
    public DataHandler()
    {
        receiveMsgs = new Queue <DataPacket>();
        sendMsgs    = new Queue <DataPacket>();
        receiveLock = new object();
        sendLock    = new object();
        loginUser   = new Dictionary <Socket, string>();
        userState   = new Dictionary <string, UserState>();

        SetNotifier();

        database = AccountDatabase.Instance;
        database.InitailizeDatabase();
        dungeonDatabase = DungeonDatabase.Instance;
        dungeonDatabase.InitializeDungeonDatabase();
        monsterDatabase = MonsterDatabase.Instance;
        monsterDatabase.InitializeMonsterDatabase();

        roomManager = new RoomManager();

        Thread handleThread = new Thread(new ThreadStart(DataHandle));

        handleThread.Start();
    }
 public TellerController(AccountDatabase a, CustomerDatabase c)
 {
     aDatabase = a;
     cDatabase = c;
 }
Example #10
0
 public TellerController(AccountDatabase a, CustomerDatabase c)
 {
     aDatabase = a;
     cDatabase = c;
 }
 /// <summary>
 /// The constructor takes handles from the databases, and adds them to the private fields.
 /// </summary>
 /// <param name="c">A handle to the customer database.</param>
 /// <param name="a">A handle to the account database.</param>
 public AtmPresenter(CustomerDatabase c, AccountDatabase a)
 {
     aDatabase = a;
     cDatabase = c;
 }
Example #12
0
        static void Main(string[] args)
        {
            // Choose Test
            Console.WriteLine("account or gameElements?");
            string response1 = Console.ReadLine();

            // Test Accounts
            if (response1 == "account")
            {
                Console.WriteLine("read or write?");
                string response2 = Console.ReadLine();
                // Test Writing a New Account
                if (response2 == "write")
                {
                    Console.WriteLine("Beginning Write Test...");
                    AccountRecord   testRecord = new AccountRecord();
                    AccountDatabase database   = new AccountDatabase();
                    database.OpenConnection();
                    //request dummy data
                    Console.WriteLine("Please provide a username:"******"Please provide a password:"******"A duplicate exists.  No account was created.  Try a different name.");
                    }
                    database.CloseConnection();
                }
                // Test Reading an Existing Account
                else
                {
                    Console.WriteLine("Beginning Read Test...");
                    AccountRecord   testRecord = new AccountRecord();
                    AccountDatabase database   = new AccountDatabase();
                    database.OpenConnection();
                    //request dummy data
                    Console.WriteLine("Please provide a username:"******"Please provide a password:"******"Hello {testRecord.Username}!");
                    Console.WriteLine(testRecord.ErrorString);
                    database.CloseConnection();
                }
            }
            // Test Other Database Activity
            else
            {
                Console.WriteLine("Beginning Other Database Test...");
                CardDatabase  database = new CardDatabase();
                List <string> names    = new List <string>();
                database.OpenConnection();
                // Test Pull All String Names
                names = database.RequestAllGameElementNames();
                foreach (string name in names)
                {
                    Console.WriteLine(name);
                }
                Console.WriteLine("Test 1 Complete.");
                CardDealer  dealer = new CardDealer();
                List <Card> cards1 = dealer.ListAllCards();
                // Test Pull All Card Records
                List <Card> moreCards = new List <Card>();
                foreach (Card card2 in cards1)
                {
                    Console.WriteLine(card2.Name);
                }
                Console.WriteLine("Test 2 Complete.");
                // Test Pull a Specific Card Record
                SystemCard  sensor = dealer.ChooseRandomSensor();
                List <Card> cards6 = dealer.DealCardsForSensor(sensor);
                foreach (Card carde in cards6)
                {
                    Console.WriteLine(carde.Name);
                }
                Console.WriteLine(sensor.Name);
                Console.WriteLine("Please Provide the name of one of the cards above (type exactly):");
                CardRecord card = database.RequestCardByName(Console.ReadLine());
                Console.WriteLine($"{card.Name},{card.ADCType},{card.IsMultiplexed},{card.SignalConditioning}");

                database.CloseConnection();
            }
            Console.WriteLine("Nothing went wrong in this tests");
            Console.ReadLine();
        }
Example #13
0
 /// <summary>
 /// The constructor takes handles from the databases, and adds them to the private fields.
 /// </summary>
 /// <param name="c">A handle to the customer database.</param>
 /// <param name="a">A handle to the account database.</param>
 public AtmPresenter(CustomerDatabase c, AccountDatabase a)
 {
     aDatabase = a;
     cDatabase = c;
 }