public ViewerStatsMessage GetBySession(UUID sessionID)
 {
     QueryFilter filter = new QueryFilter();
     filter.andFilters.Add("session_id", sessionID);
     List<string> results = GD.Query(new string[1] {"*"}, m_realm, filter, null, null, null);
     return BuildSession(results, 0);
 }
Esempio n. 2
0
        public IAgentInfo GetAgent(UUID agentID)
        {
            /*object remoteValue = DoRemoteForUser(agentID, agentID);
            if (remoteValue != null)
                return (IAgentInfo)remoteValue;*/
            IAgentInfo agent = new IAgentInfo();
            List<string> query = null;
            try
            {
                QueryFilter filter = new QueryFilter();
                filter.andFilters["ID"] = agentID;
                filter.andFilters["`Key`"] = "AgentInfo";
                query = GD.Query(new string[1] { "`Value`" }, "userdata", filter, null, null, null);
            }
            catch
            {
            }

            if (query == null || query.Count == 0)
            {
                return null; //Couldn't find it, return null then.
            }

            OSDMap agentInfo = (OSDMap) OSDParser.DeserializeLLSDXml(query[0]);

            agent.FromOSD(agentInfo);
            agent.PrincipalID = agentID;
            return agent;
        }
Esempio n. 3
0
 public List<string> FindLSLData(string token, string key)
 {
     QueryFilter filter = new QueryFilter();
     filter.andFilters["Token"] = token.MySqlEscape(50);
     filter.andFilters["KeySetting"] = token.MySqlEscape(50);
     return GD.Query(new string[1] { "*" }, "lslgenericdata", filter, null, null, null);
 }
Esempio n. 4
0
        public bool AddClassified(Classified classified)
        {
            object remoteValue = DoRemote(classified);
            if (remoteValue != null || m_doRemoteOnly)
                return remoteValue != null && (bool) remoteValue;

            if (GetUserProfile(classified.CreatorUUID) == null)
                return false;
            string keywords = classified.Description;
            if (keywords.Length > 512)
                keywords = keywords.Substring(keywords.Length - 512, 512);
            //It might be updating, delete the old
            QueryFilter filter = new QueryFilter();
            filter.andFilters["ClassifiedUUID"] = classified.ClassifiedUUID;
            GD.Delete("userclassifieds", filter);
            List<object> values = new List<object>
                                      {
                                          classified.Name,
                                          classified.Category,
                                          classified.SimName,
                                          classified.CreatorUUID,
                                          classified.ScopeID,
                                          classified.ClassifiedUUID,
                                          OSDParser.SerializeJsonString(classified.ToOSD()),
                                          classified.PriceForListing,
                                          keywords
                                      };
            return GD.Insert("userclassifieds", values.ToArray());
        }
 public bool Delete(UUID id, bool ignoreFlags)
 {
     try
     {
         if (!ignoreFlags)
         {
             AssetBase asset = GetAsset(id, false);
             if (asset == null)
                 return false;
             if ((int) (asset.Flags & AssetFlags.Maptile) != 0 || //Depriated, use Deletable instead
                 (int) (asset.Flags & AssetFlags.Deletable) != 0)
                 ignoreFlags = true;
         }
         if (ignoreFlags)
         {
             QueryFilter filter = new QueryFilter();
             filter.andFilters["id"] = id;
             m_Gd.Delete("assets", filter);
         }
     }
     catch (Exception e)
     {
         if (MainConsole.Instance != null)
             MainConsole.Instance.Error("[LocalAssetDatabase] Error while deleting asset " + e);
     }
     return true;
 }
