public void PerformTransaction(VM vm, bool testOnly, uint uid1, uint uid2, int amount, VMAsyncTransactionCallback callback) { var result = PerformTransaction(vm, testOnly, uid1, uid2, amount); if (callback != null) { var obj1 = vm.GetObjectByPersist(uid1); var obj2 = vm.GetObjectByPersist(uid2); var finalAmount = amount; new System.Threading.Thread(() => { //System.Threading.Thread.Sleep(250); callback(result, finalAmount, uid1, (obj1 == null) ? 0 : obj1.TSOState.Budget.Value, uid2, (obj2 == null) ? 0 : obj2.TSOState.Budget.Value); }).Start(); } }
public void PerformTransaction(VM vm, bool testOnly, uint uid1, uint uid2, int amount, short type, short thread, VMAsyncTransactionCallback callback) { Host.InBackground(() => { using (var db = DAFactory.Get()) { var result = (testOnly)?db.Avatars.TestTransaction(uid1, uid2, amount, 0):db.Avatars.Transaction(uid1, uid2, amount, type); if (result == null) { result = new Database.DA.Avatars.DbTransactionResult() { success = false } } ; var finalAmount = amount; //update client side budgets for avatars involved. vm.SendCommand(new VMNetAsyncResponseCmd(thread, new VMTransferFundsState { Responded = true, Success = result.success, TransferAmount = result.amount, UID1 = uid1, Budget1 = (uint)result.source_budget, UID2 = uid2, Budget2 = (uint)result.dest_budget })); callback(result.success, result.amount, uid1, (uint)result.source_budget, uid2, (uint)result.dest_budget); } }); }
public void PerformTransaction(VM vm, bool testOnly, uint uid1, uint uid2, int amount, short type, VMAsyncTransactionCallback callback) { PerformTransaction(vm, testOnly, uid1, uid2, amount, type, 0, callback); }
public void PurchaseFromOwner(VM vm, VMMultitileGroup obj, uint purchaserPID, VMAsyncInventorySaveCallback callback, VMAsyncTransactionCallback tcallback) { var objectPID = obj.BaseObject.PersistID; var objb = obj.BaseObject; uint guid = objb.Object.OBJ.GUID; if (objb.MasterDefinition != null) { guid = objb.MasterDefinition.GUID; } var isNew = objectPID == 0; var state = new VMStandaloneObjectMarshal(obj); var dbState = GenerateObjectPersist(obj); var salePrice = obj.SalePrice; var owner = ((VMTSOObjectState)objb.TSOState).OwnerID; //object will stay on lot for now. Host.InBackground(() => { using (var da = DAFactory.Get()) { SaveInventoryState(isNew, objectPID, state, dbState, guid, (bool success, uint objPID) => { if (success) { //todo: transaction-ify this whole thing? might need a large scale rollback... var tresult = da.Avatars.Transaction(purchaserPID, owner, salePrice, 0); if (tresult == null) { tresult = new Database.DA.Avatars.DbTransactionResult() { success = false } } ; //update the budgets of the respective characters. var finalAmount = salePrice; tcallback(tresult.success, tresult.amount, purchaserPID, (uint)tresult.source_budget, owner, (uint)tresult.dest_budget); if (tresult.success) { dbState.owner_id = purchaserPID; dbState.lot_id = null; da.Objects.UpdatePersistState(objPID, dbState); //perform the final object transfer. todo: logging callback(true, objPID); } else { callback(false, objPID); } } else { callback(false, objPID); } }, true); } }); }
public void PerformTransaction(VM vm, bool testOnly, uint uid1, uint uid2, int amount, short type, short thread, VMAsyncTransactionCallback callback) { var result = PerformTransaction(vm, testOnly, uid1, uid2, amount); if (callback != null) { var obj1 = vm.GetObjectByPersist(uid1); var obj2 = vm.GetObjectByPersist(uid2); var finalAmount = amount; new System.Threading.Thread(() => { //update client side budgets for avatars involved. vm.SendCommand(new VMNetAsyncResponseCmd(thread, new VMTransferFundsState { Responded = true, Success = result, TransferAmount = finalAmount, UID1 = uid1, Budget1 = (obj1 == null) ? 0 : obj1.TSOState.Budget.Value, UID2 = uid2, Budget2 = (obj2 == null) ? 0 : obj2.TSOState.Budget.Value })); callback(result, finalAmount, uid1, (obj1 == null) ? 0 : obj1.TSOState.Budget.Value, uid2, (obj2 == null) ? 0 : obj2.TSOState.Budget.Value); }).Start(); } }
public void PurchaseFromOwner(VM vm, VMMultitileGroup obj, uint purchaserPID, VMAsyncInventorySaveCallback callback, VMAsyncTransactionCallback tcallback) { callback(true, obj.BaseObject.PersistID); //todo: nice stub for this using database? }
public void PerformTransaction(VM vm, bool testOnly, uint uid1, uint uid2, int amount, VMAsyncTransactionCallback callback) { var result = PerformTransaction(vm, testOnly, uid1, uid2, amount); if (callback != null) { var obj1 = vm.GetObjectByPersist(uid1); var obj2 = vm.GetObjectByPersist(uid2); var finalAmount = amount; new System.Threading.Thread(() => { //System.Threading.Thread.Sleep(250); callback(result, finalAmount, uid1, (obj1 == null) ? 0 : obj1.TSOState.Budget.Value, uid2, (obj2 == null) ? 0 : obj2.TSOState.Budget.Value); }).Start(); } }
public void PerformTransaction(VM vm, bool testOnly, uint uid1, uint uid2, int amount, VMAsyncTransactionCallback callback) { Host.InBackground(() => { using (var db = DAFactory.Get()) { var result = (testOnly)?db.Avatars.TestTransaction(uid1, uid2, amount, 0):db.Avatars.Transaction(uid1, uid2, amount, 0); if (result == null) { result = new Database.DA.Avatars.DbTransactionResult() { success = false } } ; var finalAmount = amount; callback(result.success, result.amount, uid1, (uint)result.source_budget, uid2, (uint)result.dest_budget); } }); }