List <ParcelExperienceEntry> IParcelExperienceList.this[UUID regionID, UUID parcelID] { get { var result = new List <ParcelExperienceEntry>(); using (var connection = new MySqlConnection(m_ConnectionString)) { connection.Open(); using (var cmd = new MySqlCommand("SELECT * FROM parcelexperiences WHERE RegionID = @regionid AND ParcelID = @parcelid", connection)) { cmd.Parameters.AddParameter("@regionid", regionID); cmd.Parameters.AddParameter("@parcelid", parcelID); using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { var entry = new ParcelExperienceEntry { RegionID = reader.GetUUID("RegionID"), ParcelID = reader.GetUUID("ParcelID"), ExperienceID = new UEI(reader.GetUUID("ExperienceID")), IsAllowed = reader.GetBool("IsAllowed") }; result.Add(entry); } } } } return(result); } }
private bool CompareEntry(ParcelExperienceEntry a, ParcelExperienceEntry b) { var items = new List <string>(); if (a.RegionID != b.RegionID) { items.Add("RegionID"); } if (a.ExperienceID != b.ExperienceID) { items.Add("ExperienceID"); } if (a.ParcelID != b.ParcelID) { items.Add("ParcelID"); } if (a.IsAllowed != b.IsAllowed) { items.Add("IsAllowed"); } if (items.Count != 0) { m_Log.InfoFormat("Mismatched items: {0}", string.Join(" ", items)); } return(items.Count == 0); }
bool IParcelExperienceList.TryGetValue(UUID regionID, UUID parcelID, UEI experienceID, out ParcelExperienceEntry entry) { using (var connection = new MySqlConnection(m_ConnectionString)) { connection.Open(); /* we use a specific implementation to reduce the result set here */ using (var cmd = new MySqlCommand("SELECT IsAllowed FROM parcelexperiences WHERE RegionID = @regionid AND ParcelID = @parcelid AND ExperienceID LIKE @experienceid LIMIT 1", connection)) { cmd.Parameters.AddParameter("@regionid", regionID); cmd.Parameters.AddParameter("@parcelid", parcelID); cmd.Parameters.AddParameter("@experienceid", experienceID.ID); using (MySqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { entry = new ParcelExperienceEntry { RegionID = regionID, ParcelID = parcelID, ExperienceID = new UEI(experienceID), IsAllowed = reader.GetBool("IsAllowed") }; return(true); } } } entry = default(ParcelExperienceEntry); return(false); } }
public ParcelExperienceEntry(ParcelExperienceEntry src) { RegionID = src.RegionID; ParcelID = src.ParcelID; ExperienceID = src.ExperienceID; IsAllowed = src.IsAllowed; }
bool IParcelExperienceList.TryGetValue(UUID regionID, UUID parcelID, UEI experienceID, out ParcelExperienceEntry entry) { RwLockedDictionary <UUID, ParcelExperienceEntry> list; ParcelExperienceEntry ret; if (m_Data.TryGetValue(GenParcelAccessListKey(regionID, parcelID), out list) && list.TryGetValue(experienceID.ID, out ret)) { entry = new ParcelExperienceEntry(ret); return(true); } entry = default(ParcelExperienceEntry); return(false); }
void IParcelExperienceList.Store(ParcelExperienceEntry entry) { using (var connection = new MySqlConnection(m_ConnectionString)) { connection.Open(); var data = new Dictionary <string, object> { ["RegionID"] = entry.RegionID, ["ParcelID"] = entry.ParcelID, ["ExperienceID"] = entry.ExperienceID.ID, ["IsAllowed"] = entry.IsAllowed }; connection.ReplaceInto("parcelexperiences", data); } }
private void ParcelAccessListUpdateManage(UUID parcelID, Dictionary <UUID, ParcelAccessListUpdate.Data> entries, IParcelExperienceList list, bool setallow) { IEnumerable <ParcelExperienceEntry> reslist = from entry in list[Scene.ID, parcelID] where (entry.IsAllowed && setallow) || (!entry.IsAllowed && !setallow) select entry; foreach (var listed in reslist) { if (!entries.ContainsKey(listed.ExperienceID.ID)) { list.Remove(Scene.ID, parcelID, listed.ExperienceID); } } foreach (var upd in entries.Values) { UEI expInfo; if (Scene.ExperienceService.TryGetValue(upd.ID, out expInfo)) { var pae = new ParcelExperienceEntry { RegionID = Scene.ID, ExperienceID = expInfo, IsAllowed = setallow, ParcelID = parcelID }; list.Store(pae); } else if (Agent.ExperienceService != null && Agent.ExperienceService.TryGetValue(upd.ID, out expInfo) && Agent.ExperienceService.TryRequestAuthorization(Agent.Owner, expInfo)) { Scene.ExperienceNameService?.Store(expInfo); var pae = new ParcelExperienceEntry { RegionID = Scene.ID, ExperienceID = expInfo, IsAllowed = setallow, ParcelID = parcelID }; list.Store(pae); } } }
public override bool Run() { var regionID = new UUID("12345678-1234-1234-1234-123456789012"); var experienceID = new UEI("11223344-1122-1122-1122-112233445566"); var experienceID2 = new UEI("11223344-1122-1122-1122-112233445567"); var parcelID = new UUID("11223344-1122-1122-1122-665544332211"); var testentry = new ParcelExperienceEntry { RegionID = regionID, ExperienceID = experienceID, ParcelID = parcelID, IsAllowed = true }; ParcelExperienceEntry entry; m_Log.Info("Testing non-existence 1A"); if (SimulationData.Parcels.Experiences.TryGetValue(regionID, parcelID, experienceID, out entry)) { return(false); } m_Log.Info("Testing non-existence 2A"); try { entry = SimulationData.Parcels.Experiences[regionID, parcelID, experienceID]; return(false); } catch (KeyNotFoundException) { /* this is the expected */ } m_Log.Info("Testing non-existence 3A"); if (SimulationData.Parcels.Experiences[regionID, parcelID].Count != 0) { return(false); } SimulationData.Parcels.Experiences.Store(testentry); m_Log.Info("Testing existence 1A"); if (!SimulationData.Parcels.Experiences.TryGetValue(regionID, parcelID, experienceID, out entry)) { return(false); } if (!CompareEntry(entry, testentry)) { return(false); } m_Log.Info("Testing existence 2A"); entry = SimulationData.Parcels.Experiences[regionID, parcelID, experienceID]; if (!CompareEntry(entry, testentry)) { return(false); } m_Log.Info("Testing existence 3A"); List <ParcelExperienceEntry> entries = SimulationData.Parcels.Experiences[regionID, parcelID]; if (entries.Count != 1) { return(false); } if (!CompareEntry(entries[0], testentry)) { return(false); } m_Log.Info("Removing entry"); if (!SimulationData.Parcels.Experiences.Remove(regionID, parcelID, experienceID)) { return(false); } m_Log.Info("Testing that a non-existing entry on removal is false"); if (SimulationData.Parcels.Experiences.Remove(regionID, parcelID, experienceID)) { return(false); } testentry.IsAllowed = false; m_Log.Info("Testing non-existence 1B"); if (SimulationData.Parcels.Experiences.TryGetValue(regionID, parcelID, experienceID, out entry)) { return(false); } m_Log.Info("Testing non-existence 2B"); try { entry = SimulationData.Parcels.Experiences[regionID, parcelID, experienceID]; return(false); } catch (KeyNotFoundException) { /* this is the expected */ } m_Log.Info("Testing non-existence 3B"); if (SimulationData.Parcels.Experiences[regionID, parcelID].Count != 0) { return(false); } SimulationData.Parcels.Experiences.Store(testentry); m_Log.Info("Testing existence 1B"); if (!SimulationData.Parcels.Experiences.TryGetValue(regionID, parcelID, experienceID, out entry)) { return(false); } if (!CompareEntry(entry, testentry)) { return(false); } m_Log.Info("Testing existence 2B"); entry = SimulationData.Parcels.Experiences[regionID, parcelID, experienceID]; if (!CompareEntry(entry, testentry)) { return(false); } m_Log.Info("Testing existence 3B"); entries = SimulationData.Parcels.Experiences[regionID, parcelID]; if (entries.Count != 1) { return(false); } if (!CompareEntry(entries[0], testentry)) { return(false); } m_Log.Info("Removing entry"); if (!SimulationData.Parcels.Experiences.Remove(regionID, parcelID, experienceID)) { return(false); } m_Log.Info("Testing that a non-existing entry on removal is false"); if (SimulationData.Parcels.Experiences.Remove(regionID, parcelID, experienceID)) { return(false); } var testentry2 = new ParcelExperienceEntry { RegionID = regionID, ExperienceID = experienceID2, ParcelID = parcelID, IsAllowed = true }; m_Log.Info("Store two entries"); SimulationData.Parcels.Experiences.Store(testentry); SimulationData.Parcels.Experiences.Store(testentry2); m_Log.Info("Check that two entries exist"); if (SimulationData.Parcels.Experiences[regionID, parcelID].Count != 2) { return(false); } m_Log.Info("Remove first entry"); if (!SimulationData.Parcels.Experiences.Remove(regionID, parcelID, experienceID)) { return(false); } m_Log.Info("Check existence of entry 2"); if (!SimulationData.Parcels.Experiences.TryGetValue(regionID, parcelID, experienceID2, out entry)) { return(false); } m_Log.Info("Re-add first entry"); SimulationData.Parcels.Experiences.Store(testentry); m_Log.Info("Remove all experience entries"); SimulationData.Parcels.Experiences.Remove(regionID, parcelID); m_Log.Info("Check that no entries exist"); if (SimulationData.Parcels.Experiences[regionID, parcelID].Count != 0) { return(false); } return(true); }
public void Store(ParcelExperienceEntry entry) { string key = GenParcelAccessListKey(entry.RegionID, entry.ParcelID); m_Data[key][entry.ExperienceID.ID] = new ParcelExperienceEntry(entry); }