Esempio n. 6
0
        public FriendInfo[] GetFriends(UUID principalID)
        {
            List<FriendInfo> infos = new List<FriendInfo>();

            QueryTables tables = new QueryTables();
            tables.AddTable(m_realm, "my");
            tables.AddTable(m_realm, "his", JoinType.Inner,
                            new[,] {{"my.Friend", "his.PrincipalID"}, {"my.PrincipalID", "his.Friend"}});
            QueryFilter filter = new QueryFilter();
            filter.andFilters["my.PrincipalID"] = principalID;
            List<string> query = GD.Query(new string[]
                                              {
                                                  "my.Friend",
                                                  "my.Flags",
                                                  "his.Flags"
                                              }, tables, filter, null, null, null);

            //These are used to get the other flags below

            for (int i = 0; i < query.Count; i += 3)
            {
                FriendInfo info = new FriendInfo
                                      {
                                          PrincipalID = principalID,
                                          Friend = query[i],
                                          MyFlags = int.Parse(query[i + 1]),
                                          TheirFlags = int.Parse(query[i + 2])
                                      };
                infos.Add(info);
            }
            return infos.ToArray();
        }
Esempio n. 7
0
        /// <summary>
        ///   Get a user's profile
        /// </summary>
        /// <param name = "agentID"></param>
        /// <returns></returns>
        public IUserProfileInfo GetUserProfile(UUID agentID)
        {
            IUserProfileInfo UserProfile = new IUserProfileInfo();
            //Try from the user profile first before getting from the DB
            if (UserProfilesCache.TryGetValue(agentID, out UserProfile))
                return UserProfile;
            else
            {
                QueryFilter filter = new QueryFilter();
                filter.andFilters["ID"] = agentID;
                filter.andFilters["`Key`"] = "LLProfile";
                List<string> query = null;
                //Grab it from the almost generic interface
                query = GD.Query(new string[] { "Value" }, "userdata", filter, null, null, null);

                if (query == null || query.Count == 0)
                    return null;
                //Pull out the OSDmap
                OSDMap profile = (OSDMap) OSDParser.DeserializeLLSDXml(query[0]);

                UserProfile = new IUserProfileInfo();
                UserProfile.FromOSD(profile);

                //Add to the cache
                UserProfilesCache[agentID] = UserProfile;

                return UserProfile;
            }
        }
 public bool Delete(UUID ownerID, string friend)
 {
     QueryFilter filter = new QueryFilter();
     filter.andFilters["PrincipalID"] = ownerID;
     filter.andFilters["Friend"] = friend;
     return GD.Delete(m_realm, filter);
 }
        public UserInfo Get(string userID, bool checkOnlineStatus, out bool onlineStatusChanged)
        {
            onlineStatusChanged = false;

            QueryFilter filter = new QueryFilter();
            filter.andFilters["UserID"] = userID;
            List<string> query = GD.Query(new string[1] {"*"}, m_realm, filter, null, null, null);

            if (query.Count == 0)
            {
                return null;
            }
            UserInfo user = ParseQuery(query)[0];

            //Check LastSeen
            DateTime timeLastSeen = Util.ToDateTime(int.Parse(query[2]));
            DateTime timeNow = DateTime.Now.ToUniversalTime();
            if (checkOnlineStatus && m_checkLastSeen && user.IsOnline && (timeLastSeen.AddHours(1) < timeNow))
            {
                MainConsole.Instance.Warn("[UserInfoService]: Found a user (" + user.UserID +
                                          ") that was not seen within the last hour " +
                                          "(since " + timeLastSeen.ToLocalTime().ToString() + ", time elapsed " +
                                          (timeNow - timeLastSeen).Days + " days, " + (timeNow - timeLastSeen).Hours +
                                          " hours)! Logging them out.");
                user.IsOnline = false;
                Set(user);
                onlineStatusChanged = true;
            }
            return user;
        }
 public virtual bool DeleteFolders(string field, string val, bool safe)
 {
     QueryFilter filter = new QueryFilter();
     filter.andFilters[field] = val;
     if (safe)
     {
         filter.andFilters["type"] = "-1";
     }
     return GD.Delete(m_foldersrealm, filter);
 }
        public AvatarArchive GetAvatarArchive(string Name)
        {
            QueryFilter filter = new QueryFilter();
            filter.andFilters["Name"] = Name;
            List<string> RetVal = GD.Query(new string[] { "*" }, "avatararchives", filter, null, null, null);

            return (RetVal.Count == 0) ?  null :  new AvatarArchive {
                Name = RetVal[0],
                ArchiveXML = RetVal[1]
            };
        }
