Ejemplo n.º 1
0
        public async void UnlockAccount_work()
        {
            var account      = new Account.Account();
            var isSuccessful = await account.UnlockAccountAsync(url, "0xdc6626c228f2f093ab1dc052b6a75f48bfadbd5c", "123456");

            Assert.True(isSuccessful);
        }
        public void Approve(Account.Account approverAccount, User approverUser)
        {
            RequiresApproverAccountIsTheReceiverAccount(approverAccount);
            RequiresTransferConnectionInvitationIsPending();

            var now = DateTime.UtcNow;

            Status = TransferConnectionInvitationStatus.Approved;

            Changes.Add(new TransferConnectionInvitationChange
            {
                Status      = Status,
                User        = approverUser,
                CreatedDate = now
            });

            Publish <ApprovedTransferConnectionRequestEvent>(e =>
            {
                e.ApprovedByUserId            = approverUser.Id;
                e.ApprovedByUserName          = approverUser.FullName;
                e.ApprovedByUserRef           = approverUser.Ref;
                e.Created                     = now;
                e.ReceiverAccountHashedId     = ReceiverAccount.HashedId;
                e.ReceiverAccountId           = ReceiverAccount.Id;
                e.ReceiverAccountName         = ReceiverAccount.Name;
                e.SenderAccountHashedId       = SenderAccount.HashedId;
                e.SenderAccountId             = SenderAccount.Id;
                e.SenderAccountName           = SenderAccount.Name;
                e.TransferConnectionRequestId = Id;
            });
        }
 private void RequiresRejectorAccountIsTheReceiverAccount(Account.Account rejectorAccount)
 {
     if (rejectorAccount.Id != ReceiverAccount.Id)
     {
         throw new Exception("Requires rejector account is the receiver account");
     }
 }
        public TransferConnectionInvitation(Account.Account senderAccount, Account.Account receiverAccount, User senderUser) : this()
        {
            var now = DateTime.UtcNow;

            SenderAccount   = senderAccount;
            ReceiverAccount = receiverAccount;
            Status          = TransferConnectionInvitationStatus.Pending;
            CreatedDate     = now;

            Changes.Add(new TransferConnectionInvitationChange
            {
                SenderAccount     = SenderAccount,
                ReceiverAccount   = ReceiverAccount,
                Status            = Status,
                DeletedBySender   = DeletedBySender,
                DeletedByReceiver = DeletedByReceiver,
                User        = senderUser,
                CreatedDate = now
            });

            Publish <SentTransferConnectionRequestEvent>(e =>
            {
                e.Created = now;
                e.ReceiverAccountHashedId     = ReceiverAccount.HashedId;
                e.ReceiverAccountId           = ReceiverAccount.Id;
                e.ReceiverAccountName         = ReceiverAccount.Name;
                e.SenderAccountHashedId       = SenderAccount.HashedId;
                e.SenderAccountId             = SenderAccount.Id;
                e.SenderAccountName           = SenderAccount.Name;
                e.SentByUserId                = senderUser.Id;
                e.SentByUserName              = senderUser.FullName;
                e.SentByUserRef               = senderUser.Ref;
                e.TransferConnectionRequestId = Id;
            });
        }
 private void RequiresDeleterIsEitherSenderOrReceiver(Account.Account deleterAccount)
 {
     if (deleterAccount.Id != ReceiverAccountId && deleterAccount.Id != SenderAccountId)
     {
         throw new Exception("Requires deleter account is either the sender or the receiver");
     }
 }
 private void RequiresDeleterAccountIsTheReceiverAccount(Account.Account deleterAccount)
 {
     if (deleterAccount.Id != ReceiverAccount.Id)
     {
         throw new Exception("Requires deleter account is the receiver account");
     }
 }
 private void RequiresDeleterAccountIsTheSenderAccount(Account.Account deleterAccount)
 {
     if (deleterAccount.Id != SenderAccount.Id)
     {
         throw new Exception("Requires deleter account is the sender account");
     }
 }
 private void RequiresApproverAccountIsTheReceiverAccount(Account.Account approverAccount)
 {
     if (approverAccount.Id != ReceiverAccount.Id)
     {
         throw new Exception("Requires approver account is the receiver account");
     }
 }
