protected bool LoadProfile(ulong playerID, bool reload = false) { if (playerID == 0) { return(false); } string path = "bank_" + playerID.ToString(); BankProfile profile = datafile.ReadObject <BankProfile> (path); if (!(profile is BankProfile)) { return(false); } if (profile.Count == 0) { return(false); } if (banks.ContainsKey(playerID)) { banks [playerID] = profile; } else { banks.Add(playerID, profile); } return(true); }
/// <summary> /// Helper method to generate PaymentInstruction object using BankProfile /// </summary> private static PaymentInstruction GetSchedulePaymentWithNewBankProfile(string accountNumber, BankProfile bankProfile) { // Service Provider's Payment Identifier (Payment PrimaryKey) string paymentReferenceId = Guid.NewGuid().ToString(); // The date to pull funds from consumers account DateTime paymentDate = DateTime.Today.AddDays(5); // The total amount to pull funds from consumers account double paymentAmount = 750.00; // Create empty collection of Allocations var allocList = PaymentFactory.NewAllocationList(); // Create an Allocation for MaintenanceFees, and add to Allocation collection allocList.Add( PaymentFactory.CreateAllocation(AssignmentCode.MaintenanceFee1, 235.00) ); // Create an Allocation for Consumer's Reserve Account, and add to Allocation collection allocList.Add( PaymentFactory.CreateAllocation(AssignmentCode.AccountReserves, 500.00) ); // Create an Allocation for Meracord Fees, and add to Allocation collection allocList.Add( PaymentFactory.CreateAllocation(AssignmentCode.NoteWorldFee, 15.00) ); // Call PaymentFactory Create Method, and return Transport.PaymentInstruction Instance return PaymentFactory.Create(accountNumber, paymentReferenceId, paymentDate, bankProfile, paymentAmount, allocList); }
void InvalidateBank(BasePlayer player, BankProfile profile, StorageContainer view) { bool returned = false; if (view != null && view.inventory != null && view.inventory.itemList != null) { foreach (var item in view.inventory.itemList.ToArray()) { ItemLimit limit = GetItemLimit(item); if (limit != null) { if (item.amount < limit.minimum) { returned = true; if (player.inventory.containerMain == null || (player.inventory.containerMain != null && !item.MoveToContainer(player.inventory.containerMain))) { if (player.inventory.containerBelt == null || (player.inventory.containerBelt != null && !item.MoveToContainer(player.inventory.containerBelt))) { item.Drop(player.eyes.HeadForward() * 2, default(Vector3)); } } continue; } if (item.amount > limit.maximum) { returned = true; Item invalidItem; if (limit.maximum > 0) { invalidItem = item.SplitItem(item.amount - limit.maximum); } else { invalidItem = item; } if (invalidItem != null) { if (player.inventory.containerMain == null || (player.inventory.containerMain != null && !invalidItem.MoveToContainer(player.inventory.containerMain))) { if (player.inventory.containerBelt == null || (player.inventory.containerBelt != null && !invalidItem.MoveToContainer(player.inventory.containerBelt))) { invalidItem.Drop(player.eyes.HeadForward() * 2, default(Vector3)); } } } } } } } if (returned) { SendReply(player, GetMsg("Limit: Return", player)); } }
object CanUseDoor(BasePlayer player, BaseLock lockItem) { if (!keyring) { return(null); } if (MasterKey != null) { var result = MasterKey.Call("CanUseDoor", player, lockItem); if (result is bool) { return(null); } } if (lockItem is KeyLock && banks.ContainsKey(player.userID)) { KeyLock keyLock = (KeyLock)lockItem; BankProfile bank = banks[player.userID]; List <int> codes = new List <int>(); foreach (ItemProfile profile in bank.items) { if (profile.dataInt != 0) { codes.Add(profile.dataInt); } } if (!keyLock.IsLocked()) { return(null); } if (keyLock.HasLockPermission(player)) { return(null); } int keyCode = (int)keyCodeField.GetValue(keyLock); foreach (int code in codes) { if (code == keyCode) { return(true); } } return(false); } return(null); }
// GET: BaseTest public ActionResult TEST_JSON_FILL_BANKDATA() { Database.SetInitializer(new BankContextController()); Bank b1 = new Bank(); Bank b2 = new Bank(); bankDb.Banks.AddRange(new List <Bank> { b1, b2 }); bankDb.SaveChanges(); BankProfile bp1 = new BankProfile { BankProfileId = b1.BankId, Name = "JapanBank", Location = "Tokyo", Code = "JPNB", Country = "Japan" }; BankProfile bp2 = new BankProfile { BankProfileId = b2.BankId, Name = "KazBank", Location = "Almaty", Code = "KAZB", Country = "Kazakhstan" }; bankDb.BanksProfile.AddRange(new List <BankProfile> { bp1, bp2 }); bankDb.SaveChanges(); b1.Accounts.Add(new BankAccount { AccountCode = "B1_REF1", AccountName = "B1_REF1", TotalFinanceAmount = 2000 }); b1.Accounts.Add(new BankAccount { AccountCode = "B1_REF2", AccountName = "B1_REF2", TotalFinanceAmount = 3000 }); b1.Accounts.Add(new BankAccount { AccountCode = "B1_REF3", AccountName = "B1_REF3", TotalFinanceAmount = 4000 }); b2.Accounts.Add(new BankAccount { AccountCode = "B2_REF1", AccountName = "B2_REF1", TotalFinanceAmount = 2000 }); b2.Accounts.Add(new BankAccount { AccountCode = "B2_REF2", AccountName = "B2_REF2", TotalFinanceAmount = 3000 }); b2.Accounts.Add(new BankAccount { AccountCode = "B2_REF3", AccountName = "B2_REF3", TotalFinanceAmount = 4000 }); bankDb.SaveChanges(); return(Json("SUCCESS", JsonRequestBehavior.AllowGet)); }
void SaveProfile(ulong playerID, BankProfile profile = null) { if (profile == null) { if (!banks.ContainsKey(playerID)) { return; } profile = banks[playerID]; } string path = "bank_" + playerID.ToString(); int pc = profile.Count; datafile.WriteObject <BankProfile>(path, profile); profile.dirty = false; }
void OpenBank(BasePlayer player, BaseEntity targArg) { Subscribe(nameof(CanNetworkTo)); Subscribe(nameof(OnEntityTakeDamage)); //Subscribe(nameof(OnItemAddedToContainer)); var pos = new Vector3(player.transform.position.x, player.transform.position.y - 1, player.transform.position.z); string box = GetBox(player); int slots = GetSlots(player); var view = GameManager.server.CreateEntity(box, pos) as StorageContainer; view.GetComponent <DestroyOnGroundMissing> ().enabled = false; view.GetComponent <GroundWatch> ().enabled = false; if (!view) { return; } view.limitNetworking = true; view.transform.position = pos; player.EndLooting(); if (targArg is BasePlayer) { BasePlayer target = targArg as BasePlayer; BankProfile profile = banks [target.userID]; ItemContainer bank = profile.GetContainer(target, slots); if (!containers.ContainsKey(bank)) { containers.Add(bank, player.userID); } view.enableSaving = false; view.Spawn(); view.inventory = bank; profile.open = true; onlinePlayers [player].View = view; onlinePlayers [player].Target = target; timer.In(0.1f, delegate() { view.PlayerOpenLoot(player); }); } }
public BankProfile CreateBankProfile(BankProfile bankProfile, AdministrationAccessLevel accessLevel = AdministrationAccessLevel.ReadOnlyAccessToSystem) { if (accessLevel == AdministrationAccessLevel.FullAccessToSystem) { if (db.Banks.Any()) { var bank = db.Banks.First(); if (bank.Profile == null) { AddBankProfile(bank, bankProfile, AdministrationAccessLevel.FullAccessToSystem); } } } else { return(null); } return(bankProfile); }
protected bool LoadProfile(ulong playerID, bool reload = false) { #if DEBUG Puts($"Loading Bank {playerID}"); #endif if (playerID == 0) { return(false); } //if (banks.ContainsKey (playerID)) { // return true; //} string path = "bank_" + playerID.ToString(); BankProfile profile = datafile.ReadObject <BankProfile> (path); if (!(profile is BankProfile)) { return(false); } if (profile.Count == 0) { return(false); } if (banks.ContainsKey(playerID)) { banks [playerID] = profile; } else { banks.Add(playerID, profile); } return(true); }
public void CreateSystem() { Bank bank = new Bank(); BankProfile profile = new BankProfile { BankProfileId = bank.BankId, Name = "Bank of Tokyo-Mitsubishi UFJ", Location = "Tokyo - Shibuya - Sector II - Building 'Mitsubishi Corporation Office'", Code = "JAP_MITSU_BANK_MAIN", Country = "Japan" }; List <BankAccount> accounts = new List <BankAccount> { new BankAccount { AccountCode = profile.Code, AccountName = profile.Name.Replace("MAIN", "TOKYO"), TotalFinanceAmount = 2000000000, }, new BankAccount { AccountCode = profile.Code, AccountName = profile.Name.Replace("MAIN", "OSAKA"), TotalFinanceAmount = 1000000000, }, new BankAccount { AccountCode = profile.Code, AccountName = profile.Name.Replace("MAIN", "KYOTO"), TotalFinanceAmount = 500000000, } }; bank.Profile = profile; foreach (var e in accounts) { bank.Accounts.Add(e); } foreach (var e in accounts) { sum = sum += e.TotalFinanceAmount; } List <AutomatedTellerMachine> automatedTellerMachines = new List <AutomatedTellerMachine>(); for (int i = 0; i < 10; i++) { automatedTellerMachines.Add(new AutomatedTellerMachine { AutomatedTellerMachineCode = profile.Code.Replace("MAIN", "ATM_" + "ID_" + rand.Next(0, 9) + rand.Next(0, 9)), CurrentAviableMoneyAmount = sum / 10, OwnerBankCode = profile.Code }); } foreach (var e in automatedTellerMachines) { bank.BankAutomatedTellerMachines.Add(e); } Repository.CreateBank(bank, AdministrationAccessLevel.FullAccessToSystem); }
public void AddBankProfile(Bank bank, BankProfile bankProfile, AdministrationAccessLevel accessLevel = AdministrationAccessLevel.ReadOnlyAccessToSystem) { db.Banks.Find(bank).Profile = bankProfile; db.SaveChanges(); }
/// <summary> /// Execute Payment.Schedule() method /// </summary> private static void SchedulePaymentWithNewBankProfile(string accountNumber, BankProfile bankProfile) { // Build payment transport object to send to web service var payment = GetSchedulePaymentWithNewBankProfile(accountNumber, bankProfile); // Call Payment WebService Schedule Method var paymentResult = _session.Payment.Schedule(payment); Helper.ShowResults("Payment.Schedule()", paymentResult); }
void CloseBank(BasePlayer player, StorageContainer view) { if (!onlinePlayers.ContainsKey(player)) { return; } if (onlinePlayers [player].View == null) { return; } if (!banks.ContainsKey(player.userID)) { return; } BankProfile profile = banks [player.userID]; InvalidateBank(player, profile, view); profile.items.Clear(); foreach (Item item in view.inventory.itemList) { profile.Add(item); } SaveProfile(player.userID, profile); foreach (Item item in view.inventory.itemList.ToArray()) { if (item.position != -1) { item.RemoveFromContainer(); item.Remove(0f); } } profile.open = false; if (containers.ContainsKey(view.inventory)) { containers.Remove(view.inventory); } player.inventory.loot.containers = new List <ItemContainer> (); view.inventory = new ItemContainer(); if (player.inventory.loot.IsLooting()) { player.SendConsoleCommand("inventory.endloot", null); } onlinePlayers [player].View = null; onlinePlayers [player].Target = null; view.Kill(BaseNetworkable.DestroyMode.None); //view.KillMessage(); if (onlinePlayers.Values.Count(p => p.View != null) <= 0) { //Unsubscribe(nameof(CanNetworkTo)); Unsubscribe(nameof(OnEntityTakeDamage)); } }