Esempio n. 12
0
        public List<string> FindLSLData(string token, string key)
        {
            object remoteValue = DoRemote(token, key);
            if (remoteValue != null || m_doRemoteOnly)
                return (List<string>) remoteValue;

            QueryFilter filter = new QueryFilter();
            filter.andFilters["Token"] = token;
            filter.andFilters["KeySetting"] = key;
            return GD.Query(new string[1] {"*"}, "lslgenericdata", filter, null, null, null);
        }
Esempio n. 13
0
 public SchedulerItem Get(string id)
 {
     if (id != "")
     {
         QueryFilter filter = new QueryFilter();
         filter.andFilters["id"] = id;
         List<string> results = m_Gd.Query(theFields, "scheduler", filter, null, null, null);
         return LoadFromList(results);
     }
     return null;
 }
 public bool DeleteAccount(UUID userID, bool archiveInformation)
 {
     if (archiveInformation)
     {
         return GD.Update(m_realm, new Dictionary<string, object> {{"UserLevel", -2}}, null,
                          new QueryFilter {andFilters = new Dictionary<string, object> {{"PrincipalID", userID}}},
                          null, null);
     }
     QueryFilter filter = new QueryFilter();
     filter.andFilters.Add("PrincipalID", userID);
     return GD.Delete(m_realm, filter);
 }
 public bool Store(UUID PrincipalID, string Friend, int Flags, int Offered)
 {
     QueryFilter filter = new QueryFilter();
     filter.andFilters["PrincipalID"] = PrincipalID;
     filter.andFilters["Friend"] = Friend;
     GD.Delete(m_realm, filter);
     Dictionary<string, object> row = new Dictionary<string, object>(4);
     row["PrincipalID"] = PrincipalID;
     row["Friend"] = Friend;
     row["Flags"] = Flags;
     row["Offered"] = Offered;
     return GD.Insert(m_realm, row);
 }
 public bool ExistsAsset(UUID uuid)
 {
     try
     {
         QueryFilter filter = new QueryFilter();
         filter.andFilters["id"] = uuid;
         return m_Gd.Query(new string[] { "id" }, "assets", filter, null, null, null).Count > 0;
     }
     catch (Exception e)
     {
         MainConsole.Instance.ErrorFormat("[LocalAssetDatabase]: Failure fetching asset {0}" + Environment.NewLine + e, uuid);
     }
     return false;
 }
        public RegionInfo GetRegionInfo(UUID regionID)
        {
            QueryFilter filter = new QueryFilter();
            filter.andFilters["RegionID"] = regionID;
            List<string> RetVal = GD.Query(new[] { "RegionInfo" }, "simulator", filter, null, null, null);

            if (RetVal.Count == 0)
            {
                return null;
            }

            RegionInfo replyData = new RegionInfo();
            replyData.UnpackRegionInfoData((OSDMap)OSDParser.DeserializeJson(RetVal[0]));
            return replyData;
        }
Esempio n. 18
0
 public AvatarAppearance Get(UUID PrincipalID)
 {
     QueryFilter filter = new QueryFilter();
     filter.andFilters["PrincipalID"] = PrincipalID;
     List<string> data;
     lock (m_lock)
     {
         data = GD.Query(new string[] {"Appearance"}, m_realm, filter, null, null, null);
     }
     if (data.Count == 0)
         return null;
     AvatarAppearance appearance = new AvatarAppearance();
     appearance.FromOSD((OSDMap) OSDParser.DeserializeJson(data[0]));
     return appearance;
 }
