public UserCurrency GetUserCurrency(UUID agentId) { object remoteValue = DoRemoteByURL("CurrencyServerURI", agentId); if (remoteValue != null || m_doRemoteOnly) { return((UserCurrency)remoteValue); } Dictionary <string, object> where = new Dictionary <string, object>(1); where["PrincipalID"] = agentId; List <string> query = m_gd.Query(new string[] { "*" }, _REALM, new QueryFilter() { andFilters = where }, null, null, null); UserCurrency currency; if (query.Count == 0) { currency = new UserCurrency(agentId, 0, 0, 0, false, 0); UserCurrencyCreate(agentId); return(currency); } return(new UserCurrency(query)); }
private void UserCurrencyUpdate(UserCurrency agent, bool full) { if (full) { m_gd.Update(_REALM, new Dictionary <string, object> { { "LandInUse", agent.LandInUse }, { "Tier", agent.Tier }, { "IsGroup", agent.IsGroup }, { "Amount", agent.Amount }, { "StipendsBalance", agent.StipendsBalance } }, null, new QueryFilter() { andFilters = new Dictionary <string, object> { { "PrincipalID", agent.PrincipalID } } } , null, null); } else { m_gd.Update(_REALM, new Dictionary <string, object> { { "LandInUse", agent.LandInUse }, { "Tier", agent.Tier }, { "IsGroup", agent.IsGroup } }, null, new QueryFilter() { andFilters = new Dictionary <string, object> { { "PrincipalID", agent.PrincipalID } } } , null, null); } }
void UserCurrencyUpdate(UserCurrency agent, bool full) { if (full) m_gd.Update (_REALM, new Dictionary<string, object> { { "LandInUse", agent.LandInUse }, { "Tier", agent.Tier }, { "IsGroup", agent.IsGroup }, { "Amount", agent.Amount }, { "StipendsBalance", agent.StipendsBalance } }, null, new QueryFilter () { andFilters = new Dictionary<string, object> { { "PrincipalID", agent.PrincipalID } } }, null, null ); else m_gd.Update (_REALM, new Dictionary<string, object> { { "LandInUse", agent.LandInUse }, { "Tier", agent.Tier }, { "IsGroup", agent.IsGroup } }, null, new QueryFilter () { andFilters = new Dictionary<string, object> { { "PrincipalID", agent.PrincipalID } } }, null, null) ; }
public UserCurrency GetUserCurrency(UUID agentId) { object remoteValue = DoRemoteByURL("CurrencyServerURI", agentId); if (remoteValue != null || m_doRemoteOnly) return (UserCurrency) remoteValue; Dictionary<string, object> where = new Dictionary<string, object>(1); where["PrincipalID"] = agentId; List<string> query = m_gd.Query(new [] {"*"}, _REALM, new QueryFilter() { andFilters = where }, null, null, null); UserCurrency currency; if ((query == null) || (query.Count == 0)) { currency = new UserCurrency(agentId, 0, 0, 0, false, 0); UserCurrencyCreate(agentId); return currency; } return new UserCurrency(query); }
public bool UserCurrencyTransfer(UUID toID, UUID fromID, UUID toObjectID, string toObjectName, UUID fromObjectID, string fromObjectName, uint amount, string description, TransactionType type, UUID transactionID) { if (m_doRemoteOnly) { object remoteValue = DoRemoteByURL("CurrencyServerURI", toID, fromID, toObjectID, toObjectName, fromObjectID, fromObjectName, amount, description, type, transactionID); return(remoteValue != null && (bool)remoteValue); } // check if the 'toID' is a group var groupService = Framework.Utilities.DataManager.RequestPlugin <IGroupsServiceConnector> (); if (groupService.IsGroup(toID)) { return(GroupCurrencyTransfer(toID, fromID, false, toObjectName, fromObjectID, fromObjectName, (int)amount, description, type, transactionID)); } // use transfer UserCurrency toCurrency = GetUserCurrency(toID); UserCurrency fromCurrency = fromID == UUID.Zero ? null : GetUserCurrency(fromID); if (toCurrency == null) { return(false); } // Groups (legacy) should not receive stipends if ((type == TransactionType.StipendPayment) && toCurrency.IsGroup) { return(false); } if (fromCurrency != null) { if (fromID == (UUID)Constants.BankerUUID) { // payment from the Banker // 20150730 - greythane - need to fiddle 'the books' as -ve balances are not currently available fromCurrency.Amount += amount; } else { // Normal users cannot have a credit balance.. check to see whether they have enough money if ((int)fromCurrency.Amount - (int)amount < 0) { return(false); // Not enough money } } // subtract this payment fromCurrency.Amount -= amount; UserCurrencyUpdate(fromCurrency, true); } if (fromID == toID) { toCurrency = GetUserCurrency(toID); } //Update the user who is getting paid toCurrency.Amount += amount; UserCurrencyUpdate(toCurrency, true); //Must send out notifications to the users involved so that they get the updates if (m_userInfoService == null) { m_userInfoService = m_registry.RequestModuleInterface <IAgentInfoService>(); m_userAccountService = m_registry.RequestModuleInterface <IUserAccountService> (); } if (m_userInfoService != null) { UserInfo toUserInfo = m_userInfoService.GetUserInfo(toID.ToString()); UserInfo fromUserInfo = fromID == UUID.Zero ? null : m_userInfoService.GetUserInfo(fromID.ToString()); UserAccount toAccount = m_userAccountService.GetUserAccount(null, toID); UserAccount fromAccount = m_userAccountService.GetUserAccount(null, fromID); if (m_config.SaveTransactionLogs) { AddTransactionRecord( (transactionID == UUID.Zero ? UUID.Random() : transactionID), description, toID, fromID, amount, type, toCurrency.Amount, (fromCurrency == null ? 0 : fromCurrency.Amount), (toAccount == null ? "System" : toAccount.Name), (fromAccount == null ? "System" : fromAccount.Name), toObjectName, fromObjectName, (fromUserInfo == null ? UUID.Zero : fromUserInfo.CurrentRegionID) ); } if (fromID == toID) { if (toUserInfo != null && toUserInfo.IsOnline) { SendUpdateMoneyBalanceToClient(toID, transactionID, toUserInfo.CurrentRegionURI, toCurrency.Amount, toAccount == null ? "" : (toAccount.Name + " paid you " + InWorldCurrency + amount + (description == "" ? "" : ": " + description))); } } else { if (toUserInfo != null && toUserInfo.IsOnline) { SendUpdateMoneyBalanceToClient(toID, transactionID, toUserInfo.CurrentRegionURI, toCurrency.Amount, fromAccount == null ? "" : (fromAccount.Name + " paid you " + InWorldCurrency + amount + (description == "" ? "" : ": " + description))); } if (fromUserInfo != null && fromUserInfo.IsOnline) { SendUpdateMoneyBalanceToClient(fromID, transactionID, fromUserInfo.CurrentRegionURI, fromCurrency.Amount, "You paid " + (toAccount == null ? "" : toAccount.Name) + " " + InWorldCurrency + amount); } } } return(true); }
public bool GroupCurrencyTransfer(UUID groupID, UUID userId, bool payUser, string toObjectName, UUID fromObjectID, string fromObjectName, int amount, string description, TransactionType type, UUID transactionID) { GroupBalance gb = new GroupBalance { StartingDate = DateTime.UtcNow }; // Not sure if a group will receive a system payment but.. UserCurrency fromCurrency = userId == UUID.Zero ? null : GetUserCurrency(userId); // Groups (legacy) should not receive stipends if (type == TransactionType.StipendPayment) { return(false); } if (fromCurrency != null) { // Normal users cannot have a credit balance.. check to see whether they have enough money if ((int)fromCurrency.Amount - amount < 0) { return(false); // Not enough money } } // is thiis a payment to the group or to the user? if (payUser) { amount = -1 * amount; } uint fromBalance = 0; if (fromCurrency != null) { // user payment fromCurrency.Amount -= (uint)amount; UserCurrencyUpdate(fromCurrency, true); fromBalance = fromCurrency.Amount; } // track specific group fees switch (type) { case TransactionType.GroupJoin: gb.GroupFee += amount; break; case TransactionType.LandAuction: gb.LandFee += amount; break; case TransactionType.ParcelDirFee: gb.ParcelDirectoryFee += amount; break; } if (payUser) { gb.TotalTierDebit -= amount; // not sure if this the correct place yet? Are these currency or land credits? } else { gb.TotalTierCredits += amount; // .. or this? } // update the group balance gb.Balance += amount; GroupCurrencyUpdate(groupID, gb, true); //Must send out notifications to the users involved so that they get the updates if (m_userInfoService == null) { m_userInfoService = m_registry.RequestModuleInterface <IAgentInfoService>(); m_userAccountService = m_registry.RequestModuleInterface <IUserAccountService> (); } if (m_userInfoService != null) { UserInfo agentInfo = userId == UUID.Zero ? null : m_userInfoService.GetUserInfo(userId.ToString()); UserAccount agentAccount = m_userAccountService.GetUserAccount(null, userId); var groupService = Framework.Utilities.DataManager.RequestPlugin <IGroupsServiceConnector> (); var groupInfo = groupService.GetGroupRecord(userId, groupID, null); var groupName = "Unknown"; if (groupInfo != null) { groupName = groupInfo.GroupName; } if (m_config.SaveTransactionLogs) { AddGroupTransactionRecord( (transactionID == UUID.Zero ? UUID.Random() : transactionID), description, groupID, groupName, userId, (agentAccount == null ? "System" : agentAccount.Name), amount, type, gb.TotalTierCredits, // assume this it the 'total credit for the group but it may be land tier credit?? (int)fromBalance, // this will be zero if this isa system <> group transaction toObjectName, fromObjectName, (agentInfo == null ? UUID.Zero : agentInfo.CurrentRegionID) ); } if (agentInfo != null && agentInfo.IsOnline) { SendUpdateMoneyBalanceToClient(userId, transactionID, agentInfo.CurrentRegionURI, fromBalance, "You paid " + groupName + " " + InWorldCurrency + amount); } } return(true); }
public bool UserCurrencyTransfer(UUID toID, UUID fromID, UUID toObjectID, string toObjectName, UUID fromObjectID, string fromObjectName, uint amount, string description, TransactionType type, UUID transactionID) { object remoteValue = DoRemoteByURL("CurrencyServerURI", toID, fromID, toObjectID, toObjectName, fromObjectID, fromObjectName, amount, description, type, transactionID); if (remoteValue != null || m_doRemoteOnly) { return((bool)remoteValue); } UserCurrency toCurrency = GetUserCurrency(toID); UserCurrency fromCurrency = fromID == UUID.Zero ? null : GetUserCurrency(fromID); if (toCurrency == null) { return(false); } if (fromCurrency != null) { //Check to see whether they have enough money if ((int)fromCurrency.Amount - (int)amount < 0) { return(false); //Not enough money } fromCurrency.Amount -= amount; UserCurrencyUpdate(fromCurrency, true); } if (fromID == toID) { toCurrency = GetUserCurrency(toID); } //Update the user whose getting paid toCurrency.Amount += amount; UserCurrencyUpdate(toCurrency, true); //Must send out notifications to the users involved so that they get the updates if (m_syncMessagePoster == null) { m_syncMessagePoster = m_registry.RequestModuleInterface <ISyncMessagePosterService>(); m_userInfoService = m_registry.RequestModuleInterface <IAgentInfoService>(); } if (m_syncMessagePoster != null) { UserInfo toUserInfo = m_userInfoService.GetUserInfo(toID.ToString()); UserInfo fromUserInfo = fromID == UUID.Zero ? null : m_userInfoService.GetUserInfo(fromID.ToString()); UserAccount toAccount = m_registry.RequestModuleInterface <IUserAccountService>() .GetUserAccount(null, toID); UserAccount fromAccount = m_registry.RequestModuleInterface <IUserAccountService>() .GetUserAccount(null, fromID); if (m_config.SaveTransactionLogs) { AddTransactionRecord((transactionID == UUID.Zero ? UUID.Random() : transactionID), description, toID, fromID, amount, type, (toCurrency == null ? 0 : toCurrency.Amount), (fromCurrency == null ? 0 : fromCurrency.Amount), (toAccount == null ? "System" : toAccount.Name), (fromAccount == null ? "System" : fromAccount.Name), toObjectName, fromObjectName, (fromUserInfo == null ? UUID.Zero : fromUserInfo.CurrentRegionID)); } if (fromID == toID) { if (toUserInfo != null && toUserInfo.IsOnline) { SendUpdateMoneyBalanceToClient(toID, transactionID, toUserInfo.CurrentRegionURI, toCurrency.Amount, toAccount == null ? "" : (toAccount.Name + " paid you $" + amount + (description == "" ? "" : ": " + description))); } } else { if (toUserInfo != null && toUserInfo.IsOnline) { SendUpdateMoneyBalanceToClient(toID, transactionID, toUserInfo.CurrentRegionURI, toCurrency.Amount, fromAccount == null ? "" : (fromAccount.Name + " paid you $" + amount + (description == "" ? "" : ": " + description))); } if (fromUserInfo != null && fromUserInfo.IsOnline) { SendUpdateMoneyBalanceToClient(fromID, transactionID, fromUserInfo.CurrentRegionURI, fromCurrency.Amount, "You paid " + (toAccount == null ? "" : toAccount.Name) + " $" + amount); } } } return(true); }
public XmlRpcResponse PreflightBuyLandPrepFunc(XmlRpcRequest request, IPEndPoint ep) { Hashtable requestData = (Hashtable)request.Params [0]; XmlRpcResponse ret = new XmlRpcResponse(); Hashtable retparam = new Hashtable(); Hashtable membershiplevels = new Hashtable(); membershiplevels.Add("levels", membershiplevels); Hashtable landuse = new Hashtable(); Hashtable level = new Hashtable { { "id", "00000000-0000-0000-0000-000000000000" }, { m_connector.GetConfig().UpgradeMembershipUri, "Premium Membership" } }; if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy")) { UUID agentId; UUID.TryParse((string)requestData ["agentId"], out agentId); UserCurrency currency = m_connector.GetUserCurrency(agentId); IUserProfileInfo profile = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector> ("IProfileConnector").GetUserProfile(agentId); OSDMap replyData = null; bool response = false; UserInfo user = m_agentInfoService.GetUserInfo(agentId.ToString()); if (user == null) { landuse.Add("action", false); retparam.Add("success", false); retparam.Add("currency", currency); retparam.Add("membership", level); retparam.Add("landuse", landuse); retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); ret.Value = retparam; } else { OSDMap map = new OSDMap(); map ["Method"] = "GetLandData"; map ["AgentID"] = agentId; m_syncMessagePoster.Get(user.CurrentRegionURI, map, (o) => { replyData = o; response = true; }); while (!response) { Thread.Sleep(10); } if (replyData == null || replyData ["Success"] == false) { landuse.Add("action", false); retparam.Add("success", false); retparam.Add("currency", currency); retparam.Add("membership", level); retparam.Add("landuse", landuse); retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); ret.Value = retparam; } else { if (replyData.ContainsKey("SalePrice")) { int landTierNeeded = (int)(currency.LandInUse + replyData ["Area"].AsInteger()); bool needsUpgrade = false; switch (profile.MembershipGroup) { case "Premium": case "": needsUpgrade = landTierNeeded >= currency.Tier; break; case "Banned": needsUpgrade = true; break; } landuse.Add("action", needsUpgrade); retparam.Add("success", true); retparam.Add("currency", currency); retparam.Add("membership", level); retparam.Add("landuse", landuse); retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); ret.Value = retparam; } } } } return(ret); }
public XmlRpcResponse PreflightBuyLandPrepFunc(XmlRpcRequest request, IPEndPoint ep) { Hashtable requestData = (Hashtable)request.Params[0]; XmlRpcResponse ret = new XmlRpcResponse(); Hashtable retparam = new Hashtable(); Hashtable membershiplevels = new Hashtable(); membershiplevels.Add("levels", membershiplevels); Hashtable landuse = new Hashtable(); Hashtable level = new Hashtable { { "id", "00000000-0000-0000-0000-000000000000" }, { m_connector.GetConfig().UpgradeMembershipUri, "Premium Membership" } }; if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy")) { UUID agentId; UUID.TryParse((string)requestData["agentId"], out agentId); UserCurrency currency = m_connector.GetUserCurrency(agentId); IUserProfileInfo profile = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>("IProfileConnector").GetUserProfile(agentId); //IClientCapsService client = m_dustCurrencyService.Registry.RequestModuleInterface<ICapsService>().GetClientCapsService(agentId); OSDMap replyData = null; bool response = false; UserInfo user = m_agentInfoService.GetUserInfo(agentId.ToString()); if (user == null) { landuse.Add("action", false); retparam.Add("success", false); retparam.Add("currency", currency); retparam.Add("membership", level); retparam.Add("landuse", landuse); retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); ret.Value = retparam; } else { OSDMap map = new OSDMap(); map["Method"] = "GetLandData"; map["AgentID"] = agentId; m_syncMessagePoster.Get(user.CurrentRegionURI, map, (o) => { replyData = o; response = true; }); while (!response) { Thread.Sleep(10); } if (replyData == null || replyData["Success"] == false) { landuse.Add("action", false); retparam.Add("success", false); retparam.Add("currency", currency); retparam.Add("membership", level); retparam.Add("landuse", landuse); retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); ret.Value = retparam; } else { //if (client != null) // m_dustCurrencyService.SendGridMessage(agentId, String.Format(m_dustCurrencyService.m_options.MessgeBeforeBuyLand, profile.DisplayName, replyData.ContainsKey("SalePrice")), false, UUID.Zero); if (replyData.ContainsKey("SalePrice")) { // I think, this might be usable if they don't have the money // Hashtable currencytable = new Hashtable { { "estimatedCost", replyData["SalePrice"].AsInteger() } }; int landTierNeeded = (int)(currency.LandInUse + replyData["Area"].AsInteger()); bool needsUpgrade = false; switch (profile.MembershipGroup) { case "Premium": case "": needsUpgrade = landTierNeeded >= currency.Tier; break; case "Banned": needsUpgrade = true; break; } // landuse.Add("action", m_DustCurrencyService.m_options.upgradeMembershipUri); landuse.Add("action", needsUpgrade); retparam.Add("success", true); retparam.Add("currency", currency); retparam.Add("membership", level); retparam.Add("landuse", landuse); retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); ret.Value = retparam; } } } } return(ret); }
public bool GroupCurrencyTransfer(UUID groupID, UUID userId, bool payUser, string toObjectName, UUID fromObjectID, string fromObjectName, int amount, string description, TransactionType transType, UUID transactionID) { // Groups (legacy) should not receive stipends if (transType == TransactionType.StipendPayment) { return(false); } GroupBalance gb = new GroupBalance { StartingDate = DateTime.UtcNow }; // Not sure if a group will receive a system payment (UUID = Zero) but.. UserCurrency fromuserCurrency = userId == UUID.Zero ? null : GetUserCurrency(userId); if (fromuserCurrency != null) { // Normal users cannot have a credit balance.. check to see whether they have enough money if ((int)fromuserCurrency.Amount - amount < 0) { return(false); // Not enough money } } // is this a payment from a user to the group or from the group to the user? if (payUser) { gb.TotalTierDebits += amount; // not sure if this the correct place yet? Total of group payments amount = -1 * amount; } else { gb.TotalTierCredits += amount; // .. total of group receipts } uint userBalance = 0; if (fromuserCurrency != null) { // user payment fromuserCurrency.Amount -= (uint)amount; UserCurrencyUpdate(fromuserCurrency, true); userBalance = fromuserCurrency.Amount; } // track specific group fees switch (transType) { case TransactionType.GroupJoin: gb.GroupFee += amount; break; case TransactionType.LandAuction: gb.LandFee += amount; break; case TransactionType.ParcelDirFee: gb.ParcelDirectoryFee += amount; break; } // update the group balance gb.Balance += amount; GroupCurrencyUpdate(groupID, gb, true); // Must send out notifications to the users involved so that they get the updates if (m_userInfoService != null) { UserInfo agentInfo = userId == UUID.Zero ? null : m_userInfoService.GetUserInfo(userId.ToString()); UserAccount agentAccount = m_userAccountService.GetUserAccount(null, userId); var groupService = Framework.Utilities.DataManager.RequestPlugin <IGroupsServiceConnector> (); var groupInfo = groupService.GetGroupRecord(userId, groupID, null); var groupName = "Unknown"; if (groupInfo != null) { groupName = groupInfo.GroupName; } // record the group transaction if (m_config.SaveTransactionLogs) { AddGroupTransactionRecord( (transactionID == UUID.Zero ? UUID.Random() : transactionID), description, groupID, groupName, userId, (agentAccount.Valid ? agentAccount.Name : "System"), amount, transType, gb.TotalTierCredits, // assume this it the 'total credit for the group but it may be land tier credit?? (int)userBalance, // this will be zero if this isa system <> group transaction toObjectName, fromObjectName, (agentInfo == null ? UUID.Zero : agentInfo.CurrentRegionID) ); } var paidToMsg = ""; var paidFromMsg = ""; var paidDesc = (description == "" ? "" : " for " + description); if (amount > 0) { paidToMsg = (groupInfo == null ? " received " : groupName + " paid you ") + InWorldCurrency + amount + paidDesc; paidFromMsg = "You paid " + (groupInfo == null ? "" : groupName + " ") + InWorldCurrency + amount + paidDesc; } if (agentInfo != null) { if (payUser) { if (agentInfo.IsOnline) { SendUpdateMoneyBalanceToClient(userId, transactionID, agentInfo.CurrentRegionURI, userBalance, paidToMsg); } } else { if (fromObjectID != UUID.Zero) { SendUpdateMoneyBalanceToClient(fromObjectID, transactionID, agentInfo.CurrentRegionURI, (uint)amount, paidFromMsg); } } } } return(true); }