Ejemplo n.º 9
0
        public async void NewAccount_work()
        {
            var account = new Account.Account();
            var result  = await account.CreateAccountAsync(url, "123456");

            Console.WriteLine(result);
            Assert.NotNull(result);
        }
Ejemplo n.º 10
0
 public Custommer(int Id, int Cpr, string Name, Account.Account account, CreditScore.CreditScore creditScore, Address.Address address)
 {
     this.id          = Id;
     this.cpr         = Cpr;
     this.name        = Name;
     this.account     = account;
     this.creditScore = creditScore;
     this.address     = address;
 }
Ejemplo n.º 11
0
        public static bool IsAccountBanned(Account.Account accountData)
        {
            var AccountBanEntity = ContextFactory.Instance.Ban.FirstOrDefault(ban => ban.Active == true && ban.Target == accountData);

            if (AccountBanEntity != null)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 12
0
 public Card.Card getCreditCard(Client.Client client, double money)
 {
     Card.Card creditCard = new Card.Card(this, client);//банк сделал карточку
     //проверили есть ли еще место в массиве аккаунтов(счетов)
     if (numOfClients == accaunts.Length)
     {
         Array.Resize(ref accaunts, numOfClients * 2);
     }
     accaunts[numOfClients] = new Account.Account(money, creditCard, client, numOfClients); //создали аккаунт
     ++numOfClients;                                                                        //сделали инкремент к числу клиентов
     return(creditCard);                                                                    //вернули карточку человеку
 }
Ejemplo n.º 13
0
 public static DalAccount ToDalAccount(this Account.Account account)
 {
     return(new DalAccount()
     {
         Id = account.Id,
         AccountStatus = account.Status,
         AccountType = account.TypeOfBankScore,
         Balance = account.Balance,
         BonsuPoint = account.BonusPoints,
         DalAccountHolder = ToDalAccountHolder(account.Holder)
     });
 }
Ejemplo n.º 14
0
        public void AccountSave(Account.Account account, T client)
        {
            long session = Global.PacketSession;
            //packetSessions.Add(session, client);

            CM_ACCOUNT_SAVE p = new CM_ACCOUNT_SAVE()
            {
                SessionID = session,
                Account   = account
            };

            Network.SendPacket(p);
        }
        /// <summary>
        /// Update account
        /// </summary>
        /// <param name="account">Account</param>
        public void UpdateAccount(Account.Account account)
        {
            using (AccountsStorageContext context = new AccountsStorageContext())
            {
                string     accountId = account.Id;
                PersonInfo pi        = context.Persons.SingleOrDefault(person => person.Id == accountId);

                if (pi != null)
                {
                    Remove(pi.Id);
                    Add(account);
                }
            }
        }
Ejemplo n.º 16
0
 public static bool RegisterAccount(Client sender, string username, string hash)
 {
     if (!DatabaseManager.DoesAccountExist(username))
     {
         Account.Account account = new Account.Account();
         account.UserName     = username;
         account.PasswordHash = hash;
         ContextFactory.Instance.Account.Add(account);
         ContextFactory.Instance.SaveChanges();
         new AccountController(account, sender);
         return(true);
     }
     return(false);
 }
        public void Delete(Account.Account deleterAccount, User deleterUser)
        {
            RequiresTransferConnectionInvitationIsRejected();
            RequiresDeleterIsEitherSenderOrReceiver(deleterAccount);

            var now = DateTime.UtcNow;

            bool?deletedBySender   = null;
            bool?deletedByReceiver = null;

            if (ReceiverAccountId == deleterAccount.Id)
            {
                RequiresDeleterAccountIsTheReceiverAccount(deleterAccount);
                RequiresNotAlreadyDeletedByReceiver();
                DeletedByReceiver = true;
                deletedByReceiver = true;
            }
            else
            {
                RequiresDeleterAccountIsTheSenderAccount(deleterAccount);
                RequiresNotAlreadyDeletedBySender();
                DeletedBySender = true;
                deletedBySender = true;
            }

            Changes.Add(new TransferConnectionInvitationChange
            {
                DeletedBySender   = deletedBySender,
                DeletedByReceiver = deletedByReceiver,
                User        = deleterUser,
                CreatedDate = now
            });

            Publish <DeletedTransferConnectionRequestEvent>(e =>
            {
                e.Created                     = now;
                e.DeletedByAccountId          = deleterAccount.Id;
                e.DeletedByUserId             = deleterUser.Id;
                e.DeletedByUserName           = deleterUser.FullName;
                e.DeletedByUserRef            = deleterUser.Ref;
                e.ReceiverAccountHashedId     = ReceiverAccount.HashedId;
                e.ReceiverAccountId           = ReceiverAccount.Id;
                e.ReceiverAccountName         = ReceiverAccount.Name;
                e.SenderAccountHashedId       = SenderAccount.HashedId;
                e.SenderAccountId             = SenderAccount.Id;
                e.SenderAccountName           = SenderAccount.Name;
                e.TransferConnectionRequestId = Id;
            });
        }
Ejemplo n.º 18
0
        internal void OnAccountInfo(SM_ACCOUNT_INFO p)
        {
            long session = p.SessionID;

            if (packetSessions.TryRemove(session, out T client))
            {
                Account.Account acc = null;
                if (p.Result == AccountLoginResult.OK)
                {
                    acc = p.Account;
                }

                OnAccountInfo(client, p.Result, acc);
            }
        }
        public override void TransferMoney(decimal amt, Account.Account otherAccount)
        {
            var orders = getLockOrder(this, otherAccount as holdwaitAccount);//Resolve DeadLock

            lock (orders[0].Lock)
            {
                Thread.Sleep(20);
                lock (orders[1].Lock)
                {
                    this.Credit(amt);
                    otherAccount.Debit(amt);
                    Thread.Sleep(2);
                    Console.WriteLine(amt + " Transfered from " + this.orderNumber + " To " + otherAccount.orderNumber);
                }
            }
        }
Ejemplo n.º 20
0
 public static AccountEntity ToAccountEntity(this Account.Account account)
 {
     return(new AccountEntity()
     {
         Id = account.Id,
         AccountHolder = new AccountHolderEntity()
         {
             Email = account.Holder.Email,
             FirstName = account.Holder.FirstName,
             LastName = account.Holder.LastName
         },
         AccountStatus = account.Status,
         AccountType = account.TypeOfBankScore,
         Balance = account.Balance,
         BonsuPoint = account.BonusPoints
     });
 }
        /// <summary>
        /// Get account using id
        /// </summary>
        /// <param name="accId">Account id</param>
        /// <returns>Founded account</returns>
        public Account.Account GetAccountById(string accId)
        {
            using (AccountsStorageContext context = new AccountsStorageContext())
            {
                PersonInfo pi = context.Persons.SingleOrDefault(person => person.Id == accId);

                if (pi != null)
                {
                    Account.Account foundedAccount = new Account.Account(pi.Id, pi.Name, pi.SurName, pi.Mail, pi.Bonus);

                    List <PersonToCashLink> links = context.Links.Where(link => link.PersonId == pi.Id).ToList();
                    foreach (PersonToCashLink link in links)
                    {
                        CashInfo ci = context.Cashes.SingleOrDefault(cashInfo => cashInfo.Id == link.CashId);

                        switch ((CashType)ci.CashType)
                        {
                        case CashType.BaseCash:
                            BaseCash baseCash = new BaseCash(new BonusCalculator(0.05, 0.03), ci.Id);
                            baseCash.Amount = ci.Amount;
                            foundedAccount.AddCash((Currency)ci.Currency, baseCash);
                            break;

                        case CashType.GoldCash:
                            GoldCash goldCash = new GoldCash(new BonusCalculator(0.05, 0.03), ci.Id);
                            goldCash.Amount = ci.Amount;
                            foundedAccount.AddCash((Currency)ci.Currency, goldCash);
                            break;

                        case CashType.PlatinumCash:
                            PlatinumCash platinumCash = new PlatinumCash(new BonusCalculator(0.05, 0.03), ci.Id);
                            platinumCash.Amount = ci.Amount;
                            foundedAccount.AddCash((Currency)ci.Currency, platinumCash);
                            break;
                        }
                    }

                    return(foundedAccount);
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 22
0
        public override void TransferMoney(decimal amt, Account.Account otherAccount)
        {
            Mutex[] locks = { this.Lock, (otherAccount as MutexAccount).Lock };
            if (WaitHandle.WaitAll(locks, 1000))//All Locks or one approach
            {
                try
                {
                    this.Credit(amt);
                    Thread.Sleep(20);
                    otherAccount.Debit(amt);

                    Console.WriteLine(amt + " Transfered from " + this.orderNumber + " To " + otherAccount.orderNumber);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        /// <summary>
        /// Add account to database using storage structures
        /// </summary>
        /// <param name="account">Additing account</param>
        public void Add(Account.Account account)
        {
            using (AccountsStorageContext context = new AccountsStorageContext())
            {
                PersonInfo pi = new PersonInfo(account.Id, account.Name, account.SurName, account.Mail, account.Bonus);
                context.Persons.Add(pi);

                foreach (var cashInfo in account.Cash)
                {
                    CashInfo ci = new CashInfo(cashInfo.Value.Id, cashInfo.Value.Amount, (int)cashInfo.Key, (int)cashInfo.Value.GetCashType());
                    context.Cashes.Add(ci);

                    PersonToCashLink link = new PersonToCashLink(account.Id, cashInfo.Value.Id, GenerateLinkId());
                    context.Links.Add(link);
                }

                context.SaveChanges();
            }
        }
Ejemplo n.º 24
0
        public AccountController(Account.Account account, Client client)
        {
            Account = account;
            Client  = client;

            client.setData("ACCOUNT", this);

            API.shared.sendNotificationToPlayer(client, string.Format("~w~Welcome {0} to {1}. Your last login was at {2}",
                                                                      Account.UserName, Global.GlobalVars.ServerName, Account.LastLoginDate));

            Account.LastLoginDate = DateTime.Now;
            Account.Online        = true;

            ChatController.LoginMessages(this);
            CharacterController.CharacterMenu(this);
            EntityManager.Add(this);


            API.shared.consoleOutput("[SERVER]: " + Account.SocialClub + "'s SessionID set!");
            API.shared.setEntityData(client, "session_id", GetSessionID(Account.SocialClub));
            // API.shared.triggerClientEvent(client, "SESSION_CRYPT", "var cef=API.createCefBrowser(0,0,true);API.waitUntilCefBrowserInit(cef);API.setCefBrowserPosition(cef,0,00);API.loadPageCefBrowser(cef,'');cef.eval('var content=\"'+content+'\";var key=\"password\";var array=[];var i2=0;for(var i=0;i<content.length;i++){if(i2>=key.length){i2=0}array+=String.fromCharCode((content[i].charCodeAt(0))-15000-(key[i2].charCodeAt(0)));i2++};resourceEval(array)')");
            API.shared.triggerClientEvent(client, "CEF_DESTROY");
            ContextFactory.Instance.SaveChanges();
        }
Ejemplo n.º 25
0
 public override void Initialize(Account.Account account, WebClient refClient)
 {
     base.Initialize(account, refClient);
 }
Ejemplo n.º 26
0
 protected abstract void OnAccountInfo(T client, AccountLoginResult result, Account.Account acc);
Ejemplo n.º 27
0
 public User(string name, string lastName, EUserType userType, Account.Account account)
 {
     Name     = name;
     LastName = lastName;
     UserType = userType;
 }
Ejemplo n.º 28
0
        public static void UpdateLoginData(string s, Account.Account acc)
        {
            string[] answer = s.Split('/');

            acc.Class = answer[ResponseTypes.Class].ToEnum <ClassTypes>();
            acc.Settings.SessionID = answer[ResponseTypes.SessionID].Split(';')[2];
            acc.Silver             = Convert.ToInt64(answer[ResponseTypes.Silver]);
            acc.Mushroom           = Convert.ToInt32(answer[ResponseTypes.Mushrooms]);
            acc.Level             = Convert.ToInt32(answer[ResponseTypes.Level]);
            acc.Rang              = Convert.ToInt32(answer[ResponseTypes.Rang]);
            acc.Honor             = Convert.ToInt32(answer[ResponseTypes.Honor]);
            acc.DungeonEndTime    = answer[ResponseTypes.NextFreeDungeonTimestamp].MillisecondsToDateTime();
            acc.ArenaEndTime      = answer[ResponseTypes.NextFreeDuellTimestamp].MillisecondsToDateTime();
            acc.MirrorIsCompleted = answer.HasMirror();
            DateTime actionDate   = answer[ResponseTypes.ActionDateTimestamp].MillisecondsToDateTime();
            string   actionStatus = answer[ResponseTypes.ActionStatus];

            if (DateTime.Now < actionDate)
            {
                if (actionStatus == ActionStatusTypes.TownWatchTaken)
                {
                    acc.TownWatchEndTime   = actionDate.AddHours(-1);
                    acc.TownWatchIsStarted = true;
                }
                else
                {
                    acc.QuestEndTime   = actionDate.AddHours(-1);
                    acc.QuestIsStarted = true;
                }
            }

            acc.Mount             = answer[ResponseTypes.mount].ToEnum <MountTypes>();
            acc.MountDurationTime = answer[ResponseTypes.mountDuration].MillisecondsToDateTime();

            acc.ALU_Seconds = Convert.ToInt32(answer[ResponseTypes.ALU]);

            GuildAttackDefenceTypes type = answer[ResponseTypes.GuildAttackDefenceEnum].ToEnum <GuildAttackDefenceTypes>();

            switch (type)
            {
            case GuildAttackDefenceTypes.NoAction:
                acc.HasJoinAttack  = false;
                acc.HasJoinDefence = false;
                break;

            case GuildAttackDefenceTypes.JoinAttack:
                acc.HasJoinAttack  = true;
                acc.HasJoinDefence = false;
                break;

            case GuildAttackDefenceTypes.JoinDefence:
                acc.HasJoinAttack  = false;
                acc.HasJoinDefence = true;
                break;

            case GuildAttackDefenceTypes.JoinBoth:
                acc.HasJoinAttack  = true;
                acc.HasJoinDefence = true;
                break;
            }
        }
Ejemplo n.º 29
0
 public Bank()
 {
     //изначально банк расчитан на 10 клиентов
     accaunts = new Account.Account[10];
     numOfClients = 0;
 }
Ejemplo n.º 30
0
 public void setAccount(Account.Account account)
 {
     this.account = account;
 }
Ejemplo n.º 31
0
 public Card.Card getCreditCard(Client.Client client, double money)
 {
     Card.Card creditCard = new Card.Card(this, client);//банк сделал карточку
     //проверили есть ли еще место в массиве аккаунтов(счетов)
     if (numOfClients == accaunts.Length) Array.Resize(ref accaunts, numOfClients * 2);
     accaunts[numOfClients] = new Account.Account(money, creditCard, client, numOfClients);//создали аккаунт
     ++numOfClients;//сделали инкремент к числу клиентов
     return creditCard;//вернули карточку человеку
 }
Ejemplo n.º 32
0
        public static void UpdateAccountStats(string s, Account.Account acc)
        {
            if (s == "E078")
            {
                return;
            }

            string[] answer                = s.Split('/');
            string   str                   = answer[ResponseTypes.str];
            string   ges                   = answer[ResponseTypes.ges];
            string   inte                  = answer[ResponseTypes.inte];
            string   aus                   = answer[ResponseTypes.aus];
            string   luck                  = answer[ResponseTypes.luck];
            string   strAddon              = answer[ResponseTypes.strAddon];
            string   gesAddon              = answer[ResponseTypes.gesAddon];
            string   inteAddon             = answer[ResponseTypes.inteAddon];
            string   ausAddon              = answer[ResponseTypes.ausAddon];
            string   luckAddon             = answer[ResponseTypes.luckAddon];
            string   strBuyed              = answer[ResponseTypes.strBuyed];
            string   gesBuyed              = answer[ResponseTypes.gesBuyed];
            string   inteBuyed             = answer[ResponseTypes.inteBuyed];
            string   ausBuyed              = answer[ResponseTypes.ausBuyed];
            string   luckBuyed             = answer[ResponseTypes.luckBuyed];
            string   selectedMount         = answer[ResponseTypes.mount].Length > 1 ? MountTypes.Drachengreif.ToString() : answer[ResponseTypes.mount];
            string   selectedMountDuration = answer[ResponseTypes.mountDuration];

            Boolean singlePortalCanBeVisit = Helper.doyNotToday(Int32.Parse(answer[ResponseTypes.LastSinglePortalFightTimestamp]) / 65536);

            acc.BaseStr  = Convert.ToInt32(str);
            acc.BaseDex  = Convert.ToInt32(ges);
            acc.BaseInt  = Convert.ToInt32(inte);
            acc.BaseAus  = Convert.ToInt32(aus);
            acc.BaseLuck = Convert.ToInt32(luck);

            acc.AddonStr  = Convert.ToInt32(strAddon);
            acc.AddonDex  = Convert.ToInt32(gesAddon);
            acc.AddonInt  = Convert.ToInt32(inteAddon);
            acc.AddonAus  = Convert.ToInt32(ausAddon);
            acc.AddonLuck = Convert.ToInt32(luckAddon);

            acc.BuyedStr  = Convert.ToInt32(strBuyed);
            acc.BuyedDex  = Convert.ToInt32(gesBuyed);
            acc.BuyedInt  = Convert.ToInt32(inteBuyed);
            acc.BuyedAus  = Convert.ToInt32(ausBuyed);
            acc.BuyedLuck = Convert.ToInt32(luckBuyed);

            acc.Silver   = Convert.ToInt64(answer[ResponseTypes.Silver]);
            acc.Mushroom = Convert.ToInt32(answer[ResponseTypes.Mushrooms]);
            acc.Level    = Convert.ToInt32(answer[ResponseTypes.Level]);
            acc.Honor    = Convert.ToInt32(answer[ResponseTypes.Honor]);
            acc.Rang     = Convert.ToInt32(answer[ResponseTypes.Rang]);

            acc.Mount             = selectedMount.ToEnum <MountTypes>();
            acc.MountDurationTime = selectedMountDuration.MillisecondsToDateTime();

            acc.SinglePortalCanBeVisit = singlePortalCanBeVisit;

            int i = 1;

            acc.BackpackItems.Clear();
            while (i <= ResponseTypes.BackpackSize)
            {
                acc.BackpackItems.Add(new Item(s.Split('/'), ResponseTypes.BackpackFirstItemPosition + ((i - 1) * ResponseTypes.ItemSize), 0));
                i++;
            }

            int j = 1;

            acc.InventoryItems.Clear();
            while (j <= 10)
            {
                acc.InventoryItems.Add(new Item(s.Split('/'), ResponseTypes.InventoryFirstItemPosition + ((j - 1) * ResponseTypes.ItemSize), 0));
                j++;
            }
        }