Esempio n. 19
0
        [CanBeReflected(ThreatLevel = OpenSim.Services.Interfaces.ThreatLevel.Low)]        public void UpdateLSLData(string token, string key, string value)
        {
            object remoteValue = DoRemote(token, key, value);            if (remoteValue != null || m_doRemoteOnly)                return;            if (FindLSLData(token, key).Count == 0)
            {
                GD.Insert("lslgenericdata", new[] {token.MySqlEscape(50), key.MySqlEscape(50), value.MySqlEscape(50)});
            }
            else
            {
                Dictionary<string, object> values = new Dictionary<string, object>(1);
                values["ValueSetting"] = value.MySqlEscape(50);

                QueryFilter filter = new QueryFilter();
                filter.andFilters["KeySetting"] = key.MySqlEscape(50);

                GD.Update("lslgenericdata", values, null, filter, null, null);
            }
        }
Esempio n. 20
0
 public bool Store(UUID PrincipalID, AvatarData data)
 {
     QueryFilter filter = new QueryFilter();
     filter.andFilters["PrincipalID"] = PrincipalID;
     GD.Delete(m_realm, filter);
     List<object[]> insertList = new List<object[]>();
     foreach(KeyValuePair<string, string> kvp in data.Data)
     {
         insertList.Add(new object[3]{
             PrincipalID,
             kvp.Key.MySqlEscape(32),
             kvp.Key == "Textures" ? kvp.Value : kvp.Value.MySqlEscape()
         });
     }
     GD.InsertMultiple(m_realm, insertList);
     return true;
 }
Esempio n. 21
0
        public bool CheckToken(UUID principalID, string token, int lifetime)
        {
            if (Environment.TickCount - m_LastExpire > 30000)
            {
                DoExpire();
            }

            uint now = Utils.DateTimeToUnixTime(DateTime.Now);
            Dictionary<string, object> values = new Dictionary<string, object>(1);
            values["validity"] = now + (lifetime*60);

            QueryFilter filter = new QueryFilter();
            filter.andFilters["UUID"] = principalID;
            filter.andFilters["token"] = token;
            filter.andLessThanEqFilters["validity"] = (int) now;

            return GD.Update(m_tokensrealm, values, null, filter, null, null);
        }
Esempio n. 22
0
 public AuthData Get(UUID principalID, string authType)
 {
     QueryFilter filter = new QueryFilter();
     filter.andFilters["UUID"] = principalID;
     filter.andFilters["accountType"] = authType;
     List<string> query = GD.Query(new string[1] { "*" }, m_realm, filter, null, null, null);
     AuthData data = null;
     for (int i = 0; i < query.Count; i += 5)
     {
         data = new AuthData
         {
             PrincipalID = UUID.Parse(query[i]),
             PasswordHash = query[i + 1],
             PasswordSalt = query[i + 2],
             AccountType = query[i + 3]
         };
     }
     return data;
 }
 public bool Store(UUID PrincipalID, AvatarData data)
 {
     lock (m_locks[PrincipalID])
     {
         QueryFilter filter = new QueryFilter();
         filter.andFilters["PrincipalID"] = PrincipalID;
         GD.Delete(m_realm, filter);
         List<object[]> insertList = new List<object[]>();
         foreach (KeyValuePair<string, string> kvp in data.Data)
         {
             insertList.Add(new object[3]{
                 PrincipalID,
                 kvp.Key,
                 kvp.Value
             });
         }
         GD.InsertMultiple(m_realm, insertList);
     }
     return true;
 }
