bool IUserPreferencesInterface.TryGetValue(UUI user, out ProfilePreferences prefs) { using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT * FROM usersettings where useruuid = @uuid", conn)) { cmd.Parameters.AddParameter("@uuid", user.ID); using (MySqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { prefs = new ProfilePreferences() { User = user, IMviaEmail = reader.GetBool("imviaemail"), Visible = reader.GetBool("visible") }; return(true); } else { prefs = new ProfilePreferences() { User = user, IMviaEmail = false, Visible = false }; return(true); } } } } }
public static GroupInfo ToGroupInfo(this MySqlDataReader reader, string memberCount = "MemberCount") { var info = new GroupInfo(); info.ID.ID = reader.GetUUID("GroupID"); string uri = reader.GetString("Location"); if (!string.IsNullOrEmpty(uri)) { info.ID.HomeURI = new Uri(uri, UriKind.Absolute); } info.ID.GroupName = reader.GetString("Name"); info.Charter = reader.GetString("Charter"); info.InsigniaID = reader.GetUUID("InsigniaID"); info.Founder.ID = reader.GetUUID("FounderID"); info.MembershipFee = reader.GetInt32("MembershipFee"); info.IsOpenEnrollment = reader.GetBool("OpenEnrollment"); info.IsShownInList = reader.GetBool("ShowInList"); info.IsAllowPublish = reader.GetBool("AllowPublish"); info.IsMaturePublish = reader.GetBool("MaturePublish"); info.OwnerRoleID = reader.GetUUID("OwnerRoleID"); info.MemberCount = reader.GetInt32(memberCount); info.RoleCount = reader.GetInt32("RoleCount"); return(info); }
public static GroupMember ToGroupMember(this MySqlDataReader reader) => new GroupMember() { Group = new UGI(reader.GetUUID("GroupID")), Principal = new UUI(reader.GetUUID("PrincipalID")), SelectedRoleID = reader.GetUUID("SelectedRoleID"), Contribution = reader.GetInt32("Contribution"), IsListInProfile = reader.GetBool("ListInProfile"), IsAcceptNotices = reader.GetBool("AcceptNotices"), AccessToken = reader.GetString("AccessToken") };
ProfileProperties IPropertiesInterface.this[UGUI user] { get { using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT * FROM userprofile where useruuid = @uuid LIMIT 1", conn)) { cmd.Parameters.AddParameter("@uuid", user.ID); using (MySqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { return(new ProfileProperties { User = user, Partner = reader.GetUGUI("profilePartner"), PublishProfile = reader.GetBool("profileAllowPublish"), PublishMature = reader.GetBool("profileMaturePublish"), WebUrl = reader.GetString("profileURL"), WantToMask = reader.GetUInt32("profileWantToMask"), WantToText = reader.GetString("profileWantToText"), SkillsMask = reader.GetUInt32("profileSkillsMask"), SkillsText = reader.GetString("profileSkillsText"), Language = reader.GetString("profileLanguages"), ImageID = reader.GetUUID("profileImage"), AboutText = reader.GetString("profileAboutText"), FirstLifeImageID = reader.GetUUID("profileFirstImage"), FirstLifeText = reader.GetString("profileFirstText") }); } else { return(new ProfileProperties { User = user, Partner = UGUI.Unknown, WebUrl = string.Empty, WantToText = string.Empty, SkillsText = string.Empty, Language = string.Empty, AboutText = string.Empty, FirstLifeText = string.Empty }); } } } } } }
ProfilePreferences IUserPreferencesInterface.this[UUI user] { get { using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT * FROM usersettings where useruuid = @uuid", conn)) { cmd.Parameters.AddParameter("@uuid", user.ID); using (MySqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { return(new ProfilePreferences() { User = user, IMviaEmail = reader.GetBool("imviaemail"), Visible = reader.GetBool("visible") }); } else { return(new ProfilePreferences() { User = user, IMviaEmail = false, Visible = false }); } } } } } set { var replaceVals = new Dictionary <string, object> { ["useruuid"] = user.ID, ["imviaemail"] = value.IMviaEmail, ["visible"] = value.Visible }; using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); conn.ReplaceInto("usersettings", replaceVals); } } }
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); } }
bool IAssetMetadataServiceInterface.TryGetValue(UUID key, out AssetMetadata metadata) { using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT * FROM assetrefs WHERE id=@id LIMIT 1", conn)) { cmd.Parameters.AddParameter("@id", key); using (MySqlDataReader dbReader = cmd.ExecuteReader()) { if (dbReader.Read()) { metadata = new AssetMetadata { ID = dbReader.GetUUID("id"), Type = dbReader.GetEnum <AssetType>("assetType"), Name = dbReader.GetString("name"), CreateTime = dbReader.GetDate("create_time"), AccessTime = dbReader.GetDate("access_time"), Flags = dbReader.GetEnum <AssetFlags>("asset_flags"), Temporary = dbReader.GetBool("temporary") }; return(true); } } } } metadata = null; return(false); }
List <EstateExperienceInfo> IEstateExperienceServiceInterface.this[uint estateID] { get { var result = new List <EstateExperienceInfo>(); using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT * FROM estateexperiences WHERE EstateID = @estateid", conn)) { cmd.Parameters.AddParameter("@estateid", estateID); using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { result.Add(new EstateExperienceInfo { EstateID = reader.GetUInt32("EstateID"), ExperienceID = new UEI(reader.GetUUID("ExperienceID")), IsAllowed = reader.GetBool("IsAllowed") }); } } } } return(result); } }
bool IEstateExperienceServiceInterface.TryGetValue(uint estateID, UEI experienceID, out EstateExperienceInfo info) { using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT * FROM estateexperiences WHERE EstateID = @estateid AND ExperienceID = @experienceid LIMIT 1", conn)) { cmd.Parameters.AddParameter("@estateid", estateID); cmd.Parameters.AddParameter("@experienceid", experienceID.ID); using (MySqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { info = new EstateExperienceInfo { EstateID = estateID, ExperienceID = experienceID, IsAllowed = reader.GetBool("IsAllowed") }; return(true); } } } } info = default(EstateExperienceInfo); return(false); }
public static InventoryItem ToItem(this MySqlDataReader reader) { var item = new InventoryItem(reader.GetUUID("ID")) { ParentFolderID = reader.GetUUID("ParentFolderID"), Name = reader.GetString("Name"), Description = reader.GetString("Description"), InventoryType = reader.GetEnum <InventoryType>("InventoryType"), Flags = reader.GetEnum <InventoryFlags>("Flags"), CreationDate = reader.GetDate("CreationDate"), IsGroupOwned = reader.GetBool("IsGroupOwned"), AssetID = reader.GetUUID("AssetID"), AssetType = reader.GetEnum <AssetType>("AssetType"), Owner = reader.GetUGUI("OwnerID"), LastOwner = reader.GetUGUI("LastOwnerID"), Creator = reader.GetUGUI("CreatorID"), Group = new UGI(reader.GetUUID("GroupID")) }; item.Permissions.Base = reader.GetEnum <InventoryPermissionsMask>("BasePermissionsMask"); item.Permissions.Current = reader.GetEnum <InventoryPermissionsMask>("CurrentPermissionsMask"); item.Permissions.EveryOne = reader.GetEnum <InventoryPermissionsMask>("EveryOnePermissionsMask"); item.Permissions.NextOwner = reader.GetEnum <InventoryPermissionsMask>("NextOwnerPermissionsMask"); item.Permissions.Group = reader.GetEnum <InventoryPermissionsMask>("GroupPermissionsMask"); item.SaleInfo.Price = reader.GetInt32("SalePrice"); item.SaleInfo.Type = reader.GetEnum <InventoryItem.SaleInfoData.SaleType>("SaleType"); item.SaleInfo.PermMask = reader.GetEnum <InventoryPermissionsMask>("SalePermissionsMask"); return(item); }
bool IRegionExperienceList.TryGetValue(UUID regionID, UEI experienceID, out RegionExperienceInfo info) { using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT * FROM regionexperiences WHERE RegionID = @regionid AND ExperienceID = @experienceid LIMIT 1", conn)) { cmd.Parameters.AddParameter("@regionid", regionID); cmd.Parameters.AddParameter("@experienceid", experienceID.ID); using (MySqlDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { info = new RegionExperienceInfo { ExperienceID = new UEI(reader.GetUUID("ExperienceID")), RegionID = reader.GetUUID("RegionID"), IsAllowed = reader.GetBool("IsAllowed"), }; return(true); } } } } info = default(RegionExperienceInfo); return(false); }
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); } }
Dictionary <UUID, bool> IExperiencePermissionsInterface.this[UUI agent] { get { var result = new Dictionary <UUID, bool>(); using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT ExperienceID,User,IsAllowed FROM experienceusers WHERE User LIKE @user", conn)) { cmd.Parameters.AddParameter("@user", agent.ID.ToString() + "%"); using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { UUI ret = reader.GetUUI("User"); if (ret.EqualsGrid(agent)) { result.Add(reader.GetUUID("ExperienceID"), reader.GetBool("IsAllowed")); } } } } } return(result); } }
bool IExperiencePermissionsInterface.TryGetValue(UUID experienceID, UUI agent, out bool allowed) { using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT User,IsAllowed FROM experienceusers WHERE ExperienceID = @experienceid AND User LIKE @user", conn)) { cmd.Parameters.AddParameter("@experienceid", experienceID); cmd.Parameters.AddParameter("@user", agent.ID.ToString() + "%"); using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { UUI ret = reader.GetUUI("User"); if (ret.EqualsGrid(agent)) { allowed = reader.GetBool("IsAllowed"); return(true); } } } } } allowed = false; return(false); }
List <RegionExperienceInfo> IRegionExperienceList.this[UUID regionID] { get { List <RegionExperienceInfo> result = new List <RegionExperienceInfo>(); using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT * FROM regionexperiences WHERE RegionID = @regionid", conn)) { cmd.Parameters.AddParameter("@regionid", regionID); using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { result.Add(new RegionExperienceInfo { ExperienceID = new UEI(reader.GetUUID("ExperienceID")), RegionID = reader.GetUUID("RegionID"), IsAllowed = reader.GetBool("IsAllowed"), }); } } } } return(result); } }
private ObjectGroup ObjectGroupFromDbReader(MySqlDataReader dbReader) => new ObjectGroup() { IsTempOnRez = dbReader.GetBool("IsTempOnRez"), Owner = dbReader.GetUUI("Owner"), LastOwner = dbReader.GetUUI("LastOwner"), Group = dbReader.GetUGI("Group"), SaleType = dbReader.GetEnum <InventoryItem.SaleInfoData.SaleType>("SaleType"), SalePrice = dbReader.GetInt32("SalePrice"), PayPrice0 = dbReader.GetInt32("PayPrice0"), PayPrice1 = dbReader.GetInt32("PayPrice1"), PayPrice2 = dbReader.GetInt32("PayPrice2"), PayPrice3 = dbReader.GetInt32("PayPrice3"), PayPrice4 = dbReader.GetInt32("PayPrice4"), AttachedPos = dbReader.GetVector3("AttachedPos"), AttachPoint = dbReader.GetEnum <AttachmentPoint>("AttachPoint"), IsIncludedInSearch = dbReader.GetBool("IsIncludedInSearch"), RezzingObjectID = dbReader.GetUUID("RezzingObjectID") };
public static UserAccount ToUserAccount(this MySqlDataReader reader, Uri homeURI) { var info = new UserAccount(); string gkUri; UserRegionData regData; info.Principal.ID = reader.GetUUID("ID"); info.Principal.FirstName = reader.GetString("FirstName"); info.Principal.LastName = reader.GetString("LastName"); info.Principal.HomeURI = homeURI; info.Principal.IsAuthoritative = true; info.Email = reader.GetString("Email"); info.Created = reader.GetDate("Created"); info.UserLevel = reader.GetInt32("UserLevel"); info.UserFlags = reader.GetEnum <UserFlags>("UserFlags"); info.UserTitle = reader.GetString("UserTitle"); info.IsLocalToGrid = true; info.IsEverLoggedIn = reader.GetBool("IsEverLoggedIn"); gkUri = reader.GetString("LastGatekeeperURI"); regData = new UserRegionData { RegionID = reader.GetUUID("LastRegionID"), Position = reader.GetVector3("LastPosition"), LookAt = reader.GetVector3("LastLookAt"), }; if (!string.IsNullOrEmpty(gkUri)) { regData.GatekeeperURI = new URI(gkUri); } if (regData.RegionID != UUID.Zero) { info.LastRegion = regData; } gkUri = reader.GetString("HomeGatekeeperURI"); regData = new UserRegionData { RegionID = reader.GetUUID("HomeRegionID"), Position = reader.GetVector3("HomePosition"), LookAt = reader.GetVector3("HomeLookAt"), }; if (!string.IsNullOrEmpty(gkUri)) { regData.GatekeeperURI = new URI(gkUri); } if (regData.RegionID != UUID.Zero) { info.HomeRegion = regData; } return(info); }
private ObjectPartInventoryItem ObjectPartInventoryItemFromDbReader(MySqlDataReader dbReader) { var item = new ObjectPartInventoryItem(dbReader.GetUUID("InventoryID")) { AssetID = dbReader.GetUUID("AssetID"), AssetType = dbReader.GetEnum <AssetType>("AssetType"), CreationDate = dbReader.GetDate("CreationDate"), Creator = dbReader.GetUGUI("Creator"), Description = dbReader.GetString("Description"), Flags = dbReader.GetEnum <InventoryFlags>("Flags"), Group = dbReader.GetUGI("Group"), IsGroupOwned = dbReader.GetBool("GroupOwned"), InventoryType = dbReader.GetEnum <InventoryType>("InventoryType"), LastOwner = dbReader.GetUGUI("LastOwner"), Name = dbReader.GetString("Name"), Owner = dbReader.GetUGUI("Owner"), ParentFolderID = dbReader.GetUUID("PrimID"), NextOwnerAssetID = dbReader.GetUUID("NextOwnerAssetID"), ExperienceID = dbReader.GetUEI("ExperienceID"), CollisionFilter = new ObjectPartInventoryItem.CollisionFilterParam { DbSerialization = dbReader.GetBytes("CollisionFilterData") } }; item.Permissions.Base = dbReader.GetEnum <InventoryPermissionsMask>("BasePermissions"); item.Permissions.Current = dbReader.GetEnum <InventoryPermissionsMask>("CurrentPermissions"); item.Permissions.EveryOne = dbReader.GetEnum <InventoryPermissionsMask>("EveryOnePermissions"); item.Permissions.Group = dbReader.GetEnum <InventoryPermissionsMask>("GroupPermissions"); item.Permissions.NextOwner = dbReader.GetEnum <InventoryPermissionsMask>("NextOwnerPermissions"); item.SaleInfo.Type = dbReader.GetEnum <InventoryItem.SaleInfoData.SaleType>("SaleType"); item.SaleInfo.Price = dbReader.GetInt32("SalePrice"); item.SaleInfo.PermMask = dbReader.GetEnum <InventoryPermissionsMask>("SalePermMask"); var grantinfo = new ObjectPartInventoryItem.PermsGranterInfo(); if (((string)dbReader["PermsGranter"]).Length != 0) { try { grantinfo.PermsGranter = dbReader.GetUGUI("PermsGranter"); } catch { /* no action required */ } } grantinfo.PermsMask = dbReader.GetEnum <ScriptPermissions>("PermsMask"); grantinfo.DebitPermissionKey = dbReader.GetUUID("DebitPermissionKey"); item.PermsGranter = grantinfo; return(item); }
public static GridUserInfo ToGridUser(this MySqlDataReader reader) => new GridUserInfo() { User = new UUI(reader.GetUUID("ID")), HomeRegionID = reader.GetUUID("HomeRegionID"), HomeLookAt = reader.GetVector3("HomeLookAt"), HomePosition = reader.GetVector3("HomePosition"), LastRegionID = reader.GetUUID("LastRegionID"), LastLookAt = reader.GetVector3("LastLookAt"), LastPosition = reader.GetVector3("LastPosition"), IsOnline = reader.GetBool("IsOnline"), LastLogin = reader.GetDate("LastLogin"), LastLogout = reader.GetDate("LastLogout") };
public static GroupNotice ToGroupNotice(this MySqlDataReader reader) => new GroupNotice() { Group = new UGI(reader.GetUUID("GroupID")), ID = reader.GetUUID("NoticeID"), Timestamp = reader.GetDate("Timestamp"), FromName = reader.GetString("FromName"), Subject = reader.GetString("Subject"), Message = reader.GetString("Message"), HasAttachment = reader.GetBool("HasAttachment"), AttachmentType = reader.GetEnum <AssetType>("AttachmentType"), AttachmentName = reader.GetString("AttachmentName"), AttachmentItemID = reader.GetUUID("AttachmentItemID"), AttachmentOwner = new UUI(reader.GetUUID("AttachmentOwnerID")) };
public static EstateInfo ToEstateInfo(this MySqlDataReader reader) => new EstateInfo { ID = reader.GetUInt32("ID"), Name = reader.GetString("Name"), Owner = reader.GetUGUI("Owner"), Flags = reader.GetEnum <RegionOptionFlags>("Flags"), PricePerMeter = reader.GetInt32("PricePerMeter"), BillableFactor = reader.GetDouble("BillableFactor"), SunPosition = reader.GetDouble("SunPosition"), AbuseEmail = reader.GetString("AbuseEmail"), CovenantID = reader.GetUUID("CovenantID"), CovenantTimestamp = reader.GetDate("CovenantTimestamp"), UseGlobalTime = reader.GetBool("UseGlobalTime"), ParentEstateID = reader.GetUInt32("ParentEstateID") };
internal List <UUID> GetAssetRefs(UUID key) { var references = new List <UUID>(); using (var conn = new MySqlConnection(m_ConnectionString)) { bool processed; conn.Open(); using (var cmd = new MySqlCommand("SELECT usesprocessed FROM assetrefs WHERE id = @id LIMIT 1", conn)) { cmd.Parameters.AddParameter("@id", key); using (MySqlDataReader dbReader = cmd.ExecuteReader()) { processed = dbReader.Read() && dbReader.GetBool("usesprocessed"); } } AssetData data; if (processed) { using (var cmd = new MySqlCommand("SELECT usesid FROM assetsinuse WHERE id = @id", conn)) { cmd.Parameters.AddParameter("@id", key); using (MySqlDataReader dbReader = cmd.ExecuteReader()) { while (dbReader.Read()) { references.Add(dbReader.GetUUID("usesid")); } } } } else if (TryGetValue(key, out data)) { references = data.References; references.Remove(UUID.Zero); references.Remove(data.ID); } else { throw new AssetNotFoundException(key); } return(references); } }
public override bool TryGetValue(UUID key, out AssetMetadata metadata, out int length) { metadata = null; length = 0; using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT id, LENGTH(data) AS dataLength, assetrefs.assetType, name, create_time, access_time, asset_flags, temporary FROM assetrefs INNER JOIN assetdata ON assetrefs.hash = assetdata.hash AND assetrefs.assetType = assetdata.assetType WHERE id = @id LIMIT 1", conn)) { cmd.Parameters.AddParameter("@id", key); using (MySqlDataReader dbReader = cmd.ExecuteReader()) { if (!dbReader.Read()) { return(false); } metadata = new AssetMetadata { ID = dbReader.GetUUID("id"), Type = dbReader.GetEnum <AssetType>("assetType"), Name = dbReader.GetString("name"), CreateTime = dbReader.GetDate("create_time"), AccessTime = dbReader.GetDate("access_time"), Flags = dbReader.GetEnum <AssetFlags>("asset_flags"), Temporary = dbReader.GetBool("temporary") }; length = dbReader.GetInt32("dataLength"); } } if (DateTime.UtcNow - metadata.AccessTime > TimeSpan.FromHours(1)) { /* update access_time */ using (var cmd = new MySqlCommand("UPDATE assetrefs SET access_time = @access WHERE id = @id", conn)) { cmd.Parameters.AddWithValue("@access", Date.GetUnixTime()); cmd.Parameters.AddWithValue("@id", key); cmd.ExecuteNonQuery(); } } return(true); } }
public static UserAccount ToUserAccount(this MySqlDataReader reader, Uri homeURI) { var info = new UserAccount(); info.Principal.ID = reader.GetUUID("ID"); info.Principal.FirstName = reader.GetString("FirstName"); info.Principal.LastName = reader.GetString("LastName"); info.Principal.HomeURI = homeURI; info.Principal.IsAuthoritative = true; info.ScopeID = reader.GetUUID("ScopeID"); info.Email = reader.GetString("Email"); info.Created = reader.GetDate("Created"); info.UserLevel = reader.GetInt32("UserLevel"); info.UserFlags = reader.GetUInt32("UserFlags"); info.UserTitle = reader.GetString("UserTitle"); info.IsLocalToGrid = true; info.IsEverLoggedIn = reader.GetBool("IsEverLoggedIn"); return(info); }
public override bool TryGetValue(UUID key, out AssetData asset) { asset = null; using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT * FROM assetrefs INNER JOIN assetdata ON assetrefs.hash = assetdata.hash AND assetrefs.assetType = assetdata.assetType WHERE id = @id", conn)) { cmd.Parameters.AddParameter("@id", key); using (MySqlDataReader dbReader = cmd.ExecuteReader()) { if (!dbReader.Read()) { return(false); } asset = new AssetData() { ID = dbReader.GetUUID("id"), Data = dbReader.GetBytes("data"), Type = dbReader.GetEnum <AssetType>("assetType"), Name = dbReader.GetString("name"), CreateTime = dbReader.GetDate("create_time"), AccessTime = dbReader.GetDate("access_time"), Flags = dbReader.GetEnum <AssetFlags>("asset_flags"), Temporary = dbReader.GetBool("temporary") }; } } if (DateTime.UtcNow - asset.AccessTime > TimeSpan.FromHours(1)) { /* update access_time */ using (var cmd = new MySqlCommand("UPDATE assetrefs SET access_time = @access WHERE id = @id", conn)) { cmd.Parameters.AddWithValue("@access", Date.GetUnixTime()); cmd.Parameters.AddWithValue("@id", key); cmd.ExecuteNonQuery(); } } return(true); } }
public override List <GridInstantMessage> GetOfflineIMs(UUID principalID) { var ims = new List <GridInstantMessage>(); using (var connection = new MySqlConnection(m_ConnectionString)) { connection.Open(); using (var cmd = new MySqlCommand("SELECT * FROM offlineim WHERE ToAgentID = @id", connection)) { cmd.Parameters.AddParameter("@id", principalID); using (MySqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { var im = new GridInstantMessage() { ID = reader.GetUInt64("ID"), FromAgent = reader.GetUUI("FromAgent"), FromGroup = reader.GetUGI("FromGroup"), ToAgent = new UUI(reader.GetUUID("ToAgentID")), Dialog = reader.GetEnum <GridInstantMessageDialog>("Dialog"), IsFromGroup = reader.GetBool("IsFromGroup"), Message = reader.GetString("Message"), IMSessionID = reader.GetUUID("IMSessionID"), Position = reader.GetVector3("Position"), BinaryBucket = reader.GetBytes("BinaryBucket"), ParentEstateID = reader.GetUInt32("ParentEstateID"), RegionID = reader.GetUUID("RegionID"), Timestamp = reader.GetDate("Timestamp"), IsOffline = true }; ims.Add(im); } } } } return(ims); }
private GroupMembership MembershipFromReader(MySqlDataReader reader, UUI requestingAgent) => new GroupMembership() { IsAcceptNotices = reader.GetBool("AcceptNotices"), Contribution = reader.GetInt32("Contribution"), GroupInsigniaID = reader.GetUUID("InsigniaID"), GroupPowers = reader.GetEnum <GroupPowers>("RolePowers"), GroupTitle = reader.GetString("RoleTitle"), IsListInProfile = reader.GetBool("ListInProfile"), Group = ResolveName(requestingAgent, new UGI(reader.GetUUID("GroupID"))), Principal = ResolveName(new UUI(reader.GetUUID("PrincipalID"))), IsAllowPublish = reader.GetBool("AllowPublish"), Charter = reader.GetString("Charter"), ActiveRoleID = reader.GetUUID("ActiveRoleID"), Founder = ResolveName(new UUI(reader.GetUUID("FounderID"))), AccessToken = reader.GetString("AccessToken"), IsMaturePublish = reader.GetBool("MaturePublish"), IsOpenEnrollment = reader.GetBool("OpenEnrollment"), MembershipFee = reader.GetInt32("MembershipFee"), IsShownInList = reader.GetBool("ShowInList") };
bool ISimulationDataLightShareStorageInterface.TryGetValue(UUID regionID, out EnvController.WindlightSkyData skyData, out EnvController.WindlightWaterData waterData) { using (var conn = new MySqlConnection(m_ConnectionString)) { conn.Open(); using (var cmd = new MySqlCommand("SELECT * FROM lightshare WHERE RegionID = @regionid LIMIT 1", conn)) { cmd.Parameters.AddWithValue("@regionid", regionID.ToString()); using (MySqlDataReader reader = cmd.ExecuteReader()) { if (!reader.Read()) { skyData = EnvController.WindlightSkyData.Defaults; waterData = EnvController.WindlightWaterData.Defaults; return(false); } skyData = new EnvController.WindlightSkyData { Ambient = reader.GetWLVector4("Ambient"), CloudColor = reader.GetWLVector4("CloudColor"), CloudCoverage = reader.GetDouble("CloudCoverage"), BlueDensity = reader.GetWLVector4("BlueDensity"), CloudDetailXYDensity = reader.GetVector3("CloudDetailXYDensity"), CloudScale = reader.GetDouble("CloudScale"), CloudScroll = reader.GetWLVector2("CloudScroll"), CloudScrollXLock = reader.GetBool("CloudScrollXLock"), CloudScrollYLock = reader.GetBool("CloudScrollYLock"), CloudXYDensity = reader.GetVector3("CloudXYDensity"), DensityMultiplier = reader.GetDouble("DensityMultiplier"), DistanceMultiplier = reader.GetDouble("DistanceMultiplier"), DrawClassicClouds = reader.GetBool("DrawClassicClouds"), EastAngle = reader.GetDouble("EastAngle"), HazeDensity = reader.GetDouble("HazeDensity"), HazeHorizon = reader.GetDouble("HazeHorizon"), Horizon = reader.GetWLVector4("Horizon"), MaxAltitude = reader.GetInt32("MaxAltitude"), SceneGamma = reader.GetDouble("SceneGamma"), SunGlowFocus = reader.GetDouble("SunGlowFocus"), SunGlowSize = reader.GetDouble("SunGlowSize"), SunMoonColor = reader.GetWLVector4("SunMoonColor"), SunMoonPosition = reader.GetDouble("SunMoonPosition") }; waterData = new EnvController.WindlightWaterData { BigWaveDirection = reader.GetWLVector2("BigWaveDirection"), LittleWaveDirection = reader.GetWLVector2("LittleWaveDirection"), BlurMultiplier = reader.GetDouble("BlurMultiplier"), FresnelScale = reader.GetDouble("FresnelScale"), FresnelOffset = reader.GetDouble("FresnelOffset"), NormalMapTexture = reader.GetUUID("NormalMapTexture"), ReflectionWaveletScale = reader.GetVector3("ReflectionWaveletScale"), RefractScaleAbove = reader.GetDouble("RefractScaleAbove"), RefractScaleBelow = reader.GetDouble("RefractScaleBelow"), UnderwaterFogModifier = reader.GetDouble("UnderwaterFogModifier"), Color = reader.GetColor("WaterColor"), FogDensityExponent = reader.GetDouble("FogDensityExponent") }; return(true); } } } }
ParcelInfo ISimulationDataParcelStorageInterface.this[UUID regionID, UUID parcelID] { get { using (var connection = new MySqlConnection(m_ConnectionString)) { connection.Open(); using (var cmd = new MySqlCommand("SELECT * FROM parcels WHERE RegionID = '" + regionID.ToString() + "' AND ParcelID = '" + parcelID.ToString() + "' LIMIT 1", connection)) { using (MySqlDataReader dbReader = cmd.ExecuteReader()) { if (!dbReader.Read()) { throw new KeyNotFoundException(); } var pi = new ParcelInfo((int)dbReader["BitmapWidth"], (int)dbReader["BitmapHeight"]) { Area = dbReader.GetInt32("Area"), AuctionID = dbReader.GetUInt32("AuctionID"), AuthBuyer = dbReader.GetUGUI("AuthBuyer"), Category = dbReader.GetEnum <ParcelCategory>("Category"), ClaimDate = dbReader.GetDate("ClaimDate"), ClaimPrice = dbReader.GetInt32("ClaimPrice"), ID = dbReader.GetUUID("ParcelID"), Group = dbReader.GetUGI("Group"), GroupOwned = dbReader.GetBool("IsGroupOwned"), Description = dbReader.GetString("Description"), Flags = dbReader.GetEnum <ParcelFlags>("Flags"), LandingType = dbReader.GetEnum <TeleportLandingType>("LandingType"), LandingPosition = dbReader.GetVector3("LandingPosition"), LandingLookAt = dbReader.GetVector3("LandingLookAt"), Name = dbReader.GetString("Name"), LocalID = dbReader.GetInt32("LocalID"), MediaID = dbReader.GetUUID("MediaID"), Owner = dbReader.GetUGUI("Owner"), SnapshotID = dbReader.GetUUID("SnapshotID"), SalePrice = dbReader.GetInt32("SalePrice"), OtherCleanTime = dbReader.GetInt32("OtherCleanTime"), MediaAutoScale = dbReader.GetBool("MediaAutoScale"), MediaType = dbReader.GetString("MediaType"), MediaWidth = dbReader.GetInt32("MediaWidth"), MediaHeight = dbReader.GetInt32("MediaHeight"), MediaLoop = dbReader.GetBool("MediaLoop"), ObscureMedia = dbReader.GetBool("ObscureMedia"), ObscureMusic = dbReader.GetBool("ObscureMusic"), MediaDescription = dbReader.GetString("MediaDescription"), RentPrice = dbReader.GetInt32("RentPrice"), AABBMin = dbReader.GetVector3("AABBMin"), AABBMax = dbReader.GetVector3("AABBMax"), ParcelPrimBonus = dbReader.GetDouble("ParcelPrimBonus"), PassPrice = dbReader.GetInt32("PassPrice"), PassHours = dbReader.GetDouble("PassHours"), ActualArea = dbReader.GetInt32("ActualArea"), BillableArea = dbReader.GetInt32("BillAbleArea"), Status = dbReader.GetEnum <ParcelStatus>("Status"), SeeAvatars = dbReader.GetBool("SeeAvatars"), AnyAvatarSounds = dbReader.GetBool("AnyAvatarSounds"), GroupAvatarSounds = dbReader.GetBool("GroupAvatarSounds"), IsPrivate = dbReader.GetBool("IsPrivate") }; pi.LandBitmap.DataNoAABBUpdate = dbReader.GetBytes("Bitmap"); var uri = (string)dbReader["MusicURI"]; if (!string.IsNullOrEmpty(uri)) { pi.MusicURI = new URI(uri); } uri = (string)dbReader["MediaURI"]; if (!string.IsNullOrEmpty(uri)) { pi.MediaURI = new URI(uri); } return(pi); } } } } }
private ObjectPart ObjectPartFromDbReader(MySqlDataReader dbReader) { var objpart = new ObjectPart(dbReader.GetUUID("ID")) { LoadedLinkNumber = dbReader.GetInt32("LinkNumber"), Position = dbReader.GetVector3("Position"), Rotation = dbReader.GetQuaternion("Rotation"), SitText = dbReader.GetString("SitText"), TouchText = dbReader.GetString("TouchText"), Name = dbReader.GetString("Name"), Description = dbReader.GetString("Description"), SitTargetOffset = dbReader.GetVector3("SitTargetOffset"), SitTargetOrientation = dbReader.GetQuaternion("SitTargetOrientation"), Creator = dbReader.GetUUI("Creator"), CreationDate = dbReader.GetDate("CreationDate"), RezDate = dbReader.GetDate("RezDate"), Flags = dbReader.GetEnum <PrimitiveFlags>("Flags"), CameraAtOffset = dbReader.GetVector3("CameraAtOffset"), CameraEyeOffset = dbReader.GetVector3("CameraEyeOffset"), PhysicsShapeType = dbReader.GetEnum <PrimitivePhysicsShapeType>("PhysicsShapeType"), PathfindingType = dbReader.GetEnum <PathfindingType>("PathfindingType"), WalkableCoefficientAvatar = dbReader.GetDouble("WalkableCoefficientAvatar"), WalkableCoefficientA = dbReader.GetDouble("WalkableCoefficientA"), WalkableCoefficientB = dbReader.GetDouble("WalkableCoefficientB"), WalkableCoefficientC = dbReader.GetDouble("WalkableCoefficientC"), WalkableCoefficientD = dbReader.GetDouble("WalkableCoefficientD"), Material = dbReader.GetEnum <PrimitiveMaterial>("Material"), Size = dbReader.GetVector3("Size"), Slice = dbReader.GetVector3("Slice"), MediaURL = dbReader.GetString("MediaURL"), AngularVelocity = dbReader.GetVector3("AngularVelocity"), PointLight = new ObjectPart.PointLightParam { DbSerialization = dbReader.GetBytes("LightData") }, Projection = new ObjectPart.ProjectionParam { DbSerialization = dbReader.GetBytes("ProjectionData") }, Text = new ObjectPart.TextParam { Serialization = dbReader.GetBytes("HoverTextData") }, Flexible = new ObjectPart.FlexibleParam { DbSerialization = dbReader.GetBytes("FlexibleData") }, Sound = new ObjectPart.SoundParam { Serialization = dbReader.GetBytes("LoopedSoundData") }, CollisionSound = new ObjectPart.CollisionSoundParam { Serialization = dbReader.GetBytes("ImpactSoundData") }, Shape = new ObjectPart.PrimitiveShape { Serialization = dbReader.GetBytes("PrimitiveShapeData") }, ParticleSystemBytes = dbReader.GetBytes("ParticleSystem"), TextureEntryBytes = dbReader.GetBytes("TextureEntryBytes"), TextureAnimationBytes = dbReader.GetBytes("TextureAnimationBytes"), ScriptAccessPin = dbReader.GetInt32("ScriptAccessPin"), ForceMouselook = dbReader.GetBoolean("ForceMouselook"), BaseMask = dbReader.GetEnum <InventoryPermissionsMask>("BasePermissions"), OwnerMask = dbReader.GetEnum <InventoryPermissionsMask>("CurrentPermissions"), EveryoneMask = dbReader.GetEnum <InventoryPermissionsMask>("EveryOnePermissions"), GroupMask = dbReader.GetEnum <InventoryPermissionsMask>("GroupPermissions"), NextOwnerMask = dbReader.GetEnum <InventoryPermissionsMask>("NextOwnerPermissions"), ClickAction = dbReader.GetEnum <ClickActionType>("ClickAction"), PassCollisionMode = dbReader.GetEnum <PassEventMode>("PassCollisionMode"), PassTouchMode = dbReader.GetEnum <PassEventMode>("PassTouchMode"), Velocity = dbReader.GetVector3("Velocity"), IsSoundQueueing = dbReader.GetBool("IsSoundQueueing"), IsAllowedDrop = dbReader.GetBool("IsAllowedDrop"), PhysicsDensity = dbReader.GetDouble("PhysicsDensity"), PhysicsFriction = dbReader.GetDouble("PhysicsFriction"), PhysicsRestitution = dbReader.GetDouble("PhysicsRestitution"), PhysicsGravityMultiplier = dbReader.GetDouble("PhysicsGravityMultiplier"), IsVolumeDetect = dbReader.GetBool("IsVolumeDetect"), IsPhantom = dbReader.GetBool("IsPhantom"), IsPhysics = dbReader.GetBool("IsPhysics"), IsRotateXEnabled = dbReader.GetBool("IsRotateXEnabled"), IsRotateYEnabled = dbReader.GetBool("IsRotateYEnabled"), IsRotateZEnabled = dbReader.GetBool("IsRotateZEnabled"), IsBlockGrab = dbReader.GetBool("IsBlockGrab"), IsSandbox = dbReader.GetBool("IsSandbox"), IsDieAtEdge = dbReader.GetBool("IsDieAtEdge"), IsReturnAtEdge = dbReader.GetBool("IsReturnAtEdge"), IsBlockGrabObject = dbReader.GetBool("IsBlockGrabObject"), SandboxOrigin = dbReader.GetVector3("SandboxOrigin"), ExtendedMesh = new ObjectPart.ExtendedMeshParams { DbSerialization = dbReader.GetBytes("ExtendedMeshData") } }; using (var ms = new MemoryStream(dbReader.GetBytes("DynAttrs"))) { foreach (KeyValuePair <string, IValue> kvp in (Map)LlsdBinary.Deserialize(ms)) { objpart.DynAttrs.Add(kvp.Key, kvp.Value); } } return(objpart); }