Esempio n. 24
0
        public void UpdateLSLData(string token, string key, string value)
        {
            object remoteValue = DoRemote(token, key, value);
            if (remoteValue != null || m_doRemoteOnly)
                return;
            if (FindLSLData(token, key).Count == 0)
            {
                GD.Insert("lslgenericdata", new[] {token, key, value});
            }
            else
            {
                Dictionary<string, object> values = new Dictionary<string, object>(1);
                values["ValueSetting"] = value;

                QueryFilter filter = new QueryFilter();
                filter.andFilters["KeySetting"] = key;

                GD.Update("lslgenericdata", values, null, filter, null, null);
            }
        }
        public FriendInfo[] GetFriends(UUID principalID)
        {
            List<FriendInfo> infos = new List<FriendInfo>();
            QueryFilter filter = new QueryFilter();
            filter.andFilters["PrincipalID"] = principalID;
            List<string> query = GD.Query(new string[]{
                "Friend",
                "Flags"
            }, m_realm, filter, null, null, null);

            //These are used to get the other flags below
            List<string> keys = new List<string>();
            List<object> values = new List<object>();

            for (int i = 0; i < query.Count; i += 2)
            {
                FriendInfo info = new FriendInfo{
                    PrincipalID = principalID,
                    Friend = query[i],
                    MyFlags = int.Parse(query[i + 1])
                };
                infos.Add(info);

                Dictionary<string, object> where = new Dictionary<string, object>(2);
                where["PrincipalID"] = info.Friend;
                where["Friend"] = info.PrincipalID;

                List<string> query2 = GD.Query(new string[1] { "Flags" }, m_realm, new QueryFilter{
                    andFilters = where
                }, null, null, null);

                if (query2.Count >= 1)
                {
                    infos[infos.Count - 1].TheirFlags = int.Parse(query2[0]);
                }

                keys = new List<string>();
                values = new List<object>();
            }
            return infos.ToArray();
        }
        public void AddAgentGroupInvite(UUID requestingAgentID, UUID inviteID, UUID GroupID, UUID roleID, UUID AgentID, string FromAgentName)
        {
            object remoteValue = DoRemote(requestingAgentID, inviteID, GroupID, roleID, AgentID, FromAgentName);
            if (remoteValue != null || m_doRemoteOnly)
                return;

            if (CheckGroupPermissions(requestingAgentID, GroupID, (ulong)GroupPowers.Invite))
            {
                QueryFilter filter = new QueryFilter();
                filter.andFilters["AgentID"] = AgentID;
                filter.andFilters["GroupID"] = GroupID;
                data.Delete("osgroupinvite", filter);

                Dictionary<string, object> row = new Dictionary<string, object>(6);
                row["InviteID"] = inviteID;
                row["GroupID"] = GroupID;
                row["RoleID"] = roleID;
                row["AgentID"] = AgentID;
                row["TMStamp"] = Util.UnixTimeSinceEpoch();
                row["FromAgentName"] = FromAgentName.MySqlEscape(50);
                data.Insert("osgroupinvite", row);
            }
        }
Esempio n. 27
0
        public bool AddClassified(Classified classified)
        {
            object remoteValue = DoRemote(classified);
            if (remoteValue != null || m_doRemoteOnly)
                return remoteValue != null && (bool)remoteValue;

            if (GetUserProfile(classified.CreatorUUID) == null)
                return false;
            //It might be updating, delete the old
            QueryFilter filter = new QueryFilter();
            filter.andFilters["ClassifiedUUID"] = classified.ClassifiedUUID;
            GD.Delete("userclassifieds", filter);
            List<object> values = new List<object>{
                classified.Name.MySqlEscape(),
                classified.Category,
                classified.SimName.MySqlEscape(),
                classified.CreatorUUID,
                classified.ClassifiedUUID,
                OSDParser.SerializeJsonString(classified.ToOSD()),
                classified.ScopeID
            };
            return GD.Insert("userclassifieds", values.ToArray());
        }
Esempio n. 28
0
 public abstract bool Delete(string table, QueryFilter queryFilter);
Esempio n. 29
0
 public void WriteAuroraVersion(Version version, string MigrationName)
 {
     if (!TableExists(VERSION_TABLE_NAME))
     {
         CreateTable(VERSION_TABLE_NAME, new[]{new ColumnDefinition{
             Name = COLUMN_VERSION,
             Type = new ColumnTypeDef{ Type= ColumnType.String, Size = 100 }
         }}, new IndexDefinition[0]);
     }
     //Remove previous versions
     QueryFilter filter = new QueryFilter();
     filter.andFilters[COLUMN_NAME] = MigrationName;
     Delete(VERSION_TABLE_NAME, filter);
     //Add the new version
     Insert(VERSION_TABLE_NAME, new[] {version.ToString(), MigrationName});
 }
Esempio n. 30
0
 public abstract List<string> Query(string[] wantedValue, string table, QueryFilter queryFilter, Dictionary<string, bool> sort, uint? start, uint? count);